-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement error handling/timeout on readLine from LoRa module #242
Comments
Yeah I am aware of this issue. It's not just a matter of adding the timeout, that's why it was never implemented, but I agree that a deadlock is not nice either. The problem is that if you return early, the library doesn't know the state of the RN module anymore. If the next command would work, the first response may be some previous response that's in a buffer, instead of the expected response. Also, the RN module should return a response all the time – otherwise I think there's an issue with the RN module. In any case, it makes sense to put a timeout on the serial. If |
Yeah I see your point about returning too early. RN module as you say should work 100% of the time, however sometimes we see it locks up, not knowing why or what triggered it. I would agree that fixing the root cause would be the best solution, but unfortunately we cant access the raw firmware of the RN module to figure out what goes wrong. So then we though about how to handle this error. You may argue that if the response time is over a certain value the RN module is likely in a faulty state. If the function is returning a zero, as you suggest, it will give the application the possibility to handle the error which is an enhancement to now. |
I see two approaches to handle the timeout.
|
I think we have to use a timeout, as The timeout could be set in the application sketch by the user, so that's why it's expecting and looping over Instead, I think we need to have some invalid state marker in the class, to inform the application that the RN module needs to be reset. Can you work on a PR? |
I have created a PR. Let me know your thoughts about it. |
I sometimes experience that the LoRa module(RN2483) does not send anything back after a sendBytes. The current implementation will wait forever until a return signal is send. This will result in deadlock unless a WDT is externally used. On many MCU's the WDT will have less than 8s count which is not always enough for a message to send.
arduino-device-lib/src/TheThingsNetwork.cpp
Lines 360 to 369 in 23c933f
I propose that a timeout is implemented to handle if there is no response from RN2483 within reasonable time.
The text was updated successfully, but these errors were encountered: