Reputation: 3
I need to read 50 consecutive registers from a Modbus device in a single request and then split the data into 25 attributes (32bit integer).
This request is realted to thingsboard-gateway GitHub issues #1589 (Modbus batch reading)
and #1664 (Missing delay between requersts)
.
On the connector side, I could create a byte-type attribute and read 50 registers using function code 0x04 (Read Input Registers), resulting in a 100-byte object.
Could I then use the Rule Engine to split these 100 bytes into 25 attributes? For example, I need to take the first 4 bytes and convert them into one 32-bit integer, and so on.
Upvotes: 0
Views: 40
Reputation: 559
Use Script Transformation
rule node to parse and re-pack incoming 100 bytes to what you want. Then link this node with Save attributes
rule node to store transformed data as attributes.
Optionally, to avoid mess of different flows you could create device profile specifically for your Modbus devices and use this profile name in Modbus connector configuration of gateway. Then create separate rule chain with aforementioned nodes and assign that chain to the created device profile.
Upvotes: 0