Modbus : Error of lenght

Hi all,

I'm using a P30H captor from Lummel and I would like to collect the value from the captor by the Modbus TCP/IP Protocol.

I verified the slave id, register and IP adress with Modbus Doctor.


But when I tried to get the value in Node-Red, I get this error ; image
Do you have any idea for solving it ?

[{"id":"684f0762.d4f9e8","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"8fc69fba.ad7e1","type":"debug","z":"684f0762.d4f9e8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":730,"y":220,"wires":[]},{"id":"e306c8fc.aed118","type":"modbus-flex-getter","z":"684f0762.d4f9e8","name":"","showStatusActivities":true,"showErrors":true,"logIOActivities":false,"server":"5a4d7d51.7640b4","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":true,"keepMsgProperties":false,"x":510,"y":180,"wires":[["2cc5fcc0.0200e4"],["8fc69fba.ad7e1"]]},{"id":"2cc5fcc0.0200e4","type":"modbus-response","z":"684f0762.d4f9e8","name":"","registerShowMax":"100","x":750,"y":120,"wires":[]},{"id":"b5da8ef4.7de02","type":"function","z":"684f0762.d4f9e8","name":"","func":"msg.payload = { \n    value: msg.payload, \n    'fc': 3, \n    'unitid': 1, \n    'address': 7500,\n    'quantity': 2\n} \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":300,"y":180,"wires":[["e306c8fc.aed118"]]},{"id":"9c5dd677.2cdfc8","type":"inject","z":"684f0762.d4f9e8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":110,"y":180,"wires":[["b5da8ef4.7de02"]]},{"id":"5a4d7d51.7640b4","type":"modbus-client","z":"","name":"Capteur P30H","clienttype":"tcp","bufferCommands":false,"stateLogEnabled":true,"queueLogEnabled":true,"tcpHost":"192.168.0.9","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true}]

Thanks a lot for your help

Hi,

I noticed in your function you have value: msg.payload

msg.payload = { 
    value: msg.payload, 
    'fc': 3, 
    'unitid': 1, 
    'address': 7500,
    'quantity': 2
} 
return msg;

that line i think is not necessary since you are doing a modbus Read .. not sure if that is the issue.
[EDIT] another thing you can try is start with a leading '4' since holding registers are in the 40000 range ?
So for address 7500 try 47500.

Based on the documentation of your device .. the modbus device reply is a 32-bit float ..
there is a Buffer-parser node perfect for these type of convertions

Thanks for your answer !
I've try with the buffer but no answer :

[{"id":"729d145c.94f90c","type":"buffer-parser","z":"684f0762.d4f9e8","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"uint32le","name":"item1","offset":1,"length":4,"offsetbit":0,"scale":1,"mask":""}],"swap1":"swap32","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"value","resultTypeType":"output","multipleResult":true,"setTopic":true,"x":650,"y":180,"wires":[["8fc69fba.ad7e1","2cc5fcc0.0200e4"]]}]

Did I set the correct settings for the buffer ?

First we need to get a reply from your device? Do you get a reply now ?

The buffer-parser can be used directly after your Modbus flex getter and is used only for converting different buffer data types by passing the msg.responseBuffer.buffer to it.

Possible settings could be the following. Depending on your device maybe Swap 16 or float(le)

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.