21.06.2019, 12:05
You can enable debug mode to see what data is sent/received:
You can also add mb:flush() after sleep to discard any invalid data that could be received.
Code:
require('luamodbus')
buffer = {}
function logger(c)
table.insert(buffer, c)
end
mb = luamodbus.rtu()
mb:open('/dev/RS485-1', 9600, 'E', 8, 1, 'H')
mb:connect()
mb:setslave(1)
mb:setdebug(logger)
-- read/write here
log(table.concat(buffer))
You can also add mb:flush() after sleep to discard any invalid data that could be received.
Code:
mb:writereadregisters(write_reg_start, write_reg_value_1, write_reg_value_2, write_reg_value_3..., read_reg_start, read_reg_count)