Page 1 of 1

Modbus TCP slave registers getting reset without signal

Posted: 02 Jul 2024, 12:33
by peterq
Hi,

I am experimenting with using a RevPi core as a Modbus TCP slave and am experiencing some unexpected behaviour which I was hoping someone could explain.

I can set up the virtual TCP slave adapter in PiCtory and when I run

Code: Select all

piTest -d
I get the following.

Code: Select all

Address: 64 module type: 24577 (0x6001) ModbusTCP Slave Adapter V0.0
Module is present
     input offset: 124 length: 64
    output offset: 188 length: 64
If I then set a register (I have named one Command) to a specific value using

Code: Select all

piTest -w Command,5 
I get the expected result

Code: Select all

Write value 5 dez (=0005 hex) to offset 124.
Then when I poll the register with

Code: Select all

piTest -r Command
the register is set to zero after a short but seemingly random amount of time (around 30s) which I can see from the output of the above:

Code: Select all

...
2 Byte-Value of Command: 5 dez (=0005 hex)
2 Byte-Value of Command: 5 dez (=0005 hex)
2 Byte-Value of Command: 5 dez (=0005 hex)
2 Byte-Value of Command: 5 dez (=0005 hex)
2 Byte-Value of Command: 5 dez (=0005 hex)
2 Byte-Value of Command: 5 dez (=0005 hex)
2 Byte-Value of Command: 0 dez (=0000 hex)
2 Byte-Value of Command: 0 dez (=0000 hex)
2 Byte-Value of Command: 0 dez (=0000 hex)
2 Byte-Value of Command: 0 dez (=0000 hex)
There are no modbus commands being sent to the unit so I would expect this register would stay at the setpoint indefinitely - is this correct?

Thanks very much!

Re: Modbus TCP slave registers getting reset without signal

Posted: 04 Jul 2024, 09:37
by dirk
Hi peterq, thank you for your detailed report and the description of your approach, that's wonderful.

What values do the Modbus status registers show? Maybe there is some kind of error code visible.
How to Use RevPi Connect as Modbus TCP Master - Industrial Raspberry Pi (revolutionpi.com)
  • Modbus_Master_Status
  • Modbus_Action_Status_[1… 32]
Is "piTest -x" called from an application running in parallel?

Are there generally parallel accesses to the process image? You can work with the command "lsof" and access "piControl0".

Code: Select all

pi@RevPi123834:~ $ sudo lsof /dev/piControl0                                                                                                                                                                                                 COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME                                                                                                                                                                                    piModbusM 2784 root    4u   CHR  240,0      0t0  174 /dev/piControl0
Finally, you can restore the factory settings with the steps of the
Revolution Pi Checklist