|
oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
|
Interactive command-line interface over the system console. More...
Data Structures | |
| struct | ove_shell_cmd |
| Descriptor for a single shell command. More... | |
Macros | |
| #define | OVE_SHELL_MAX_ARGS 8 |
| Maximum number of arguments (including command name) per shell line. | |
Typedefs | |
| typedef void(* | ove_shell_cmd_fn) (int argc, const char *argv[]) |
| Prototype for a shell command handler function. | |
| typedef void(* | ove_shell_output_hook_t) (const char *data, size_t len) |
| Shell output hook for capturing command output. | |
Functions | |
| int | ove_shell_init (void) |
| Initialise the shell subsystem. | |
| int | ove_shell_register_cmd (const struct ove_shell_cmd *cmd) |
| Register a command with the shell. | |
| void | ove_shell_process_char (int c) |
| Feed one character into the shell input processor. | |
| void | ove_shell_process_line (const char *line) |
| Process a complete input line through the shell. | |
| void | ove_shell_set_output_hook (ove_shell_output_hook_t hook) |
| Set a hook to capture shell output. | |
Interactive command-line interface over the system console.
Implements a simple line-editing shell that tokenises input lines and dispatches them to registered command handlers. Commands are registered at run time via ove_shell_register_cmd and driven character-by-character through ove_shell_process_char (typically called from a console receive callback or a dedicated task).
The maximum number of space-separated tokens per line is OVE_SHELL_MAX_ARGS.
CONFIG_OVE_SHELL. | #define OVE_SHELL_MAX_ARGS 8 |
Maximum number of arguments (including command name) per shell line.
The shell splits each input line into at most this many whitespace-delimited tokens before dispatching to the command handler.
| typedef void(* ove_shell_cmd_fn) (int argc, const char *argv[]) |
Prototype for a shell command handler function.
Called by the shell when the user enters a matching command. argc is the total number of tokens (including the command name in argv[0]) and is always at least 1. argv is a NULL-terminated array of pointers to the individual tokens within the line buffer; the strings are valid only for the duration of the call.
| [in] | argc | Number of arguments (including the command name). |
| [in] | argv | Array of argc argument strings, terminated by NULL. |
| typedef void(* ove_shell_output_hook_t) (const char *data, size_t len) |
Shell output hook for capturing command output.
| [in] | data | Output text. |
| [in] | len | Length in bytes. |
| int ove_shell_init | ( | void | ) |
Initialise the shell subsystem.
Sets up internal state and registers built-in commands (e.g. help). Must be called before ove_shell_register_cmd or ove_shell_process_char.
CONFIG_OVE_SHELL. | int ove_shell_register_cmd | ( | const struct ove_shell_cmd * | cmd | ) |
Register a command with the shell.
Adds the command described by cmd to the shell's dispatch table. The name field is used for matching; duplicate names produce implementation-defined behavior.
| [in] | cmd | Pointer to a persistent ove_shell_cmd descriptor. |
CONFIG_OVE_SHELL. | void ove_shell_process_char | ( | int | c | ) |
Feed one character into the shell input processor.
Appends c to the internal line buffer. On receipt of a newline the accumulated line is tokenised and dispatched to the matching registered command handler, or an error message is printed if no match is found. Backspace and other editing characters are handled transparently.
This function is typically called from a console receive ISR, a DMA callback, or a dedicated input task.
| [in] | c | Character to process (raw byte from the console). |
CONFIG_OVE_SHELL. | void ove_shell_process_line | ( | const char * | line | ) |
Process a complete input line through the shell.
Tokenises line and dispatches to the matching command handler. Equivalent to feeding each character of the line via process_char, but more convenient for programmatic use (e.g. WebSocket terminal).
| [in] | line | NUL-terminated input line (without trailing newline). |
| void ove_shell_set_output_hook | ( | ove_shell_output_hook_t | hook | ) |
Set a hook to capture shell output.
When set, shell command output (normally printed to console) is also forwarded to this hook. Pass NULL to remove.
| [in] | hook | Output hook function (or NULL). |