15.11.2024, 09:13
This error is usually caused by an issue on the physical communication level.
Disable RTU in Modbus settings and run this script once. Post what you get in Logs. Change device address (1) as needed.
Disable RTU in Modbus settings and run this script once. Post what you get in Logs. Change device address (1) as needed.
Code:
require('luamodbus')
mb = luamodbus.rtu()
mb:open('/dev/RS485-1', 9600, 'N', 8, 1, 'H')
mb:connect()
buffer = {}
mb:setdebug(function(msg)
buffer[ #buffer + 1 ] = msg
end)
mb:setslave(1)
res, err = mb:writemultipleregisters(28302, 0)
log(res, err)
mb:close()
log(table.concat(buffer))