Logic Machine Forum
Modbus connection status (mbproxy) - 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 connection status (mbproxy) (/showthread.php?tid=1335)



Modbus connection status (mbproxy) - leonidas - 09.04.2018

Hello,

I have this code for reading modbus values. It is in resident script ~20s.
Now I need to make an alarm if there is no modbus connection and we are not getting new values.
How can I do it?

Code:
mbproxy = require('mbproxy')
mb = mbproxy.new()
mb:setslave(2)

--Actual temp
grp.write('32/3/1', (mb:readinputregistervalue(8203, 'uint16')/10),dt.float16)
os.sleep(0.5)
--Setpoint temp
grp.write('32/3/2', (mb:readinputregistervalue(8202, 'uint16')/10),dt.float16)
os.sleep(0.5)

Thanks.


RE: Modbus connection status (mbproxy) - admin - 09.04.2018

mb:read... function will return nil when device cannot be reached.