Forráskód Böngészése

minmea: added minmea_parse_gsv

mek_x 11 éve
szülő
commit
c273d92a33
2 módosított fájl, 53 hozzáadás és 0 törlés
  1. 37 0
      minmea.c
  2. 16 0
      minmea.h

+ 37 - 0
minmea.c

@@ -287,6 +287,8 @@ enum minmea_sentence_id minmea_sentence_id(const char *sentence)
         return MINMEA_SENTENCE_GGA;
     if (!strcmp(type+2, "GSA"))
         return MINMEA_SENTENCE_GSA;
+    if (!strcmp(type+2, "GSV"))
+        return MINMEA_SENTENCE_GSV;
 
     return MINMEA_UNKNOWN;
 }
@@ -385,6 +387,41 @@ bool minmea_parse_gsa(struct minmea_sentence_gsa *frame, const char *sentence)
     return true;
 }
 
+bool minmea_parse_gsv(struct minmea_sentence_gsv *frame, const char *sentence)
+{
+    // $GPGSV,3,1,11,03,03,111,00,04,15,270,00,06,01,010,00,13,06,292,00*74
+    char type[6];
+
+    if (!minmea_scan(sentence, "tiiiiiiiiiiiiiiiiiii",
+            type,
+            &frame->total_msgs,
+            &frame->msg_nr,
+            &frame->total_sats,
+            &frame->sats[0].nr,
+            &frame->sats[0].elevation,
+            &frame->sats[0].azimuth,
+            &frame->sats[0].snr,
+            &frame->sats[1].nr,
+            &frame->sats[1].elevation,
+            &frame->sats[1].azimuth,
+            &frame->sats[1].snr,
+            &frame->sats[2].nr,
+            &frame->sats[2].elevation,
+            &frame->sats[2].azimuth,
+            &frame->sats[2].snr,
+            &frame->sats[3].nr,
+            &frame->sats[3].elevation,
+            &frame->sats[3].azimuth,
+            &frame->sats[3].snr
+            )) {
+        return false;
+    }
+    if (strcmp(type+2, "GSV"))
+        return false;
+
+    return true;
+}
+
 int minmea_gettimeofday(struct timeval *tv, const struct minmea_date *date, const struct minmea_time *time)
 {
     if (date->year == -1 || time->hours == -1)

+ 16 - 0
minmea.h

@@ -31,6 +31,7 @@ enum minmea_sentence_id {
     MINMEA_SENTENCE_RMC,
     MINMEA_SENTENCE_GGA,
     MINMEA_SENTENCE_GSA,
+    MINMEA_SENTENCE_GSV
 };
 
 struct minmea_date {
@@ -89,6 +90,20 @@ struct minmea_sentence_gsa {
     int vdop, vdop_scale;
 };
 
+struct minmea_sat_info {
+    int nr;
+    int elevation;
+    int azimuth;
+    int snr;
+};
+
+struct minmea_sentence_gsv {
+    int total_msgs;
+    int msg_nr;
+    int total_sats;
+    struct minmea_sat_info sats[4];
+};
+
 /**
  * Check sentence validity and checksum. Returns true for valid sentences.
  */
@@ -123,6 +138,7 @@ bool minmea_scan(const char *sentence, const char *format, ...);
 bool minmea_parse_rmc(struct minmea_sentence_rmc *frame, const char *sentence);
 bool minmea_parse_gga(struct minmea_sentence_gga *frame, const char *sentence);
 bool minmea_parse_gsa(struct minmea_sentence_gsa *frame, const char *sentence);
+bool minmea_parse_gsv(struct minmea_sentence_gsv *frame, const char *sentence);
 
 /**
  * Convert GPS UTC date/time representation to a UNIX timestamp.