Common CLI functionality including main structure and core functions.
More...
|
| struct | tr_cli |
| | Structure which defines the current state of the CLI. More...
|
|
| void | tr_cli_init (const char *prompt, void(*put_char)(char ch)) |
| | Starts up the Embedded CLI subsystem.
|
| bool | tr_cli_insert_char (char ch) |
| | Adds a new character into the buffer.
|
| const char * | tr_cli_get_line (void) |
| | Returns the null terminated internal buffer.
|
| int | tr_cli_argc (char ***argv) |
| | Parses the internal buffer and returns it as an argc/argv combo.
|
| void | tr_cli_prompt (void) |
| | Outputs the CLI prompt.
|
| const char * | tr_cli_get_history (int history_pos) |
| | Retrieves a history command line.
|
| void | tr_cli_char_received (char data) |
| | Passes a received character to the CLI.
|
| void | tr_cli_common_printf (const char *pFormat,...) |
| | Printf function used for printing to terminal.
|
Common CLI functionality including main structure and core functions.
◆ TR_CLI_HISTORY_LEN
| #define TR_CLI_HISTORY_LEN 1000 |
Maximum number of bytes to retain of history data.
Define this to 0 to remove history support.
◆ TR_CLI_LOCAL_ECHO
| #define TR_CLI_LOCAL_ECHO 1 |
Enable or disable local echo.
◆ TR_CLI_MAX_ARGC
| #define TR_CLI_MAX_ARGC 16 |
Maximum number of arguments we reserve space for.
◆ TR_CLI_MAX_LINE
| #define TR_CLI_MAX_LINE 120 |
Maximum number of bytes to accept in a single line.
◆ TR_CLI_MAX_PROMPT_LEN
| #define TR_CLI_MAX_PROMPT_LEN 10 |
Maximum number of bytes in the prompt.
◆ TR_CLI_PROMPT
| #define TR_CLI_PROMPT "trident> " |
CLI prompt to display after pressing enter.
◆ TR_CLI_SERIAL_XLATE
| #define TR_CLI_SERIAL_XLATE 1 |
Translate CR -> NL on input and output CR NL on output.
This allows "natural" processing when using a serial terminal.
◆ tr_cli_argc()
| int tr_cli_argc |
( |
char *** | argv | ) |
|
Parses the internal buffer and returns it as an argc/argv combo.
- Parameters
-
| [out] | argv | Pointer to store the argument vector. |
- Returns
- Number of values in argv (maximum of TR_CLI_MAX_ARGC).
◆ tr_cli_char_received()
| void tr_cli_char_received |
( |
char | data | ) |
|
Passes a received character to the CLI.
- Parameters
-
| [in] | data | Character received on the terminal. |
◆ tr_cli_common_printf()
| void tr_cli_common_printf |
( |
const char * | pFormat, |
|
|
| ... ) |
Printf function used for printing to terminal.
This function can be re-defined by the application using the CLI to add additional formatting behavior if desired.
- Parameters
-
| [in] | pFormat | Printf format string. |
| [in] | ... | Printf parameters. |
◆ tr_cli_get_history()
| const char * tr_cli_get_history |
( |
int | history_pos | ) |
|
Retrieves a history command line.
- Parameters
-
| [in] | history_pos | 0 is the most recent command, 1 is the one before that, etc. |
- Returns
- Pointer to the history command line, or NULL if the history buffer is exceeded.
◆ tr_cli_get_line()
| const char * tr_cli_get_line |
( |
void | | ) |
|
Returns the null terminated internal buffer.
- Returns
- Pointer to the internal buffer, or NULL if the buffer is not yet complete.
◆ tr_cli_init()
| void tr_cli_init |
( |
const char * | prompt, |
|
|
void(* | put_char )(char ch) ) |
Starts up the Embedded CLI subsystem.
This should only be called once during system initialization.
- Parameters
-
| [in] | prompt | The prompt string to display. |
| [in] | put_char | Function pointer for character output. |
◆ tr_cli_insert_char()
| bool tr_cli_insert_char |
( |
char | ch | ) |
|
Adds a new character into the buffer.
- Parameters
-
| [in] | ch | The character to add to the buffer. |
- Returns
- true if the buffer should now be processed.
- Note
- This function should not be called from an interrupt handler.
◆ tr_cli_prompt()
| void tr_cli_prompt |
( |
void | | ) |
|
Outputs the CLI prompt.
This should be called after tr_cli_argc or tr_cli_get_line has been called and the command fully processed.