07.05.2019, 11:10
Use this script to test communication between RS485-1 <> RS485-2. Only single resident script is required.
Code:
require('serial')
p1 = serial.open('/dev/RS485-1', { duplex = 'half' })
p2 = serial.open('/dev/RS485-2', { duplex = 'half' })
function test(p1, p2)
p1:flush()
p2:flush()
for i = 1, 100 do
p1:write('1234567890')
res = p2:read(10, 1)
if not res or res ~= '1234567890' then
haserror = true
break
end
end
end
haserror = false
test(p2, p1)
test(p1, p2)
if haserror then
alert('RS485 ERROR')
else
alert('RS485 OK')
end