altos: Trim skytraq NMEA messages. Shrink NMEA header matching code
authorKeith Packard <keithp@keithp.com>
Sun, 13 Nov 2011 02:54:14 +0000 (18:54 -0800)
committerKeith Packard <keithp@keithp.com>
Sun, 13 Nov 2011 02:54:14 +0000 (18:54 -0800)
Tell the skytraq to not bother sending a bunch of the NMEA messages
that we don't parse.

Explicitly look for 'G' follows by 'P' instead of having some general
header matching code.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/drivers/ao_gps_skytraq.c

index 6290960677651febc0b309f3b8ea252dc92628a5..050573e877282012acf1776668396f980822bfdf 100644 (file)
 #include "ao.h"
 #endif
 
-#define AO_GPS_LEADER          2
-
-static __code char ao_gps_header[] = "GP";
-
 __xdata uint8_t ao_gps_mutex;
 static __data char ao_gps_char;
 static __data uint8_t ao_gps_cksum;
@@ -50,7 +46,7 @@ static __pdata struct ao_telemetry_satellite  ao_gps_tracking_next;
     (id^a^b^c^d^e^f^g^h^i^j^k^l^m^n), STQ_E
 
 static __code uint8_t ao_gps_config[] = {
-       SKYTRAQ_MSG_8(0x08, 1, 1, 1, 1, 1, 1, 1, 0), /* configure nmea */
+       SKYTRAQ_MSG_8(0x08, 1, 0, 1, 0, 1, 0, 0, 0), /* configure nmea */
        /* gga interval */
        /* gsa interval */
        /* gsv interval */
@@ -418,11 +414,12 @@ ao_gps_nmea_parse(void)
        ao_gps_cksum = 0;
        ao_gps_error = 0;
 
-       for (a = 0; a < AO_GPS_LEADER; a++) {
-               ao_gps_lexchar();
-               if (ao_gps_char != ao_gps_header[a])
-                       return;
-       }
+       ao_gps_lexchar();
+       if (ao_gps_char != 'G')
+               return;
+       ao_gps_lexchar();
+       if (ao_gps_char != 'P')
+               return;
 
        ao_gps_lexchar();
        a = ao_gps_char;
@@ -459,7 +456,6 @@ ao_gps(void) __reentrant
                if (ao_serial_getchar() == '$') {
                        ao_gps_nmea_parse();
                }
-
        }
 }