Logic Machine Forum
Rs 485 - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Rs 485 (/showthread.php?tid=5153)



Rs 485 - a455115 - 14.12.2023

Hello admin, I have a device that operates on RS485. I would like to read data from it. It's not Modbus, but some other RS485. How can I 'listen' to what is coming on the port?


RE: Rs 485 - admin - 14.12.2023

This script will log every received character in hexadecimal form.
Code:
port = require('serial').open('/dev/RS485-1', {
  baudrate = 9600,
  parity = 'even',
  duplex = 'half',
})

while true do
  ch = port:read(1, 1)
  if ch then
    loghex(ch)
  end
end



RE: Rs 485 - AISystem - 14.12.2023

I needed something similar for rs232 too. There was one example on the site for rs 232 but it is gone.
Thank you!


RE: Rs 485 - admin - 14.12.2023

For RS232 change /dev/RS485-1 to /dev/RS232 and duplex from half to full