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 alarm if the other device does not respond in certain time
#3
Thank you admin! This time the system is not Modbus, it is RS485 ASCII. so I will use os.time() to store the last device responce and compare it with current time in resident script .

I would also like to have your suggestion about what timeout I should use in the
port:read(bytes, timeout) method.

The condition is, as I wrote in the first thread,
>When sending command from LM to the other device, the other device is suppose to give LM a respond in at most 3 seconds.
> However if the device does not give any responce in 5 min, I need to consider that as an error and indicate an alert.

I am sorry, maybe it's a basic questions but I appreciate if you could help (:

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

port:flush()
res, err = port:read(27, 3)

--example res = ":00010001130077770010AB"
t = split(res, ":")

for k,v in pairs(t) do
~~
end
```
Reply


Messages In This Thread
RE: RS485 alarm if the other device does not respond in certain time - by Hadeel - 21.06.2022, 07:03

Forum Jump: