|
CTS-SAT-1-OBC-Firmware
|

Macros | |
| #define | LFS_MAX_PATH_LENGTH 200 |
| #define | LOG(severity, fmt, ...) |
Enumerations | |
| enum | LOG_severity_enum_t { LOG_SEVERITY_DEBUG = 1 << 0 , LOG_SEVERITY_NORMAL = 1 << 1 , LOG_SEVERITY_WARNING = 1 << 2 , LOG_SEVERITY_ERROR = 1 << 3 , LOG_SEVERITY_CRITICAL = 1 << 4 } |
| enum | COMMS_bulk_file_downlink_state_enum_t { COMMS_BULK_FILE_DOWNLINK_STATE_IDLE , COMMS_BULK_FILE_DOWNLINK_STATE_DOWNLINKING , COMMS_BULK_FILE_DOWNLINK_STATE_PAUSED } |
Functions | |
| int | snprintf (char *buf, unsigned int size, const char *fmt,...) |
| int | strlen (const char *s) |
| void | LOG_message (uint32_t source, LOG_severity_enum_t severity, uint32_t sink_mask, const char *fmt,...) |
| lfs_ssize_t | LFS_file_size (const char file_name[], uint8_t enable_log_messages) |
| Returns the file size. | |
| int8_t | LFS_read_file_checksum_sha256 (const char filepath[], uint32_t start_offset, uint32_t max_length, uint8_t sha256_dest[32]) |
| Computes the SHA256 checksum of a file in LittleFS. | |
| void | GEN_byte_array_to_hex_str (const uint8_t *byte_array, uint32_t byte_array_len, char *dest_str, uint32_t dest_str_size) |
| Writes a byte array to a hex string (no spaces between bytes). | |
| int32_t | COMMS_bulk_file_downlink_start (char *file_path, uint32_t start_offset, uint32_t max_bytes) |
| Initiate a bulk file downlink over the UHF radio. | |
| static uint32_t | TIME_uptime_ms () |
| static uint16_t | parse_token (const char *src, uint16_t src_offset, uint16_t src_len, char *dst, uint16_t dst_size) |
| static int8_t | hex_to_int (char c) |
| static int32_t | parse_int (const char *s, bool *ok) |
| Parse a string into an integer. | |
| static int8_t | bulk_downlink_start_fixed (const char *src_file_path, uint32_t start_offset, uint32_t byte_count) |
| Main operation in this blob. | |
| static int8_t | fill_response_output_buffer (const char *src_file_path, uint32_t start_offset, uint32_t max_length, char *response_output_buf, uint16_t response_output_buf_len) |
| Fill the response output buffer with info about the file (very helpful for decoding). | |
| __attribute__ ((used, section(".text.entry"))) | |
Variables | |
| static const uint32_t | LOG_SYSTEM_TELECOMMAND = 1 << 12 |
| static const uint32_t | LOG_SINK_ALL = (1 << 4) - 1 |
| static const char | ARG_DELIM = ';' |
| static const char * | BLOB_NAME = "bulk_downlink_start_blob" |
| lfs_t | LFS_filesystem |
| volatile uint32_t | TIME_uptime_ms_from_tim6 |
| COMMS_bulk_file_downlink_state_enum_t | COMMS_bulk_file_downlink_state |
| char | COMMS_bulk_file_downlink_file_path [LFS_MAX_PATH_LENGTH] |
| #define LFS_MAX_PATH_LENGTH 200 |
| #define LOG | ( | severity, | |
| fmt, | |||
| ... ) |
| enum LOG_severity_enum_t |
| __attribute__ | ( | (used, section(".text.entry")) | ) |

|
static |
Main operation in this blob.
| src_file_path | |
| start_offset | |
| byte_count |
Implementation is like this: The goal here is not to re-implement COMMS_bulk_file_downlink_start(), but rather to set the state to trick that function into first closing the open file (if applicable), and then doing its normal thing (which is 100% correct).
We are fixing a bug in the "end of bulk downlink" logic by a hack at the start of the next downlink, basically.


| int32_t COMMS_bulk_file_downlink_start | ( | char * | file_path, |
| uint32_t | start_offset, | ||
| uint32_t | max_bytes ) |
Initiate a bulk file downlink over the UHF radio.
| file_path | File name/path to downlink. |
| start_offset | The byte offset in the file to start downlinking from (0 for start). |
| max_bytes | The maximum number of bytes to downlink. Maximum value is 1000000 (1 MB, COMMS_bulk_file_downlink_total_bytes), for safety (to avoid a very very long-running downlink chain). Values >1 MB will be limited to 1 MB, and value 0 will be set to 1 MB. |

|
static |
Fill the response output buffer with info about the file (very helpful for decoding).
| src_file_path | |
| start_offset | |
| max_length | Max length of the file to read, or 0 to read full file. |
| response_output_buf | |
| response_output_buf_len |


|
extern |
Writes a byte array to a hex string (no spaces between bytes).
| byte_array | Input byte array. |
| byte_array_len | Length of input byte_array. |
| dest_str | The destination to write a C-string to. |
| dest_str_size | The size of the dest_str array, allocated before calling. Must be at least byte_array_len * 3 + 1 to fit the entire string. |

|
static |

| lfs_ssize_t LFS_file_size | ( | const char | file_name[], |
| uint8_t | enable_log_messages ) |
Returns the file size.
| file_name | - Pointer to buffer holding the file name to open |

|
extern |
Computes the SHA256 checksum of a file in LittleFS.
| filepath | Path to the file to read and compute the checksum for. |
| start_offset | The offset in the file from which to start reading. |
| max_length | The maximum number of bytes to read from the file. 0 means read the entire file. |
| sha256_dest | 32-byte array to be filled with checksum. |

|
extern |
|
static |
Parse a string into an integer.
| s | String to parse. Valid formats: "0x<digits>" or "<digits>". Underscores are ignored. |


|
static |

|
extern |
|
extern |
|
inlinestatic |
|
static |
|
static |
|
extern |
|
extern |
|
extern |
Created on: May 2, 2024 Author: Saksham Puri
|
static |
|
static |
|
extern |