ModBus TCP Slave - 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 (/showthread.php?tid=2357) |
ModBus TCP Slave - Gadjoken - 20.11.2019 Hello following the update of a HomeLynk I have my script for sending data on a IRIO that no longer works: Code: SLAVE_ADDRESS='192.168.70.246' Resident script:20: attempt to index global 'cnv' (a nil value) stack traceback: Resident script:20: in function 'update_registers' Do you have a solution to restore the connection? Thanks. B.R. RE: ModBus TCP Slave - admin - 20.11.2019 Replace all instances of cnv.tonumber(val) with tonumber(val) or 0 RE: ModBus TCP Slave - Gadjoken - 20.11.2019 Replace with tonumber (val) and error message is : Resident script:20: bad argument #1 to 'rshift' (number expected, got nil) stack traceback: [C]: in function 'rshift' Resident script:20: in function 'update_registers' I tried with 0 no error but no communication. B.R. RE: ModBus TCP Slave - admin - 20.11.2019 Can you log what value are you trying to convert to number. Is it Boolean value? RE: ModBus TCP Slave - Gadjoken - 21.11.2019 I sent data 2 Bytes floating point. B.R. RE: ModBus TCP Slave - admin - 21.11.2019 2 Bytes floating point is a number so it cannot raise an error. Can you post data types for all objects? Try this function instead of tonumber (add it to script and replace tonumber with mbtonumber): Code: function mbtonumber(val) |