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 script
#2
You can try reading data from a resident script. Just make sure that you disable RTU in modbus mapper, otherwise it will not work. Also you need to change script parameters like port name, baud, slave id etc. Once script finishes you will see the result in Logs tab.

Code:
require('luamodbus')
mb = luamodbus.rtu()

-- open serial connection, set correct port name, baud and parity
mb:open('/dev/RS485', 38400, 'E', 8, 1, 'H')
mb:connect()

-- set slave ID
mb:setslave(10)

res, err = mb:readinputregisters(792)

-- close serial connection
mb:close()

log(res, err)
Reply


Messages In This Thread
Modbus script - by oyvindnordbo - 19.05.2016, 12:09
RE: Modbus script - by admin - 19.05.2016, 13:17
RE: Modbus script - by oyvindnordbo - 20.05.2016, 06:14
RE: Modbus script - by zoltan - 21.05.2016, 19:34

Forum Jump: