CTS-SAT-1-OBC-Firmware
Loading...
Searching...
No Matches
telecommand_parser.h
Go to the documentation of this file.
1
2#ifndef INCLUDE_GUARD__TELECOMMAND_PARSER_H__
3#define INCLUDE_GUARD__TELECOMMAND_PARSER_H__
4
7
8// Max len of `args_str_no_parens` in `TCMD_parsed_tcmd_to_execute_t`, including null terminator.
9#define TCMD_ARGS_STR_NO_PARENS_SIZE 255
10
11#define TCMD_PREFIX_STR "CTS1+"
12#define TCMD_PREFIX_STR_LEN 5
13
14static const uint8_t TCMD_SHA256_LENGTH_BYTES = 32;
15
16uint8_t TCMD_is_char_alphanumeric(char c);
18
19uint8_t TCMD_check_starts_with_device_id(const char *tcmd_str, uint32_t tcmd_str_len);
20int32_t TCMD_parse_telecommand_get_index(const char *tcmd_str, uint32_t tcmd_str_len);
21
22uint8_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);
23uint8_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);
24uint8_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);
25uint8_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);
26
27
28uint8_t TCMD_get_suffix_tag_uint64(const char *str, const char *tag_name, uint64_t *value_dest);
29uint8_t TCMD_get_suffix_tag_hex_array(const char *str, const char *tag_name, uint8_t *value_dest);
30uint8_t TCMD_get_suffix_tag_str(const char *str, const char *tag_name, char *value_dest, uint16_t value_dest_max_len);
31
32uint8_t TCMD_parse_full_telecommand(const char tcmd_str[],
33 TCMD_parsed_tcmd_to_execute_t *parsed_tcmd_output);
34
35
36#endif // INCLUDE_GUARD__TELECOMMAND_PARSER_H__
37
Definition telecommand_types.h:37
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.
Definition telecommand_parser.c:508
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.
Definition telecommand_parser.c:482
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.
Definition telecommand_parser.c:229
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.
Definition telecommand_parser.c:586
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.
Definition telecommand_parser.c:168
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.
Definition telecommand_parser.c:534
uint8_t TCMD_is_char_valid_telecommand_name_char(char c)
Returns whether a character is a valid character in a telecommand name.
Definition telecommand_parser.c:34
uint8_t TCMD_is_char_alphanumeric(char c)
Returns whether a character is alphanumeric (0-9, A-Z, a-z).
Definition telecommand_parser.c:20
static const uint8_t TCMD_SHA256_LENGTH_BYTES
Definition telecommand_parser.h:14
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.
Definition telecommand_parser.c:111
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.
Definition telecommand_parser.c:286
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).
Definition telecommand_parser.c:43
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.
Definition telecommand_parser.c:64