Hi all so, first release of node-red-contrib-buffer-parser
The name doesnt do it justice so I will post snippets from the readme below - to try and explain it.
Hope its of use to people.
About
A dynamic Node-RED node to convert values in a buffer or integer array into the many different data type(s). Supports Big/Little Endian, BCD, byte swapping and much more.
A picture is worth a thousand words
Summary of functionality
- Setup a specification and convert multiple parts of an array or buffer to...
- int, int8, byte,
- int16, int16le, int16be, uint16, uint16le, uint16be,
- int32, int32le, int32be, uint32, uint32le, uint32be,
- bigint64, bigint64be, bigint64le, biguint64, biguint64be, biguint64le,
- float, floatle, floatbe, double, doublele, doublebe,
- 8bit, 16bit, 16bitle, 16bitbe, bool,
- bcd, bcdle, bcdbe,
- string, ascii, utf8, utf16le, ucs2, latin1, binary
- Specification is dynamic & can be sent in as a msg/flow/global property - permitting fully dynamic setup (e.g. via a dashboard)
- The specification format permits random access (e.g. no need for any skips when accessing only first and last elements)
- You can specify the same offset many times to convert the same piece of data several times
- The data can be byte swapped one or more times. 16, 32 or 64 bit swaps are possible. The byte swaps are done prior to any data conversions like LE or BE functions (sometimes it is necessary to do multiple swaps)
- The output can be sent in any
msg
property. e.g. you can send results out inmsg.my.nested.property
. This has the advantage of leaving the original payload in tact. - Input data can come from any msg property (not limited to
msg.payload
) - Input data can be a 16bit array (common plc data format) simplifying working with PLC type data arrays
- Output results can be multiple messages as
topic
andpayload
- ideal for taking PLC data and sending it directly to MQTT
- Output results can be a single msg style output
- ideal for converting multiple different data elements into one object to pass on to perhaps a template node for preparing a SQL or HTML statement using {{mustache}} formatting
- additionally, output results can be 1 of 4 styles...
- "value" : the parsed values are sent in an array
- "object" : the parsed values are sent as named objects with the value set
.value
and other contextual properties included (like the item specification) - "array" : the parsed values are sent as objects in an array, with each object containing a
.value
property and other contextual properties included (like the item specification) - "buffer" : this mode simply returns a buffer (no item processing)
- Built in help