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

minmea_scan(): read check bit problem #78

Open
yuanjinghh opened this issue Apr 22, 2024 · 2 comments
Open

minmea_scan(): read check bit problem #78

yuanjinghh opened this issue Apr 22, 2024 · 2 comments

Comments

@yuanjinghh
Copy link

Hi,
When I was parsing GSV data, I found that in some cases, the incoming packet parsing failed.
Then, I did error tracing and found that the last field of the packet is hexadecimal data,
and when it starts with a letter, such as B0*2, strtol() fails to parse, returns 0(base is 10), and endptr points to B,
minmea_isfield () returns true, and the parsing error exits.

 case 'i':
        { // Integer value, default 0 (int).
            int value = 0;

            if (field)
            {
                char *endptr;
                value = strtol(field, &endptr, 10);
                if (minmea_isfield(*endptr))
                    goto parse_error;
            }

            *va_arg(ap, int *) = value;
        }
        break;

However, it seems to me that this is a bug in the program, and it exists in other parsing, but I don't have a good way to solve it.I just fixed the problem for a while to meet my needs.

            if (field)
            {
                char *endptr;
                value = strtol(field, &endptr, 10);
                if (minmea_isfield(*endptr))
                {
                    if (strtol(field, &endptr, 16) != 0)
                        result = true;
                    goto parse_error;
            }

I don't know if there is any problem with my understanding, and I hope there is a better way to solve this problem.
Thanks.

@kosma
Copy link
Owner

kosma commented Apr 22, 2024

Please post:

  • Full unedited line as received from the GPS receiver
  • Model of the GPS receiver

Then I can adapt the library to parse the sentence.

@yuanjinghh
Copy link
Author

Oh, I'm so sorry. It's my problem.

  • GPS receiver: UM982
  • Protocol: NMEA V4.10
    Just because I'm using a different version of the protocol.
    GSV Note: NMEA 4.10+ systems (u-blox 9, Quectel LCD79) may emit an extra field, Signal ID, just before the checksum.

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

No branches or pull requests

2 participants