2018 revision to classic DataBus AVC code.
Dependencies: LSM303DLM Servo SerialGraphicLCD L3G4200D IncrementalEncoder SimpleShell
Diff: stats_report.h
- Revision:
- 24:a7f92dfc5310
- Parent:
- 0:7e98bbfd102a
- Child:
- 28:eab1b0680bb2
diff -r 5e61cf4a8c34 -r a7f92dfc5310 stats_report.h --- a/stats_report.h Tue Dec 18 17:09:38 2018 +0000 +++ b/stats_report.h Fri Dec 21 20:04:09 2018 +0000 @@ -36,11 +36,13 @@ // Collect the static system information mbed_stats_sys_get(&sys_stats); + /* printf("=============================== SYSTEM INFO ================================\r\n"); printf("Mbed OS Version: %ld \r\n", sys_stats.os_version); printf("CPU ID: 0x%lx \r\n", sys_stats.cpu_id); printf("Compiler ID: %d \r\n", sys_stats.compiler_id); printf("Compiler Version: %ld \r\n", sys_stats.compiler_version); + */ } ~SystemReport(void) @@ -53,7 +55,7 @@ */ void report_state(void) { - report_cpu_stats(); + //report_cpu_stats(); report_heap_stats(); report_thread_stats(); @@ -68,8 +70,6 @@ { static uint64_t prev_idle_time = 0; - printf("================= CPU STATS =================\r\n"); - // Collect and print cpu stats mbed_stats_cpu_get(&cpu_stats); @@ -78,6 +78,7 @@ uint8_t usage = 100 - ((diff * 100) / (sample_time_ms * 1000)); // usec;; prev_idle_time = cpu_stats.idle_time; + puts(""); printf("Idle: %d%% Usage: %d%% \r\n", idle, usage); } @@ -88,11 +89,9 @@ */ void report_heap_stats(void) { - printf("================ HEAP STATS =================\r\n"); - // Collect and print heap stats mbed_stats_heap_get(&heap_stats); - + puts(""); printf("Current heap: %lu\r\n", heap_stats.current_size); printf("Max heap size: %lu\r\n", heap_stats.max_size); } @@ -102,18 +101,20 @@ */ void report_thread_stats(void) { - printf("================ THREAD STATS ===============\r\n"); - // Collect and print running thread stats int count = mbed_stats_thread_get_each(thread_stats, max_thread_count); + puts(""); + puts("ID state prio stack free name"); + puts("======== ===== ==== ====== ====== =============="); for (int i = 0; i < count; i++) { - printf("ID: 0x%lx \r\n", thread_stats[i].id); - printf("Name: %s \r\n", thread_stats[i].name); - printf("State: %ld \r\n", thread_stats[i].state); - printf("Priority: %ld \r\n", thread_stats[i].priority); - printf("Stack Size: %ld \r\n", thread_stats[i].stack_size); - printf("Stack Space: %ld \r\n", thread_stats[i].stack_space); + printf(" 0x%04x ", thread_stats[i].id & 0xFFFF); + printf(" %4d ", thread_stats[i].state); + printf(" %4d ", thread_stats[i].priority); + printf(" %5d ", thread_stats[i].stack_size); + printf(" %5d ", thread_stats[i].stack_space); + printf(" %s ", thread_stats[i].name); + puts(""); } } };