CTS-SAT-1-OBC-Firmware
Loading...
Searching...
No Matches
configuration.c File Reference
#include "config/configuration.h"
#include "comms_drivers/ax100_tx.h"
#include "comms_drivers/comms_tx.h"
#include "rtos_tasks/rtos_bootup_operation_fsm_task.h"
#include "comms_drivers/rf_antenna_switch.h"
#include "rtos_tasks/rtos_bulk_downlink_task.h"
#include "littlefs/littlefs_helper.h"
#include <stdio.h>
#include <stdint.h>
#include <string.h>
Include dependency graph for configuration.c:

Functions

int16_t CONFIG_get_int_var_index (const char *search_name)
 Finds an int config variable in CONFIG_int_config_variables and returns its index.
int16_t CONFIG_get_str_var_index (const char *search_name)
 Finds a string config variable in CONFIG_str_config_variables and returns its index.
uint8_t CONFIG_set_int_variable (const char *var_name, const uint64_t new_value)
 Assigns a new value to an integer configuration variable.
uint8_t CONFIG_set_str_variable (const char *var_name, const char *new_value)
 Assigns a new value to a string configuration variable.
uint16_t CONFIG_int_var_to_json (const char *var_name, char *json_str, const uint16_t json_str_max_len)
 Converts an integer configuration variable to a JSON string.
uint16_t CONFIG_all_int_vars_to_json (char *json_str, const uint16_t json_str_size)
 Converts ALL integer configuration variables to a tightly-packed JSON dictionary string.
uint16_t CONFIG_str_var_to_json (const char *var_name, char *json_str, const uint16_t json_str_max_len)
 Converts a string configuration variable to a JSON string.

Variables

uint32_t EPS_monitor_safety_adcs_interval_ms
 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
 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
 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 TASK_heartbeat_period_ms
 The period of the heartbeat task, in milliseconds. 0 to disable.
uint32_t TCMD_require_valid_sha256
 Boolean. When 1, the telecommand parser will require a valid SHA256 hash in the telecommand string.
uint32_t CONFIG_EPS_enable_uart_debug_print
 When enabled, the EPS's raw data is sent to the debug UART.
uint32_t TCMD_handle_ax100_tcmds_interval_ms
 The interval between handling telecommands (parsing and adding to agenda) uplinked via the UHF radio. Note: Does not include execution. Decrease this to 200ms-250ms (or lower) if bulk uplinking large amounts of data (e.g., firmware).
uint32_t TCMD_handle_umbilical_tcmds_interval_ms
 The interval between handling telecommands (parsing and adding to agenda) from the umbilical UART.
uint32_t MPI_max_temperature_shutoff_celcius
 If the MPI exceeds this value during data recording, recording will be disabled.
uint32_t MPI_max_recording_duration_sec
 Maximum duration for MPI data recording in seconds.
uint32_t STM32_system_reset_interval_sec
 If the system uptime exceeds this value, the system will reset (reboot).
uint32_t STM32_system_reset_no_uplink_interval_sec
 If the duration since an AX100 uplink telecommand exceeds this value, the system will reset (reboot).
uint32_t COMMS_beacon_interval_ms
 Interval between basic beacon packets, in ms.
uint32_t GNSS_write_cmd_mode_data_to_firehose_file
 Boolean. Whether to store command-mode GNSS data to the firehose file.
uint32_t LOG_timestamp_prefix_format
 Format for the timestamp prefix.
uint32_t TCMD_enqueue_from_agenda_file_interval_ms
 Interval between enqueuing telecommands from the agenda file, in ms.
uint32_t TCMD_enqueue_grace_period_ms
 When enqueuing telecommands from a file, gracefully handle time resync values <= this value.
uint32_t TCMD_max_consecutive_burst_execution_size
 Execute this many telecommands back-to-back when they come due, if they're available.
uint32_t LOG_file_flush_interval_sec
 Interval in seconds at which to flush the log file to the filesystem.
uint32_t LOG_file_rotation_interval_sec
 Interval in seconds where a new dated log file is created, and the old file is closed.
uint32_t CONFIG_int_demo_var_1 = 13345
 Does nothing. Used for testing configuration variables.
uint32_t EPS_monitor_interval_ms = 20000
 The interval at which the EPS_monitor_and_disable_overcurrent_channels task runs.
uint32_t TCMD_require_unique_tssent = 0
 Boolean. Whether to require the @tssent suffix tag for all telecommands.
const uint32_t CONFIG_freertos_min_remaining_stack_percent = 20
 The percentage of the stack space that should remain free. If the free space falls below this percentage, a warning will be logged.
CONFIG_integer_config_entry_t CONFIG_int_config_variables []
const uint8_t CONFIG_int_config_variables_count = sizeof(CONFIG_int_config_variables) / sizeof(CONFIG_integer_config_entry_t)
char CONFIG_str_demo_var_1 [25] = "CONFIG_str_demo_var_1"
char CONFIG_str_demo_var_2 [50] = "CONFIG_str_demo_var_2"
char COMMS_beacon_friendly_message_str [COMMS_BEACON_FRIENDLY_MESSAGE_SIZE]
char TCMD_active_agenda_filename [LFS_MAX_PATH_LENGTH]
 The file path of the agenda file to load upcoming telecommands from.
CONFIG_string_config_entry_t CONFIG_str_config_variables []
const uint8_t CONFIG_str_config_variables_count = sizeof(CONFIG_str_config_variables) / sizeof(CONFIG_string_config_entry_t)

Function Documentation

◆ CONFIG_all_int_vars_to_json()

uint16_t CONFIG_all_int_vars_to_json ( char * json_str,
const uint16_t json_str_size )

Converts ALL integer configuration variables to a tightly-packed JSON dictionary string.

Parameters
json_strBuffer to write the JSON string to
json_str_sizeMax length of the buffer
Returns
Length of the JSON string
Note
The JSON string is in the format: {"var1":value,"var2":value,...}
Here is the caller graph for this function:

◆ CONFIG_get_int_var_index()

int16_t CONFIG_get_int_var_index ( const char * search_name)

Finds an int config variable in CONFIG_int_config_variables and returns its index.

Parameters
nameName of the variable being searched, as registered in CONFIG_int_config_variables
Returns
-1 if not found, otherwise the index of the variable in CONFIG_int_config_variables
Here is the caller graph for this function:

◆ CONFIG_get_str_var_index()

int16_t CONFIG_get_str_var_index ( const char * search_name)

Finds a string config variable in CONFIG_str_config_variables and returns its index.

Parameters
nameName of the variable being searched, as registered in CONFIG_str_config_variables
Returns
-1 if not found, otherwise the index of the variable in CONFIG_str_config_variables
Here is the caller graph for this function:

◆ CONFIG_int_var_to_json()

uint16_t CONFIG_int_var_to_json ( const char * var_name,
char * json_str,
const uint16_t json_str_max_len )

Converts an integer configuration variable to a JSON string.

Parameters
var_nameName of the variable
json_strBuffer to write the JSON string to
json_str_max_lenMax length of the buffer
Returns
Length of the JSON string
Note
The JSON string is in the format: {"name":"var_name","value":value}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CONFIG_set_int_variable()

uint8_t CONFIG_set_int_variable ( const char * var_name,
const uint64_t new_value )

Assigns a new value to an integer configuration variable.

Parameters
var_nameName of the variable
new_valueNew value
Returns
0 if success, > 0 if failure
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CONFIG_set_str_variable()

uint8_t CONFIG_set_str_variable ( const char * var_name,
const char * new_value )

Assigns a new value to a string configuration variable.

Parameters
config_varPointer to the configuration variable
new_valueNew value
Returns
0 if success, > 0 if failure
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CONFIG_str_var_to_json()

uint16_t CONFIG_str_var_to_json ( const char * var_name,
char * json_str,
const uint16_t json_str_max_len )

Converts a string configuration variable to a JSON string.

Parameters
var_nameName of the variable
json_strBuffer to write the JSON string to
json_str_max_lenMax length of the buffer
Returns
If successful, Length of the JSON string (>1), otherwise 1
Note
The JSON string is in the format: {"name":"var_name","value":"value"}
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ COMMS_beacon_friendly_message_str

char COMMS_beacon_friendly_message_str[COMMS_BEACON_FRIENDLY_MESSAGE_SIZE]
extern

◆ COMMS_beacon_interval_ms

uint32_t COMMS_beacon_interval_ms
extern

Interval between basic beacon packets, in ms.

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

◆ CONFIG_EPS_enable_uart_debug_print

uint32_t CONFIG_EPS_enable_uart_debug_print
extern

When enabled, the EPS's raw data is sent to the debug UART.

◆ CONFIG_freertos_min_remaining_stack_percent

const uint32_t CONFIG_freertos_min_remaining_stack_percent = 20

The percentage of the stack space that should remain free. If the free space falls below this percentage, a warning will be logged.

◆ CONFIG_int_config_variables

CONFIG_integer_config_entry_t CONFIG_int_config_variables[]

◆ CONFIG_int_config_variables_count

const uint8_t CONFIG_int_config_variables_count = sizeof(CONFIG_int_config_variables) / sizeof(CONFIG_integer_config_entry_t)

◆ CONFIG_int_demo_var_1

uint32_t CONFIG_int_demo_var_1 = 13345

Does nothing. Used for testing configuration variables.

◆ CONFIG_str_config_variables

CONFIG_string_config_entry_t CONFIG_str_config_variables[]
Initial value:
= {
{
.variable_name = "CONFIG_str_demo_var_1",
.variable_pointer = CONFIG_str_demo_var_1,
.max_length = sizeof(CONFIG_str_demo_var_1)
},
{
.variable_name = "CONFIG_str_demo_var_2",
.variable_pointer = CONFIG_str_demo_var_2,
.max_length = sizeof(CONFIG_str_demo_var_2)
},
{
.variable_name = "COMMS_beacon_friendly_message_str",
.variable_pointer = COMMS_beacon_friendly_message_str,
.max_length = sizeof(COMMS_beacon_friendly_message_str)
},
{
.variable_name = "TCMD_active_agenda_filename",
.variable_pointer = TCMD_active_agenda_filename,
.max_length = sizeof(TCMD_active_agenda_filename)
},
}
char TCMD_active_agenda_filename[LFS_MAX_PATH_LENGTH]
The file path of the agenda file to load upcoming telecommands from.
Definition agenda_from_file.c:23
char COMMS_beacon_friendly_message_str[COMMS_BEACON_FRIENDLY_MESSAGE_SIZE]
Definition beacon.c:37
char CONFIG_str_demo_var_2[50]
Definition configuration.c:179
char CONFIG_str_demo_var_1[25]
Definition configuration.c:178

◆ CONFIG_str_config_variables_count

const uint8_t CONFIG_str_config_variables_count = sizeof(CONFIG_str_config_variables) / sizeof(CONFIG_string_config_entry_t)

◆ CONFIG_str_demo_var_1

char CONFIG_str_demo_var_1[25] = "CONFIG_str_demo_var_1"

◆ CONFIG_str_demo_var_2

char CONFIG_str_demo_var_2[50] = "CONFIG_str_demo_var_2"

◆ EPS_max_time_deviation_for_sync_ms

uint32_t EPS_max_time_deviation_for_sync_ms
extern

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_interval_ms

uint32_t EPS_monitor_interval_ms = 20000

The interval at which the EPS_monitor_and_disable_overcurrent_channels task runs.

◆ EPS_monitor_safety_adcs_interval_ms

uint32_t EPS_monitor_safety_adcs_interval_ms
extern

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
extern

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.

◆ GNSS_write_cmd_mode_data_to_firehose_file

uint32_t GNSS_write_cmd_mode_data_to_firehose_file
extern

Boolean. Whether to store command-mode GNSS data to the firehose file.

If GNSS firehose storage mode is enabled, and the send_cmd_get_response function is used, this config variable controls whether the command-mode response data is written to the firehose file.

◆ LOG_file_flush_interval_sec

uint32_t LOG_file_flush_interval_sec
extern

Interval in seconds at which to flush the log file to the filesystem.

Note
Nominal: 60 seconds = 1 minute.

◆ LOG_file_rotation_interval_sec

uint32_t LOG_file_rotation_interval_sec
extern

Interval in seconds where a new dated log file is created, and the old file is closed.

Note
Nominal: 1800 seconds = 30 minutes.

◆ LOG_timestamp_prefix_format

uint32_t LOG_timestamp_prefix_format
extern

Format for the timestamp prefix.

Options:

  • 0=synctime+offset
  • 1=ISO8601-like datetime with ms
  • 2=ISO8601-like datetime without ms
  • other=synctime+offset (fallback)
    Note
    Configurable with the configuration telecommand.
    Could be an enum in a perfect world, but using int for speed of implementation.

◆ MPI_max_recording_duration_sec

uint32_t MPI_max_recording_duration_sec
extern

Maximum duration for MPI data recording in seconds.

Note
Set this value to 0 (via configuration) to disable the duration limit.
This configuration variable is designed to prevent against an operator failing to schedule a stop telecommand for MPI data recording.

◆ MPI_max_temperature_shutoff_celcius

uint32_t MPI_max_temperature_shutoff_celcius
extern

If the MPI exceeds this value during data recording, recording will be disabled.

Note
Set this value to 0 (via configuration) to disable the temperature shutoff feature.

◆ STM32_system_reset_interval_sec

uint32_t STM32_system_reset_interval_sec
extern

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
extern

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.

◆ TASK_heartbeat_period_ms

uint32_t TASK_heartbeat_period_ms
extern

The period of the heartbeat task, in milliseconds. 0 to disable.

◆ TCMD_active_agenda_filename

char TCMD_active_agenda_filename[LFS_MAX_PATH_LENGTH]
extern

The file path of the agenda file to load upcoming telecommands from.

Warning
While a default agenda is set, it is critical to understand that you SHOULD NOT fill this agenda file unless absolutely necessary. If you create and fill an agenda with this default name, it will run on every boot, thus defeating the purpose of reboots being a stable, fail-safe startup mode.
Note
If system stability ends up being super bad, you can put commands in the default to run at the earth poles on subsequent reboots. That's probably the only time you should ever create this file though!
Nominally, put the agenda in another random file, then update this config string to point to that other file. That way, on reboot, the agenda stops running (as a fail-safe)!
Set this to "DISABLED" (case-sensitive) to disable this feature entirely.

◆ TCMD_enqueue_from_agenda_file_interval_ms

uint32_t TCMD_enqueue_from_agenda_file_interval_ms
extern

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
extern

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.

◆ TCMD_handle_ax100_tcmds_interval_ms

uint32_t TCMD_handle_ax100_tcmds_interval_ms
extern

The interval between handling telecommands (parsing and adding to agenda) uplinked via the UHF radio. Note: Does not include execution. Decrease this to 200ms-250ms (or lower) if bulk uplinking large amounts of data (e.g., firmware).

◆ TCMD_handle_umbilical_tcmds_interval_ms

uint32_t TCMD_handle_umbilical_tcmds_interval_ms
extern

The interval between handling telecommands (parsing and adding to agenda) from the umbilical UART.

Any value from 1ms to millions is reasonable. 20ms is a good value for optimized bulk uplink. Note: Does not include execution.

◆ TCMD_max_consecutive_burst_execution_size

uint32_t TCMD_max_consecutive_burst_execution_size
extern

Execute this many telecommands back-to-back when they come due, if they're available.

Increase this past 3 to execute commands faster (e.g., during bulk uplink).

Note
Default: 3.

◆ TCMD_require_unique_tssent

uint32_t TCMD_require_unique_tssent = 0

Boolean. Whether to require the @tssent suffix tag for all telecommands.

1 = require, 0 = don't require

◆ TCMD_require_valid_sha256

uint32_t TCMD_require_valid_sha256
extern

Boolean. When 1, the telecommand parser will require a valid SHA256 hash in the telecommand string.