-
Notifications
You must be signed in to change notification settings - Fork 97
Feature/prevent inf loop #210
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
Conversation
johanstokking
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove comments and format the code (spaces between operators, use code formatter)
Also maybe while (!read && loops--) is short and clear?
|
But this comes down to style preference. If you want the library to follow your style I'll change it. |
src/TheThingsNetwork.cpp
Outdated
| { | ||
| readResponse(SYS_TABLE, SYS_TABLE, SYS_GET_HWEUI, buffer, sizeof(buffer)); | ||
| debugPrintIndex(SHOW_EUI, buffer); | ||
| if(strlen(buffer)<16) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting
Times out after 10 seconds now.
Remove waitForOk to prevent a merge conflict
a3d99b3 to
ada96c1
Compare
ada96c1 to
952e413
Compare
src/TheThingsNetwork.cpp
Outdated
| while (read == 0 && timeout > 0) | ||
| while (read == 0 && attempts > 0) | ||
| { | ||
| timeout--; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
readBytesUntil has a timeout of 1000ms. If you have multiple attempts to call that function, the attempts are directly proportional to the timeout. timeout makes more sense to me, because it is a value in seconds.
|
This should only be used after resetting the module, to test that there is actually a module out there. Otherwise, the RN module is stable enough to respond with something. Setting an arbitrary timeout, even user defined, is causing trouble by having stuff available on the serial that causes issues with request/response expectations. |
|
The original reason I added this was to notify the user that communication with the RN was unsuccessful. This can be either because the wrong serial port was defined and passed to this library, or that the RN module is not responding (bad wiring, etc). In the current state the library will just hang indefinitely. |
Prevent an infinite loop in the
readLinefunction. An infinite loop might occur when the wrong Serial port is defined. Therefore print out an error in theshowStatusfunction, returning after 10 seconds, rather than waiting indefinitely.