Skip to content
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 connection tracking and basic exception handler. #35

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

amarburg
Copy link
Collaborator

@amarburg amarburg commented Jan 31, 2024

Zero-th order update which should reduce segfaults from Oculus.

This addresses two core problems:

  1. When the IP address for the sonar is provided (as opposed to relying on auto-detection), "isConnected()" was using a function which did not actually indicate if the socket was connected (it indicated that the socket was "open" but did not validate IP address, port, etc). Instead, we track this state manually. This prevents the code from erroneously sending data to a non-existent (or not powered on) destination.
  2. When you send data to a non-existent destination, asio throws an exception, which wasn't being caught. Added a highest-level catch.

The remaining failure point is that we still don't have a higher-level retry loop, so it won't catch if the sonar was off, then was turned on and became available. Or was on, then turned off, then on again. TBD.

Current behavior is:

  • IpAddress provided to driver, but sonar is not on. Outcome: Library goes into an infinite wait (Waiting for data on a closed socket that will never open)
  • Sonar is connected (either through autodetect or manually specified), then turn off. Outcome: Library goes into an infinite wait (Waiting for data on a closed socket that will never open)

@amarburg
Copy link
Collaborator Author

I've expanded the scope of this PR; it now includes "real" error checking for disconnects, tx/rx errors and timeouts. The library largely does not do anything autonomously, instead relying on onDisconnect and onTimeout callbacks for the userspace code to coordinate a response.

This works for both "auto" and specified-IP modes, although finding the right amount of debug output was a challenge -- right now we can't distinguish "the connection was lost (the sonar dropped out)" from "I (re-)tried but couldn't reach the sonar". In the former case you want some log output. In the latter, you might prefer not to have continuous updates as it retries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant