1.0.16 • Published 4 years ago

odx_pdu_hexarray v1.0.16

Weekly downloads
3
License
ISC
Repository
github
Last release
4 years ago

How to Use:

create an object:

const pdu = new HexArray([0, 0, 0, 0]);

insert some raw data

pdu.insert(byteposition, bitposition, length, data);
  • byteposition and bitposition: the start within the pdu
  • length: number of bits to insert
  • data: int value to insert

bytes count from left to right and bits count from right to left [byte0, byte1...,bit2, bit1, bit0,byte2,...]

get Raw data

reads a specific part within the pdu

  • byteposition and bitposition: the start within the pdu
  • length: number of bits to read

returns an integer

pdu.getRaw(byteposition, bitposition, length);

insert some physical data

well, this needs a translation object which looks like:

const translation = {
  byteposition: 0,
  bitposition: 0,
  bitlength: 8,
  offset: 0,
  numerator: 1,
  texttable: [{ lowerLimit: 0, upperLimit: 1, text: "null" }]
};

(where the texttable is optional)

now you can insert

pdu.insertPhysical(physicalData, translation);

get Physical Data with Dictionary

you have to create a dictionary array containing translations:

const dictionary = [
  {
    name: "Value1",
    translation: translationObj1
  },
  {
    name: "Value2",
    translation: translationObj2
  }
];

now you can get physical data

pdu.getTranslated(dictionary);

this will return for example:

  {
    Value1: 1,
    Value2: "null"
  }
1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago