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
#4
You don't even need to store the time, you can simply count the number of times the device did not reply. Check the res variable contents because it will be nil on error and trying to manipulate res as a string will result in a script error.

Code:
res, err = port:read(27, 3) if res then   errors = 0   -- parse res contents else   errors = (errors or 0) + 1   if errors == 100 then     alert('device read timeout')   end end
Reply


Messages In This Thread
RE: RS485 alarm if the other device does not respond in certain time - by admin - 21.06.2022, 13:44

Forum Jump: