05.06.2024, 07:12
Use this script to send a command and receive a reply from the bridge. Make sure that only a single script instance is running at any time. Serial port cannot be shared between multiple concurrent scripts.
Code:
require('serial')
port = serial.open('/dev/RS485-1', { baudrate = 9600 })
function readreply()
local line = {}
while true do
local char, err = port:read(1, 5)
if char == nil then
return nil, err
elseif char == ';' then
break
else
line[ #line + 1 ] = char
end
end
return table.concat(line)
end
command = '!000V?;'
port:write(command)
res, err = readreply()
log(res, err)