-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci.hh
135 lines (109 loc) · 2.86 KB
/
ci.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
* Copyright (C) 2004-2011 David Weber <david@embeddedtoolbox.com>
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __CI_H__
#define __CI_H__
#include <stdint.h>
#include "cmd_table.h"
#include "status.h"
#include "libtecla.h"
typedef char ci_buf_t[CMD_BUF_LENGTH];
/**
* @class ci
*
* @brief Command interpreter class definition
*/
class ci
{
private:
cmd_table_entry_t* cmd_table;
uint32_t num_cmds;
const char* prompt_string;
GetLine* get_line;
protected:
public:
ci(cmd_table_entry_t* cmd_table, uint32_t num_cmds, const char* prompt_string);
~ci();
/**
* @brief Initializes the command interpreter
*
* @return void
*/
void init();
/**
* @brief The main loop of the command interpreter
*
* @return void
*/
void run();
/**
* @brief Invokes function associated with a command
*
* @param line The command line string
* @param cmd_args The command line string separated into arguments
* @param num_args The number of arguments in cmd_args array
*
* @return SUCCESS or error code
*/
status_t handler(const char* line, arg_array_t cmd_args, uint32_t num_args);
/**
* @brief Acquires a command from the command input source
*
* @param buf buffer containing acquired command
*
* @return SUCCESS or error code
*/
status_t receive_cmd(ci_buf_t buf);
/**
* @brief Parses the cmd_line parameter and invokes associated function handler
*
* @param
*
* @return SUCCESS or error code
*/
status_t process_cmd(const char* cmd_line);
/**
* @brief Sends response to a command
*
* @return void
*/
void send_response();
/**
* @brief Handles error returned from process commands
*
* @param status SUCCESS or error code
*
* @return
*/
void process_status(const char* cmd_line, status_t status);
/**
* @brief Prints the command's arguments
*
* @param args array of argument strings
* @param num_args number of arguments present in args array
*
* @return void
*/
void print_args(arg_array_t args, uint32_t num_args);
/**
* @brief Prints command summary
*
* @return void
*/
void help(void);
};
#endif //__CI_H__