Logic Machine Forum
Modbus TCP Slave Problem - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Modbus TCP Slave Problem (/showthread.php?tid=6025)



Modbus TCP Slave Problem - JaegerMa2 - 17.06.2025

Hello
I want to write values to a slave. The script I have has been configured with various logs to determine where the problem lies. The log indicates that the script is running successfully, but no values are being written. When I check the traffic on port 502 with Wireshark, I don't see any traffic. However, when I poll the slave using Modbuspoll, everything works fine. I've also tried adjusting the register address because it might be offset by 1, but to no avail. Can someone tell me what I'm doing wrong?


RE: Modbus TCP Slave Problem - admin - 17.06.2025

The recommended way is to use profiles instead of scripts: https://forum.logicmachine.net/showthread.php?tid=5911

Each value for writemultipleregisters is passed as a separate argument, not a table:
Code:
mb:writemultipleregisters(32, 1)
mb:writemultipleregisters(33, 1)

You can write to both registers with one call:
Code:
mb:writeregisters(32, 1, 1)