summaryrefslogtreecommitdiff
path: root/src/tangara
diff options
context:
space:
mode:
authorailurux <ailurux@noreply.codeberg.org>2025-02-10 22:24:45 +0000
committerailurux <ailurux@noreply.codeberg.org>2025-02-10 22:24:45 +0000
commit3ead3465c3b9accf567c35c69ddffc43320161e9 (patch)
tree8c613cd802ba554c8a02aea53a2875ece62f5feb /src/tangara
parent90b302a9f4677502935564be51c060fb98cc765b (diff)
parent187cd772ee4027f252b03788cb1c0774d62ef207 (diff)
downloadtangara-fw-3ead3465c3b9accf567c35c69ddffc43320161e9.tar.gz
Merge pull request 'Console: Update doco to point to `sdkconfig`, and handle no-stats cases.' (#257) from tursiae/tangara-fw:tasksconfig into main
Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/257
Diffstat (limited to 'src/tangara')
-rw-r--r--src/tangara/app_console/app_console.cpp36
1 files changed, 33 insertions, 3 deletions
diff --git a/src/tangara/app_console/app_console.cpp b/src/tangara/app_console/app_console.cpp
index 394a47f2..2a8f290b 100644
--- a/src/tangara/app_console/app_console.cpp
+++ b/src/tangara/app_console/app_console.cpp
@@ -207,8 +207,14 @@ void RegisterDbInit() {
int CmdTasks(int argc, char** argv) {
#if (configUSE_TRACE_FACILITY == 0)
- std::cout << "configUSE_TRACE_FACILITY must be enabled" << std::endl;
- std::cout << "also consider configTASKLIST_USE_COREID" << std::endl;
+ std::cout
+ << "FreeRTOS is not configured to track task info." << std::endl
+ << "You can enable task tracing via sdkconfig, by setting" << std::endl
+ << "CONFIG_FREERTOS_USE_TRACE_FACILITY=y. Alternately, use" << std::endl
+ << "idf.py menuconfig to enable Components/FreeRTOS/Kernel" << std::endl
+ << "configUSE_TRACE_FACILITY to do the same." << std::endl << std::endl
+ << "Also consider 'Enable display of xCoreID in vTaskList'," << std::endl
+ << "or CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID=y" << std::endl;
return 1;
#endif
@@ -218,6 +224,14 @@ int CmdTasks(int argc, char** argv) {
return 1;
}
+ // Sample the task runtime percentage over 2.5 seconds if collecting
+ // task statistics. Else, we don't need to sample for as long.
+#ifdef CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS
+ const int kSamplePeriodMs = 2500;
+#else
+ const int kSamplePeriodMs = 10;
+#endif
+
// Pad the number of tasks so that uxTaskGetSystemState still returns info
// if new tasks are started during measurement.
size_t num_tasks = uxTaskGetNumberOfTasks() + 4;
@@ -229,11 +243,23 @@ int CmdTasks(int argc, char** argv) {
size_t start_num_tasks =
uxTaskGetSystemState(start_status, num_tasks, &start_elapsed_ticks);
- vTaskDelay(pdMS_TO_TICKS(2500));
+ vTaskDelay(pdMS_TO_TICKS(kSamplePeriodMs));
size_t end_num_tasks =
uxTaskGetSystemState(end_status, num_tasks, &end_elapsed_ticks);
+ uint32_t elapsed_ticks = end_elapsed_ticks - start_elapsed_ticks;
+
+ if (0 == elapsed_ticks) {
+ std::cout << "Warning: the scheduler is not recording run-time" << std::endl
+ << "statistics, and this means that detailed task" << std::endl
+ << "information is not available." << std::endl
+ << "Enable CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS" << std::endl
+ << "in sdkconfig to capture these stats, or via" << std::endl
+ << "idf.py menuconfig, in Components/FreeRTOS/Kernel" << std::endl
+ << "configGENERATE_RUN_TIME_STATS." << std::endl;
+ }
+
std::vector<std::pair<uint32_t, std::pmr::string>> info_strings;
for (int i = 0; i < start_num_tasks; i++) {
int k = -1;
@@ -279,8 +305,12 @@ int CmdTasks(int argc, char** argv) {
str << "\t\t";
}
+#ifdef CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS
str << std::fixed << std::setprecision(1) << (time_percent * 100);
str << "%";
+#else
+ str << "(unavailable)";
+#endif
info_strings.push_back({run_time, std::pmr::string{str.str()}});
}