|
|
@@ -53,7 +53,7 @@ int handle_gps_time(float gtime, int date) {
|
|
|
int day,month,year;
|
|
|
int hour,min,sec,frac;
|
|
|
int n = 0;
|
|
|
- time_t utc,now;
|
|
|
+ time_t utc, now;
|
|
|
|
|
|
char buffer[32] = {0};
|
|
|
|
|
|
@@ -64,18 +64,16 @@ int handle_gps_time(float gtime, int date) {
|
|
|
day = month = year = 0;
|
|
|
hour = min = sec = frac = 0;
|
|
|
|
|
|
-
|
|
|
// Just to be *ahem* clear, as per NMEA standard the date is encoded DDMMYY, and the time of day
|
|
|
// is encoded HHMMSS[.frac] where there is an optional fractional second field denoted by a decimal point.
|
|
|
// we must be able to decode the fractional seconds field but we discard the information since it is not
|
|
|
// reliable enough to be worth the bother.
|
|
|
//
|
|
|
|
|
|
-
|
|
|
// Start out with zero parsed fields
|
|
|
//
|
|
|
n = 0;
|
|
|
-
|
|
|
+
|
|
|
// Construct and then re-parse the time from its icky format to discrete values (this should result
|
|
|
// in at least three (possibly four) fields.
|
|
|
//
|
|
|
@@ -165,7 +163,7 @@ static int handle_stale_gps_condition() {
|
|
|
// MAILBOX_GPS_STATUS.
|
|
|
//
|
|
|
int return_code = 0;
|
|
|
-
|
|
|
+
|
|
|
// This will hold the gps_good flag as it stood at the beginning of this subroutine
|
|
|
// previous to any adjustments we make.
|
|
|
//
|
|
|
@@ -190,7 +188,7 @@ static int handle_stale_gps_condition() {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// If we have determined that we need to declare the GPS data stale and invalid and
|
|
|
// we have a valid connection to the IPC hub we should use that IPC hub connection to
|
|
|
// add a note to the diagnostic log indicating that we've declared the GPS data stale.
|
|
|
@@ -346,23 +344,24 @@ int update_gps(char *in) {
|
|
|
// Require at least MIN_SATS_FOR_TIME satellites to accept a new system clock value from the GPS unit.
|
|
|
// This is to keep a crummy GPS fix from generating a bogus or unstable system time.
|
|
|
//
|
|
|
-
|
|
|
+
|
|
|
if(my_gps_stat.num_sats >= MIN_SATS_FOR_TIME) {
|
|
|
|
|
|
// Pass the time field (f1) and the date field (f9) in to the routine that sets the system clock if needed.
|
|
|
// (this routine also stores the utc timestamp derived from the GPS date and time fields so it can be passed to
|
|
|
// other modules that may have a need for this information).
|
|
|
//
|
|
|
- handle_gps_time(f1,(int)f9);
|
|
|
+ //handle_gps_time(f1,(int)f9);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(num > 0) {
|
|
|
+
|
|
|
// update snapshot with latitude
|
|
|
//
|
|
|
my_gps_stat.lat = f3 * ((f4 == 'N')?(1):(-1));
|
|
|
-
|
|
|
+
|
|
|
// longitude
|
|
|
//
|
|
|
my_gps_stat.lon = f5 * ((f6 == 'E')?(1):(-1));
|
|
|
@@ -378,7 +377,7 @@ int update_gps(char *in) {
|
|
|
// update snapshot's staledate
|
|
|
//
|
|
|
my_gps_stat.stamp = time(NULL);
|
|
|
-
|
|
|
+
|
|
|
return_code |= 1;
|
|
|
|
|
|
}
|
|
|
@@ -414,8 +413,6 @@ int update_gps(char *in) {
|
|
|
//
|
|
|
my_gps_stat.num_sats = f7;
|
|
|
|
|
|
-
|
|
|
-
|
|
|
// Do NOT store the timestamp since we only want to remember timestamps of position
|
|
|
// fixes and the GPGGA message is all metadata (number of satellites, fix quality, etc...).
|
|
|
// It is worth noting that GPGGA does report altitude, but that is not a piece of information
|
|
|
@@ -495,16 +492,16 @@ int reset_gps() {
|
|
|
|
|
|
if (gps_fd < 0) { return -1; }
|
|
|
|
|
|
- n = stlren(msg_gps_off)+1;
|
|
|
+ n = strlen(msg_gps_off)+1;
|
|
|
write(gps_fd, msg_gps_off, n);
|
|
|
|
|
|
- n = stlren(msg_gps_poll_off)+1;
|
|
|
+ n = strlen(msg_gps_poll_off)+1;
|
|
|
write(gps_fd, msg_gps_poll_off, n);
|
|
|
|
|
|
- n = stlren(msg_gps_on)+1;
|
|
|
+ n = strlen(msg_gps_on)+1;
|
|
|
write(gps_fd, msg_gps_on, n);
|
|
|
|
|
|
- n = stlren(msg_gps_poll_on)+1;
|
|
|
+ n = strlen(msg_gps_poll_on)+1;
|
|
|
write(gps_fd, msg_gps_poll_on, n);
|
|
|
|
|
|
return 0;
|