jeudi 28 juin 2018

Regex for GPS data

I am trying to check whether a GPS lock is active by parsing NMEA messages from a GPS chip.

The following line with the highlighted 'A' confirms the data is valid and hence a GPS lock is active.

$GPRMC,132417.000,A,5112.2257,N,00009.5337,W,0.00,288.79,140618,,,A*76

It is possible that the number between 'GPRMC' and 'A' is missing if there no GPS lock, in which case we 'V' (for invalid data) instead of 'A'.

I know I could do this by string manipulation, searching for the second comma after the GPRMC keyword and then checking we have a letter A after that.

Is there a more elegant way using regex? I'm not as familiar with regex expressions as I would like to be.

I am trying to do this in C++14.

Aucun commentaire:

Enregistrer un commentaire