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
#7
port:read(17) is a blocking read. It won't return until 17 bytes are read.
For one-way communication you can use UDP for data transport between scripts:
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(1)
  port:write(':RR\r\n')
end

Send commands like this:
Code:
data = '123456'

sock = require('socket').udp()
sock:sendto(data, '127.0.0.1', 5485)
sock:close()
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: