oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions
Shell

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.
 

Detailed Description

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.

Note
Requires CONFIG_OVE_SHELL.

Macro Definition Documentation

◆ OVE_SHELL_MAX_ARGS

#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 Documentation

◆ ove_shell_cmd_fn

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.

Parameters
[in]argcNumber of arguments (including the command name).
[in]argvArray of argc argument strings, terminated by NULL.

◆ ove_shell_output_hook_t

typedef void(* ove_shell_output_hook_t) (const char *data, size_t len)

Shell output hook for capturing command output.

Parameters
[in]dataOutput text.
[in]lenLength in bytes.

Function Documentation

◆ ove_shell_init()

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.

Returns
OVE_OK on success, negative error code on failure.
Note
Requires CONFIG_OVE_SHELL.

◆ ove_shell_register_cmd()

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.

Parameters
[in]cmdPointer to a persistent ove_shell_cmd descriptor.
Returns
OVE_OK on success, negative error code on failure (e.g. table full).
Note
Requires CONFIG_OVE_SHELL.

◆ ove_shell_process_char()

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.

Parameters
[in]cCharacter to process (raw byte from the console).
Note
Requires CONFIG_OVE_SHELL.

◆ ove_shell_process_line()

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).

Parameters
[in]lineNUL-terminated input line (without trailing newline).

◆ ove_shell_set_output_hook()

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.

Parameters
[in]hookOutput hook function (or NULL).