Cli API.
More...
#include <furi.h>
Go to the source code of this file.
|
typedef struct Cli | Cli |
| Cli type anonymous structure.
|
|
typedef void(* | CliCallback) (Cli *cli, FuriString *args, void *context) |
| Cli callback function pointer.
|
|
|
enum | CliSymbols {
CliSymbolAsciiSOH = 0x01
, CliSymbolAsciiETX = 0x03
, CliSymbolAsciiEOT = 0x04
, CliSymbolAsciiBell = 0x07
,
CliSymbolAsciiBackspace = 0x08
, CliSymbolAsciiTab = 0x09
, CliSymbolAsciiLF = 0x0A
, CliSymbolAsciiCR = 0x0D
,
CliSymbolAsciiEsc = 0x1B
, CliSymbolAsciiUS = 0x1F
, CliSymbolAsciiSpace = 0x20
, CliSymbolAsciiDel = 0x7F
} |
|
enum | CliCommandFlag { CliCommandFlagDefault = 0
, CliCommandFlagParallelSafe
, CliCommandFlagInsomniaSafe = (1 << 1)
} |
|
|
void | cli_add_command (Cli *cli, const char *name, CliCommandFlag flags, CliCallback callback, void *context) |
| Add cli command Registers you command callback.
|
|
void | cli_print_usage (const char *cmd, const char *usage, const char *arg) |
| Print unified cmd usage tip.
|
|
void | cli_delete_command (Cli *cli, const char *name) |
| Delete cli command.
|
|
size_t | cli_read (Cli *cli, uint8_t *buffer, size_t size) |
| Read from terminal.
|
|
size_t | cli_read_timeout (Cli *cli, uint8_t *buffer, size_t size, uint32_t timeout) |
| Non-blocking read from terminal.
|
|
bool | cli_cmd_interrupt_received (Cli *cli) |
| Non-blocking check for interrupt command received.
|
|
void | cli_write (Cli *cli, const uint8_t *buffer, size_t size) |
| Write to terminal Do it only from inside of cli call.
|
|
char | cli_getc (Cli *cli) |
| Read character.
|
|
void | cli_nl (Cli *cli) |
| New line Send new ine sequence.
|
|
void | cli_session_open (Cli *cli, void *session) |
|
void | cli_session_close (Cli *cli) |
|
bool | cli_is_connected (Cli *cli) |
|
◆ CliCallback
typedef void(* CliCallback) (Cli *cli, FuriString *args, void *context) |
Cli callback function pointer.
Implement this interface and use add_cli_command
- Parameters
-
args | string with what was passed after command |
context | pointer to whatever you gave us on cli_add_command |
◆ CliCommandFlag
Enumerator |
---|
CliCommandFlagDefault | Default, loader lock is used.
|
CliCommandFlagParallelSafe | Safe to run in parallel with other apps, loader lock is not used.
|
CliCommandFlagInsomniaSafe | Safe to run with insomnia mode on.
|
◆ cli_add_command()
Add cli command Registers you command callback.
- Parameters
-
cli | pointer to cli instance |
name | command name |
flags | CliCommandFlag |
callback | callback function |
context | pointer to whatever we need to pass to callback |
◆ cli_cmd_interrupt_received()
bool cli_cmd_interrupt_received |
( |
Cli * | cli | ) |
|
Non-blocking check for interrupt command received.
- Parameters
-
- Returns
- true if received
◆ cli_delete_command()
void cli_delete_command |
( |
Cli * | cli, |
|
|
const char * | name ) |
Delete cli command.
- Parameters
-
cli | pointer to cli instance |
name | command name |
◆ cli_getc()
char cli_getc |
( |
Cli * | cli | ) |
|
Read character.
- Parameters
-
- Returns
- char
◆ cli_print_usage()
void cli_print_usage |
( |
const char * | cmd, |
|
|
const char * | usage, |
|
|
const char * | arg ) |
Print unified cmd usage tip.
- Parameters
-
cmd | cmd name |
usage | usage tip |
arg | arg passed by user |
◆ cli_read()
size_t cli_read |
( |
Cli * | cli, |
|
|
uint8_t * | buffer, |
|
|
size_t | size ) |
Read from terminal.
- Parameters
-
cli | Cli instance |
buffer | pointer to buffer |
size | size of buffer in bytes |
- Returns
- bytes read
◆ cli_read_timeout()
size_t cli_read_timeout |
( |
Cli * | cli, |
|
|
uint8_t * | buffer, |
|
|
size_t | size, |
|
|
uint32_t | timeout ) |
Non-blocking read from terminal.
- Parameters
-
cli | Cli instance |
buffer | pointer to buffer |
size | size of buffer in bytes |
timeout | timeout value in ms |
- Returns
- bytes read
◆ cli_write()
void cli_write |
( |
Cli * | cli, |
|
|
const uint8_t * | buffer, |
|
|
size_t | size ) |
Write to terminal Do it only from inside of cli call.
- Parameters
-
cli | Cli instance |
buffer | pointer to buffer |
size | size of buffer in bytes |