Revision f3ac1c96 core/src/aos_shell.c

View differences:

core/src/aos_shell.c
32 32
#include <aos_time.h>
33 33
#include <aos_system.h>
34 34
#include <string.h>
35
/******************************************************************************/
36
/* LOCAL DEFINITIONS                                                          */
37
/******************************************************************************/
35 38

  
36 39
/**
37 40
 * @brief   Event mask to be set on OS related events.
......
43 46
 */
44 47
#define AOS_SHELL_EVENTMASK_INPUT               EVENT_MASK(1)
45 48

  
49
/******************************************************************************/
50
/* EXPORTED VARIABLES                                                         */
51
/******************************************************************************/
52

  
53
/******************************************************************************/
54
/* LOCAL TYPES                                                                */
55
/******************************************************************************/
56

  
57
/*
58
 * forward declarations
59
 */
60
static size_t _channelwrite(void *instance, const uint8_t *bp, size_t n);
61
static size_t _channelread(void *instance, uint8_t *bp, size_t n);
62
static msg_t _channelput(void *instance, uint8_t b);
63
static msg_t _channelget(void *instance);
64
static msg_t _channelputt(void *instance, uint8_t b, sysinterval_t time);
65
static msg_t _channelgett(void *instance, sysinterval_t time);
66
static size_t _channelwritet(void *instance, const uint8_t *bp, size_t n, sysinterval_t time);
67
static size_t _channelreadt(void *instance, uint8_t *bp, size_t n, sysinterval_t time);
68
static msg_t _channelctl(void *instance, unsigned int operation, void *arg);
69
static size_t _streamwrite(void *instance, const uint8_t *bp, size_t n);
70
static size_t _stremread(void *instance, uint8_t *bp, size_t n);
71
static msg_t _streamput(void *instance, uint8_t b);
72
static msg_t _streamget(void *instance);
73

  
74
static const struct AosShellChannelVMT _channelvmt = {
75
  (size_t) 0,
76
  _channelwrite,
77
  _channelread,
78
  _channelput,
79
  _channelget,
80
  _channelputt,
81
  _channelgett,
82
  _channelwritet,
83
  _channelreadt,
84
  _channelctl,
85
};
86

  
87
static const struct AosShellStreamVMT _streamvmt = {
88
  (size_t) 0,
89
  _streamwrite,
90
  _stremread,
91
  _streamput,
92
  _streamget,
93
};
94

  
95
/**
96
 * @brief   Enumerator of special keyboard keys.
97
 */
98
typedef enum special_key {
99
  KEY_UNKNOWN,      /**< any/unknow key */
100
  KEY_AMBIGUOUS,    /**< key is ambiguous */
101
  KEY_TAB,          /**< tabulator key */
102
  KEY_ESCAPE,       /**< escape key */
103
  KEY_BACKSPACE,    /**< backspace key */
104
  KEY_INSERT,       /**< insert key */
105
  KEY_DELETE,       /**< delete key */
106
  KEY_HOME,         /**< home key */
107
  KEY_END,          /**< end key */
108
  KEY_PAGE_UP,      /**< page up key */
109
  KEY_PAGE_DOWN,    /**< page down key */
110
  KEY_ARROW_UP,     /**< arrow up key */
111
  KEY_ARROW_DOWN,   /**< arrow down key */
112
  KEY_ARROW_LEFT,   /**< arrow left key */
113
  KEY_ARROW_RIGHT,  /**< arrow right key */
114
} special_key_t;
115

  
116
/**
117
 * @brief   Enumerator for case (in)sensitive character matching.
118
 */
119
typedef enum charmatch {
120
  CHAR_MATCH_NOT    = 0,  /**< Characters do not match at all. */
121
  CHAR_MATCH_NCASE  = 1,  /**< Characters would match case insensitive. */
122
  CHAR_MATCH_CASE   = 2,  /**< Characters do match with case. */
123
} charmatch_t;
124

  
125
/******************************************************************************/
126
/* LOCAL VARIABLES                                                            */
127
/******************************************************************************/
128

  
129
/******************************************************************************/
130
/* LOCAL FUNCTIONS                                                            */
131
/******************************************************************************/
132

  
46 133
/**
47 134
 * @brief   Implementation of the BaseAsynchronous write() method (inherited from BaseSequentialStream).
48 135
 */
......
142 229
/**
143 230
 * @brief   Implementation of the BaseAsynchronousChannel ctl() method.
144 231
 */
145
static msg_t _channelctl(void *instance, unsigned int operation, void *arg) {
232
static msg_t _channelctl(void *instance, unsigned int operation, void *arg)
233
{
146 234
  (void) instance;
147 235

  
148 236
  switch (operation) {
......
158 246
  return MSG_OK;
159 247
}
160 248

  
161
static const struct AosShellChannelVMT _channelvmt = {
162
  (size_t) 0,
163
  _channelwrite,
164
  _channelread,
165
  _channelput,
166
  _channelget,
167
  _channelputt,
168
  _channelgett,
169
  _channelwritet,
170
  _channelreadt,
171
  _channelctl,
172
};
173

  
174 249
static size_t _streamwrite(void *instance, const uint8_t *bp, size_t n)
175 250
{
176 251
  aosDbgCheck(instance != NULL);
......
224 299
  return 0;
225 300
}
226 301

  
227
static const struct AosShellStreamVMT _streamvmt = {
228
  (size_t) 0,
229
  _streamwrite,
230
  _stremread,
231
  _streamput,
232
  _streamget,
233
};
234

  
235
/**
236
 * @brief   Enumerator of special keyboard keys.
237
 */
238
typedef enum special_key {
239
  KEY_UNKNOWN,      /**< any/unknow key */
240
  KEY_AMBIGUOUS,    /**< key is ambiguous */
241
  KEY_TAB,          /**< tabulator key */
242
  KEY_ESCAPE,       /**< escape key */
243
  KEY_BACKSPACE,    /**< backspace key */
244
  KEY_INSERT,       /**< insert key */
245
  KEY_DELETE,       /**< delete key */
246
  KEY_HOME,         /**< home key */
247
  KEY_END,          /**< end key */
248
  KEY_PAGE_UP,      /**< page up key */
249
  KEY_PAGE_DOWN,    /**< page down key */
250
  KEY_ARROW_UP,     /**< arrow up key */
251
  KEY_ARROW_DOWN,   /**< arrow down key */
252
  KEY_ARROW_LEFT,   /**< arrow left key */
253
  KEY_ARROW_RIGHT,  /**< arrow right key */
254
} special_key_t;
255

  
256
/**
257
 * @brief   Enumerator for case (in)sensitive character matching.
258
 */
259
typedef enum charmatch {
260
  CHAR_MATCH_NOT    = 0,  /**< Characters do not match at all. */
261
  CHAR_MATCH_NCASE  = 1,  /**< Characters would match case insensitive. */
262
  CHAR_MATCH_CASE   = 2,  /**< Characters do match with case. */
263
} charmatch_t;
264

  
265 302
/**
266 303
 * @brief   Print the shell prompt
267 304
 * @details Depending on the configuration flags, the system uptime is printed before the prompt string.
......
1095 1132
  return arg;
1096 1133
}
1097 1134

  
1135
/******************************************************************************/
1136
/* EXPORTED FUNCTIONS                                                         */
1137
/******************************************************************************/
1138

  
1098 1139
/**
1099 1140
 * @brief   Initializes a shell object with the specified parameters.
1100 1141
 *

Also available in: Unified diff