summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Kuethe <chris.kuethe@gmail.com>2007-01-11 02:06:56 +0000
committerChris Kuethe <chris.kuethe@gmail.com>2007-01-11 02:06:56 +0000
commit033735841667900a4646e3749f23149b08e6e61e (patch)
treef0512650ba8a27eb57501c28727a5d7afb8f5b90
parentbf95b046a85dfc29c47fa85f8ec107767a6e42fd (diff)
downloadgpsd-033735841667900a4646e3749f23149b08e6e61e.tar.gz
Fix to a packet-sniffer bug handling $P..
Diego Berge sent me an example of some line noise which just happened to have $P<garbage> in it. This tricked the packet sniffer into thinking it found an NMEA device. This change means that now 2 letters are required after the '$' to trigger a detect. If this still false-positives too much, I might crank it up to 4, to match on $PFec, $PFST, $PUBX, $PSRF and the like.
-rw-r--r--packet.c8
-rw-r--r--packet_states.h1
2 files changed, 8 insertions, 1 deletions
diff --git a/packet.c b/packet.c
index 8bbd4fd7..961c627c 100644
--- a/packet.c
+++ b/packet.c
@@ -178,7 +178,7 @@ static void nextstate(struct gps_packet_t *lexer,
if (c == 'G')
lexer->state = NMEA_PUB_LEAD;
else if (c == 'P') /* vendor sentence */
- lexer->state = NMEA_LEADER_END;
+ lexer->state = NMEA_VENDOR_LEAD;
else if (c =='I') /* Seatalk */
lexer->state = SEATALK_LEAD_1;
else if (c =='A') /* SiRF Ack */
@@ -192,6 +192,12 @@ static void nextstate(struct gps_packet_t *lexer,
else
lexer->state = GROUND_STATE;
break;
+ case NMEA_VENDOR_LEAD:
+ if (isalpha(c))
+ lexer->state = NMEA_LEADER_END;
+ else
+ lexer->state = GROUND_STATE;
+ break;
#ifdef TNT_ENABLE
case TNT_LEADER:
lexer->state = NMEA_LEADER_END;
diff --git a/packet_states.h b/packet_states.h
index a0615f18..696360af 100644
--- a/packet_states.h
+++ b/packet_states.h
@@ -7,6 +7,7 @@
#ifdef NMEA_ENABLE
NMEA_DOLLAR, /* we've seen first character of NMEA leader */
NMEA_PUB_LEAD, /* seen second character of NMEA G leader */
+ NMEA_VENDOR_LEAD, /* seen second character of NMEA P leader */
NMEA_LEADER_END, /* seen end char of NMEA leader, in body */
NMEA_CR, /* seen terminating \r of NMEA packet */
NMEA_RECOGNIZED, /* saw trailing \n of NMEA packet */