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.
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.
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 lastfield
of the packet is hexadecimal data, and when it starts with a letter, such asB0*2
,strtol()
fails to parse, returns 0(base is10
), andendptr
points toB
,minmea_isfield ()
returnstrue
, and the parsing error exits.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.
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.