LogicMachine Forum
Modbus TCP debug - Printable Version

+- LogicMachine 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 debug (/showthread.php?tid=4230)



Modbus TCP debug - MarcusH - 09.09.2022

Hi

Im wondring if its possible for Lm to debug incoming requests from master. 

i know about the "mbConfusedetdebug".

I managed to get this when using mb:readregister(x) in combination with mb:debug | * string: [00][01][00][00][00][06][FF][03][00][02][00][01] | 
This is excatly what i want , but i need to recieve it when an external master sends a request, not the Lm trying to read or write.

I wan't to be able to debug the request so i can use the data later in the code for mapping different settings. 

-Marcus


RE: Modbus TCP debug - admin - 12.09.2022

This example will create Modbus TCP slave on port 502. It will log all requests/responses.
Code:
require('luamodbus') mb = luamodbus.tcp() mb:open('0.0.0.0', 502) mb:setmapping(0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF) debug = {} mb:setdebug(function(ch)   debug[ #debug + 1 ] = ch end) while true do   mb:handleslave()   if #debug > 0 then     log(table.concat(debug))     debug = {}   end end