diff options
-rw-r--r-- | gpsd.h-tail | 2 | ||||
-rw-r--r-- | packet.c | 25 | ||||
-rw-r--r-- | packet_states.h | 12 |
3 files changed, 24 insertions, 15 deletions
diff --git a/gpsd.h-tail b/gpsd.h-tail index 75c868cc..20055009 100644 --- a/gpsd.h-tail +++ b/gpsd.h-tail @@ -111,6 +111,8 @@ extern void rtcm2_output_magnavox(isgps30bits_t *, FILE *); extern void rtcm3_unpack(/*@out@*/struct rtcm3_t *, char *); extern void rtcm3_dump(struct rtcm3_t *rtcm, FILE *); +extern ssize_t oncore_payload_length(unsigned char id1,unsigned char id2); + /* Next, declarations for the core library... */ /* factors for converting among confidence interval units */ @@ -554,23 +554,30 @@ static void nextstate(struct gps_packet_t *lexer, #endif /* SUPERSTAR2_ENABLE */ #ifdef ONCORE_ENABLE case ONCORE_AT2: - if (isupper(c)) + if (isupper(c)) { + lexer->length = c; lexer->state = ONCORE_ID1; - else + } else lexer->state = GROUND_STATE; break; case ONCORE_ID1: - if (isalpha(c)) - lexer->state = ONCORE_ID2; - else + if (isalpha(c)) { + lexer->length = + oncore_payload_length((unsigned char) lexer->length,c); + if ((ssize_t) lexer->length != -1) { + lexer->state = ONCORE_PAYLOAD; + break; + } + } lexer->state = GROUND_STATE; break; - case ONCORE_ID2: - lexer->state = ONCORE_PAYLOAD; - break; case ONCORE_PAYLOAD: + if (--lexer->length == 0) + lexer->state = ONCORE_CHECKSUM; + break; + case ONCORE_CHECKSUM: if (c != '\r') - lexer->state = ONCORE_PAYLOAD; + lexer->state = GROUND_STATE; else lexer->state = ONCORE_CR; break; diff --git a/packet_states.h b/packet_states.h index 72a57fa6..99845b51 100644 --- a/packet_states.h +++ b/packet_states.h @@ -126,12 +126,12 @@ #endif #ifdef ONCORE_ENABLE - ONCORE_AT2, /* second @ */ - ONCORE_ID1, /* first character of command type */ - ONCORE_ID2, /* second character of command type */ - ONCORE_PAYLOAD, - ONCORE_CR, /* closing CR */ - ONCORE_RECOGNIZED, /* closing LF */ + ONCORE_AT2, /* second @ */ + ONCORE_ID1, /* first character of command type */ + ONCORE_PAYLOAD, /* payload eating */ + ONCORE_CHECKSUM, /* checksum byte */ + ONCORE_CR, /* closing CR */ + ONCORE_RECOGNIZED, /* closing LF */ #endif |