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.

MODBUS TCP SLAVE
#1
I have this exmple the modbus tcp slave.
But when I try to read the log I get an error.
why?

this is the type error that have 

* arg: 1
  * string: read failed
* arg: 2
  * string: Bad file descriptor


Code:
require('luamodbus') if not mb then    mb = luamodbus.tcp()   end   mb:open('0.0.0.0', 502)   mb:connect()   mb:setslave(2)   mb:setmapping(1, 1, 3300, 1)     function setint64(grpaddr, regaddr)     local value = grp.getvalue(grpaddr) or 0     local raw = knxdatatype.encode(value, dt.int64).dataraw     local r1 = raw:byte(2) * 0x100 + raw:byte(1)     local r2 = raw:byte(4) * 0x100 + raw:byte(3)     local r3 = raw:byte(6) * 0x100 + raw:byte(5)     local r4 = raw:byte(8) * 0x100 + raw:byte(7)    val, err = mb:setregisters(regaddr, r4,r3,r2,r1) end   function updateregisters()     setint64('32/1/1', 3204)   end   updateregisters()   val, err = mb:readregistervalue(3204, 'int64', 'b') log (val,err)   if val then     log('read ok', val)   else     log('read failed', err)   end
Reply


Messages In This Thread
MODBUS TCP SLAVE - by palomino - 22.09.2022, 11:57
RE: MODBUS TCP SLAVE - by admin - 22.09.2022, 12:07

Forum Jump: