EE445M RTOS
Taken at the University of Texas Spring 2015
shellpp.hpp
Go to the documentation of this file.
1 /* -*- mode: c++; c-basic-offset: 4; -*- */
2 #ifndef __shellpp__
3 #define __shellpp__
4 
5 #include <stdbool.h>
6 
7 #include "uartpp.hpp"
8 #include "bufferpp.hpp"
9 #include "semaphorepp.hpp"
10 
15 #define SHELL_COMMANDS 2
16 
17 #define SYSTEM_MAX_NAME_LENGTH 10
18 #define SYSTEM_MAX_COMMANDS 5
19 
21 #define SHELL_MAX_PS1_LENGTH 4
22 
24 #define SHELL_BUFFER_LENGTH 32
25 
26 #define UART_VERBOSE true
27 
28 typedef uint8_t exit_status_t;
29 typedef exit_status_t (*sys_cmd)(const char*);
30 
31 class shell {
32 private:
35  /* Wondering why there's a +1 here? Waldo has the answers */
37 
39  int32_t ustrncmp(const char*, const char*, uint32_t);
40  void* memset(void* b, int c, int len);
41 
43  uint32_t strlen(const char*);
44 
45  static exit_status_t help_info(const char* args);
46  static exit_status_t doctor(const char* args);
47  static exit_status_t witch(const char* args);
48  static exit_status_t jester(const char* args);
49 
50  static exit_status_t motor_start(const char* args);
51  static exit_status_t motor_stop(const char* args);
52 
55 
56  static void ustrcpy(char* dest, const char* source);
57 
58  void init_ps1(void);
59 
60  static semaphore* m_start;
61  static semaphore* m_stop;
62 
64  void init(void);
65 
66 public:
67  shell();
68  shell(uart* u);
69  shell(uart* u, semaphore* m_start, semaphore* m_stop);
70 
72  void clear_buffer();
73 
75  void set_ps1(char* new_ps1);
76 
78  void print_ps1();
79 
81  bool type(char ch);
82 
84  void backspace(void);
85 
87  void accept(char ch);
88 
91 };
92 
93 #endif
94 
uint8_t exit_status_t
Definition: shellpp.hpp:28
int32_t ustrncmp(const char *, const char *, uint32_t)
Definition: shellpp.cpp:44
Definition: uartpp.hpp:28
void init_ps1(void)
Definition: shellpp.cpp:102
static exit_status_t motor_start(const char *args)
Definition: shellpp.cpp:201
exit_status_t(* sys_cmd)(const char *)
Definition: shellpp.hpp:29
bool type(char ch)
Definition: shellpp.cpp:159
exit_status_t execute_command()
Definition: shellpp.cpp:228
static void ustrcpy(char *dest, const char *source)
Definition: shellpp.cpp:66
char ps1[4+1]
Definition: shellpp.hpp:36
void init(void)
Definition: shellpp.cpp:75
static sys_cmd system_command_funcs[2]
Definition: shellpp.hpp:54
static exit_status_t witch(const char *args)
Definition: shellpp.cpp:28
shell()
Definition: shellpp.cpp:81
void print_ps1()
Definition: shellpp.cpp:153
static exit_status_t motor_stop(const char *args)
Definition: shellpp.cpp:207
#define SHELL_COMMANDS
Definition: shellpp.hpp:15
static exit_status_t jester(const char *args)
Definition: shellpp.cpp:35
static exit_status_t doctor(const char *args)
Definition: shellpp.cpp:21
static semaphore * m_stop
Definition: shellpp.hpp:61
void accept(char ch)
Definition: shellpp.cpp:174
#define SHELL_MAX_PS1_LENGTH
Definition: shellpp.hpp:21
#define SYSTEM_MAX_NAME_LENGTH
Definition: shellpp.hpp:17
void set_ps1(char *new_ps1)
Definition: shellpp.cpp:147
void backspace(void)
Definition: shellpp.cpp:192
static exit_status_t help_info(const char *args)
buffer< char, 32 > buf
Definition: shellpp.hpp:34
static char system_command_names[2][10]
Definition: shellpp.hpp:53
void clear_buffer()
Definition: shellpp.cpp:142
uart * uart0
Definition: shellpp.hpp:33
void * memset(void *b, int c, int len)
Definition: shellpp.cpp:113
uint32_t strlen(const char *)
Definition: shellpp.cpp:126
static semaphore * m_start
Definition: shellpp.hpp:60