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.

RS485 signal collision
#9
Then you will need something like this. It will request the status after each write or socket read timeout so it can happen faster than once every 60 seconds. But I don't think that it will be an issue.
Code:
if not server then
  require('socket')
  server = socket.udp()
  server:setsockname('127.0.0.1', 5485)
  server:settimeout(60)
end

if not port then
  require('serial')
  port = serial.open('/dev/RS485-1', {
    baudrate = 19200,
    databits = 8,
    stopbits = 1,
    parity = 'none',
    duplex = 'half'
  })
end

data = server:receive()
if data then
  port:write(data)
  os.sleep(0.5)
end

port:write(':RR\r\n')
data = port:read(17, 1) -- read 17 bytes for up to 1 second
if data and #data == 17 then
  -- parse data response here
end
Reply


Messages In This Thread
RS485 signal collision - by Hadeel - 02.12.2022, 15:17
RE: RS485 signal collision - by Daniel - 02.12.2022, 15:33
RE: RS485 signal collision - by Hadeel - 02.12.2022, 15:54
RE: RS485 signal collision - by Daniel - 02.12.2022, 15:56
RE: RS485 signal collision - by Hadeel - 02.12.2022, 16:20
RE: RS485 signal collision - by Hadeel - 03.12.2022, 10:57
RE: RS485 signal collision - by admin - 05.12.2022, 07:51
RE: RS485 signal collision - by Hadeel - 05.12.2022, 18:58
RE: RS485 signal collision - by admin - 06.12.2022, 07:49
RE: RS485 signal collision - by Hadeel - 07.12.2022, 15:03
RE: RS485 signal collision - by Hadeel - 23.03.2023, 02:31
RE: RS485 signal collision - by admin - 23.03.2023, 06:00
RE: RS485 signal collision - by Hadeel - 23.03.2023, 07:48
RE: RS485 signal collision - by admin - 23.03.2023, 08:41
RE: RS485 signal collision - by Hadeel - 28.03.2023, 08:35
RE: RS485 signal collision - by admin - 30.03.2023, 05:42
RE: RS485 signal collision - by Hadeel - 30.03.2023, 07:59

Forum Jump: