This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

LM as ModbusSlave. Transaction ID error
#1
I have two LMs and I run one script on them to transfer values from LM via Modbus. On one of the LMs everything works fine, on the second "Transaction ID error". Please help me! I'm still quite a beginner.
 
The first LM has package  luamodbus 20160606
On the second LM - luamodbus 20190219

Code:
if not mb then   require('genohm-scada.eibdgm')   require('luamodbus')   -- list of coil mapping, starting from 0   coils = {}   -- list of register mapping, starting from 0   registers = {     {'40/1/5',dt.float32,0},{'40/1/6',0xFF,1} }   holdingRegisters = {     {'40/1/7',dt.uint16} }     -- list of register data types, element count must match registers table         -- knx group write callback   function knxgroupwrite(event)     local value     -- try to find matching coil     for id, addr in ipairs(coils) do       if event.dst == addr then         value = knxdatatype.decode(event.datahex, dt.bool)         mb:setcoils(id - 1, value)       end     end         -- try to find matching holding register     for id, addr in ipairs(holdingRegisters) do       if event.dst == addr[1] then         value = knxdatatype.decode(event.datahex,addr[2])         mb:setregisters(id-1, value)       end       end     -- try to find matching input register     for id, addr in ipairs(registers) do       if event.dst == addr[1] then         if (addr[2]==dt.float32) then           value = knxdatatype.decode(string.sub(event.datahex,1,4), dt.uint32)         mb:setinputregisters(1+addr[3], value)             value = knxdatatype.decode(string.sub(event.datahex,-4), dt.uint32)       mb:setinputregisters(addr[3], value)             elseif (addr[2]==0xFF) then             else               value = knxdatatype.decode(event.datahex,addr[2])               mb:setinputregisters(addr[3], value)             end       end     end   end   -- coil write callback   function mbwritecoils(coil, value)     local addr = coils[ coil + 1 ]     if addr then       grp.write(addr, value, dt.bool)     end   end   -- register write callback function mbwriteregisters(register, value) local addr = holdingRegisters[ register + 1 ][1]     if addr then   grp.write(addr, value, holdingRegisters[ register + 1][2])     end   end   -- knx group monitor, handles group writes   knxclient = eibdgm:new({ timeout = 0.1 })   knxclient:sethandler('groupwrite', knxgroupwrite)   -- modbus slave, listen on all interfaces and default port 502   mb = luamodbus.tcp()   mb:open('0.0.0.0', 502)    --setting slave id is optional    --mb:setslave(1)   mb:setreceivetimeout(0.1)   mb:setmapping(#coils, 0, #holdingRegisters, #registers)   -- init coils   for id, addr in ipairs(coils) do     value = grp.getvalue(addr)     mb:setcoils(id - 1, value)   end   -- init holding registers   for id, addr in ipairs(holdingRegisters) do     value = grp.getvalue(addr[1])     mb:setregisters(id - 1, value)   end   -- init registers   for id, addr in ipairs(registers) do     if (addr[2]==dt.float32) then     elseif(addr[2]==0xFF) then     else       value = grp.getvalue(addr[1])       mb:setregisters(addr[3], value)   end   end     -- set callbacks for coil and register write   mb:setwritecoilcb(mbwritecoils)   mb:setwriteregistercb(mbwriteregisters) end -- handle modbus and knx mb:handleslave() knxclient:step()
Reply
#2
Why are you trying to use ModBus for data exchange? You can use KNX/IP routing without any scripts for this.
Reply
#3
We will transfer data to a top system that only understands ModBus. LM will work as a gateway.
Strange that the script with data like int16 works fine. Сould you give me the package luamodbus 20160606 for the test?
Reply
#4
Which libmodbus (not luamodbus) package versions do you have on both devices?
Reply
#5
Yes. Both devices have libmodbus
Reply
#6
Tell me the package versions on both devices
Reply
#7
on old device 3.1.2-4, on new - 3.1.2-5
"Transaction ID error" - on new device
Reply
#8
There are no changes related to ModBus TCP between these versions. Check if you have any errors in the Error Log. TCP slave script has been used by many users an no one reported this error before. This might also be an issue in your top system. If it runs on Windows then you can provide a WireShark dump to see what's causing this issue.
Reply


Forum Jump: