Revision 3da12676
| core/inc/aos_shell.h | ||
|---|---|---|
| 35 | 35 |
/* CONSTANTS */ |
| 36 | 36 |
/******************************************************************************/ |
| 37 | 37 |
|
| 38 |
|
|
| 39 |
|
|
| 40 | 38 |
/** |
| 41 | 39 |
* @brief Shell event flag that is emitted when the thread starts. |
| 42 | 40 |
*/ |
| ... | ... | |
| 242 | 240 |
*/ |
| 243 | 241 |
thread_t* thread; |
| 244 | 242 |
|
| 243 |
#if (CH_CFG_USE_REGISTRY == TRUE) || defined(__DOXYGEN__) |
|
| 244 |
|
|
| 245 |
/** |
|
| 246 |
* @brief Name of the shell and the associated thread. |
|
| 247 |
*/ |
|
| 248 |
const char* name; |
|
| 249 |
|
|
| 250 |
#endif /* (CH_CFG_USE_REGISTRY == TRUE) */ |
|
| 251 |
|
|
| 245 | 252 |
/** |
| 246 | 253 |
* @brief Event source. |
| 247 | 254 |
*/ |
| ... | ... | |
| 333 | 340 |
#if defined(__cplusplus) |
| 334 | 341 |
extern "C" {
|
| 335 | 342 |
#endif /* defined(__cplusplus) */ |
| 336 |
void aosShellInit(aos_shell_t* shell, const char* prompt, char inbuf[], size_t entries, size_t linewidth, size_t numargs); |
|
| 343 |
void aosShellInit(aos_shell_t* shell, const char* name, const char* prompt, char inbuf[], size_t entries, size_t linewidth, size_t numargs);
|
|
| 337 | 344 |
void aosShellStreamInit(AosShellStream* stream); |
| 338 | 345 |
void aosShellChannelInit(AosShellChannel* channel, BaseAsynchronousChannel* asyncchannel); |
| 339 | 346 |
aos_status_t aosShellAddCommand(aos_shell_t* shell, aos_shellcommand_t* cmd); |
| core/src/aos_main.cpp | ||
|---|---|---|
| 78 | 78 |
/* LOCAL VARIABLES */ |
| 79 | 79 |
/******************************************************************************/ |
| 80 | 80 |
|
| 81 |
#if (CH_CFG_USE_REGISTRY == TRUE) || defined(__DOXYGEN__) |
|
| 82 |
|
|
| 83 |
/** |
|
| 84 |
* @brief Name of the main thread. |
|
| 85 |
*/ |
|
| 86 |
static const char _threadName[] = "control (main)"; |
|
| 87 |
|
|
| 88 |
#endif /* (CH_CFG_USE_REGISTRY == TRUE) */ |
|
| 89 |
|
|
| 81 | 90 |
/** |
| 82 | 91 |
* @brief Listener object for GPIO events. |
| 83 | 92 |
*/ |
| ... | ... | |
| 269 | 278 |
#if defined(MODULE_INIT_KERNEL_EXTRA) |
| 270 | 279 |
MODULE_INIT_KERNEL_EXTRA(); |
| 271 | 280 |
#endif /* defined(MODULE_INIT_KERNEL_EXTRA) */ |
| 281 |
#if (CH_CFG_USE_REGISTRY == TRUE) |
|
| 282 |
currp->name = _threadName; |
|
| 283 |
#endif /* (CH_CFG_USE_REGISTRY == TRUE) */ |
|
| 272 | 284 |
|
| 273 | 285 |
// AMiRo-OS, additional interrupts and custom OS additions (if any) |
| 274 | 286 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) |
| core/src/aos_shell.c | ||
|---|---|---|
| 1838 | 1838 |
* @brief Initializes a shell object with the specified parameters. |
| 1839 | 1839 |
* |
| 1840 | 1840 |
* @param[in,out] shell Pointer to the shell object to be initialized. |
| 1841 |
* @param[in] name Name of the shell thread (may be NULL). |
|
| 1841 | 1842 |
* @param[in] prompt Prompt line to print (NULL = use default prompt). |
| 1842 | 1843 |
* @param[in] inbuf Two dimensional input buffer. |
| 1843 | 1844 |
* @param[in] entries Number of entries in the input buffer (1st dimension). |
| 1844 | 1845 |
* @param[in] linewidth Length of each entry in the input buffer (2nd dimension). |
| 1845 | 1846 |
* @param[in] numargs Maximum number of arguments (defines size of internal buffer). |
| 1846 | 1847 |
*/ |
| 1847 |
void aosShellInit(aos_shell_t* shell, const char* prompt, char inbuf[], size_t entries, size_t linewidth, size_t numargs) |
|
| 1848 |
void aosShellInit(aos_shell_t* shell, const char* name, const char* prompt, char inbuf[], size_t entries, size_t linewidth, size_t numargs)
|
|
| 1848 | 1849 |
{
|
| 1849 | 1850 |
aosDbgCheck(shell != NULL); |
| 1850 | 1851 |
aosDbgCheck(inbuf != NULL); |
| ... | ... | |
| 1854 | 1855 |
|
| 1855 | 1856 |
// set parameters |
| 1856 | 1857 |
shell->thread = NULL; |
| 1858 |
#if (CH_CFG_USE_REGISTRY == TRUE) |
|
| 1859 |
shell->name = name; |
|
| 1860 |
#else /* (CH_CFG_USE_REGISTRY == TRUE) */ |
|
| 1861 |
(void)name; |
|
| 1862 |
#endif /* (CH_CFG_USE_REGISTRY == TRUE) */ |
|
| 1857 | 1863 |
chEvtObjectInit(&shell->eventSource); |
| 1858 | 1864 |
aosShellStreamInit(&shell->stream); |
| 1859 | 1865 |
shell->prompt = prompt; |
| ... | ... | |
| 2179 | 2185 |
aos_shellcommand_t* cmd; |
| 2180 | 2186 |
|
| 2181 | 2187 |
// initialize variables and buffers |
| 2188 |
#if (CH_CFG_USE_REGISTRY == TRUE) |
|
| 2189 |
currp->name = ((aos_shell_t*)shell)->name; |
|
| 2190 |
#endif /* (CH_CFG_USE_REGISTRY == TRUE) */ |
|
| 2182 | 2191 |
rdata.input.length = 0; |
| 2183 | 2192 |
rdata.input.cursorpos = 0; |
| 2184 | 2193 |
memset(rdata.input.escseq, '\0', AOS_SHELL_ESCSEQUENCE_LENGTH * sizeof(char)); |
| core/src/aos_system.c | ||
|---|---|---|
| 88 | 88 |
static int _shellcmd_configcb(BaseSequentialStream* stream, int argc, char* argv[]); |
| 89 | 89 |
static int _shellcmd_infocb(BaseSequentialStream* stream, int argc, char* argv[]); |
| 90 | 90 |
static int _shellcmd_shutdowncb(BaseSequentialStream* stream, int argc, char* argv[]); |
| 91 |
#if ((CH_CFG_USE_REGISTRY == TRUE) && (CH_DBG_STATISTICS == TRUE)) || defined(__DOXYGEN__) |
|
| 92 |
static int _shellcmd_cpuloadcb(BaseSequentialStream* stream, int argc, char* argv[]); |
|
| 93 |
#endif /* (CH_CFG_USE_REGISTRY == TRUE) && (CH_DBG_STATISTICS == TRUE) */ |
|
| 91 | 94 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
| 92 | 95 |
static int _shellcmd_kerneltestcb(BaseSequentialStream* stream, int argc, char* argv[]); |
| 93 | 96 |
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */ |
| ... | ... | |
| 111 | 114 |
#if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__) |
| 112 | 115 |
|
| 113 | 116 |
/** |
| 117 |
* @brief System shell name. |
|
| 118 |
*/ |
|
| 119 |
static const char _shell_name[] = "system shell"; |
|
| 120 |
|
|
| 121 |
/** |
|
| 114 | 122 |
* @brief Shell thread working area. |
| 115 | 123 |
*/ |
| 116 | 124 |
static THD_WORKING_AREA(_shell_wa, AMIROOS_CFG_SHELL_STACKSIZE); |
| ... | ... | |
| 139 | 147 |
static AOS_SHELL_COMMAND(_shellcmd_shutdown, "module:shutdown", _shellcmd_shutdowncb); |
| 140 | 148 |
#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */ |
| 141 | 149 |
|
| 150 |
#if ((CH_CFG_USE_REGISTRY == TRUE) && (CH_DBG_STATISTICS == TRUE)) || defined(__DOXYGEN__) |
|
| 151 |
|
|
| 152 |
/** |
|
| 153 |
* @brief Shell command to read out CPU load. |
|
| 154 |
*/ |
|
| 155 |
static AOS_SHELL_COMMAND(_shellcmd_cpuload, "module:cpuload", _shellcmd_cpuloadcb); |
|
| 156 |
|
|
| 157 |
#endif /* (CH_CFG_USE_REGISTRY == TRUE) && (CH_DBG_STATISTICS == TRUE) */ |
|
| 158 |
|
|
| 142 | 159 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
| 143 | 160 |
|
| 144 | 161 |
/** |
| 145 |
* @brief Shell kommand to run a test of the ChibiOS/RT kernel.
|
|
| 162 |
* @brief Shell command to run a test of the ChibiOS/RT kernel.
|
|
| 146 | 163 |
*/ |
| 147 | 164 |
static AOS_SHELL_COMMAND(_shellcmd_kerneltest, "kernel:test", _shellcmd_kerneltestcb); |
| 148 | 165 |
|
| ... | ... | |
| 238 | 255 |
_printSystemInfoLine(stream, "Core Variant", SYSTEM_INFO_NAMEWIDTH, "%s", PORT_CORE_VARIANT_NAME); |
| 239 | 256 |
#endif /* defined(PORT_CORE_VARIANT_NAME) */ |
| 240 | 257 |
_printSystemInfoLine(stream, "Architecture", SYSTEM_INFO_NAMEWIDTH, "%s", PORT_ARCHITECTURE_NAME); |
| 258 |
_printSystemInfoLine(stream, "Core Frequency", SYSTEM_INFO_NAMEWIDTH, "%u MHz", SystemCoreClock / 1000000); |
|
| 241 | 259 |
_printSystemInfoSeparator(stream, '-', SYSTEM_INFO_WIDTH); |
| 242 | 260 |
#if (AMIROOS_CFG_SSSP_ENABLE == true) |
| 243 | 261 |
_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_SSSP_VERSION_MAJOR, AOS_SSSP_VERSION_MINOR); |
| ... | ... | |
| 622 | 640 |
#endif /* (AMIROOS_CFG_BOOTLOADER == X) */ |
| 623 | 641 |
} |
| 624 | 642 |
|
| 643 |
#if ((CH_CFG_USE_REGISTRY == TRUE) && (CH_DBG_STATISTICS == TRUE)) || defined(__DOXYGEN__) |
|
| 644 |
|
|
| 645 |
/** |
|
| 646 |
* @brief Callback function for the module:cpuload shell command. |
|
| 647 |
* |
|
| 648 |
* @param[in] stream The I/O stream to use. |
|
| 649 |
* @param[in] argc Number of arguments. |
|
| 650 |
* @param[in] argv List of pointers to arguments. |
|
| 651 |
* |
|
| 652 |
* @return An exit status. |
|
| 653 |
*/ |
|
| 654 |
static int _shellcmd_cpuloadcb(BaseSequentialStream* stream, int argc, char* argv[]) |
|
| 655 |
{
|
|
| 656 |
aosDbgCheck(stream != NULL); |
|
| 657 |
|
|
| 658 |
(void)argc; |
|
| 659 |
(void)argv; |
|
| 660 |
|
|
| 661 |
// local variables |
|
| 662 |
rttime_t sum = 0; |
|
| 663 |
thread_t* thd = chRegFirstThread(); |
|
| 664 |
|
|
| 665 |
// accumulate system load |
|
| 666 |
do {
|
|
| 667 |
sum += thd->stats.cumulative; |
|
| 668 |
thd = chRegNextThread(thd); |
|
| 669 |
} while (thd); |
|
| 670 |
sum += ch.kernel_stats.m_crit_thd.cumulative + ch.kernel_stats.m_crit_isr.cumulative; |
|
| 671 |
|
|
| 672 |
// calculate and retreive cpu load per thread |
|
| 673 |
chprintf(stream, "threads & critical zones:\n"); |
|
| 674 |
thd = chRegFirstThread(); |
|
| 675 |
do {
|
|
| 676 |
chprintf(stream, "\t%22s: %6.2f%%\n", |
|
| 677 |
(thd->name != NULL) ? thd->name : "<unnamed thread>", |
|
| 678 |
(float)thd->stats.cumulative / (float)sum * 100.f); |
|
| 679 |
thd = chRegNextThread(thd); |
|
| 680 |
} while (thd); |
|
| 681 |
chprintf(stream, "\t%22s: %6.2f%%\n", |
|
| 682 |
"thread critical zones", |
|
| 683 |
(float)ch.kernel_stats.m_crit_thd.cumulative / (float)sum * 100.f); |
|
| 684 |
chprintf(stream, "\t%22s: %6.2f%%\n", |
|
| 685 |
"ISR critical zones", |
|
| 686 |
(float)ch.kernel_stats.m_crit_isr.cumulative / (float)sum * 100.f); |
|
| 687 |
|
|
| 688 |
// retreive further real-time statistics |
|
| 689 |
chprintf(stream, "\nworst critical zones:\n"); |
|
| 690 |
chprintf(stream, "\tthreads: %uus (%u clocks @ %uMHz)\n", |
|
| 691 |
RTC2US(SystemCoreClock, ch.kernel_stats.m_crit_thd.worst), |
|
| 692 |
ch.kernel_stats.m_crit_thd.worst, |
|
| 693 |
SystemCoreClock / 1000000); |
|
| 694 |
chprintf(stream, "\t ISRs: %uus (%u clocks @ %uMHz)\n", |
|
| 695 |
RTC2US(SystemCoreClock, ch.kernel_stats.m_crit_isr.worst), |
|
| 696 |
ch.kernel_stats.m_crit_isr.worst, |
|
| 697 |
SystemCoreClock / 1000000); |
|
| 698 |
|
|
| 699 |
return 0; |
|
| 700 |
} |
|
| 701 |
|
|
| 702 |
#endif /* (CH_CFG_USE_REGISTRY == TRUE) && (CH_DBG_STATISTICS == TRUE) */ |
|
| 703 |
|
|
| 625 | 704 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__) |
| 626 | 705 |
|
| 627 | 706 |
/** |
| ... | ... | |
| 750 | 829 |
|
| 751 | 830 |
/* init shell */ |
| 752 | 831 |
aosShellInit(&aos.shell, |
| 832 |
_shell_name, |
|
| 753 | 833 |
shellPrompt, |
| 754 | 834 |
_shell_buffer, |
| 755 | 835 |
SYSTEM_SHELL_BUFFERENTRIES, |
| ... | ... | |
| 759 | 839 |
aosShellAddCommand(&aos.shell, &_shellcmd_config); |
| 760 | 840 |
aosShellAddCommand(&aos.shell, &_shellcmd_info); |
| 761 | 841 |
aosShellAddCommand(&aos.shell, &_shellcmd_shutdown); |
| 842 |
#if ((CH_CFG_USE_REGISTRY == TRUE) && (CH_DBG_STATISTICS == TRUE)) || defined(__DOXYGEN__) |
|
| 843 |
aosShellAddCommand(&aos.shell, &_shellcmd_cpuload); |
|
| 844 |
#endif /* (CH_CFG_USE_REGISTRY == TRUE) && (CH_DBG_STATISTICS == TRUE) */ |
|
| 762 | 845 |
#if (AMIROOS_CFG_TESTS_ENABLE == true) |
| 763 | 846 |
aosShellAddCommand(&aos.shell, &_shellcmd_kerneltest); |
| 764 | 847 |
#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */ |
| modules/aos_chconf.h | ||
|---|---|---|
| 492 | 492 |
* @note The default is @p FALSE. |
| 493 | 493 |
*/ |
| 494 | 494 |
#if !defined(CH_DBG_STATISTICS) |
| 495 |
#if ((CH_CFG_USE_TM == TRUE) && (AMIROOS_CFG_DBG == true)) || defined(__DOXYGEN__)
|
|
| 495 |
#if ((CH_CFG_USE_TM == TRUE) && ((AMIROOS_CFG_DBG == true) || AMIROOS_CFG_PROFILE == true)) || defined(__DOXYGEN__)
|
|
| 496 | 496 |
#define CH_DBG_STATISTICS TRUE |
| 497 | 497 |
#else |
| 498 | 498 |
#define CH_DBG_STATISTICS FALSE |
Also available in: Unified diff