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.

LM5 RS485 check
#4
here is the script for RS485 self-test with either OK or ERROR message in Alerts. 
Make sure to adjust port names accordingly (2nd, 3rd lines):

Code:
require('serial')

port1 = serial.open('/dev/RS485-1', { duplex = 'half' })
port2 = serial.open('/dev/RS485-2', { duplex = 'half' })

function test(p1, p2)
errors = 0

p1:flush()
p2:flush()

for i = 1, 100 do
p1:write('1234567890')
res = p2:read(10, 1)
if res and res == '1234567890' then
res = '+'
else
res = '-'
errors = errors + 1
if errors > 5 then
break
end
end

io.write(res)
io.flush()

if i % 50 == 0 then
print()
end
end
end

test(port2, port1)
test(port1, port2)

alert(errors > 0 and 'ERROR' or 'OK')
Reply


Messages In This Thread
LM5 RS485 check - by gtsamis - 03.03.2019, 15:11
RE: LM5 RS485 check - by admin - 03.03.2019, 16:24
RE: LM5 RS485 check - by gtsamis - 07.03.2019, 08:11
RE: LM5 RS485 check - by edgars - 10.06.2019, 07:12
RE: LM5 RS485 check - by edgars - 10.06.2019, 07:16
RE: LM5 RS485 check - by davidchispas - 23.09.2019, 15:22
RE: LM5 RS485 check - by Daniel - 23.09.2019, 15:35
RE: LM5 RS485 check - by davidchispas - 23.09.2019, 16:08
RE: LM5 RS485 check - by Daniel - 23.09.2019, 16:34
RE: LM5 RS485 check - by davidchispas - 23.09.2019, 17:27
RE: LM5 RS485 check - by Daniel - 24.09.2019, 07:54
RE: LM5 RS485 check - by davidchispas - 24.09.2019, 13:09
RE: LM5 RS485 check - by edgars - 25.09.2019, 07:38
RE: LM5 RS485 check - by admin - 26.09.2019, 08:04

Forum Jump: