Page 1 of 1

Modbus RTU Master "Modbus_Master_Status"

Posted: 13 Dec 2019, 14:39
by Ibrahim Stracey
Hi everyone,

I seem to be having quite a strange problem. From reading the documentation about the Modbus RTU Master, it seems to me that the "Modbus_Master_Status" variable should change based on if an error occurs (eg, if a slave device is disconnected). What I'm trying to do is use the Modbus RTU Master to connect to an arduino which transmits some sensor data. The communication works perfectly and I'm able to read the data correctly. However, I've discovered that when I disconnect the arduino while the modbus is running, the "Modbus_Master_Status" variable does not change (it stays on "0"). But if i run "piTest -x" the modbus master status changes to 255. Even writing "1" to the "Master_Action_Reset" seems to have no effect. Only a full driver reset seems to make any change. From what I can tell from the documentation, if a device is disconnected the master status should change to 0x10 or 0x11, not 255. Even after confirming that the devices no longer show up on the RevPI Connect (by running "ls /dev/ttyACM*"), the master status stays at 0 after a disconnect. Any idea why this is happening? The same anomaly occurs with the "Modbus_Action_Status_1" variable.

thanks

Re: Modbus RTU Master "Modbus_Master_Status"

Posted: 16 Dec 2019, 11:34
by dirk
Hi Ibrahim Stracey, your ideas are good. The Modbus_Master_Status is involved with the device path i.e. if you configured a device /dev/ttyUSB0 which is not present or available.
The Modbus_Action_Status is involved when the ModbusRTU slave is involved i.e. if it is not present.

Re: Modbus RTU Master "Modbus_Master_Status"

Posted: 17 Dec 2019, 09:16
by Ibrahim Stracey
Thanks Dirk for confirming that I'm on the right track. But the strange issue still persists. The Modbus_Master_Status and Modbus_Action_Status only change when I perform a full driver reset (piTest -x). For example, If I check the Modbus_Master_Status it will show 0, but when I unplug the Arduino it still shows 0. It only changes now to "17" after a driver reset. Any idea why that is? My requirements are such that I need the error statuses to change dynamically, i.e. the Master status and action status should change immediately when a device is unplugged. I need to avoid a driver reset as much as possible. I've also noticed that the Virtual Modbus Master won't "resume" the connection with a device until I perform a driver reset. I hope this all makes sense!

Thank you

Re: Modbus RTU Master "Modbus_Master_Status"

Posted: 18 Dec 2019, 14:55
by dirk
Hi Ibrahim Stracey, I uderstand your ideas and the need of a general "error" indicator. But the current implementation is that every action as a corresponding action status which you have to query.