CTS-SAT-1-OBC-Firmware
Loading...
Searching...
No Matches
gnss_time.h File Reference
#include <stdint.h>
#include <time.h>
Include dependency graph for gnss_time.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

uint64_t GNSS_parse_timea_response_and_convert_to_unix_time_ms (char *input_str, uint64_t *unix_time_ms)
 Parses a GNSS receiver TIMEA message and converts it into Unix epoch time in milliseconds.
uint8_t GNSS_set_obc_time_based_on_gnss_time_uart ()
 Sets the OBC's time, based on the GNSS receiver's current time.
uint8_t GNSS_set_obc_time_based_on_gnss_pps ()
 Modify the already-synced OBC time to move the time by up to 499ms to align with the GNSS PPS.

Function Documentation

◆ GNSS_parse_timea_response_and_convert_to_unix_time_ms()

uint64_t GNSS_parse_timea_response_and_convert_to_unix_time_ms ( char * input_str,
uint64_t * unix_time_ms )

Parses a GNSS receiver TIMEA message and converts it into Unix epoch time in milliseconds.

The function expects a full TIMEA log string as input (e.g., starting with "#TIMEA,..."). It tokenizes the string, extracts UTC date and time fields, validates their integrity, and converts them to a Unix timestamp in milliseconds.

Parameters
input_strThe GNSS response string (e.g., from a TIMEA log).
Returns
uint8_t returning 0 for success and 1 for error.
Note
Has unit tests.
Here is the caller graph for this function:

◆ GNSS_set_obc_time_based_on_gnss_pps()

uint8_t GNSS_set_obc_time_based_on_gnss_pps ( )

Modify the already-synced OBC time to move the time by up to 499ms to align with the GNSS PPS.

Returns
0 on success. 1 on initial validation failure (bad PPS enabling). 5 on adjustment timeout. 10 on PPS command failure.
Note
Related Spec: https://github.com/CalgaryToSpace/CTS-SAT-1-OBC-Firmware/issues/503
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNSS_set_obc_time_based_on_gnss_time_uart()

uint8_t GNSS_set_obc_time_based_on_gnss_time_uart ( )

Sets the OBC's time, based on the GNSS receiver's current time.

This function sends a command to the GNSS receiver to fetch the current time, parses the TIMEA response to extract UTC time, converts it to Unix epoch time, and sets the system clock accordingly.

Returns
0 on success, >0 on failure.
Here is the call graph for this function:
Here is the caller graph for this function: