![]() |
Modbus function code 23 (#17) - 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 function code 23 (#17) (/showthread.php?tid=5949) |
Modbus function code 23 (#17) - alb-smith - 27.03.2025 Does LM support the Modbus function code 23 with profiles or with a script (luamodbus)? Thanks. RE: Modbus function code 23 (#17) - admin - 27.03.2025 See this: https://forum.logicmachine.net/showthread.php?tid=1225&pid=13244#pid13244 Are you sure that function 23 is needed? Usually you can do writing and reading separately. RE: Modbus function code 23 (#17) - alb-smith - 27.03.2025 Thanks for the answer. User manual of this device seems to require FC 23 as you can see in the picture. It's a Modbus interface for Mastervolt Battery charger (https://www.mastervolt.it/prodotti/masterbus-interfaces/masterbus-modbus-interface/) RE: Modbus function code 23 (#17) - alb-smith - 28.03.2025 When trying to implement communication with this device I always get the error "Bad file descriptor". This LM uses both Modbus RTU ports with a different configuration. Code: require('luamodbus') This is the RTU port configuration: RE: Modbus function code 23 (#17) - admin - 28.03.2025 RS must be uppercase in the port name. RE: Modbus function code 23 (#17) - alb-smith - 29.03.2025 I partially solved it using the send() function sending a string to the device. In debug I can see the response which is complete and correct but the mb:receive() function returns a timeout error. Code: require('luamodbus') Logs report: Response error: Operation timed out Debug: * string: [01][17][00][00][00][06][00][00][00][06][0C][0A][01][AE][0F][00][00][00][11][00][00][00][00][91][AF] Waiting for a indication... <01><17><0C><0A><01><AE><0F><00><00><00><11><00><00><00><42><C1><35>ERROR Operation timed out: select The response captured by debug is complete and correct. I tried to change setreceivetimeout() and setresponsetimeout() with no effects. RE: Modbus function code 23 (#17) - admin - 31.03.2025 You can't use receive for master operation. The equivalent of your raw string using writereadregisters is this: Code: mb:writereadregisters(0, 0x0A01, 0xAE0F, 0, 0x0011, 0, 0, 0, 6) |