-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
Prevent GPS injection from choking the GPS driver #12710
Conversation
Sending a continuous stream of injection messages can cause the GPS driver to get stuck indefinitely in the handling loop.
@@ -416,7 +416,10 @@ void GPS::handleInjectDataTopic() | |||
{ | |||
bool updated = false; | |||
|
|||
const size_t max_num_injections = 6; |
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.
Magic numbers :-) Can you add a comment why it's 6?
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.
Fair point 👍
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.
Problem is I don't remember exactly the argument for 6. I think the injection data that belongs together is split into multiple messages for multiple sattelite networks. So Galileo, Baidu etc.
Let me ask someone who knows for sure.
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.
Code style is broken, otherwise looks good.
Sending a continuous stream of injection messages can cause the GPS driver to get stuck indefinitely in the handling loop.
Solves #11716
FYI @tdnet12434
Describe problem solved by the proposed pull request
Sending a continuous stream of injection data can cause the GPS driver to get stuck indefinitely in the handling loop.
Test data / coverage
We tested with a proprietary module able to spam GPS injection data for a few seconds.
@tdnet12434 came to the same conclusion individually: #11716 (comment)
Describe your preferred solution
This proposed solution is a bit hacky, since it uses a hard-coded integer for the maximum number of consecutive injection message to handle. We are limiting to 6 consecutive messages, since a GPS injection data set can be split and sent as multiple messages. Reading only a single message per loop might yield incomplete injection data. According to our knowledge, no injection data set is larger than 3 messages.
Describe possible alternatives
Any solution not involving a magic number.