Loading...
Searching...
No Matches
shell.h
1
5
6// ALLOW FORMATTING
7#ifndef SHELL_H
8#define SHELL_H
9
10#include "FreeRTOS.h"
11#include "stdbool.h"
12#include "task.h"
13
14#include "topic.h"
15#include "uart.h"
16
17extern Topic *shellTopic;
18void Shell_setUart(UART_t *uart);
19void pubShellRxInterrupt();
20
21// clang-format off
22
23// Macro for shell program definition boilerplate. The expansion of this will define
24// a static global-scope ShellProgramHandle_t pointer to a compound literal struct.
25#define DEFINE_PROGRAM_HANDLE(progName, execFunction, helpFunction) \
26static ShellProgramHandle_t __attribute__((section(".shell_" progName), unused)) \
27*progHandle = &(ShellProgramHandle_t){ \
28 .name = progName, \
29 .exec = execFunction, \
30 .help = helpFunction \
31};
32
33// Max allowable characters for name
34#define SHELL_PROGRAM_NAME_LENGTH 20
35
36// Max allowable characters for shell string
37#define SHELL_MSG_LENGTH 255
38
39// Terminal clear screen control sequence
40#define CMD_CLEAR "\033[3J\033[H\033[2J"
41
42// clang-format on
43
51
60typedef struct ShellProgramHandle_t {
61 char name[SHELL_PROGRAM_NAME_LENGTH];
62 void (*exec)(UART_t *, char *);
63 void (*help)(UART_t *);
65
66void vShellProcess(void *argument);
67bool Shell_run(char *programName);
68bool Shell_sigint();
69
71
72#endif
char name[SHELL_PROGRAM_NAME_LENGTH]
Program name as referenced by the shell.
Definition shell.h:61
void(* help)(UART_t *)
Program help-string print function.
Definition shell.h:63
void(* exec)(UART_t *, char *)
Program entry point function pointer.
Definition shell.h:62
void vShellProcess(void *argument)
Definition shell.c:64
bool Shell_run(char *programName)
Executes a shell program by name.
Definition shell.c:167
bool Shell_sigint()
Exit any running task and clear to new line.
Definition shell.c:206
Struct definition for shell program handle.
Definition shell.h:60
Struct definition for UART interface.
Definition uart.h:132
Public representation of a Topic.
Definition topic.h:71