|
CTS-SAT-1-OBC-Firmware
|
#include "telecommand_exec/telecommand_parser.h"#include "telecommand_exec/telecommand_definitions.h"#include "telecommand_exec/telecommand_executor.h"#include "telecommand_exec/telecommand_types.h"#include "debug_tools/debug_uart.h"#include "timekeeping/timekeeping.h"#include "log/log.h"#include "transforms/arrays.h"#include "config/configuration.h"#include "littlefs/littlefs_helper.h"#include "comms_drivers/comms_tx.h"#include <stdio.h>#include <stdint.h>#include <string.h>#include <stdbool.h>
Functions | |
| static uint16_t | TCMD_agenda_get_free_slot_idx () |
| Gets the index of the first free ("invalid") slot in the agenda. | |
| uint8_t | TCMD_add_tcmd_to_agenda (const TCMD_parsed_tcmd_to_execute_t *parsed_tcmd) |
| Adds a telecommand to the agenda (schedule/queue) of telecommands to execute. | |
| uint16_t | TCMD_get_agenda_used_slots_count () |
| Gets the number of used slots in the agenda (how many valid and pending telecommands). | |
| int16_t | TCMD_get_next_tcmd_agenda_slot_to_execute () |
| Finds the index into TCMD_agenda (slot_num) of the next telecommand to execute. | |
| static int8_t | TCMD_store_resp_to_file (const char *resp_fname, const char *response_output_buf, uint64_t timestamp_sent, const char args_str_no_parens[], uint8_t tcmd_idx, uint32_t duration_ms, uint8_t return_code) |
| Logs a message to a file. | |
| static uint8_t | TCMD_execute_parsed_telecommand_now (const TCMD_parsed_tcmd_to_execute_t *parsed_tcmd, char *response_output_buf, uint16_t response_output_buf_size) |
| Executes a telecommand immediately, based on the minimum info required to execute a telecommand. | |
| uint8_t | TCMD_execute_telecommand_in_agenda (const uint16_t tcmd_agenda_slot_num, char *response_output_buf, uint16_t response_output_buf_size) |
| Executes a telecommand from the agenda immediately. | |
| uint8_t | TCMD_log_pending_agenda_entries () |
| Fetches the active agendas and logs each as a JSONL entry. | |
Variables | |
| uint32_t | TCMD_total_tcmd_queued_count = 0 |
| uint64_t | TCMD_latest_received_tcmd_timestamp_sent = 0 |
| uint16_t | TCMD_timestamp_sent_head = 0 |
| The head of the circular buffer of timestamps of telecommands that have been sent. | |
| uint16_t | TCMD_timestamp_sent_used_slots = 0 |
| Counter of the number of used slots at the start of TCMD_timestamp_sent_store. | |
| uint64_t | TCMD_timestamp_sent_store [TCMD_TIMESTAMP_RECORD_SIZE] = {0} |
| The circular buffer of timestamps of telecommands that have been sent. | |
| TCMD_parsed_tcmd_to_execute_t | TCMD_agenda [TCMD_AGENDA_SIZE] |
| The agenda (schedule queue) of telecommands to execute. | |
| uint8_t | TCMD_agenda_is_valid [TCMD_AGENDA_SIZE] = {0} |
| A flag indicating whether a given index in TCMD_agenda is valid (i.e., filled with a not-yet-executed command). | |
| uint16_t | TCMD_agenda_last_used_slot = 0 |
| Index into TCMD_agenda and TCMD_agenda_is_valid of the last used slot. | |
| uint8_t TCMD_add_tcmd_to_agenda | ( | const TCMD_parsed_tcmd_to_execute_t * | parsed_tcmd | ) |
Adds a telecommand to the agenda (schedule/queue) of telecommands to execute.
| parsed_tcmd | The parsed telecommand to add to the agenda. |


|
static |
Gets the index of the first free ("invalid") slot in the agenda.


|
static |
Executes a telecommand immediately, based on the minimum info required to execute a telecommand.
| parsed_tcmd | The parsed telecommand to execute (index, args, timestamp sent, destination file). |
| response_output_buf | A buffer to store the response from the telecommand. |
| response_output_buf_size | The size of the response_output_buf. |


| uint8_t TCMD_execute_telecommand_in_agenda | ( | const uint16_t | tcmd_agenda_slot_num, |
| char * | response_output_buf, | ||
| uint16_t | response_output_buf_size ) |
Executes a telecommand from the agenda immediately.
| tcmd_agenda_slot_num | The index into TCMD_agenda for the telecommand to execute. |
| response_output_buf | A buffer to store the response from the telecommand. |
| response_output_buf_size | The size of the response_output_buf. |


| uint16_t TCMD_get_agenda_used_slots_count | ( | ) |
Gets the number of used slots in the agenda (how many valid and pending telecommands).

| int16_t TCMD_get_next_tcmd_agenda_slot_to_execute | ( | ) |
Finds the index into TCMD_agenda (slot_num) of the next telecommand to execute.


| uint8_t TCMD_log_pending_agenda_entries | ( | ) |
Fetches the active agendas and logs each as a JSONL entry.


|
static |
Logs a message to a file.
| resp_fname | The name of the file to log to. |
| response_output_buf | The message to log. |


| TCMD_parsed_tcmd_to_execute_t TCMD_agenda[TCMD_AGENDA_SIZE] |
The agenda (schedule queue) of telecommands to execute.
| uint8_t TCMD_agenda_is_valid[TCMD_AGENDA_SIZE] = {0} |
A flag indicating whether a given index in TCMD_agenda is valid (i.e., filled with a not-yet-executed command).
| uint16_t TCMD_agenda_last_used_slot = 0 |
Index into TCMD_agenda and TCMD_agenda_is_valid of the last used slot.
The next telecommand to entered into the agenda will fill this slot, or will go into the first free slot after this one.
| uint64_t TCMD_latest_received_tcmd_timestamp_sent = 0 |
| uint16_t TCMD_timestamp_sent_head = 0 |
The head of the circular buffer of timestamps of telecommands that have been sent.
| uint64_t TCMD_timestamp_sent_store[TCMD_TIMESTAMP_RECORD_SIZE] = {0} |
The circular buffer of timestamps of telecommands that have been sent.
| uint16_t TCMD_timestamp_sent_used_slots = 0 |
Counter of the number of used slots at the start of TCMD_timestamp_sent_store.
| uint32_t TCMD_total_tcmd_queued_count = 0 |