Skip to content

Commit

Permalink
AP_GPS: add support for getting PPS timestamp directly
Browse files Browse the repository at this point in the history
  • Loading branch information
bugobliterator committed Dec 28, 2023
1 parent fcfbbb6 commit 4cd4399
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions libraries/AP_GPS/AP_GPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,13 @@ uint64_t AP_GPS::last_message_epoch_usec(uint8_t instance) const
return istate_time_to_epoch_ms(istate.time_week, drivers[instance]->get_last_itow_ms()) * 1000ULL;
}

uint64_t AP_GPS::last_pps_time_usec(uint8_t instance) const
{
if (drivers[instance] == nullptr) {
return 0;
}
return drivers[instance]->get_last_pps_time_us();
}
/*
send some more initialisation string bytes if there is room in the
UART transmit buffer
Expand Down
5 changes: 5 additions & 0 deletions libraries/AP_GPS/AP_GPS.h
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,11 @@ class AP_GPS
return last_corrected_gps_time_usec(primary_instance);
}

uint64_t last_pps_time_usec(uint8_t instance) const;
uint64_t last_pps_time_usec() const {
return last_pps_time_usec(primary_instance);
}

// convert GPS week and millis to unix epoch in ms
static uint64_t istate_time_to_epoch_ms(uint16_t gps_week, uint32_t gps_ms);

Expand Down
2 changes: 2 additions & 0 deletions libraries/AP_GPS/GPS_Backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ class AP_GPS_Backend
return gps.option_set(option);
}

uint64_t get_last_pps_time_us() const { return _last_pps_time_us; }

protected:
AP_HAL::UARTDriver *port; ///< UART we are attached to
AP_GPS &gps; ///< access to frontend (for parameters)
Expand Down

0 comments on commit 4cd4399

Please sign in to comment.