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

Prevent GPS injection from choking the GPS driver #12710

Merged
merged 4 commits into from
Aug 23, 2019

Conversation

potaito
Copy link
Contributor

@potaito potaito commented Aug 15, 2019

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.

Sending a continuous stream of injection messages can cause the
GPS driver to get stuck indefinitely in the handling loop.
@potaito potaito requested a review from bkueng August 15, 2019 10:57
@potaito potaito self-assigned this Aug 15, 2019
@@ -416,7 +416,10 @@ void GPS::handleInjectDataTopic()
{
bool updated = false;

const size_t max_num_injections = 6;
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point 👍

Copy link
Contributor Author

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.

bkueng
bkueng previously approved these changes Aug 19, 2019
Copy link
Member

@bkueng bkueng left a 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.

@dagar dagar merged commit 2cb26dd into master Aug 23, 2019
@dagar dagar deleted the fix/gps-injection-chokes-driver branch August 23, 2019 23:12
@potaito
Copy link
Contributor Author

potaito commented Sep 2, 2019

My apologies. I left for vacation without completing this PR. Thanks @bkueng and @dagar for finishing it. Much appreciated 👍

bozkurthan pushed a commit to bozkurthan/Firmware that referenced this pull request Sep 4, 2019
Sending a continuous stream of injection messages can cause the
GPS driver to get stuck indefinitely in the handling loop.
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.

3 participants