Add $--ZDA sentences

* Expand LDLIBS var in Makefile
* Add parser zda
* Extend sentence_id
* Add example
This commit is contained in:
Dawid Marszałkiewicz 2017-06-16 12:54:17 +02:00 committed by Kosma Moczek
parent 6618d51f0c
commit a370e981d8
3 changed files with 55 additions and 0 deletions

View File

@ -107,6 +107,24 @@ int main(void)
} }
} break; } break;
case MINMEA_SENTENCE_ZDA: {
struct minmea_sentence_zda frame;
if (minmea_parse_zda(&frame, line)) {
printf(INDENT_SPACES "$xxZDA: %d:%d:%d %02d.%02d.%d UTC%+03d:%02d\n",
frame.time.hours,
frame.time.minutes,
frame.time.seconds,
frame.date.day,
frame.date.month,
frame.date.year,
frame.hour_offset,
frame.minute_offset);
}
else {
printf(INDENT_SPACES "$xxZDA sentence is not parsed\n");
}
} break;
case MINMEA_INVALID: { case MINMEA_INVALID: {
printf(INDENT_SPACES "$xxxxx sentence is not valid\n"); printf(INDENT_SPACES "$xxxxx sentence is not valid\n");
} break; } break;

View File

@ -372,6 +372,8 @@ enum minmea_sentence_id minmea_sentence_id(const char *sentence, bool strict)
return MINMEA_SENTENCE_GSV; return MINMEA_SENTENCE_GSV;
if (!strcmp(type+2, "VTG")) if (!strcmp(type+2, "VTG"))
return MINMEA_SENTENCE_VTG; return MINMEA_SENTENCE_VTG;
if (!strcmp(type+2, "ZDA"))
return MINMEA_SENTENCE_ZDA;
return MINMEA_UNKNOWN; return MINMEA_UNKNOWN;
} }
@ -584,6 +586,32 @@ bool minmea_parse_vtg(struct minmea_sentence_vtg *frame, const char *sentence)
return true; return true;
} }
bool minmea_parse_zda(struct minmea_sentence_zda *frame, const char *sentence)
{
// $GPZDA,201530.00,04,07,2002,00,00*60
char type[6];
if(!minmea_scan(sentence, "tTiiiii",
type,
&frame->time,
&frame->date.day,
&frame->date.month,
&frame->date.year,
&frame->hour_offset,
&frame->minute_offset))
return false;
if (strcmp(type+2, "ZDA"))
return false;
// check offsets
if (abs(frame->hour_offset) > 13 ||
frame->minute_offset > 59 ||
frame->minute_offset < 0)
return false;
return true;
}
int minmea_gettime(struct timespec *ts, const struct minmea_date *date, const struct minmea_time *time_) int minmea_gettime(struct timespec *ts, const struct minmea_date *date, const struct minmea_time *time_)
{ {
if (date->year == -1 || time_->hours == -1) if (date->year == -1 || time_->hours == -1)

View File

@ -32,6 +32,7 @@ enum minmea_sentence_id {
MINMEA_SENTENCE_GST, MINMEA_SENTENCE_GST,
MINMEA_SENTENCE_GSV, MINMEA_SENTENCE_GSV,
MINMEA_SENTENCE_VTG, MINMEA_SENTENCE_VTG,
MINMEA_SENTENCE_ZDA,
}; };
struct minmea_float { struct minmea_float {
@ -152,6 +153,13 @@ struct minmea_sentence_vtg {
enum minmea_faa_mode faa_mode; enum minmea_faa_mode faa_mode;
}; };
struct minmea_sentence_zda {
struct minmea_time time;
struct minmea_date date;
int hour_offset;
int minute_offset;
};
/** /**
* Calculate raw sentence checksum. Does not check sentence integrity. * Calculate raw sentence checksum. Does not check sentence integrity.
*/ */
@ -195,6 +203,7 @@ 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_gst(struct minmea_sentence_gst *frame, const char *sentence);
bool minmea_parse_gsv(struct minmea_sentence_gsv *frame, const char *sentence); bool minmea_parse_gsv(struct minmea_sentence_gsv *frame, const char *sentence);
bool minmea_parse_vtg(struct minmea_sentence_vtg *frame, const char *sentence); bool minmea_parse_vtg(struct minmea_sentence_vtg *frame, const char *sentence);
bool minmea_parse_zda(struct minmea_sentence_zda *frame, const char *sentence);
/** /**
* Convert GPS UTC date/time representation to a UNIX timestamp. * Convert GPS UTC date/time representation to a UNIX timestamp.