CTS-SAT-1-OBC-Firmware
Loading...
Searching...
No Matches
rtos_background_upkeep.c File Reference
Include dependency graph for rtos_background_upkeep.c:

Functions

static void subtask_disable_adcs_if_eps_enters_safety_mode (void)
static void subtask_monitor_eps_power (void)
static void subtask_reset_system_after_very_long_uptime (void)
 If the system exceeds a very long uptime, reset the system.
static void subtask_reset_system_after_no_recent_uplinks (void)
 If the system has not received an uplink in a very long time, reset the system.
static void subtask_update_rf_switch (void)
 Update the RF switch state based on the current mode.
static void subtask_send_beacon (void)
static void subtask_sync_obc_time_based_on_eps_time (void)
static void subtask_write_boot_time_to_lfs (void)
 A minute after bootup, append a JSONL line to LFS_BOOT_LOG_FILE_NAME with the latest boot timestamp.
static void subtask_enqueue_tcmds_from_agenda_file (void)
 Enqueue telecommands from the TCMD_active_agenda_filename file.
void TASK_background_upkeep (void *argument)

Variables

static const char * LFS_BOOT_LOG_FILE_NAME = "obc_boot_log.jsonl"
uint32_t STM32_system_reset_interval_sec = 604800
 If the system uptime exceeds this value, the system will reset (reboot).
uint32_t STM32_system_reset_no_uplink_interval_sec = 216000
 If the duration since an AX100 uplink telecommand exceeds this value, the system will reset (reboot).
uint32_t EPS_monitor_safety_adcs_interval_ms = 20000
 Check whether the EPS is in safety mode. If it's in safety mode, disable all EPS power channels.
uint32_t EPS_time_sync_period_sec = 600
 How frequently to set the OBC time based on the EPS time if the time divergence is >2 seconds.
uint32_t EPS_max_time_deviation_for_sync_ms = 2000
 If the OBC time and EPS time differ by more than this value, the OBC time will be set based on the EPS time.
uint32_t COMMS_beacon_interval_ms = 20000
 Interval between basic beacon packets, in ms.
static const uint32_t COMMS_beacon_interval_ms_default_value = 20000
uint32_t TCMD_enqueue_from_agenda_file_interval_ms = 45000
 Interval between enqueuing telecommands from the agenda file, in ms.
uint32_t TCMD_enqueue_grace_period_ms = 15000
 When enqueuing telecommands from a file, gracefully handle time resync values <= this value.
uint32_t COMMS_total_beacon_count_since_boot = 0
static uint32_t EPS_monitor_last_uptime_ms = 0
static uint32_t monitor_eps_to_control_adcs_last_checked_uptime_ms = 0
static uint32_t last_beacon_send_time_ms = 0
static uint32_t uptime_of_last_eps_time_sync_ms = 0

Function Documentation

◆ subtask_disable_adcs_if_eps_enters_safety_mode()

void subtask_disable_adcs_if_eps_enters_safety_mode ( void )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ subtask_enqueue_tcmds_from_agenda_file()

void subtask_enqueue_tcmds_from_agenda_file ( void )
static

Enqueue telecommands from the TCMD_active_agenda_filename file.

Parameters
<br>

On each run, enqueue telecommands from the agenda file.

  • Nominally (no large time resyncs), enqueue telecommands with tsexec from the last enqueue runtime until <run interval> in the future.
  • In case of large time resyncs fordward in time (including the first run), enqueue telecommands with tsexec within the last 15 seconds max, potentially discarding older chunks of the agenda.
  • In case of large time resyncs backward in time (rare, off-nominal), commands maybe be re-enqueued and re-executed (unless tssent unique enforcement is enabled).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ subtask_monitor_eps_power()

void subtask_monitor_eps_power ( void )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ subtask_reset_system_after_no_recent_uplinks()

void subtask_reset_system_after_no_recent_uplinks ( void )
static

If the system has not received an uplink in a very long time, reset the system.

Parameters
<br>
Note
Associated issue: https://github.com/CalgaryToSpace/CTS-SAT-1-OBC-Firmware/issues/547
The intenion of this function is to recover the system in case of a radiation-induced hang that isn't caught by the watchdog timer. The configuration can be extended to even longer if necessary.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ subtask_reset_system_after_very_long_uptime()

void subtask_reset_system_after_very_long_uptime ( void )
static

If the system exceeds a very long uptime, reset the system.

Parameters
<br>
Note
Associated issue: https://github.com/CalgaryToSpace/CTS-SAT-1-OBC-Firmware/issues/282
The intenion of this function is to recover the system in case of a radiation-induced hang that isn't caught by the watchdog timer. The configuration can be extended to even longer if necessary.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ subtask_send_beacon()

void subtask_send_beacon ( void )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ subtask_sync_obc_time_based_on_eps_time()

void subtask_sync_obc_time_based_on_eps_time ( void )
static

Periodically check the OBC time against the EPS time, and then set the OBC time based on the EPS time if they diverge by more than 2000ms (or as configured). We make an assumption here that the EPS's time is going to be more reliable/accurate than the OBC's time, since the EPS uses a high-quality RTC.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ subtask_update_rf_switch()

void subtask_update_rf_switch ( void )
static

Update the RF switch state based on the current mode.

Note
Implemented per https://github.com/CalgaryToSpace/CTS-SAT-1-OBC-Firmware/issues/228
Here is the call graph for this function:
Here is the caller graph for this function:

◆ subtask_write_boot_time_to_lfs()

void subtask_write_boot_time_to_lfs ( void )
static

A minute after bootup, append a JSONL line to LFS_BOOT_LOG_FILE_NAME with the latest boot timestamp.

Note
We wait a minute after boot in case LFS writes are the cause of the reset to allow for debugging/formatting/etc.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TASK_background_upkeep()

void TASK_background_upkeep ( void * argument)
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ COMMS_beacon_interval_ms

uint32_t COMMS_beacon_interval_ms = 20000

Interval between basic beacon packets, in ms.

Note
Default: 20000 ms = 20 seconds (fastest rate we're globally authorized for).

◆ COMMS_beacon_interval_ms_default_value

const uint32_t COMMS_beacon_interval_ms_default_value = 20000
static

◆ COMMS_total_beacon_count_since_boot

uint32_t COMMS_total_beacon_count_since_boot = 0

◆ EPS_max_time_deviation_for_sync_ms

uint32_t EPS_max_time_deviation_for_sync_ms = 2000

If the OBC time and EPS time differ by more than this value, the OBC time will be set based on the EPS time.

Note
Default: 2000 ms = 2 seconds.
Strongly related to EPS_time_sync_period_sec.
Recommendation: Do not set to < 1500-2000ms, as the EPS time is only granular to 1 second.

◆ EPS_monitor_last_uptime_ms

uint32_t EPS_monitor_last_uptime_ms = 0
static

◆ EPS_monitor_safety_adcs_interval_ms

uint32_t EPS_monitor_safety_adcs_interval_ms = 20000

Check whether the EPS is in safety mode. If it's in safety mode, disable all EPS power channels.

Note
Default: 20000 ms = 20 seconds
Set to 0 to disable this feature.

◆ EPS_time_sync_period_sec

uint32_t EPS_time_sync_period_sec = 600

How frequently to set the OBC time based on the EPS time if the time divergence is >2 seconds.

Note
Default: 600 seconds = 10 minutes.
Set to 0 to disable time syncing.

◆ last_beacon_send_time_ms

uint32_t last_beacon_send_time_ms = 0
static

◆ LFS_BOOT_LOG_FILE_NAME

const char* LFS_BOOT_LOG_FILE_NAME = "obc_boot_log.jsonl"
static

◆ monitor_eps_to_control_adcs_last_checked_uptime_ms

uint32_t monitor_eps_to_control_adcs_last_checked_uptime_ms = 0
static

◆ STM32_system_reset_interval_sec

uint32_t STM32_system_reset_interval_sec = 604800

If the system uptime exceeds this value, the system will reset (reboot).

Note
This is to recover the system in case of a radiation-induced hang or other invalid state.
Default: 604800 sec = 7 days.
Set to 0 to disable this feature.

◆ STM32_system_reset_no_uplink_interval_sec

uint32_t STM32_system_reset_no_uplink_interval_sec = 216000

If the duration since an AX100 uplink telecommand exceeds this value, the system will reset (reboot).

Note
This is to recover the system in case of a radiation-induced hang or other invalid state.
Default: 216000 sec = 2.5 days.
Set to 0 to disable this feature.

◆ TCMD_enqueue_from_agenda_file_interval_ms

uint32_t TCMD_enqueue_from_agenda_file_interval_ms = 45000

Interval between enqueuing telecommands from the agenda file, in ms.

Note
Default: 45000 ms = 45 seconds

◆ TCMD_enqueue_grace_period_ms

uint32_t TCMD_enqueue_grace_period_ms = 15000

When enqueuing telecommands from a file, gracefully handle time resync values <= this value.

Note
Default: 15000 ms = 15 seconds
If the time resync is more than this value, then a chunk of the agenda file will be discarded, or commands may be re-enqueued and re-executed.

◆ uptime_of_last_eps_time_sync_ms

uint32_t uptime_of_last_eps_time_sync_ms = 0
static