25void vShellExec(
void *argument) {
29 params.shell->run(params.shell, params.str);
46 shell->usb = *(
UART *)DeviceHandle_getHandle(
"USB").device;
53 if (((&__shell_vector_end - &__shell_vector_start) /
sizeof(uint32_t)) > SHELL_MAX_PROGRAMS)
58 for (uint32_t *i = (uint32_t *)&__shell_vector_start; i < (uint32_t *)&__shell_vector_end; i++) {
63 shell->programHandles[idx] = registerShellProgram();
81 shell->usb.
print(&shell->usb,
"Use `help [name]` for more information on a specific command\n\r");
82 shell->usb.
print(&shell->usb,
"The following commands are currently available:\n\r");
83 for(
int i = 0; i < SHELL_MAX_PROGRAMS; i++) {
84 if(strcmp(shell->programHandles[i].name,
"")) {
85 shell->usb.
print(&shell->usb,
":");
86 shell->usb.
print(&shell->usb, shell->programHandles[i].name);
87 shell->usb.
print(&shell->usb,
"\n\r");
105 char *token = strtok((
char *)programName,
" ");
106 char *flags = strchr(token,
'\0') + 1;
110 for(
int i = 0; i < SHELL_MAX_PROGRAMS; i++) {
111 if (!strcmp(shell->programHandles[i].name, programName)) {
112 shell->programHandles[i].exec(shell, flags);
118 shell->usb.
print(&shell->usb, (
char *)programName);
119 shell->usb.
print(&shell->usb,
": command not recognized. Run `help` for a list of available commands\n\r");
137 params.shell = shell;
146 configMAX_PRIORITIES - 6,
160 shell->usb.
sendBytes(&shell->usb, (uint8_t *)
"\033[3J\033[H\033[2J", 11);
162 if (shell->taskHandle != NULL)
163 vTaskDelete(shell->taskHandle);
void(* print)(struct UART *, char *)
UART print string method.
void(* sendBytes)(struct UART *, uint8_t *, int)
UART send multiple bytes method.
Struct definition for UART interface.
int Shell_init(Shell *)
Initializes the shell, registering programs from shell vector.
void Shell_help(Shell *)
Displays available shell commands.
bool Shell_clear(Shell *)
Send clear sequence to host terminal.
void Shell_runTask(Shell *, uint8_t *)
Creates a task to run a shell program.
void Shell_run(Shell *, uint8_t *)
Executes a shell program by name.