19.04.2022, 07:43
Disable RTU in Modbus settings and run this script once. Post what you get in Logs.
You might need to change the serial settings in the script. It is currently set to 9600 baud, no parity (N) and 1 stop bit.
You might need to change the serial settings in the script. It is currently set to 9600 baud, no parity (N) and 1 stop bit.
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:readregisters(0)
log(res, err)
mb:close()
log(table.concat(buffer))