How to create an Modbus-TCP alarm status dashboard

Funny thing - using a modbus slave emulator, if i request over 127 items, i start getting strange length responses in the debug output from node-red-contrib-modbus

The slave application seems to send all the data that i request. For example, I requested 150 items & the slave responded with the right amount of data...

but the modbus flex getter only shows me the first 22 items...
image

Another oddity is Wireshark doesn't correctly recognise the response...

Normal wireshark response (127 items)...

When i request 150 items...

And this online modbus packet parser doesnt like the response.


... which leads me to think ...

  • The response is actually NG or out of spec?
  • The wireshark filter and the web site checker tool is old / limited / broken?

I dont have the energy to scour the modbus spec so if anyone familiar with the modbus tcp specification wants to analyse the following request and response packets please do...

node-red --> slave

000100000006010300000096

slave --> node-red

00010000012f01032c00010002000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005f0060000000000000000000000000000000000000000000000000000000000000007c007d007e007f00800081000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000


Possible work arounds...

  1. Do 4 sequential requests for 0~99 then 100~199 then 200~299 then 300~349 (you could do it in 3 reads but aligning to the 0, 100, 200 and 300 mark will make parsing simpler)
  2. DIY it - send 00010000000601030000015e over TCP to your slave & parse the result yourself

Demo DIY modbus TCP flow...
image

Results...

flow...

[{"id":"81661067.26948","type":"tcp request","z":"5e6c8b.7f38b374","server":"192.168.1.59","port":"502","out":"sit","splitc":" ","name":"","x":1908,"y":208,"wires":[["edb7a472.6eebc8"]]},{"id":"f77e01bf.42f16","type":"inject","z":"5e6c8b.7f38b374","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"00010000000601030000015e","payloadType":"str","x":1872,"y":144,"wires":[["50df09a0.9d44e8"]]},{"id":"50df09a0.9d44e8","type":"buffer-maker","z":"5e6c8b.7f38b374","name":"","specification":"spec","specificationType":"ui","items":[{"name":"item1","type":"hex","length":-1,"dataType":"msg","data":"payload"}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","x":2054,"y":144,"wires":[["cef58d63.4cb6","81661067.26948"]]},{"id":"f662fe41.9f3f3","type":"debug","z":"5e6c8b.7f38b374","name":"modbus response","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2282,"y":208,"wires":[]},{"id":"cef58d63.4cb6","type":"debug","z":"5e6c8b.7f38b374","name":"modbus request","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2272,"y":144,"wires":[]},{"id":"edb7a472.6eebc8","type":"buffer-parser","z":"5e6c8b.7f38b374","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"uint16be","name":"data","offset":9,"length":-1,"offsetbit":0,"scale":"1","mask":""},{"type":"buffer","name":"buffer","offset":9,"length":-1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":2102,"y":208,"wires":[["f662fe41.9f3f3"]]}]

NOTE: Here be dragons. The above flow does not check headers, does not do any error checking & i have no idea how it will handle disconnections. Feel free to use it or not but i would recommend at least checking the modbus headers and response data length at minimum before accepting the data as good