Allow driver to recover on USB disconnect / reconnect #12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overcoming intermittent USB connection issues
Background / Problem
We have gotten good use out of this driver, but have had a chronic issue of the kangaroos occasionally dropping out, causing erroneous behavior (i.e. careening across the lab, sparing no shin, wall, or scientist).
Our platform (Jetson TX2) seems to be prone to occasional USB reset events, and when this occurs, the driver is left in a state of continuing to attempt to write to a file descriptor that is no longer valid.
Solution
My solution to this is to close the port, and attempt to reopen. If it is a momentary blip, then when the device reappears on the device list, it will be reopened with a new, valid file descriptor.
Line-by-Line:
Line 322:
close()
calls the method for closing the portLine 323:
fd = -1;
will makeis_open()
returnfalse
.Line 515: When this reset occurs, the kangaroo sometimes finds itself in a timeout state. Calling
send_start_signals(address)
if a timeout error is received will clear the error and restart the device.Hopefully this will help someone else experiencing the same issues!
--Hal Jarrett, Georgia Tech Research Institute