26 for (
int i=1; i<c->
argc; i++)
27 fprintf(c->
out,
" %s", c->
argv[i]);
28 fprintf(c->
out,
"\n");
41 fprintf(c->
out,
"Unknown/bad command\n");
57 fprintf(c->
out,
"Available commands:\n");
66 for (cmd=cmd_table; (*cmd)->
name; cmd++) {
67 fprintf(c->
out,
" %s\n", (*cmd)->name);
83 for (
size_t i = 1; i < len; i++) {
84 if (isspace((
int) c->
scratch.
buf[i]) && !quote) {
118 for (cmd = cmd_table; (*cmd)->
name; cmd++) {
119 if (0 == strcmp(c->
argv[0], (*cmd)->name))
132 fprintf(c->
out,
"> ");
145 #ifndef CONFIG_NO_FIBRE
156 if (cmd_table[
lengthof(cmd_table)-1])
159 for (i = 0; i <
lengthof(cmd_table); i++)
160 if (NULL == cmd_table[i]->name ||
161 strcmp(cmd_table[i]->name, cmd->
name) > 0)
164 for (j =
lengthof(cmd_table) - 1; j > i; j--)
165 cmd_table[j] = cmd_table[j-1];
184 #ifndef CONFIG_NO_FIBRE
195 for (*i=0; cmd[*i]; ) {
199 #ifndef CONFIG_NO_FIBRE
206 #ifndef CONFIG_NO_FIBRE
235 }
else if (ch ==
'\b') {
238 fprintf(c->
out,
" \b");
240 fprintf(c->
out,
" ");
243 }
else if (ch == 3) {
244 fprintf(c->
out,
"\n");
246 }
else if (ch !=
'\n') {
void fibre_init(fibre_t *f, fibre_entrypoint_t *fn)
Dynamic initializer for a fibre descriptor.
void console_hwinit(console_t *c)
Platform dependant function that will be called during console_init().
void console_putchar(console_t *c, char d)
Asynchronously send a character to the command processor.
#define PT_SPAWN(child, thread)
Call a child thread.
#define CONSOLE_CMD_VAR_INIT(n, f)
int ringbuf_get(ringbuf_t *rb)
Extract a byte from the ring buffer.
int fibre_entrypoint_t(struct fibre *)
const console_cmd_t * cmd
void console_process(console_t *c, char d)
Synchronous console function for use in threaded environments.
union console::@0 scratch
Console command descriptor.
bool fibre_run_atomic(fibre_t *f)
int console_register(const console_cmd_t *cmd)
Register a new command.
pt_state_t console_run(console_t *c)
Console protothread entrypoint.
int console_getch(console_t *c)
Fetch a character from the command processors queue.
#define PT_BEGIN_FIBRE(f)
Fibre aware alternative to PT_BEGIN().
pt_state_t console_eval(pt_t *pt, console_t *c, const char *cmd)
Proto-thread to inject a string into the command parser.
bool ringbuf_put(ringbuf_t *rb, uint8_t d)
Insert a byte into the ring buffer.
void fibre_run(fibre_t *f)
uint16_t u16[SCRATCH_SIZE/2]
pt_state_t(* fn)(struct console *c)
void ringbuf_init(ringbuf_t *rb, void *bufp, size_t buf_len)
Runtime initializer for a ring buffer descriptor.
void console_init(console_t *c, FILE *f)
Initialized the console handler.