@@ -102,7 +102,7 @@ int GPSDriverNMEA::handleMessage(int len)
102102 int ret = 0 ;
103103
104104 if ((memcmp (_rx_buffer + 3 , " ZDA," , 4 ) == 0 ) && (uiCalcComma == 6 )) {
105-
105+ # ifndef NO_MKTIME
106106 /*
107107 UTC day, month, and year, and local time zone offset
108108 An example of the ZDA message string is:
@@ -142,6 +142,7 @@ int GPSDriverNMEA::handleMessage(int len)
142142 int utc_minute = static_cast <int >((utc_time - utc_hour * 10000 ) / 100 );
143143 double utc_sec = static_cast <double >(utc_time - utc_hour * 10000 - utc_minute * 100 );
144144
145+
145146 /*
146147 * convert to unix timestamp
147148 */
@@ -154,7 +155,7 @@ int GPSDriverNMEA::handleMessage(int len)
154155 timeinfo.tm_sec = int (utc_sec);
155156 timeinfo.tm_isdst = 0 ;
156157
157- # ifndef NO_MKTIME
158+
158159 time_t epoch = mktime (&timeinfo);
159160
160161 if (epoch > GPS_EPOCH_SECS) {
@@ -481,12 +482,7 @@ int GPSDriverNMEA::handleMessage(int len)
481482 float velocity_ms = ground_speed_K / 1 .9438445f ;
482483 float velocity_north = velocity_ms * cosf (track_rad);
483484 float velocity_east = velocity_ms * sinf (track_rad);
484- int utc_hour = static_cast <int >(utc_time / 10000 );
485- int utc_minute = static_cast <int >((utc_time - utc_hour * 10000 ) / 100 );
486- double utc_sec = static_cast <double >(utc_time - utc_hour * 10000 - utc_minute * 100 );
487- int nmea_day = static_cast <int >(nmea_date / 10000 );
488- int nmea_mth = static_cast <int >((nmea_date - nmea_day * 10000 ) / 100 );
489- int nmea_year = static_cast <int >(nmea_date - nmea_day * 10000 - nmea_mth * 100 );
485+
490486 /* convert from degrees, minutes and seconds to degrees */
491487 _gps_position->latitude_deg = int (lat * 0.01 ) + (lat * 0.01 - int (lat * 0.01 )) * 100.0 / 60.0 ;
492488 _gps_position->longitude_deg = int (lon * 0.01 ) + (lon * 0.01 - int (lon * 0.01 )) * 100.0 / 60.0 ;
@@ -500,7 +496,14 @@ int GPSDriverNMEA::handleMessage(int len)
500496 _gps_position->s_variance_m_s = 0 ;
501497 _gps_position->timestamp = gps_absolute_time ();
502498 _last_timestamp_time = gps_absolute_time ();
503-
499+
500+ #ifndef NO_MKTIME
501+ int utc_hour = static_cast <int >(utc_time / 10000 );
502+ int utc_minute = static_cast <int >((utc_time - utc_hour * 10000 ) / 100 );
503+ double utc_sec = static_cast <double >(utc_time - utc_hour * 10000 - utc_minute * 100 );
504+ int nmea_day = static_cast <int >(nmea_date / 10000 );
505+ int nmea_mth = static_cast <int >((nmea_date - nmea_day * 10000 ) / 100 );
506+ int nmea_year = static_cast <int >(nmea_date - nmea_day * 10000 - nmea_mth * 100 );
504507 /*
505508 * convert to unix timestamp
506509 */
@@ -513,7 +516,6 @@ int GPSDriverNMEA::handleMessage(int len)
513516 timeinfo.tm_sec = int (utc_sec);
514517 timeinfo.tm_isdst = 0 ;
515518
516- #ifndef NO_MKTIME
517519 time_t epoch = mktime (&timeinfo);
518520
519521 if (epoch > GPS_EPOCH_SECS) {
@@ -539,6 +541,8 @@ int GPSDriverNMEA::handleMessage(int len)
539541 }
540542
541543#else
544+ NMEA_UNUSED (utc_time);
545+ NMEA_UNUSED (nmea_date);
542546 _gps_position->time_utc_usec = 0 ;
543547#endif
544548
0 commit comments