diff --git a/mrz/mp3h1.c b/mrz/mp3h1.c index abf0333..8da3261 100644 --- a/mrz/mp3h1.c +++ b/mrz/mp3h1.c @@ -51,7 +51,6 @@ typedef struct { ui8_t subcnt1; ui8_t subcnt2; //int frnr; - int week; int yr; int mth; int day; int hrs; int min; int sec; double lat; double lon; double alt; @@ -65,8 +64,12 @@ typedef struct { ui32_t snC; ui32_t snD; ui8_t crcOK; - ui32_t gps_cnt_prev; - ui32_t gps_cnt; + // + int sec_day; + int sec_day_prev; + int gps_cnt; + int gps_cnt_prev; + int week; int jsn_freq; // freq/kHz (SDR) } gpx_t; @@ -654,16 +657,22 @@ static int get_time(gpx_t *gpx) { if (gpx->crcOK) - { // JSON frame counter: seconds since GPS (ignoring leap seconds) + { int week = 0; int tow = 0; - ui32_t sec_gps = 0; + int sec_gps = 0; gpx->gps_cnt_prev = gpx->gps_cnt; + gpx->sec_day_prev = gpx->sec_day; + gpx->sec_day = gpx->hrs*60*60 + gpx->min*60 + gpx->sec; + + + // JSON frame counter: seconds since GPS (ignoring leap seconds) + // if (gpx->yr == 0) { // 1980-01-06 week = 0; - tow = gpx->hrs*60*60 + gpx->min*60 + gpx->sec; + tow = gpx->sec_day; // yr=mth=day=0 } else { datetime2GPSweek(gpx->yr, gpx->mth, gpx->day, gpx->hrs, gpx->min, (int)(gpx->sec+0.5), &week, &tow); @@ -672,7 +681,7 @@ static int get_time(gpx_t *gpx) { gpx->week = week; if (sec_gps > gpx->gps_cnt_prev) { // skip day roll-over until date update - gpx->gps_cnt = sec_gps ; + gpx->gps_cnt = sec_gps; } } @@ -739,7 +748,7 @@ static void print_gpx(gpx_t *gpx, int crcOK) { get_time(gpx); get_GPSkoord(gpx); - if (gpx->gps_cnt != gpx->gps_cnt_prev || !option_uniq) + if (gpx->sec_day != gpx->sec_day_prev || !option_uniq) { printf(" [%2d] ", gpx->subcnt1);