| 260 |
260 |
aosDbgCheck(stream != NULL);
|
| 261 |
261 |
|
| 262 |
262 |
// local variables
|
|
263 |
#if (HAL_USE_RTC == TRUE)
|
| 263 |
264 |
struct tm dt;
|
| 264 |
265 |
aosSysGetDateTime(&dt);
|
|
266 |
#endif /* HAL_USE_RTC == TRUE */
|
| 265 |
267 |
|
| 266 |
268 |
// print static information about module and operating system
|
| 267 |
269 |
_printSystemInfoSeparator(stream, '=', SYSTEM_INFO_WIDTH);
|
| ... | ... | |
| 324 |
326 |
_printSystemInfoLine(stream, "Module ID", SYSTEM_INFO_NAMEWIDTH, "not available");
|
| 325 |
327 |
}
|
| 326 |
328 |
#endif
|
|
329 |
#if (HAL_USE_RTC == TRUE)
|
| 327 |
330 |
_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",
|
| 328 |
331 |
dt.tm_mday,
|
| 329 |
332 |
dt.tm_mon + 1,
|
| 330 |
333 |
dt.tm_year + 1900);
|
| 331 |
334 |
_printSystemInfoLine(stream, "Time", SYSTEM_INFO_NAMEWIDTH, "%02u:%02u:%02u", dt.tm_hour, dt.tm_min, dt.tm_sec);
|
|
335 |
#endif /* HAL_USE_RTC == TRUE */
|
| 332 |
336 |
|
| 333 |
337 |
_printSystemInfoSeparator(stream, '=', SYSTEM_INFO_WIDTH);
|
| 334 |
338 |
|
| ... | ... | |
| 432 |
436 |
retval = AOS_OK;
|
| 433 |
437 |
}
|
| 434 |
438 |
}
|
|
439 |
# if (HAL_USE_RTC == TRUE)
|
| 435 |
440 |
// if the user wants to configure the date or time
|
| 436 |
441 |
else if (strcmp(argv[1], "--date&time") == 0 && argc == 4) {
|
| 437 |
442 |
struct tm dt;
|
| 438 |
443 |
aosSysGetDateTime(&dt);
|
| 439 |
|
unsigned int val = atoi(argv[3]);
|
| 440 |
|
if (strcmp(argv[2], "year") == 0) {
|
|
444 |
int val = atoi(argv[3]);
|
|
445 |
if (strcmp(argv[2], "year") == 0 && val >= 1900) {
|
| 441 |
446 |
dt.tm_year = val - 1900;
|
| 442 |
447 |
}
|
| 443 |
|
else if (strcmp(argv[2], "month") == 0 && val <= 12) {
|
|
448 |
else if (strcmp(argv[2], "month") == 0 && val > 0 && val <= 12) {
|
| 444 |
449 |
dt.tm_mon = val - 1;
|
| 445 |
450 |
}
|
| 446 |
|
else if (strcmp(argv[2], "day") == 0 && val <= 31) {
|
|
451 |
else if (strcmp(argv[2], "day") == 0 && val > 0 && val <= 31) {
|
| 447 |
452 |
dt.tm_mday = val;
|
| 448 |
453 |
}
|
| 449 |
|
else if (strcmp(argv[2], "hour") == 0 && val < 24) {
|
|
454 |
else if (strcmp(argv[2], "hour") == 0 && val >= 0 && val < 24) {
|
| 450 |
455 |
dt.tm_hour = val;
|
| 451 |
456 |
}
|
| 452 |
|
else if (strcmp(argv[2], "minute") == 0 && val < 60) {
|
|
457 |
else if (strcmp(argv[2], "minute") == 0 && val >= 0 && val < 60) {
|
| 453 |
458 |
dt.tm_min = val;
|
| 454 |
459 |
}
|
| 455 |
|
else if (strcmp(argv[2], "second") == 0 && val < 60) {
|
|
460 |
else if (strcmp(argv[2], "second") == 0 && val >= 0 && val < 60) {
|
| 456 |
461 |
dt.tm_sec = val;
|
| 457 |
462 |
}
|
| 458 |
463 |
else {
|
| 459 |
|
chprintf(stream, "unknown option '%s' or value '%s'\n", argv[2], argv[3]);
|
|
464 |
chprintf(stream, "unknown option '%s' or invalid value '%s'\n", argv[2], argv[3]);
|
| 460 |
465 |
return AOS_INVALID_ARGUMENTS;
|
| 461 |
466 |
}
|
| 462 |
467 |
dt.tm_wday = aosTimeDayOfWeekFromDate(dt.tm_mday, dt.tm_mon+1, dt.tm_year+1900) % 7;
|
| ... | ... | |
| 470 |
475 |
|
| 471 |
476 |
retval = AOS_OK;
|
| 472 |
477 |
}
|
|
478 |
#endif /* HAL_USE_RTC == TRUE */
|
| 473 |
479 |
}
|
| 474 |
480 |
|
| 475 |
481 |
// print help, if required
|
| ... | ... | |
| 485 |
491 |
chprintf(stream, " Configures the prompt.\n");
|
| 486 |
492 |
chprintf(stream, " match casesensitive|caseinsenitive\n");
|
| 487 |
493 |
chprintf(stream, " Configures string matching.\n");
|
|
494 |
#if (HAL_USE_RTC == TRUE)
|
| 488 |
495 |
chprintf(stream, " --date&time OPT VAL\n");
|
| 489 |
496 |
chprintf(stream, " Set the date/time value of OPT to VAL.\n");
|
| 490 |
497 |
chprintf(stream, " Possible OPTs are:\n");
|
| ... | ... | |
| 494 |
501 |
chprintf(stream, " hour\n");
|
| 495 |
502 |
chprintf(stream, " minute\n");
|
| 496 |
503 |
chprintf(stream, " second\n");
|
|
504 |
#endif /* HAL_USE_RTC == TRUE */
|
| 497 |
505 |
}
|
| 498 |
506 |
|
| 499 |
507 |
return (argc > 1 && strcmp(argv[1], "--help") == 0) ? AOS_OK : retval;
|
| ... | ... | |
| 976 |
984 |
return;
|
| 977 |
985 |
}
|
| 978 |
986 |
|
|
987 |
#if (HAL_USE_RTC == TRUE) || defined(__DOXYGEN__)
|
|
988 |
|
| 979 |
989 |
/**
|
| 980 |
990 |
* @brief retrieves the date and time from the MCU clock.
|
| 981 |
991 |
*
|
| ... | ... | |
| 1008 |
1018 |
return;
|
| 1009 |
1019 |
}
|
| 1010 |
1020 |
|
|
1021 |
#endif /* HAL_USE_RTC == TRUE */
|
|
1022 |
|
| 1011 |
1023 |
/**
|
| 1012 |
1024 |
* @brief Initializes/Acknowledges a system shutdown/restart request.
|
| 1013 |
1025 |
* @note This functions should be called from the thread with highest priority.
|