SatNOGS-COMMS  4.1.0
A COMMS subsystem for CubeSats
Loading...
Searching...
No Matches
satnogs::comms::time Class Reference

Time and position information. More...

#include <time.hpp>

Classes

class  to_string_exception

Public Types

enum class  time_src : uint8_t { GNSS_ASSISTED_RTC = 0 , GNSS_ONLY , UPTIME }
 Source of the reported time. More...
enum class  time_granularity {
  YEAR , MONTH , DAY , HOUR ,
  MIN , SEC
}
 Granularity of time represented as string. More...

Public Member Functions

 time (time const &)=delete
void operator= (time const &)=delete
void gnss_data_cb (const struct device *dev, const struct gnss_data *data)
time_src get (uint64_t &t)
 Gets the time in ms.
time_src get (struct tm &t)
 Gets the current time.
void set (const struct tm &t)
 Sets the RTC time.
void gnss (struct gnss_data &data)
 Retrieve latest GNSS information.
uint64_t uptime ()
 Gets the current system uptime in milliseconds.
uint64_t last_gnss_update_uptime ()
 Gets the system uptime (in milliseconds) at the time of the last GNSS fix.
uint64_t last_nmea_update_uptime ()
size_t to_string (const struct tm &tm, etl::istring &s, time::time_granularity granularity) const
 Return the string represantation of a struct tm time instance following the ISO-8601 paradigm. If the conversion fails, the function returns an empty string.
size_t to_string (const struct tm &tm, etl::istring &s) const
 Overloading function of time::to_string defaulting to DAY granularity.

Static Public Member Functions

static timeget_instance ()

Static Public Attributes

static constexpr size_t to_string_max_size = 20

Detailed Description

Time and position information.

This class provides time and position (if available) information. The SatNOGS-COMMS supports diffent sources of time depending on the configuration and the available peripherals. If the RTC battery is present and has enough voltage, the RTC time is retrieved, if the RTC clock has been set at least once. This can be done either by a telecommand or by the second available time source which is the GNSS. This class uses internally the GNSS modem of the Zephyr-RTOS and parses the NMEA messages that are published on one of the available UART ports. If the GNSS declares a valid fix, the announced time is automatically set to the RTC too.

If the RTC battery is not present or failed mid-flight but the GNSS time is available, the time is updated based on the last known time information from the GNSS and the uptime.

If all the above time sources failed to provide time information, the uptime is used as a last resort.

Definition at line 59 of file time.hpp.

Member Enumeration Documentation

◆ time_granularity

Granularity of time represented as string.

Enumerator
YEAR 
MONTH 
DAY 
HOUR 
MIN 
SEC 

Definition at line 89 of file time.hpp.

◆ time_src

enum class satnogs::comms::time::time_src : uint8_t
strong

Source of the reported time.

Enumerator
GNSS_ASSISTED_RTC 

RTC that may assisted by GNSS. This time source is valid, if the RTC is present and has been set either by a telecommand or by the GNSS

GNSS_ONLY 

No RTC installed, but there is time information from a GNSS fix.

UPTIME 

No RTC or GNSS time source. The uptime is used to track time.

Definition at line 73 of file time.hpp.

Constructor & Destructor Documentation

◆ time()

satnogs::comms::time::time ( time const & )
delete

Member Function Documentation

◆ get() [1/2]

time::time_src satnogs::comms::time::get ( struct tm & t)

Gets the current time.

See also
time::get(uint64_t &t) for more details
Parameters
treference to hold the result
Returns
time::time_src the time source for the time retrieved

Definition at line 152 of file time.cpp.

◆ get() [2/2]

time::time_src satnogs::comms::time::get ( uint64_t & t)

Gets the time in ms.

The current time depends on the time source and it is equal to:

Parameters
treference to hold the result
Returns
time::time_src the time source for the time retrieved

Definition at line 111 of file time.cpp.

◆ get_instance()

time & satnogs::comms::time::get_instance ( )
inlinestatic

Definition at line 63 of file time.hpp.

◆ gnss()

void satnogs::comms::time::gnss ( struct gnss_data & data)

Retrieve latest GNSS information.

Parameters
datareference to store the retrieved information

Definition at line 237 of file time.cpp.

◆ gnss_data_cb()

void satnogs::comms::time::gnss_data_cb ( const struct device * dev,
const struct gnss_data * data )

Definition at line 54 of file time.cpp.

◆ last_gnss_update_uptime()

uint64_t satnogs::comms::time::last_gnss_update_uptime ( )

Gets the system uptime (in milliseconds) at the time of the last GNSS fix.

Returns
uint64_t Uptime in milliseconds at the time of the last GNSS update

Definition at line 179 of file time.cpp.

◆ last_nmea_update_uptime()

uint64_t satnogs::comms::time::last_nmea_update_uptime ( )

Definition at line 185 of file time.cpp.

◆ operator=()

void satnogs::comms::time::operator= ( time const & )
delete

◆ set()

void satnogs::comms::time::set ( const struct tm & t)

Sets the RTC time.

Note
Even if the RTC battery is not present, the RTC subsystem is active while the board is powered-up. Therefore its can be used to accurately track the time
Parameters
ttime in UTC

Definition at line 200 of file time.cpp.

◆ to_string() [1/2]

size_t satnogs::comms::time::to_string ( const struct tm & tm,
etl::istring & s ) const

Overloading function of time::to_string defaulting to DAY granularity.

Definition at line 326 of file time.cpp.

◆ to_string() [2/2]

size_t satnogs::comms::time::to_string ( const struct tm & tm,
etl::istring & s,
time::time_granularity granularity ) const

Return the string represantation of a struct tm time instance following the ISO-8601 paradigm. If the conversion fails, the function returns an empty string.

Parameters
tmreference to struct tm that holds the time information
setl::string to write to
granularityspecifies the wanted granularity of our stringified time (year, month, day etc.)
Returns
the number of bytes the strftime managed to write

Definition at line 290 of file time.cpp.

◆ uptime()

uint64_t satnogs::comms::time::uptime ( )

Gets the current system uptime in milliseconds.

Returns
uint64_t The current uptime in milliseconds

Definition at line 167 of file time.cpp.

Member Data Documentation

◆ to_string_max_size

size_t satnogs::comms::time::to_string_max_size = 20
staticconstexpr

Definition at line 84 of file time.hpp.


The documentation for this class was generated from the following files: