Hexadecimal frame parser
Encode & decode hexadecimal frames with ease
Install
$ npm install --save hex-frame-parser
Usage
const Decoder = Decoder;const DecoderProperty = DecoderProperty; // Objectsconst decoder = '47c85d800f03'; // the hexadecimal frame to decode // Define the syntax (bitStartPos, bitEndPos, key, type, unit, add, subtract, divide, multiply)decoderdecoderProperties; // See the resultconsole;
Properties
bitStartPos
: Number defines the position of the starting bit to decodebitEndPos
: Number defines the position of the ending bit to decodeisSigned
: Boolean defines if the data is signed or unsignedkey
: String defines the name of the data to decodetype
: String defines the type of the data to decode (see below for usable types)unit
: String defines the unit of the data to decodeadd
: Number defines the number to add to the datasubtract
: Number defines the number to subtract to the datamultiply
: Number defines the number to multiply to the datadivide
: Number defines the number to divide to the data
Types (32bits architecture)
type
can be:
char
short
int
long
float
bool
Examples
const Decoder = Decoder;const DecoderProperty = DecoderProperty; // #1const decoder_1 = '47c85d800f03';decoder_1decoderProperties;decoder_1decoderProperties;console; // #2const decoder_2 = 'b6096249';decoder_2decoderProperties;console; // #3const decoder_3 = '1a00bd4aa5181d';decoder_3decoderProperties;decoder_3decoderProperties;console; // #4const decoder_4 = '32b641e0224484';decoder_4decoderProperties;console;