[LEDE-DEV] [PATCH ugps 4/7] Use strsep for NMEA message tokenization
Petr Štetiar
ynezz at true.cz
Wed Jul 27 05:45:51 PDT 2016
strtok doesn't parse correctly following message:
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
Resulting in "datagram has wrong parameter count".
Signed-off-by: Petr Štetiar <ynezz at true.cz>
---
nmea.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/nmea.c b/nmea.c
index 05c904d..3646a36 100644
--- a/nmea.c
+++ b/nmea.c
@@ -221,13 +221,13 @@ static int
nmea_tokenize(char *msg)
{
int cnt = 0;
- char *tok = strtok(msg, ",");
+ char *tok = strsep(&msg, ",");
while (tok && cnt < MAX_NMEA_PARAM) {
nmea_params[cnt].str = tok;
nmea_params[cnt].num = atoi(tok);
cnt++;
- tok = strtok(NULL, ",");
+ tok = strsep(&msg, ",");
}
return cnt;
--
1.9.1
More information about the Lede-dev
mailing list