CTS-SAT-1-OBC-Firmware
Loading...
Searching...
No Matches
lfs_telecommand_defs.h File Reference
#include <stdint.h>
Include dependency graph for lfs_telecommand_defs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

uint8_t TCMDEXEC_fs_format_storage (const char *args_str, char *response_output_buf, uint16_t response_output_buf_len)
 Format the LittleFS storage. ERASES ALL FILES. Unmounts the filesystem if necessary.
uint8_t TCMDEXEC_fs_mount (const char *args_str, char *response_output_buf, uint16_t response_output_buf_len)
uint8_t TCMDEXEC_fs_unmount (const char *args_str, char *response_output_buf, uint16_t response_output_buf_len)
uint8_t TCMDEXEC_fs_list_directory (const char *args_str, char *response_output_buf, uint16_t response_output_buf_len)
 Telecommand: List all the files and directories within a given directory.
uint8_t TCMDEXEC_fs_list_directory_json (const char *args_str, char *response_output_buf, uint16_t response_output_buf_len)
 Telecommand: List all the files and directories within a given directory, as a JSON dict (key are paths, values are sizes).
uint8_t TCMDEXEC_fs_make_directory (const char *args_str, char *response_output_buf, uint16_t response_output_buf_len)
 Telecommand: Create a directory.
uint8_t TCMDEXEC_fs_write_file_str (const char *args_str, char *response_output_buf, uint16_t response_output_buf_len)
 Telecommand: Write data to a file in LittleFS.
uint8_t TCMDEXEC_fs_write_file_hex (const char *args_str, char *response_output_buf, uint16_t response_output_buf_len)
 Telecommand: Write hex data to a file in LittleFS with offset support.
uint8_t TCMDEXEC_fs_delete_file (const char *args_str, char *response_output_buf, uint16_t response_output_buf_len)
 Telecommand: Deletes a specified file in LittleFS.
uint8_t TCMDEXEC_fs_delete_dir (const char *args_str, char *response_output_buf, uint16_t response_output_buf_len)
 Telecommand: Deletes a specified directory, including all subfolders/subfiles.
uint8_t TCMDEXEC_fs_read_file_hex (const char *args_str, char *response_output_buf, uint16_t response_output_buf_len)
 Reads a file from LittleFS, and responds with its contents as 2-digit hex bytes (no spaces).
uint8_t TCMDEXEC_fs_read_text_file (const char *args_str, char *response_output_buf, uint16_t response_output_buf_len)
 Reads a file from LittleFS, and responds with its contents as a string.
uint8_t TCMDEXEC_fs_read_file_sha256_hash_json (const char *args_str, char *response_output_buf, uint16_t response_output_buf_len)
 Calculates the SHA256 hash of a file in LittleFS and returns it as a little-endian hex string.
uint8_t TCMDEXEC_fs_demo_write_then_read (const char *args_str, char *response_output_buf, uint16_t response_output_buf_len)
 Writes a file to LittleFS, then reads it back.
uint8_t TCMDEXEC_fs_demo_write_random_data (const char *args_str, char *response_output_buf, uint16_t response_output_buf_len)
 Write a file with pseudorandom data to LittleFS.
uint8_t TCMDEXEC_fs_benchmark_write_read (const char *args_str, char *response_output_buf, uint16_t response_output_buf_len)
 Telecommand: Benchmark LittleFS write and read operations.
uint8_t TCMDEXEC_fs_get_filesystem_stats_json (const char *args_str, char *response_output_buf, uint16_t response_output_buf_len)
 Generate a JSON string containing filesystem stats and debugging info.
uint8_t TCMDEXEC_fs_compress_file_with_heatshrink (const char *args_str, char *response_output_buf, uint16_t response_output_buf_len)
 Compress a file using heatshrink.

Function Documentation

◆ TCMDEXEC_fs_benchmark_write_read()

uint8_t TCMDEXEC_fs_benchmark_write_read ( const char * args_str,
char * response_output_buf,
uint16_t response_output_buf_len )

Telecommand: Benchmark LittleFS write and read operations.

Parameters
args_str
  • Arg 0: Write chunk size (bytes)
  • Arg 1: Write chunk count
Returns
0 on success, 1 if error parsing args, 2 if benchmark failed
Note
The maximum write chunk size is 127 bytes, apparently; need to investigate why so small.
Here is the call graph for this function:

◆ TCMDEXEC_fs_compress_file_with_heatshrink()

uint8_t TCMDEXEC_fs_compress_file_with_heatshrink ( const char * args_str,
char * response_output_buf,
uint16_t response_output_buf_len )

Compress a file using heatshrink.

Parameters
args_str
  • Arg 0: Input file path
  • Arg 1: Output file path (e.g., suffix with ".hs")
  • Arg 2: window_sz2 (min 4, recommended 8, max 15, like CLI -w arg)
  • Arg 3: lookahead_sz2 (min 3, recommended 4, less than window_sz2, like CLI -l arg)
response_output_bufOutputs the compression ratio as a message.
Returns
0 on success. 1 on arg parsing errors.
Note
Can cause system to crash and reboot. Safe to use, but just be aware.
Requires that window_sz2 > lookahead_sz2.
Heatshrink does NOT embed the window sizes in the data. You must remember them, and use them when decompressing.
Here is the call graph for this function:

◆ TCMDEXEC_fs_delete_dir()

uint8_t TCMDEXEC_fs_delete_dir ( const char * args_str,
char * response_output_buf,
uint16_t response_output_buf_len )

Telecommand: Deletes a specified directory, including all subfolders/subfiles.

Parameters
args_str
  • Arg 0: Directory name to be deleted
Note
Do not add quotations around the argument, write as is.
Here is the call graph for this function:

◆ TCMDEXEC_fs_delete_file()

uint8_t TCMDEXEC_fs_delete_file ( const char * args_str,
char * response_output_buf,
uint16_t response_output_buf_len )

Telecommand: Deletes a specified file in LittleFS.

Parameters
args_str
  • Arg 0: File name to be deleted
Note
Do not add quotations around the argument, write as is.
Here is the call graph for this function:

◆ TCMDEXEC_fs_demo_write_random_data()

uint8_t TCMDEXEC_fs_demo_write_random_data ( const char * args_str,
char * response_output_buf,
uint16_t response_output_buf_len )

Write a file with pseudorandom data to LittleFS.

Parameters
args_str
  • Arg 0: File path as string
  • Arg 1: File size in bytes (approx., best-effort)
  • Arg 2: Amount of randomness - 0 = no randomness, 1 = highly predictable, 255 = very random
response_output_buf
response_output_buf_len
Returns
0 on success, >0 on error
Here is the call graph for this function:

◆ TCMDEXEC_fs_demo_write_then_read()

uint8_t TCMDEXEC_fs_demo_write_then_read ( const char * args_str,
char * response_output_buf,
uint16_t response_output_buf_len )

Writes a file to LittleFS, then reads it back.

Parameters
args_str
  • Arg 0: File path as string
response_output_buf
response_output_buf_len
Returns
Here is the call graph for this function:

◆ TCMDEXEC_fs_format_storage()

uint8_t TCMDEXEC_fs_format_storage ( const char * args_str,
char * response_output_buf,
uint16_t response_output_buf_len )

Format the LittleFS storage. ERASES ALL FILES. Unmounts the filesystem if necessary.

Returns
LFS errror code from LFS_format().
Here is the call graph for this function:

◆ TCMDEXEC_fs_get_filesystem_stats_json()

uint8_t TCMDEXEC_fs_get_filesystem_stats_json ( const char * args_str,
char * response_output_buf,
uint16_t response_output_buf_len )

Generate a JSON string containing filesystem stats and debugging info.

Parameters
args_strNo arguments.
Returns
0 on success, 1 on error.
Note
Used space may be approximate, due to the nature of LittleFS Copy-on-Write (COW).
Here is the call graph for this function:

◆ TCMDEXEC_fs_list_directory()

uint8_t TCMDEXEC_fs_list_directory ( const char * args_str,
char * response_output_buf,
uint16_t response_output_buf_len )

Telecommand: List all the files and directories within a given directory.

Parameters
args_str
  • Arg 0: Root Directory path as string
  • Arg 1: (Offset) Number of entries to skip at the beginning
  • Arg 2: (Count) Number entries to display
Here is the call graph for this function:

◆ TCMDEXEC_fs_list_directory_json()

uint8_t TCMDEXEC_fs_list_directory_json ( const char * args_str,
char * response_output_buf,
uint16_t response_output_buf_len )

Telecommand: List all the files and directories within a given directory, as a JSON dict (key are paths, values are sizes).

Parameters
args_str
  • Arg 0: Root Directory path as string
  • Arg 1: (Offset) Number of entries to skip at the beginning
  • Arg 2: (Count) Number entries to display
Note
In the resulting JSON, the JSON value of directories is "null".
Here is the call graph for this function:

◆ TCMDEXEC_fs_make_directory()

uint8_t TCMDEXEC_fs_make_directory ( const char * args_str,
char * response_output_buf,
uint16_t response_output_buf_len )

Telecommand: Create a directory.

Parameters
args_str
  • Arg 0: Directory Name as string (e.g., "/dir1", "/dir1/subdir1")
Here is the call graph for this function:

◆ TCMDEXEC_fs_mount()

uint8_t TCMDEXEC_fs_mount ( const char * args_str,
char * response_output_buf,
uint16_t response_output_buf_len )
Here is the call graph for this function:

◆ TCMDEXEC_fs_read_file_hex()

uint8_t TCMDEXEC_fs_read_file_hex ( const char * args_str,
char * response_output_buf,
uint16_t response_output_buf_len )

Reads a file from LittleFS, and responds with its contents as 2-digit hex bytes (no spaces).

Parameters
args_str
  • Arg 0: File path as string
  • Arg 1: Start offset (bytes). Nominally, pick 0.
  • Arg 2: Length to read (bytes). 0 to read max.
Returns
0 on success, >0 on error
Here is the call graph for this function:

◆ TCMDEXEC_fs_read_file_sha256_hash_json()

uint8_t TCMDEXEC_fs_read_file_sha256_hash_json ( const char * args_str,
char * response_output_buf,
uint16_t response_output_buf_len )

Calculates the SHA256 hash of a file in LittleFS and returns it as a little-endian hex string.

Parameters
args_str
  • Arg 0: File path as string
  • Arg 1: Start offset (bytes). Nominally, pick 0.
  • Arg 2: Length to read (bytes). 0 to read max.
Returns
0 on success, >0 on error
Here is the call graph for this function:

◆ TCMDEXEC_fs_read_text_file()

uint8_t TCMDEXEC_fs_read_text_file ( const char * args_str,
char * response_output_buf,
uint16_t response_output_buf_len )

Reads a file from LittleFS, and responds with its contents as a string.

Parameters
args_str
  • Arg 0: File path as string
  • Arg 1: Start offset (bytes). Nominally, pick 0.
  • Arg 2: Length to read (bytes). 0 to read max.
Returns
0 on success, >0 on error
Here is the call graph for this function:

◆ TCMDEXEC_fs_unmount()

uint8_t TCMDEXEC_fs_unmount ( const char * args_str,
char * response_output_buf,
uint16_t response_output_buf_len )
Here is the call graph for this function:

◆ TCMDEXEC_fs_write_file_hex()

uint8_t TCMDEXEC_fs_write_file_hex ( const char * args_str,
char * response_output_buf,
uint16_t response_output_buf_len )

Telecommand: Write hex data to a file in LittleFS with offset support.

Parameters
args_str
  • Arg 0: File path as string
  • Arg 1: Offset within the file to start writing (uint64)
  • Arg 2: Hex string to write to file (e.g., "DEADBEEF" or "DE AD BE EF")
Note
The maximum number of bytes that can be written is 105 bytes
Here is the call graph for this function:

◆ TCMDEXEC_fs_write_file_str()

uint8_t TCMDEXEC_fs_write_file_str ( const char * args_str,
char * response_output_buf,
uint16_t response_output_buf_len )

Telecommand: Write data to a file in LittleFS.

Parameters
args_str
  • Arg 0: File path as string
  • Arg 1: String to write to file (up to 512 bytes)
Here is the call graph for this function: