The serial device sends json data in the following hexadecimal format:
0: 0xca
1: 0x09
2: 0x06
3: 0x02
4: 0x37
5: 0x01
6: 0x00
7: 0x00
8: 0x65
9: 0x00
10: 0x10
11: 0x06
12: 0xd2
13: 0x35
I need to combined indexes 10 and 11 to unpack the hexadecimal number. For example, index 9 = 0x10 and index 10 = 0x06, therefore the unpacked hexadecimal number is 0610. How would I do this in Node-RED?
node-red-contrib-buffer-parser (node) - Node-RED can do pretty much anything you need. There are built in example flows and built in help. Lastly if you search this forum for buffer parser the are lots of threads with detailed usage examples.
Thanks for point me in the right direction. I got it to work for me.
Is there a way to bit unpack (go from hexadecimal to binary)? For example, Buffer index 10 is the device's capabilities or attributes which is sent as a hexadecimal number. Each bit which makes up the hexadecimal number, represents the device's multiple attributes.
node-red-contrib-bitunloader can handle unpacking from numbers to bits in a couple different formats, like bit arrays or an object of bools, etc depending on how you want to process them later down the flow. It does only work with decimal numbers though.
Since you didn't reply to my response I didn't get a notification.
If you read the built in help for buffer parser you will see there is both bit types (for simply extracting bits) and there are masking and equations (for numbers i.e to get bit 7 of a single byte you could use mask 0x80
and equation =0x80
let hexString = "1A";
// Hexadezimale Zahl als String
let decimalNumber = parseInt(hexString, 16);
// Umwandlung in Dezimalzahl
console.log(decimalNumber);
// Ausgabe: 26