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.

Problem with rs485-3
#2
Connect RS485-2 and RS485-3 A/B wires together and run this self test script. It will tell whether the port is working correctly or not:
Code:
require('serial')

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

str = '1234567890'
ok = true

function test(p1, p2)
  p1:flush()
  p2:flush()

  for i = 1, 100 do
    p1:write(str)
    local res = p2:read(#str, 1)
    ok = ok and res == str
    if not ok then
      break
    end
  end
end

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

alert('RS485 self test ' .. (ok and 'OK' or 'ERROR'))
Reply


Messages In This Thread
Problem with rs485-3 - by Gijs3 - 13.02.2021, 14:38
RE: Problem with rs485-3 - by admin - 15.02.2021, 08:13

Forum Jump: