# How to create an Modbus-TCP alarm status dashboard

**URL:** <https://discourse.nodered.org/t/how-to-create-an-modbus-tcp-alarm-status-dashboard/43041>\
**Category:** Industrial\
**Created:** [22 March 2021 19:59 UTC](https://discourse.nodered.org/t/how-to-create-an-modbus-tcp-alarm-status-dashboard/43041 "2021-03-22T19:59:23Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [27 March 2021 00:02 UTC](https://discourse.nodered.org/t/how-to-create-an-modbus-tcp-alarm-status-dashboard/43041/12 "2021-03-27T00:02:02Z")

</div>

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...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/c/3c0ee84ed21627f602b3ebdbf8a1291f48ed12ea.png)

but the modbus flex getter only shows me the first 22 items...  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/0/c0722996291545988a031eb6c3b996067ab8e565.png)

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

Normal wireshark response (127 items)...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/a/fa62d610c647323505ab0ab6f0fe9ccceb92535f.png)

When i request 150 items...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/5/d5c04babe84336c504d91efdb871b98a25f5e2bb.png)

And this [online modbus packet parser](https://rapidscada.net/modbus/ModbusParser.aspx) doesnt like the response.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/7/7750e15ec6b55c78f09ecf00d11d3a66242e5bb6.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/0/e06f79012e21dacaaa8869058e1abca992618d7d.png)

... 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

```auto
000100000006010300000096

```

slave --\> node-red

```auto
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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/b/ab4093569285503c547c78b237b18ff2eb8449a2.png)

Demo DIY modbus TCP flow...  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/d/2d45f970c3e3cd2ffa7e7cdbb2f5c7ca93ba6335.png)

Results...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/d/ad14085e3d557ee5cd8aa0d43790313ab049313e.png)

flow...

```auto
[{"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

---

_[View the full topic](https://discourse.nodered.org/t/how-to-create-an-modbus-tcp-alarm-status-dashboard/43041)._
