09.11.2018, 12:31
Evrithing is good its working code:
Code:
require('serial')
port = serial.open('/dev/RS485-1', { baudrate = 57600, parity = 'none', duplex = 'half', databits = 8, stopbits = 1 })
port:flush()
function readack()
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
port:write('get sauna\r')
res, err = readack()
log(res, err)
port:close()