CTS-SAT-1-OBC-Firmware
|
#include "telecommand_exec/telecommand_types.h"
#include "telecommand_exec/telecommand_definitions.h"
Go to the source code of this file.
Macros | |
#define | TCMD_ARGS_STR_NO_PARENS_SIZE 255 |
#define | TCMD_PREFIX_STR "CTS1+" |
#define | TCMD_PREFIX_STR_LEN 5 |
Functions | |
uint8_t | TCMD_is_char_alphanumeric (char c) |
Returns whether a character is alphanumeric (0-9, A-Z, a-z). | |
uint8_t | TCMD_is_char_valid_telecommand_name_char (char c) |
Returns whether a character is a valid character in a telecommand name. | |
uint8_t | TCMD_check_starts_with_device_id (const char *tcmd_str, uint32_t tcmd_str_len) |
Returns whether tcmd_str starts with CTS1+ (TCMD_PREFIX_STR). | |
int32_t | TCMD_parse_telecommand_get_index (const char *tcmd_str, uint32_t tcmd_str_len) |
Finds an index into TCMD_telecommand_definitions for the given telecommand string. | |
uint8_t | TCMD_process_suffix_tag_tssent (const char *tcmd_suffix_tag_str, const uint16_t tcmd_suffix_tag_str_len, uint64_t *tssent_time_ms) |
Parses the @tssent=xxxx tag from the telecommand string. | |
uint8_t | TCMD_process_suffix_tag_tsexec (const char *tcmd_suffix_tag_str, const uint16_t tcmd_suffix_tag_str_len, uint64_t *tsexec_time_ms) |
Parses the @tsexec=xxxx tag from the telecommand string. | |
uint8_t | TCMD_process_suffix_tag_sha256 (const char *tcmd_suffix_tag_str, const uint16_t tcmd_suffix_tag_str_len, const char *tcmd_str, const int32_t end_of_args_idx) |
Parses the @sha256=xxxx tag from the telecommand string. | |
uint8_t | TCMD_process_suffix_tag_resp_fname (const char *tcmd_suffix_tag_str, const uint16_t tcmd_suffix_tag_str_len, char *resp_fname, const uint8_t resp_fname_len) |
Parses the @resp_fname=xxxx tag from the telecommand string. | |
uint8_t | TCMD_get_suffix_tag_uint64 (const char *str, const char *tag_name, uint64_t *value_dest) |
Searches for a str like \@tag_name=xxxx , and sets uint64_t xxxx into out_value . | |
uint8_t | TCMD_get_suffix_tag_hex_array (const char *str, const char *tag_name, uint8_t *value_dest) |
Searches for a str like \@tag_name=xxxx , and sets uint8_t array xxxx into value_dest . | |
uint8_t | TCMD_get_suffix_tag_str (const char *str, const char *tag_name, char *value_dest, uint16_t value_dest_max_len) |
Searches for a str like \@tag_name=xxxx , and sets char array xxxx into value_dest . | |
uint8_t | TCMD_parse_full_telecommand (const char tcmd_str[], TCMD_parsed_tcmd_to_execute_t *parsed_tcmd_output) |
Parses a telecommand into everything needed to execute it. | |
Variables | |
static const uint8_t | TCMD_SHA256_LENGTH_BYTES = 32 |
#define TCMD_ARGS_STR_NO_PARENS_SIZE 255 |
#define TCMD_PREFIX_STR "CTS1+" |
#define TCMD_PREFIX_STR_LEN 5 |
uint8_t TCMD_check_starts_with_device_id | ( | const char * | tcmd_str, |
uint32_t | tcmd_str_len ) |
Returns whether tcmd_str starts with CTS1+
(TCMD_PREFIX_STR).
tcmd_str | The telecommand string to check. |
tcmd_str_len | The length of the telecommand string. |
CTS1+
, 0 otherwise. uint8_t TCMD_get_suffix_tag_hex_array | ( | const char * | str, |
const char * | tag_name, | ||
uint8_t * | value_dest ) |
Searches for a str
like \@tag_name=xxxx
, and sets uint8_t array xxxx
into value_dest
.
str | The string to search within for the tag. Excluding the tag name, the length of the string must be 256 characters. |
tag_name | The tag to search for, including the '@' and '='. |
value_dest | The destination for the value. *value_dest will be set. |
uint8_t TCMD_get_suffix_tag_str | ( | const char * | str, |
const char * | tag_name, | ||
char * | value_dest, | ||
uint16_t | value_dest_max_len ) |
Searches for a str
like \@tag_name=xxxx
, and sets char array xxxx
into value_dest
.
str | The string to search within for the tag. Excluding the tag name, the length of the string must be TCMD_MAX_RESP_FNAME_LEN. |
tag_name | The tag to search for, including the '@' and '='. |
value_dest | The destination for the value. *value_dest will be set. |
uint8_t TCMD_get_suffix_tag_uint64 | ( | const char * | str, |
const char * | tag_name, | ||
uint64_t * | value_dest ) |
Searches for a str
like \@tag_name=xxxx
, and sets uint64_t xxxx
into out_value
.
str | The string (haystack) to search with for the tag. |
tag_name | The tag to search for, including the '@' and '='. |
value_dest | The destination for the value. *value_dest will be set. |
#\@\0!
uint8_t TCMD_is_char_alphanumeric | ( | char | c | ) |
Returns whether a character is alphanumeric (0-9, A-Z, a-z).
c | The character to check. |
uint8_t TCMD_is_char_valid_telecommand_name_char | ( | char | c | ) |
Returns whether a character is a valid character in a telecommand name.
c | The character to check. |
uint8_t TCMD_parse_full_telecommand | ( | const char | tcmd_str[], |
TCMD_parsed_tcmd_to_execute_t * | parsed_tcmd_output ) |
Parses a telecommand into everything needed to execute it.
tcmd_str | The telecommand string to parse. Must be null-terminated. |
parsed_tcmd_output | Pointer to the output struct, which is modified by this function. Not modified if an error occurs. |
int32_t TCMD_parse_telecommand_get_index | ( | const char * | tcmd_str, |
uint32_t | tcmd_str_len ) |
Finds an index into TCMD_telecommand_definitions for the given telecommand string.
This function searches for the longest matching telecommand string in TCMD_telecommand_definitions, where all alpha-numeric characters at the start of the to-be-parsed telecommand match the telecommand string in TCMD_telecommand_definitions. This function is case-sensitive.
tcmd_str | The telecommand string to search within, starting with prefix, optionally including args. |
uint8_t TCMD_process_suffix_tag_resp_fname | ( | const char * | tcmd_suffix_tag_str, |
const uint16_t | tcmd_suffix_tag_str_len, | ||
char * | resp_fname, | ||
const uint8_t | resp_fname_len ) |
Parses the @resp_fname=xxxx tag from the telecommand string.
tcmd_suffix_tag_str | The telecommand suffix tag string. |
tcmd_suffix_tag_str_len | The length of the telecommand suffix tag string. |
resp_fname | The destination for the log filename. |
resp_fname_len | The length of the log filename. |
The log filename is the name of the file to which the telecommand will be logged.
If the length of the filename is > TCMD_MAX_RESP_FNAME_LEN, the filename will be truncated.
uint8_t TCMD_process_suffix_tag_sha256 | ( | const char * | tcmd_suffix_tag_str, |
const uint16_t | tcmd_suffix_tag_str_len, | ||
const char * | tcmd_str, | ||
const int32_t | end_of_args_idx ) |
Parses the @sha256=xxxx tag from the telecommand string.
This function checks that the SHA256 hash of the telecommand string matches the hash provided in the tag.
tcmd_suffix_tag_str | The telecommand suffix tag string. |
tcmd_str | The telecommand string. |
end_of_args_idx | The index of the end of the arguments in the telecommand string. |
sha256_hash | The destination for the SHA256 hash. |
uint8_t TCMD_process_suffix_tag_tsexec | ( | const char * | tcmd_suffix_tag_str, |
const uint16_t | tcmd_suffix_tag_str_len, | ||
uint64_t * | tsexec_time_ms ) |
Parses the @tsexec=xxxx tag from the telecommand string.
This function checks that the timestamp to execute is valid.
tcmd_suffix_tag_str | The telecommand suffix tag string. |
tcmd_suffix_tag_str_len | The length of the telecommand suffix tag string. |
tsexec_time_ms | The destination for the timestamp to execute. |
The timestamp to execute is the time at which the telecommand should be executed.
uint8_t TCMD_process_suffix_tag_tssent | ( | const char * | tcmd_suffix_tag_str, |
const uint16_t | tcmd_suffix_tag_str_len, | ||
uint64_t * | tssent_time_ms ) |
Parses the @tssent=xxxx tag from the telecommand string.
tcmd_suffix_tag_str | The telecommand suffix tag string. |
tcmd_suffix_tag_str_len | The length of the telecommand suffix tag string. |
tssent_time_ms | The destination for the timestamp sent. |
|
static |