Trident IoT SDK
 
Loading...
Searching...
No Matches
tr_cli.h
Go to the documentation of this file.
1
10#ifndef TR_CLI_H
11#define TR_CLI_H
12
13#include <stdbool.h>
14#include "tr_printf.h"
16#include "tr_cli_buffer.h"
17
18#ifndef TR_CLI_MAX_LINE
22#define TR_CLI_MAX_LINE 120
23#endif
24
25#ifndef TR_CLI_HISTORY_LEN
30#define TR_CLI_HISTORY_LEN 1000
31#endif
32
33#ifndef TR_CLI_MAX_ARGC
37#define TR_CLI_MAX_ARGC 16
38#endif
39
40#ifndef TR_CLI_PROMPT
44#define TR_CLI_PROMPT "trident> "
45#endif
46
47#ifndef TR_CLI_MAX_PROMPT_LEN
51#define TR_CLI_MAX_PROMPT_LEN 10
52#endif
53
54#ifndef TR_CLI_SERIAL_XLATE
59#define TR_CLI_SERIAL_XLATE 1
60#endif
61
69struct tr_cli
70{
76
77#if TR_CLI_HISTORY_LEN
81 char history[TR_CLI_HISTORY_LEN];
82
86 bool searching;
87
91 int history_pos;
92#endif
93
97 int len;
98
103
107 bool done;
108
112 void (*put_char)(char ch);
113
117 void *cb_data;
118
121
126
128
130};
131
135void tr_cli_init(const char *prompt,
136 void ( *put_char )(char ch));
137
143bool tr_cli_insert_char(char ch);
144
149const char *tr_cli_get_line(void);
150
155int tr_cli_argc(char ***argv);
156
162void tr_cli_prompt(void);
163
170const char *tr_cli_get_history(int history_pos);
171
176void tr_cli_char_received(char data);
177
185void tr_cli_common_printf(const char *pFormat,
186 ...);
187
188#endif // TR_CLI_H
Definition tr_cli.h:70
int len
Definition tr_cli.h:97
bool have_csi
Definition tr_cli.h:120
char * argv[TR_CLI_MAX_ARGC]
Definition tr_cli.h:127
void * cb_data
Definition tr_cli.h:117
bool have_escape
Definition tr_cli.h:119
char buffer[TR_CLI_MAX_LINE]
Definition tr_cli.h:75
void(* put_char)(char ch)
Definition tr_cli.h:112
bool done
Definition tr_cli.h:107
char prompt[TR_CLI_MAX_PROMPT_LEN]
Definition tr_cli.h:129
int cursor
Definition tr_cli.h:102
int counter
Definition tr_cli.h:125
bool tr_cli_insert_char(char ch)
#define TR_CLI_MAX_PROMPT_LEN
Definition tr_cli.h:51
void tr_cli_init(const char *prompt, void(*put_char)(char ch))
int tr_cli_argc(char ***argv)
#define TR_CLI_HISTORY_LEN
Definition tr_cli.h:30
void tr_cli_common_printf(const char *pFormat,...)
const char * tr_cli_get_history(int history_pos)
const char * tr_cli_get_line(void)
#define TR_CLI_MAX_LINE
Definition tr_cli.h:22
void tr_cli_prompt(void)
#define TR_CLI_MAX_ARGC
Definition tr_cli.h:37
void tr_cli_char_received(char data)
code for buffering bytes to be sent to the CLI utility
common CLI utility for parsing incoming commands
A simple printf utility for debug prints and cli support. Required for remote CLI to function properl...