Logic Machine Forum
Problem with rs485-3 - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Gateway (https://forum.logicmachine.net/forumdisplay.php?fid=10)
+--- Thread: Problem with rs485-3 (/showthread.php?tid=3166)



Problem with rs485-3 - Gijs3 - 13.02.2021

Hi all,

I have a LM5p2-KC and have a problem with the third rs485 port (rs485-3), it doesn't work. When i connect the modbus device to port rs485-2 does it works, so the modbus device en profile are OK.

I removed the genohm-scada-enocean package. But it doesn't make a difference.
Can somboddy help me whit this?

Regards Gijs


RE: Problem with rs485-3 - admin - 15.02.2021

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'))