Skip to content

Added checks to discard gps data if RMC or GLL status is invalid - #32

Open
Bigmouseears wants to merge 5 commits into
mainfrom
feature/nr/gps_validation
Open

Added checks to discard gps data if RMC or GLL status is invalid#32
Bigmouseears wants to merge 5 commits into
mainfrom
feature/nr/gps_validation

Conversation

@Bigmouseears

@Bigmouseears Bigmouseears commented May 26, 2026

Copy link
Copy Markdown

Description

A brief description of the changes in the PR

Issue Link

Please provide a link to the issue (e.g. "Closes #1").

Also, if this PR is one of multiple for this issue, link the parent if this is a child OR link
the children if this is the parent. Do not use "closes" keywords on child PRs, only use them on
the parent.

Testing

  • Passes existing unit tests
  • Unit tests modified
  • Integration test performed

Attach any test artifacts here, if relevant.

Other

Leave any additional notes here

Reviewer Checklist

Standards

  • Follows FCF Architectural Standards
  • Follows SDR Coding Standards
  • Code complexity/function Size is minimized
  • Code is testable
  • Code is readable and commented properly
  • License terms are respected

Error Handling

  • Potentially unsafe functions return a status code
  • Error returns properly handled

Memory

  • Stack allocated memory is scoped correctly
  • Heap allocated memory is avoided
  • Globally allocated memory is minimized except when necessary
  • Pointers are used correctly
  • Concurrency has been considered

Performance

  • Rate limiters are respected
  • Busy waiting is avoided
  • "Delay" calls are not used in performance sensitive code

@ETSells ETSells left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

Technically should be ready to go, but I'd like some robustness cases put in place to exercise the new invalid paths. We can sync on what updating the tests should look like @Bigmouseears.

If you want to get started on them ahead of time, look in driver/_test/driver/gps/test_gps.c:test_GPS_parse, cases/NMEA_inputs.txt, and cases/gps_parse_expected.txt

@Bigmouseears

Bigmouseears commented Jun 2, 2026

Copy link
Copy Markdown
Author

I have it so that GPS data values are all set to 0 if data is invalid. Not sure if that will break anything so I guess it's worth mentioning.

@Bigmouseears

Copy link
Copy Markdown
Author

Wow i'm surprised it passed the unit tests. I wonder if I may have done the tests wrong?

@ETSells

ETSells commented Jun 3, 2026

Copy link
Copy Markdown
Member

Test request:

Add a case where there's data in the GPS struct already, and you receive an invalid message, confirm that the preexisting data is not overwritten

@ETSells

ETSells commented Jun 10, 2026

Copy link
Copy Markdown
Member

OH dude that explains so much, the driver CI is borked for unit tests and doesn't fail the job on a test fail.

Messages 9 and 15 fail to parse on the runner. Statement coverage is achieved.

@Bigmouseears
Bigmouseears requested a review from ETSells July 30, 2026 20:54

@ETSells ETSells left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Code updates look good, test cases show the result I expect, and CI runs of the test shows coverage passes the required spec and the results pass! Ship it!

Comment thread gps/gps.c
/*------------------------------------------------------------------------------
Global Variables
------------------------------------------------------------------------------*/
GPS_DATA gps_last_valid_rmc_data;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

hmm... works but id like us to consider encapsulating these to GPS's scope

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

ah, forgive my incompetence. For some reason I thought that "global" meant just visible across all functions in the file, and nowhere else.
I guess I can just make them static variables within the function then, like this (if the image works)
image

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

gps tests still pass with this implementation, at least on my end and if I didn't screw anything else up

Comment thread gps/gps.c
}
else if (gll_status == 'V')
{
*gps_ptr = gps_last_valid_gll_data;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: indentation should follow standards

Comment thread gps/gps.c
gps_ptr->gll_status = gll_status;

/* Save rest of data only if status is A: Data Valid */
if (gll_status == 'A')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

oof ik i didnt follow parentheses spacing standards when i wrote this function so this is fine for consistency. still sadge, don't ever let sophomore me write code again

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.

2 participants