diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/includes/GPS/minmea.h | 18 | ||||
-rw-r--r-- | src/common/src/GPS/gps.c | 19 | ||||
-rw-r--r-- | src/common/src/GPS/minmea.c | 25 |
3 files changed, 62 insertions, 0 deletions
diff --git a/src/common/includes/GPS/minmea.h b/src/common/includes/GPS/minmea.h index 6d7fe18..ab770a6 100644 --- a/src/common/includes/GPS/minmea.h +++ b/src/common/includes/GPS/minmea.h @@ -31,6 +31,7 @@ enum minmea_sentence_id { MINMEA_SENTENCE_GLL, MINMEA_SENTENCE_GST, MINMEA_SENTENCE_GSV, + MINMEA_SENTENCE_TXT, }; struct minmea_float { @@ -138,6 +139,22 @@ struct minmea_sentence_gsv { struct minmea_sat_info sats[4]; }; +enum minmea_txt_msgtype { + MINMEA_GPTXT_ERROR = 0, + MINMEA_GPTXT_WARNING = 1, + MINMEA_GPTXT_NOTICE = 2 +}; + +#define MINMEA_TXT_START_IX 16 + +struct minmea_sentence_txt { + int num_msg; + int msg_num; + enum minmea_txt_msgtype msgtype; + const char* text; + int text_len; +}; + /** * Calculate raw sentence checksum. Does not check sentence integrity. */ @@ -180,6 +197,7 @@ bool minmea_parse_gsa(struct minmea_sentence_gsa *frame, const char *sentence); bool minmea_parse_gll(struct minmea_sentence_gll *frame, const char *sentence); bool minmea_parse_gst(struct minmea_sentence_gst *frame, const char *sentence); bool minmea_parse_gsv(struct minmea_sentence_gsv *frame, const char *sentence); +bool minmea_parse_txt(struct minmea_sentence_txt *frame, const char *sentence); /** * Convert GPS UTC date/time representation to a UNIX timestamp. diff --git a/src/common/src/GPS/gps.c b/src/common/src/GPS/gps.c index cfc9782..19b2d8d 100644 --- a/src/common/src/GPS/gps.c +++ b/src/common/src/GPS/gps.c @@ -94,6 +94,25 @@ static void gps_task(void __attribute__ ((unused))*pvParameters) { xSemaphoreGive(timeutc_semaphore); } } break; + case MINMEA_SENTENCE_TXT: + { + struct minmea_sentence_txt frame; + if (minmea_parse_txt(&frame, rxbuf)) { + rxbuf[MINMEA_TXT_START_IX + frame.text_len] = '\0'; + + switch (frame.msgtype) { + case MINMEA_GPTXT_ERROR: + usart_debug_puts_header("GPS ERROR ", frame.text); + break; + case MINMEA_GPTXT_WARNING: + usart_debug_puts_header("GPS WARNING ", frame.text); + break; + default: + usart_debug_puts_header("GPS Message ", frame.text); + break; + } + } + } break; default: break; } diff --git a/src/common/src/GPS/minmea.c b/src/common/src/GPS/minmea.c index 8700725..4d4aeb8 100644 --- a/src/common/src/GPS/minmea.c +++ b/src/common/src/GPS/minmea.c @@ -367,6 +367,8 @@ enum minmea_sentence_id minmea_sentence_id(const char *sentence, bool strict) return MINMEA_SENTENCE_GST; if (!strcmp(type+2, "GSV")) return MINMEA_SENTENCE_GSV; + if (!strcmp(type+2, "TXT")) + return MINMEA_SENTENCE_TXT; return MINMEA_UNKNOWN; } @@ -545,6 +547,29 @@ bool minmea_parse_gsv(struct minmea_sentence_gsv *frame, const char *sentence) return true; } +bool minmea_parse_txt(struct minmea_sentence_txt *frame, const char *sentence) +{ + // Example + // $GPTXT,01,01,02,u-blox ag - www.u-blox.com*50 + char type[6]; + + if (!minmea_scan(sentence, "tiii", + type, + &frame->num_msg, + &frame->msg_num, + &frame->msgtype)) { + return false; + } + if (strcmp(type+2, "TXT")) { + return false; + } + + frame->text = sentence + MINMEA_TXT_START_IX; + frame->text_len = strlen(sentence) - MINMEA_TXT_START_IX - 5; + + return true; +} + int minmea_gettime(struct timespec *ts, const struct minmea_date *date, const struct minmea_time *time_) { if (date->year == -1 || time_->hours == -1) |