Communicate with an old device

Hello .
at work, I try to communicate with a fairly old device.
on a pc window I used a serial port monitor, to see what was going on.
with the modbus RTU protocol:

[21/04/2020 20:34:30]
Modbus Request (COM4)
Address: 1
Function: 3 (0x03) - Read Holding Registers
	Starting Address: 0
	Quantity: 1
Checksum: 33802(OK)
-------------------------------------
[21/04/2020 20:34:30]
Modbus Response (COM4)
Address: 1
Function: 3 (0x03) - Read Holding Registers
Checksum: 512(BAD)

the software that works with this device reads the data well. with modbus contrib, I send the same request and I have an error in length.

after I did a "dump" when reading a single channel. the software always sends the same .

[02/05/2020 14:51:52] Written data (COM2)
	

01 03 00 00 00 01 84 0a                           ......„.        

[02/05/2020 14:51:52] Read data (COM2)
	

01 03 02 00 15 79 8b                              .....y‹         

[02/05/2020 14:51:53] Written data (COM2)
	

01 03 00 00 00 01 84 0a                           ......„.        

[02/05/2020 14:51:53] Read data (COM2)
	

01 03 02 00 13 f9 89

avec node red , j'ai envoyé une command avec le node inject .

[
    {
        "id": "6e17b8ad.80e198",
        "type": "inject",
        "z": "88afcf0a.d8631",
        "name": "v1",
        "topic": "",
        "payload": "[\"0X01\",\"0x03\",\"0x00\",\"0x00\",\"0x00\",\"0x01\",\"0x84\",\"0x0a\"]",
        "payloadType": "bin",
        "repeat": "10",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 130,
        "y": 100,
        "wires": [
            [
                "22eca8d4.c696a8"
            ]
        ]
    }
]

I have an answer,

[2,0,34,56,93,1,3]

Capture du 2020-05-02 17-25-56

do you have any advice to try to understand where I'm doing something stupid

The first debug information is COM2 and after that COM4. Assuming this is not the issue, usually with serial communication, when it is "wrong" it is often the configuration of the COM port which is not consistent. Speed, parity, length... If one is wrong, you receive (and send) garbage.
So check the serial port parameters on both sides.
GV

I would 2nd that - it appears you are getting a checksum error - if i had to guess i would say have a look at the serial port setup parameters - in particular what your stop bits are set for (1,2, or none).

As you are getting some correct and readable data it will probably be some of the setup of the port - not speed or it would all be garbled - so i would work my way through the sequence - show us what the setup of the com port looks like ? i.e. speed, parity, start and stop bits, xon/xoff etc

Craig

To me, it looks like you are reinventing the wheel.

From the screenshots you posted, the old device appears to be using modbus.
Have you tried the modbus nodes?

If that's what didn't work for you, perhaps when you tried it was set incorrectly?

What is this old device? Perhaps it has documentation of the protocol settings & com settings?

thank you for the information.

the device is a thermoclim 8/16, to consult it we use an old pc which is about to render the soul, through a moxa nport5110.
Of course, we no longer have the documentation or the software installation CD and I couldn't find anything on the web.

thermoclim8 / 16 ------- rs232 ------ Nport5110 ------- ethernet ------- pc.

on the old pc i tried to install serial port monitor but it made everything crash. then on another pc, I copied the thermosoft directory, put various dll and ocx and I can launch the software and have serial port monitor at the same time.

I reconfigure the serial port.
baud rate 9600
data bit 8
Stop bits 1
Parity none
Flow control none
FIFO none

with node red I can read with modbus read without CRC error, it's already a good point.
now I have to find the addresses that correspond to the measurement channels.

when I log each channel I noted the order sent

v1 = 01 03 00 00 00 01 84 0a
v3 = 01 03 00 00 00 03 05cb
/
/
v15 = 01 03 00 00 00 0f 05 ce

01= ID
03= read holding register
last 2 digit crc ?
01 03 .... 0f adress ?

or I really have it all wrong, how to find address and quantity in node red modbus contrib?
thanks again

I see.

There are modbus decoders like this one...
https://rapidscada.net/modbus/ModbusParser.aspx

Example...

You can paste the hexadecimal values for send and receive to help you understand addresses and FNC codes.

from what you write in the first post, your device does not seem to send a large amount of data, I recommend using a modbus network scanner to identify what and where it writes.
From the string "01 03 xx yy 0f" xx = address yy == quantity.
The format of the data you receive (Int, floating point, etc.) is also important because it could be that the answer you receive:
[2,0,34,56,93,1,3]
is correct but you have to recompose the arrays in the native transmission format.

Thank you for your answers .

I manage to read the 1st address but when I want to read all the addresses it doesn't work anymore.

1st address reading

reading 16 address

and the log .

4 May 20:21:20 - [info] Started modified nodes
4 May 20:21:20 - [trace] runtime event: {"id":"runtime-deploy","payload":{"revision":"d02b2428254038460c7f078a0c0272b1"},"retain":true}
  contribModbus:core:client Client -> {"info":"pushed to Queue by Unit-Id","message":{"unitid":1,"fc":3,"address":0,"quantity":16,"messageId":"5eb05d24b453533edb098db3","emptyMsgOnFail":true},"unitId":1} Serial@/dev/ttyr00:9600bit/s default Unit-Id: 1 +17s
  contribModbus:core:client Client -> {"info":"queued read msg","message":{"unitid":1,"fc":3,"address":0,"quantity":16,"messageId":"5eb05d24b453533edb098db3","emptyMsgOnFail":true},"state":"connected","queueLength":1} Serial@/dev/ttyr00:9600bit/s default Unit-Id: 1 +0ms
  contribModbus:core:client Client -> queueing Serial@/dev/ttyr00:9600bit/s default Unit-Id: 1 +1ms
  contribModbus:core:client Client -> sending Serial@/dev/ttyr00:9600bit/s default Unit-Id: 1 +0ms
  contribModbus:core:client Client -> {"type":"sequential dequeue command","unitId":1,"isValidUnitId":true,"sendingAllowed":true,"serialSendingAllowed":true} Serial@/dev/ttyr00:9600bit/s default Unit-Id: 1 +3s
  contribModbus:core:client Client -> {"type":"send queue data to Modbus","unitId":1,"queueLength":1,"sendingAllowed":true,"serialSendingAllowed":false} Serial@/dev/ttyr00:9600bit/s default Unit-Id: 1 +1ms
  contribModbus:core:client Client -> {"info":"read msg via Modbus","message":{"unitid":1,"fc":3,"address":0,"quantity":16,"messageId":"5eb05d24b453533edb098db3","emptyMsgOnFail":true},"queueUnitId":1,"timeout":2500,"state":"sending"} Serial@/dev/ttyr00:9600bit/s default Unit-Id: 1 +0ms
  modbus-serial {
  modbus-serial   action: 'send serial rtu buffered',
  modbus-serial   data: <Buffer 01 03 00 00 00 10 44 06>,
  modbus-serial   unitid: 1,
  modbus-serial   functionCode: 3
  modbus-serial } +27s
  contribModbus:core:client Client -> {"state":"sending","message":"dequeue command done serial","delay":2500} Serial@/dev/ttyr00:9600bit/s default Unit-Id: 1 +1ms
  modbus-serial {
  modbus-serial   action: 'receive serial rtu buffered port',
  modbus-serial   data: <Buffer 01>,
  modbus-serial   buffer: <Buffer 01>
  modbus-serial } +395ms
  modbus-serial {
  modbus-serial   action: 'receive serial rtu buffered port',
  modbus-serial   data: <Buffer 03 02 00 e1>,
  modbus-serial   buffer: <Buffer 01 03 02 00 e1>
  modbus-serial } +4ms
  modbus-serial {
  modbus-serial   action: 'receive serial rtu buffered port',
  modbus-serial   data: <Buffer 78 0c>,
  modbus-serial   buffer: <Buffer 01 03 02 00 e1 78 0c>
  modbus-serial } +6ms
  contribModbus:core:client Client -> {"info":"queue response activate sending","sendingAllowed":true,"serialSendingAllowed":true,"queueUnitId":1} Serial@/dev/ttyr00:9600bit/s default Unit-Id: 1 +3s
  contribModbus:core:client Client -> sending Serial@/dev/ttyr00:9600bit/s default Unit-Id: 1 +1ms
  modbus-serial modbusErrorHandling:Timed out +22s
  contribModbus:core:client Client -> failed Serial@/dev/ttyr00:9600bit/s default Unit-Id: 1 +0ms
4 May 20:21:29 - [warn] [modbus-client:moxa] Client -> fsm failed state after sending Get More About It By Logging Serial@/dev/ttyr00:9600bit/s default Unit-Id: 1
4 May 20:21:29 - [warn] [modbus-flex-getter:5f019902.1af158] Modbus Failure On State sending Get More About It By Logging
  contribModbus:core:client Client -> broken Serial@/dev/ttyr00:9600bit/s default Unit-Id: 1 +1ms
4 May 20:21:29 - [warn] [modbus-client:moxa] Client -> fsm broken state after failed Get More About It By Logging Serial@/dev/ttyr00:9600bit/s default Unit-Id: 1
  contribModbus:core:client Client -> reconnecting Serial@/dev/ttyr00:9600bit/s default Unit-Id: 1 +0ms
4 May 20:21:29 - [warn] [modbus-client:moxa] Client -> fsm reconnect state after broken Get More About It By Logging Serial@/dev/ttyr00:9600bit/s default Unit-Id: 1
  contribModbus:flex:getter Timed out +27s
4 May 20:21:29 - [error] [modbus-flex-getter:5f019902.1af158] Timed out
  contribModbus:core Message Not Found undefined +27s
  contribModbus:core:client Client -> reconnecting Serial@/dev/ttyr00:9600bit/s default Unit-Id: 1 +2ms
  contribModbus:core:client Client -> init Serial@/dev/ttyr00:9600bit/s default Unit-Id: 1 +2s
4 May 20:21:31 - [warn] [modbus-client:moxa] Client -> fsm init state after reconnecting Serial@/dev/ttyr00:9600bit/s default Unit-Id: 1
4 May 20:21:31 - [warn] [modbus-client:moxa] Client -> fsm init in 2000 ms Serial@/dev/ttyr00:9600bit/s default Unit-Id: 1
  contribModbus:core:client Client -> connection close sent Serial@/dev/ttyr00:9600bit/s default Unit-Id: 1 +2s
  contribModbus:core:client Client -> RTU buffered port serial Serial@/dev/ttyr00:9600bit/s default Unit-Id: 1 +1ms
  contribModbus:core:client Client -> connection closed Serial@/dev/ttyr00:9600bit/s default Unit-Id: 1 +6ms
  contribModbus:core:client Client -> opened Serial@/dev/ttyr00:9600bit/s default Unit-Id: 1 +47ms
  contribModbus:core:client Client -> time to open Unit 1 Serial@/dev/ttyr00:9600bit/s default Unit-Id: 1 +1s
  modbus-serial modbus connection opened +5s
  contribModbus:core:client Client -> connected Serial@/dev/ttyr00:9600bit/s default Unit-Id: 1 +1ms
4 May 20:21:34 - [warn] [modbus-client:moxa] Client -> fsm connected after state opened Get More About It By Logging Serial@/dev/ttyr00:9600bit/s default Unit-Id: 1

an idea of what can go wrong?

Did the original request 16 items?

Perhaps the old device doesn't have 16 registers?

I think so

Part of Data Package Description Value
01 Slave address 0x01 (1)
03 Function code 0x03 (3) - Read Holding Registers
00 00 Starting address 0x0001 (1)
00 10 Quantity 0x0010 (16)
44 06 CRC 0x4406 (17414)

Your code starts at address 0 by the post above says address 1.

Some implementations of modbus mix this up (or add 1 or deduct 1 from your address to compensate). Try changing the address.

Also, try accessing only 15. Just to see if you can get things moving.

Edit, just looked at logs seems the address is ok.

Is there any way of adding a delay in the serial line? Try adding 30ms or maybe 100ms.

Is there any way of adding a delay in the serial line? Try adding 30ms or maybe 100ms.

I looked in the box and the thermoclim menus, I found nothing on modbus communication.
I am currently testing with inject nodes.

I am currently testing with inject nodes.
I put a 1second screen between each and I get an answer for each channel, but I'm not sure of the values, I have the impression that they vary enormously.

I will see tomorrow morning

Do you think we can do it with the stty command?

stty -a -F /dev/ttyr00
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^; erase = ^?; kill = ^U; eof = ^D; eol = ;
eol2 = ; swtch = ; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff
-iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt
-echoctl -echoke -flusho -extproc

I try to understand the stty documentation but I admit that I don't understand much

Are you still using modbus nodes or trying to get data yourself with serial node?

for the commande whit stty

chris@lmrasp:~$ stty -F /dev/ttyr00 -icanon time 250
chris@lmrasp:~$ stty -a -F /dev/ttyr00
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^; erase = ^?; kill = ^U; eof = ^D; eol = ; eol2 = ;
swtch = ; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V;
discard = ^O; min = 1; time = 250;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc
-ixany -imaxbel -iutf8
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt -echoctl
-echoke -flusho -extproc

I tried :
address 0 quantity 1 -> ok
address 1 quantity 1 -> ok



channel 2 is deactivated which would correspond to address 1 (0)

I know that address 18 or 19, it depends if it starts from 0 or 1, quantity 16 must answer me"local info"


if I lie address 19 it's the same result

with this modbus flex getter

Part of Data Package Description Value
01 Slave address 0x01 (1)
03 Function code 0x03 (3) - Read Holding Registers
00 12 Starting address 0x0013 (19)
00 10 Quantity 0x0010 (16)
E4 03 CRC 0xE403 (58371)
spying on com port tells me

[02/05/2020 08:42:38] Written data (COM2)
01 03 00 12 00 10 e4 03 ......д.

[02/05/2020 08:42:38] Read data (COM2)

01 03 0c 6c 6f 63 61 6c 20 69 6e 66 6f 20 20 6a ...local info j

14

Part of Data Package Description Value
01 Slave address 0x01 (1)
03 Function code 0x03 (3) - Read Holding Registers
0C Byte count 0x0C (12)
6C 6F 63 61 6C 20 69 6E 66 6F 20 20 Register value 0x6C6F (27759), 0x6361 (25441), 0x6C20 (27680), 0x696E (26990), 0x666F (26223), 0x2020 (8224)
6A 14 CRC 0x6A14 (27156)

hex as
I had a lot less problem to dialogue with my boiler in modbus ascii :smiley:

well, I don't really know how I did it but with 2 terminal, the first with cat / dev .... and the second with echo -e, I managed to send data and receive the right answer.
would it be possible that i don't have the right versions
npm 6.14.4
Node-RED version: v1.0.5
Node.js version: v12.16.3
node-red-contrib-modbus 5.10.1

finally, with a serial request it works.
as soon as I try with modbus flex getter I have errors.

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