|
1 |
/*
|
|
2 |
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
|
|
3 |
Copyright (C) 2016..2018 Thomas Schöpping et al.
|
|
4 |
|
|
5 |
This program is free software: you can redistribute it and/or modify
|
|
6 |
it under the terms of the GNU General Public License as published by
|
|
7 |
the Free Software Foundation, either version 3 of the License, or
|
|
8 |
(at your option) any later version.
|
|
9 |
|
|
10 |
This program is distributed in the hope that it will be useful,
|
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
GNU General Public License for more details.
|
|
14 |
|
|
15 |
You should have received a copy of the GNU General Public License
|
|
16 |
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17 |
*/
|
|
18 |
|
|
19 |
/**
|
|
20 |
* @file aos_system.c
|
|
21 |
* @brief System code.
|
|
22 |
* @details Contains system initialization and shutdown routines
|
|
23 |
* and system shell commands.
|
|
24 |
*
|
|
25 |
* @addtogroup aos_system
|
|
26 |
* @{
|
|
27 |
*/
|
|
28 |
|
|
29 |
#include <aos_system.h>
|
|
30 |
|
|
31 |
#include <amiroos.h>
|
|
32 |
#include <amiroblt.h>
|
|
33 |
#include <module.h>
|
|
34 |
#include <string.h>
|
|
35 |
#include <stdlib.h>
|
|
36 |
#if (AMIROOS_CFG_TESTS_ENABLE == true)
|
|
37 |
#include <ch_test.h>
|
|
38 |
#include <rt_test_root.h>
|
|
39 |
#endif
|
|
40 |
|
|
41 |
/**
|
|
42 |
* @brief Period of the system timer.
|
|
43 |
*/
|
|
44 |
#define SYSTIMER_PERIOD (TIME_MAX_SYSTIME - CH_CFG_ST_TIMEDELTA)
|
|
45 |
|
|
46 |
/**
|
|
47 |
* @brief Width of the printable system info text.
|
|
48 |
*/
|
|
49 |
#define SYSTEM_INFO_WIDTH 70
|
|
50 |
|
|
51 |
/**
|
|
52 |
* @brief Width of the name column of the system info table.
|
|
53 |
*/
|
|
54 |
#define SYSTEM_INFO_NAMEWIDTH 14
|
|
55 |
|
|
56 |
/* forward declarations */
|
|
57 |
static void _printSystemInfo(BaseSequentialStream* stream);
|
|
58 |
#if (AMIROOS_CFG_SHELL_ENABLE == true)
|
|
59 |
static int _shellcmd_configcb(BaseSequentialStream* stream, int argc, char* argv[]);
|
|
60 |
static int _shellcmd_infocb(BaseSequentialStream* stream, int argc, char* argv[]);
|
|
61 |
static int _shellcmd_shutdowncb(BaseSequentialStream* stream, int argc, char* argv[]);
|
|
62 |
#if (AMIROOS_CFG_TESTS_ENABLE == true)
|
|
63 |
static int _shellcmd_kerneltestcb(BaseSequentialStream* stream, int argc, char* argv[]);
|
|
64 |
#endif /* AMIROOS_CFG_TESTS_ENABLE == true */
|
|
65 |
#endif /* AMIROOS_CFG_SHELL_ENABLE == true */
|
|
66 |
|
|
67 |
/**
|
|
68 |
* @brief Timer to accumulate system uptime.
|
|
69 |
*/
|
|
70 |
static virtual_timer_t _systimer;
|
|
71 |
|
|
72 |
/**
|
|
73 |
* @brief Accumulated system uptime.
|
|
74 |
*/
|
|
75 |
static aos_timestamp_t _uptime;
|
|
76 |
|
|
77 |
/**
|
|
78 |
* @brief Timer register value of last accumulation.
|
|
79 |
*/
|
|
80 |
static systime_t _synctime;
|
|
81 |
|
|
82 |
#if (AMIROOS_CFG_SSSP_MASTER == true) || defined(__DOXYGEN__)
|
|
83 |
/**
|
|
84 |
* @brief Timer to drive the SYS_SYNC signal for system wide time synchronization according to SSSP.
|
|
85 |
*/
|
|
86 |
static virtual_timer_t _syssynctimer;
|
|
87 |
|
|
88 |
/**
|
|
89 |
* @brief Last uptime of system wide time synchronization.
|
|
90 |
*/
|
|
91 |
static aos_timestamp_t _syssynctime;
|
|
92 |
#endif
|
|
93 |
|
|
94 |
#if ((AMIROOS_CFG_SSSP_MASTER != true) && (AMIROOS_CFG_PROFILE == true)) || defined(__DOXYGEN__)
|
|
95 |
/**
|
|
96 |
* @brief Offset between local clock and system wide synchronization signal.
|
|
97 |
*/
|
|
98 |
static float _syssyncskew;
|
|
99 |
|
|
100 |
/**
|
|
101 |
* @brief Weighting factor for the low-pass filter used for calculating the @p _syssyncskew value.
|
|
102 |
*/
|
|
103 |
#define SYSTEM_SYSSYNCSKEW_LPFACTOR (0.1f / AOS_SYSTEM_TIME_RESOLUTION)
|
|
104 |
#endif
|
|
105 |
|
|
106 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__)
|
|
107 |
/**
|
|
108 |
* @brief Shell thread working area.
|
|
109 |
*/
|
|
110 |
THD_WORKING_AREA(_shell_wa, AMIROOS_CFG_SHELL_STACKSIZE);
|
|
111 |
|
|
112 |
/**
|
|
113 |
* @brief Shell input buffer.
|
|
114 |
*/
|
|
115 |
static char _shell_line[AMIROOS_CFG_SHELL_LINEWIDTH];
|
|
116 |
|
|
117 |
/**
|
|
118 |
* @brief Shell argument buffer.
|
|
119 |
*/
|
|
120 |
static char* _shell_arglist[AMIROOS_CFG_SHELL_MAXARGS];
|
|
121 |
|
|
122 |
/**
|
|
123 |
* @brief Shell command to retrieve system information.
|
|
124 |
*/
|
|
125 |
static aos_shellcommand_t _shellcmd_info = {
|
|
126 |
/* name */ "module:info",
|
|
127 |
/* callback */ _shellcmd_infocb,
|
|
128 |
/* next */ NULL,
|
|
129 |
};
|
|
130 |
|
|
131 |
/**
|
|
132 |
* @brief Shell command to set or retrieve system configuration.
|
|
133 |
*/
|
|
134 |
static aos_shellcommand_t _shellcmd_config = {
|
|
135 |
/* name */ "module:config",
|
|
136 |
/* callback */ _shellcmd_configcb,
|
|
137 |
/* next */ NULL,
|
|
138 |
};
|
|
139 |
|
|
140 |
/**
|
|
141 |
* @brief Shell command to shutdown the system.
|
|
142 |
*/
|
|
143 |
static aos_shellcommand_t _shellcmd_shutdown = {
|
|
144 |
/* name */ "system:shutdown",
|
|
145 |
/* callback */ _shellcmd_shutdowncb,
|
|
146 |
/* next */ NULL,
|
|
147 |
};
|
|
148 |
#endif /* AMIROOS_CFG_SHELL_ENABLE == true */
|
|
149 |
|
|
150 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
|
|
151 |
/**
|
|
152 |
* @brief Shell kommand to run a test of the ChibiOS/RT kernel.
|
|
153 |
*/
|
|
154 |
static aos_shellcommand_t _shellcmd_kerneltest = {
|
|
155 |
/* name */ "kernel:test",
|
|
156 |
/* callback */ _shellcmd_kerneltestcb,
|
|
157 |
/* next */ NULL,
|
|
158 |
};
|
|
159 |
#endif /* AMIROOS_CFG_TESTS_ENABLE == true */
|
|
160 |
|
|
161 |
/**
|
|
162 |
* @brief Global system object.
|
|
163 |
*/
|
|
164 |
aos_system_t aos;
|
|
165 |
|
|
166 |
/**
|
|
167 |
* @brief Print a separator line.
|
|
168 |
*
|
|
169 |
* @param[in] stream Stream to print to or NULL to print to all system streams.
|
|
170 |
* @param[in] c Character to use.
|
|
171 |
* @param[in] n Length of the separator line.
|
|
172 |
*
|
|
173 |
* @return Number of characters printed.
|
|
174 |
*/
|
|
175 |
static unsigned int _printSystemInfoSeparator(BaseSequentialStream* stream, const char c, const unsigned int n)
|
|
176 |
{
|
|
177 |
aosDbgCheck(stream != NULL);
|
|
178 |
|
|
179 |
// print the specified character n times
|
|
180 |
for (unsigned int i = 0; i < n; ++i) {
|
|
181 |
streamPut(stream, c);
|
|
182 |
}
|
|
183 |
streamPut(stream, '\n');
|
|
184 |
|
|
185 |
return n+1;
|
|
186 |
}
|
|
187 |
|
|
188 |
/**
|
|
189 |
* @brief Print a system information line.
|
|
190 |
* @details Prints a system information line with the following format:
|
|
191 |
* "<name>[spaces]fmt"
|
|
192 |
* The combined width of "<name>[spaces]" can be specified in order to align <fmt> on multiple lines.
|
|
193 |
* Note that there is not trailing newline added implicitely.
|
|
194 |
*
|
|
195 |
* @param[in] stream Stream to print to or NULL to print to all system streams.
|
|
196 |
* @param[in] name Name of the entry/line.
|
|
197 |
* @param[in] namewidth Width of the name column.
|
|
198 |
* @param[in] fmt Formatted string of information content.
|
|
199 |
*
|
|
200 |
* @return Number of characters printed.
|
|
201 |
*/
|
|
202 |
static unsigned int _printSystemInfoLine(BaseSequentialStream* stream, const char* name, const unsigned int namewidth, const char* fmt, ...)
|
|
203 |
{
|
|
204 |
aosDbgCheck(stream != NULL);
|
|
205 |
aosDbgCheck(name != NULL);
|
|
206 |
|
|
207 |
unsigned int n = 0;
|
|
208 |
va_list ap;
|
|
209 |
|
|
210 |
va_start(ap, fmt);
|
|
211 |
n += chprintf(stream, name);
|
|
212 |
while (n < namewidth) {
|
|
213 |
streamPut(stream, ' ');
|
|
214 |
++n;
|
|
215 |
}
|
|
216 |
n += chvprintf(stream, fmt, ap);
|
|
217 |
va_end(ap);
|
|
218 |
|
|
219 |
streamPut(stream, '\n');
|
|
220 |
++n;
|
|
221 |
|
|
222 |
return n;
|
|
223 |
}
|
|
224 |
|
|
225 |
/**
|
|
226 |
* @brief Prints information about the system.
|
|
227 |
*
|
|
228 |
* @param[in] stream Stream to print to.
|
|
229 |
*/
|
|
230 |
static void _printSystemInfo(BaseSequentialStream* stream)
|
|
231 |
{
|
|
232 |
aosDbgCheck(stream != NULL);
|
|
233 |
|
|
234 |
// local variables
|
|
235 |
struct tm dt;
|
|
236 |
aosSysGetDateTime(&dt);
|
|
237 |
|
|
238 |
// print static information about module and operating system
|
|
239 |
_printSystemInfoSeparator(stream, '=', SYSTEM_INFO_WIDTH);
|
|
240 |
_printSystemInfoLine(stream, "Module", SYSTEM_INFO_NAMEWIDTH, "%s (v%s)", BOARD_NAME, BOARD_VERSION);
|
|
241 |
#ifdef PLATFORM_NAME
|
|
242 |
_printSystemInfoLine(stream, "Platform", SYSTEM_INFO_NAMEWIDTH, "%s", PLATFORM_NAME);
|
|
243 |
#endif
|
|
244 |
#ifdef PORT_CORE_VARIANT_NAME
|
|
245 |
_printSystemInfoLine(stream, "Core Variant", SYSTEM_INFO_NAMEWIDTH, "%s", PORT_CORE_VARIANT_NAME);
|
|
246 |
#endif
|
|
247 |
_printSystemInfoLine(stream, "Architecture", SYSTEM_INFO_NAMEWIDTH, "%s", PORT_ARCHITECTURE_NAME);
|
|
248 |
_printSystemInfoSeparator(stream, '-', SYSTEM_INFO_WIDTH);
|
|
249 |
_printSystemInfoLine(stream, "AMiRo-OS" , SYSTEM_INFO_NAMEWIDTH, "%u.%u.%u %s (SSSP %u.%u)", AMIROOS_VERSION_MAJOR, AMIROOS_VERSION_MINOR, AMIROOS_VERSION_PATCH, AMIROOS_RELEASE_TYPE, AOS_SYSTEM_SSSP_VERSION_MAJOR, AOS_SYSTEM_SSSP_VERSION_MINOR);
|
|
250 |
_printSystemInfoLine(stream, "AMiRo-LLD" , SYSTEM_INFO_NAMEWIDTH, "%u.%u.%u %s (periphAL %u.%u)", AMIRO_LLD_VERSION_MAJOR, AMIRO_LLD_VERSION_MINOR, AMIRO_LLD_VERSION_PATCH, AMIRO_LLD_RELEASE_TYPE, PERIPHAL_VERSION_MAJOR, PERIPHAL_VERSION_MINOR);
|
|
251 |
_printSystemInfoLine(stream, "ChibiOS/RT" , SYSTEM_INFO_NAMEWIDTH, "%u.%u.%u %s", CH_KERNEL_MAJOR, CH_KERNEL_MINOR, CH_KERNEL_PATCH, (CH_KERNEL_STABLE == 1) ? "stable" : "non-stable");
|
|
252 |
_printSystemInfoLine(stream, "ChibiOS/HAL", SYSTEM_INFO_NAMEWIDTH, "%u.%u.%u %s", CH_HAL_MAJOR, CH_HAL_MINOR, CH_HAL_PATCH, (CH_HAL_STABLE == 1) ? "stable" : "non-stable");
|
|
253 |
_printSystemInfoLine(stream, "build type", SYSTEM_INFO_NAMEWIDTH,"%s", (AMIROOS_CFG_DBG == true) ? "debug" : "release");
|
|
254 |
_printSystemInfoLine(stream, "Compiler" , SYSTEM_INFO_NAMEWIDTH, "%s %u.%u.%u", "GCC", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__); // TODO: support other compilers than GCC
|
|
255 |
_printSystemInfoLine(stream, "Compiled" , SYSTEM_INFO_NAMEWIDTH, "%s - %s", __DATE__, __TIME__);
|
|
256 |
|
|
257 |
// print static information about the bootloader
|
|
258 |
_printSystemInfoSeparator(stream, '-', SYSTEM_INFO_WIDTH);
|
|
259 |
if (BL_CALLBACK_TABLE_ADDRESS->magicNumber == BL_MAGIC_NUMBER) {
|
|
260 |
_printSystemInfoLine(stream, "AMiRo-BLT", SYSTEM_INFO_NAMEWIDTH, "%u.%u.%u %s (SSSP %u.%u)", BL_CALLBACK_TABLE_ADDRESS->vBootloader.major, BL_CALLBACK_TABLE_ADDRESS->vBootloader.minor, BL_CALLBACK_TABLE_ADDRESS->vBootloader.patch,
|
|
261 |
(BL_CALLBACK_TABLE_ADDRESS->vBootloader.identifier == BL_VERSION_ID_AMiRoBLT_Release) ? "stable" :
|
|
262 |
(BL_CALLBACK_TABLE_ADDRESS->vBootloader.identifier == BL_VERSION_ID_AMiRoBLT_ReleaseCandidate) ? "release candidate" :
|
|
263 |
(BL_CALLBACK_TABLE_ADDRESS->vBootloader.identifier == BL_VERSION_ID_AMiRoBLT_Beta) ? "beta" :
|
|
264 |
(BL_CALLBACK_TABLE_ADDRESS->vBootloader.identifier == BL_VERSION_ID_AMiRoBLT_Alpha) ? "alpha" :
|
|
265 |
(BL_CALLBACK_TABLE_ADDRESS->vBootloader.identifier == BL_VERSION_ID_AMiRoBLT_PreAlpha) ? "pre-alpha" :
|
|
266 |
"<release type unknown>",
|
|
267 |
BL_CALLBACK_TABLE_ADDRESS->vSSSP.major, BL_CALLBACK_TABLE_ADDRESS->vSSSP.minor);
|
|
268 |
if (BL_CALLBACK_TABLE_ADDRESS->vSSSP.major != AOS_SYSTEM_SSSP_VERSION_MAJOR) {
|
|
269 |
if (stream) {
|
|
270 |
chprintf(stream, "WARNING: Bootloader and AMiRo-OS implement incompatible SSSP versions!\n");
|
|
271 |
} else {
|
|
272 |
aosprintf("WARNING: Bootloader and AMiRo-OS implement incompatible SSSP versions!\n");
|
|
273 |
}
|
|
274 |
}
|
|
275 |
_printSystemInfoLine(stream, "Compiler", SYSTEM_INFO_NAMEWIDTH, "%s %u.%u.%u", (BL_CALLBACK_TABLE_ADDRESS->vCompiler.identifier == BL_VERSION_ID_GCC) ? "GCC" : "<compiler unknown>", BL_CALLBACK_TABLE_ADDRESS->vCompiler.major, BL_CALLBACK_TABLE_ADDRESS->vCompiler.minor, BL_CALLBACK_TABLE_ADDRESS->vCompiler.patch); // TODO: support other compilers than GCC
|
|
276 |
} else {
|
|
277 |
if (stream) {
|
|
278 |
chprintf(stream, "Bootloader incompatible or not available.\n");
|
|
279 |
} else {
|
|
280 |
aosprintf("Bootloader incompatible or not available.\n");
|
|
281 |
}
|
|
282 |
}
|
|
283 |
|
|
284 |
// print dynamic information about the module
|
|
285 |
_printSystemInfoSeparator(stream, '-', SYSTEM_INFO_WIDTH);
|
|
286 |
if (aos.sssp.moduleId != 0) {
|
|
287 |
_printSystemInfoLine(stream, "Module ID", SYSTEM_INFO_NAMEWIDTH, "%u", aos.sssp.moduleId);
|
|
288 |
} else {
|
|
289 |
_printSystemInfoLine(stream, "Module ID", SYSTEM_INFO_NAMEWIDTH, "not available");
|
|
290 |
}
|
|
291 |
_printSystemInfoLine(stream, "Date", SYSTEM_INFO_NAMEWIDTH, "%s %02u-%02u-%04u", (dt.tm_wday == 0) ? "Sunday" : (dt.tm_wday == 1) ? "Monday" : (dt.tm_wday == 2) ? "Tuesday" : (dt.tm_wday == 3) ? "Wednesday" : (dt.tm_wday == 4) ? "Thursday" : (dt.tm_wday == 5) ? "Friday" : "Saturday",
|
|
292 |
dt.tm_mday,
|
|
293 |
dt.tm_mon + 1,
|
|
294 |
dt.tm_year + 1900);
|
|
295 |
_printSystemInfoLine(stream, "Time", SYSTEM_INFO_NAMEWIDTH, "%02u:%02u:%02u", dt.tm_hour, dt.tm_min, dt.tm_sec);
|
|
296 |
|
|
297 |
_printSystemInfoSeparator(stream, '=', SYSTEM_INFO_WIDTH);
|
|
298 |
|
|
299 |
return;
|
|
300 |
}
|
|
301 |
|
|
302 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__)
|
|
303 |
/**
|
|
304 |
* @brief Callback function for the system:config shell command.
|
|
305 |
*
|
|
306 |
* @param[in] stream The I/O stream to use.
|
|
307 |
* @param[in] argc Number of arguments.
|
|
308 |
* @param[in] argv List of pointers to the arguments.
|
|
309 |
*
|
|
310 |
* @return An exit status.
|
|
311 |
* @retval AOS_OK The command was executed successfuly.
|
|
312 |
* @retval AOS_INVALID_ARGUMENTS There was an issue with the arguemnts.
|
|
313 |
*/
|
|
314 |
static int _shellcmd_configcb(BaseSequentialStream* stream, int argc, char* argv[])
|
|
315 |
{
|
|
316 |
aosDbgCheck(stream != NULL);
|
|
317 |
|
|
318 |
// local variables
|
|
319 |
int retval = AOS_INVALID_ARGUMENTS;
|
|
320 |
|
|
321 |
// if there are additional arguments
|
|
322 |
if (argc > 1) {
|
|
323 |
// if the user wants to set or retrieve the shell configuration
|
|
324 |
if (strcmp(argv[1], "--shell") == 0) {
|
|
325 |
// if the user wants to modify the shell configuration
|
|
326 |
if (argc > 2) {
|
|
327 |
// if the user wants to modify the prompt
|
|
328 |
if (strcmp(argv[2], "prompt") == 0) {
|
|
329 |
// there must be a further argument
|
|
330 |
if (argc > 3) {
|
|
331 |
// handle the option
|
|
332 |
if (strcmp(argv[3], "text") == 0) {
|
|
333 |
aos.shell.config &= ~AOS_SHELL_CONFIG_PROMPT_MINIMAL;
|
|
334 |
retval = AOS_OK;
|
|
335 |
}
|
|
336 |
else if (strcmp(argv[3], "minimal") == 0) {
|
|
337 |
aos.shell.config |= AOS_SHELL_CONFIG_PROMPT_MINIMAL;
|
|
338 |
retval = AOS_OK;
|
|
339 |
}
|
|
340 |
else if (strcmp(argv[3], "notime") == 0) {
|
|
341 |
aos.shell.config &= ~(AOS_SHELL_CONFIG_PROMPT_UPTIME | AOS_SHELL_CONFIG_PROMPT_DATETIME);
|
|
342 |
retval = AOS_OK;
|
|
343 |
}
|
|
344 |
else if (strcmp(argv[3], "uptime") == 0) {
|
|
345 |
aos.shell.config &= ~AOS_SHELL_CONFIG_PROMPT_DATETIME;
|
|
346 |
aos.shell.config |= AOS_SHELL_CONFIG_PROMPT_UPTIME;
|
|
347 |
retval = AOS_OK;
|
|
348 |
}
|
|
349 |
else if (strcmp(argv[3], "date&time") == 0) {
|
|
350 |
aos.shell.config &= ~AOS_SHELL_CONFIG_PROMPT_UPTIME;
|
|
351 |
aos.shell.config |= AOS_SHELL_CONFIG_PROMPT_DATETIME;
|
|
352 |
retval = AOS_OK;
|
|
353 |
}
|
|
354 |
else {
|
|
355 |
chprintf(stream, "unknown option '%s'\n", argv[3]);
|
|
356 |
return AOS_INVALID_ARGUMENTS;
|
|
357 |
}
|
|
358 |
}
|
|
359 |
}
|
|
360 |
// if the user wants to modify the string matching
|
|
361 |
else if (strcmp(argv[2], "match") == 0) {
|
|
362 |
// there must be a further argument
|
|
363 |
if (argc > 3) {
|
|
364 |
if (strcmp(argv[3], "casesensitive") == 0) {
|
|
365 |
aos.shell.config |= AOS_SHELL_CONFIG_MATCH_CASE;
|
|
366 |
retval = AOS_OK;
|
|
367 |
}
|
|
368 |
else if (strcmp(argv[3], "caseinsensitive") == 0) {
|
|
369 |
aos.shell.config &= ~AOS_SHELL_CONFIG_MATCH_CASE;
|
|
370 |
retval = AOS_OK;
|
|
371 |
}
|
|
372 |
}
|
|
373 |
}
|
|
374 |
}
|
|
375 |
// if the user wants to retrieve the shell configuration
|
|
376 |
else {
|
|
377 |
chprintf(stream, "current shell configuration:\n");
|
|
378 |
chprintf(stream, " prompt text: %s\n",
|
|
379 |
(aos.shell.prompt != NULL) ? aos.shell.prompt : "n/a");
|
|
380 |
char time[10];
|
|
381 |
switch (aos.shell.config & (AOS_SHELL_CONFIG_PROMPT_UPTIME | AOS_SHELL_CONFIG_PROMPT_DATETIME)) {
|
|
382 |
case AOS_SHELL_CONFIG_PROMPT_UPTIME:
|
|
383 |
strcpy(time, "uptime"); break;
|
|
384 |
case AOS_SHELL_CONFIG_PROMPT_DATETIME:
|
|
385 |
strcpy(time, "date&time"); break;
|
|
386 |
default:
|
|
387 |
strcpy(time, "no time"); break;
|
|
388 |
}
|
|
389 |
chprintf(stream, " prompt style: %s, %s\n",
|
|
390 |
(aos.shell.config & AOS_SHELL_CONFIG_PROMPT_MINIMAL) ? "minimal" : "text",
|
|
391 |
time);
|
|
392 |
chprintf(stream, " input method: %s\n",
|
|
393 |
(aos.shell.config & AOS_SHELL_CONFIG_INPUT_OVERWRITE) ? "replace" : "insert");
|
|
394 |
chprintf(stream, " text matching: %s\n",
|
|
395 |
(aos.shell.config & AOS_SHELL_CONFIG_MATCH_CASE) ? "case sensitive" : "case insensitive");
|
|
396 |
retval = AOS_OK;
|
|
397 |
}
|
|
398 |
}
|
|
399 |
// if the user wants to configure the date or time
|
|
400 |
else if (strcmp(argv[1], "--date&time") == 0 && argc == 4) {
|
|
401 |
struct tm dt;
|
|
402 |
aosSysGetDateTime(&dt);
|
|
403 |
unsigned int val = atoi(argv[3]);
|
|
404 |
if (strcmp(argv[2], "year") == 0) {
|
|
405 |
dt.tm_year = val - 1900;
|
|
406 |
}
|
|
407 |
else if (strcmp(argv[2], "month") == 0 && val <= 12) {
|
|
408 |
dt.tm_mon = val - 1;
|
|
409 |
}
|
|
410 |
else if (strcmp(argv[2], "day") == 0 && val <= 31) {
|
|
411 |
dt.tm_mday = val;
|
|
412 |
}
|
|
413 |
else if (strcmp(argv[2], "hour") == 0 && val < 24) {
|
|
414 |
dt.tm_hour = val;
|
|
415 |
}
|
|
416 |
else if (strcmp(argv[2], "minute") == 0 && val < 60) {
|
|
417 |
dt.tm_min = val;
|
|
418 |
}
|
|
419 |
else if (strcmp(argv[2], "second") == 0 && val < 60) {
|
|
420 |
dt.tm_sec = val;
|
|
421 |
}
|
|
422 |
else {
|
|
423 |
|