08.11.2018, 14:23
Hi,
when I write an INT16 in the register concerned, the value is taken into account by the slave, but the slave then goes into error when its "time out" time is reached. It seems that the Modbus frame is misinterpreted.
This does not happen when I write UINT16 in the registers of the same slave.
Here is my script (reduced to the problem section) :
------------------------------------------------------------------------------
modbus_slave_num = 7
-- eval temps execution de ce script
local ts, tus = os.microtime()
-- nom de ce script
log("--------------------------------------------------------------------")
log(_SCRIPTNAME)
-- Init Modbus
modbus_slave_num = 7
if not mb then
require('luamodbus')
mb = luamodbus.rtu()
mb:open("/dev/RS485", 19200, "E", 8, 1,"H")
mb:connect()
end
mbetslave(modbus_slave_num)
-- register 11410 = INT16 <<<<<<<<< PROBLEM >>>>>>>>>>>>>
result1 = mb:writeregisters(11410, 130)
log ("Result1 = ",result1)
-- Fermer la connexion Modbus
mb:close()
-- eval temps execution de ce script
log("TEMPS EXCE : ", os.udifftime(ts, tus))
------------------------------------------------------------------------------
Have a nice end of day,
Dominique
when I write an INT16 in the register concerned, the value is taken into account by the slave, but the slave then goes into error when its "time out" time is reached. It seems that the Modbus frame is misinterpreted.
This does not happen when I write UINT16 in the registers of the same slave.
Here is my script (reduced to the problem section) :
------------------------------------------------------------------------------
modbus_slave_num = 7
-- eval temps execution de ce script
local ts, tus = os.microtime()
-- nom de ce script
log("--------------------------------------------------------------------")
log(_SCRIPTNAME)
-- Init Modbus
modbus_slave_num = 7
if not mb then
require('luamodbus')
mb = luamodbus.rtu()
mb:open("/dev/RS485", 19200, "E", 8, 1,"H")
mb:connect()
end
mbetslave(modbus_slave_num)
-- register 11410 = INT16 <<<<<<<<< PROBLEM >>>>>>>>>>>>>
result1 = mb:writeregisters(11410, 130)
log ("Result1 = ",result1)
-- Fermer la connexion Modbus
mb:close()
-- eval temps execution de ce script
log("TEMPS EXCE : ", os.udifftime(ts, tus))
------------------------------------------------------------------------------
Have a nice end of day,
Dominique