Loading...
Searching...
No Matches
cli.h
Go to the documentation of this file.
1
6#pragma once
7#include <furi.h>
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13typedef enum {
14 CliSymbolAsciiSOH = 0x01,
15 CliSymbolAsciiETX = 0x03,
16 CliSymbolAsciiEOT = 0x04,
17 CliSymbolAsciiBell = 0x07,
18 CliSymbolAsciiBackspace = 0x08,
19 CliSymbolAsciiTab = 0x09,
20 CliSymbolAsciiLF = 0x0A,
21 CliSymbolAsciiCR = 0x0D,
22 CliSymbolAsciiEsc = 0x1B,
23 CliSymbolAsciiUS = 0x1F,
24 CliSymbolAsciiSpace = 0x20,
25 CliSymbolAsciiDel = 0x7F,
26} CliSymbols;
27
34
35#define RECORD_CLI "cli"
36
38typedef struct Cli Cli;
39
45typedef void (*CliCallback)(Cli* cli, FuriString* args, void* context);
46
56 Cli* cli,
57 const char* name,
58 CliCommandFlag flags,
59 CliCallback callback,
60 void* context);
61
68void cli_print_usage(const char* cmd, const char* usage, const char* arg);
69
75void cli_delete_command(Cli* cli, const char* name);
76
85size_t cli_read(Cli* cli, uint8_t* buffer, size_t size);
86
96size_t cli_read_timeout(Cli* cli, uint8_t* buffer, size_t size, uint32_t timeout);
97
105
112void cli_write(Cli* cli, const uint8_t* buffer, size_t size);
113
120char cli_getc(Cli* cli);
121
124void cli_nl(Cli* cli);
125
126void cli_session_open(Cli* cli, void* session);
127
128void cli_session_close(Cli* cli);
129
130bool cli_is_connected(Cli* cli);
131
132#ifdef __cplusplus
133}
134#endif
void cli_print_usage(const char *cmd, const char *usage, const char *arg)
Print unified cmd usage tip.
Definition cli.c:96
void cli_nl(Cli *cli)
New line Send new ine sequence.
Definition cli.c:138
size_t cli_read_timeout(Cli *cli, uint8_t *buffer, size_t size, uint32_t timeout)
Non-blocking read from terminal.
Definition cli.c:66
void cli_write(Cli *cli, const uint8_t *buffer, size_t size)
Write to terminal Do it only from inside of cli call.
Definition cli.c:50
CliCommandFlag
Definition cli.h:28
@ CliCommandFlagDefault
Default, loader lock is used.
Definition cli.h:29
@ CliCommandFlagInsomniaSafe
Safe to run with insomnia mode on.
Definition cli.h:32
@ CliCommandFlagParallelSafe
Safe to run in parallel with other apps, loader lock is not used.
Definition cli.h:30
size_t cli_read(Cli *cli, uint8_t *buffer, size_t size)
Read from terminal.
Definition cli.c:57
void cli_delete_command(Cli *cli, const char *name)
Delete cli command.
Definition cli.c:409
void cli_add_command(Cli *cli, const char *name, CliCommandFlag flags, CliCallback callback, void *context)
Add cli command Registers you command callback.
Definition cli.c:381
struct Cli Cli
Cli type anonymous structure.
Definition cli.h:38
bool cli_cmd_interrupt_received(Cli *cli)
Non-blocking check for interrupt command received.
Definition cli.c:83
char cli_getc(Cli *cli)
Read character.
Definition cli.c:35
void(* CliCallback)(Cli *cli, FuriString *args, void *context)
Cli callback function pointer.
Definition cli.h:45
Definition string.c:4