pud: include nmealib v1.0.1
authorFerry Huberts <ferry.huberts@pelagic.nl>
Mon, 16 Jul 2012 13:41:44 +0000 (15:41 +0200)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Mon, 16 Jul 2012 16:02:14 +0000 (18:02 +0200)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/pud/nmealib/Makefile.inc
lib/pud/nmealib/src/conversions.c

index 3037fa8..8950380 100644 (file)
@@ -22,7 +22,7 @@ endif
 
 # we expect the version to be like 'v0.5.3-27-g0c2727a' and then strip the 'v',
 # and the '-27-g0c2727a' parts
-VERSION=1.0.0
+VERSION=1.0.1
 
 # protect against no version number
 ifeq ($(strip $(VERSION)),)
index 94cc962..edfc960 100644 (file)
@@ -259,9 +259,6 @@ void nmea_GPGSV2info(const nmeaGPGSV *pack, nmeaINFO *info) {
  * @param pack_idx pack index (zero based)
  */
 void nmea_info2GPGSV(const nmeaINFO *info, nmeaGPGSV *pack, int pack_idx) {
-       int sit;
-       int pit;
-
        assert(pack);
        assert(info);
 
@@ -270,16 +267,39 @@ void nmea_info2GPGSV(const nmeaINFO *info, nmeaGPGSV *pack, int pack_idx) {
        pack->present = info->present;
        nmea_INFO_unset_present(&pack->present, SMASK);
        if (nmea_INFO_is_present(info->present, SATINVIEW)) {
+               int sit;
+               int pit;
+               int toskip;
+
                pack->sat_count = (info->satinfo.inview < NMEA_MAXSAT) ? info->satinfo.inview : NMEA_MAXSAT;
                pack->pack_count = nmea_gsv_npack(pack->sat_count);
 
                if (pack_idx >= pack->pack_count)
-                       pack->pack_index = (pack_idx % pack->pack_count) + 1;
+                       pack->pack_index = pack->pack_count;
                else
                        pack->pack_index = pack_idx + 1;
 
-               for (pit = 0, sit = ((pack->pack_index - 1) * NMEA_SATINPACK); pit < NMEA_SATINPACK; pit++, sit++)
-                       pack->sat_data[pit] = info->satinfo.sat[sit];
+               /* now skip the first ((pack->pack_index - 1) * NMEA_SATINPACK) in view sats */
+               toskip = ((pack->pack_index - 1) * NMEA_SATINPACK);
+               sit = 0;
+               while ((toskip > 0) && (sit < NMEA_MAXSAT)) {
+                       if (info->satinfo.sat[sit].id) {
+                               toskip--;
+                       }
+                       sit++;
+               }
+
+               for (pit = 0; pit < NMEA_SATINPACK; sit++) {
+                       if (sit < NMEA_MAXSAT) {
+                               if (info->satinfo.sat[sit].id) {
+                                       pack->sat_data[pit] = info->satinfo.sat[sit];
+                                       pit++;
+                               }
+                       } else {
+                               memset(&pack->sat_data[pit], 0, sizeof(pack->sat_data[pit]));
+                               pit++;
+                       }
+               }
        }
 }