Erick / Mbed 2 deprecated ICE_BLE_TEST

Dependencies:   NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed

Fork of ICE by Erick

Revision:
34:f345fdec711d
Parent:
28:c410a61238bb
Child:
35:6235ef67faa1
--- a/src/CommandParser/cmd.cpp	Thu Sep 08 21:17:21 2016 +0000
+++ b/src/CommandParser/cmd.cpp	Thu Sep 08 22:01:00 2016 +0000
@@ -35,6 +35,7 @@
 #include "global.h"
 #include "ConfigurationHandler.h"
 #include "mDot.h"
+#include "rtos.h"
 
 Serial serial(USBTX, USBRX);
 ntshell_t ntshell;
@@ -62,7 +63,8 @@
     {"rm",                  "remove a user file",                               cmd_rm              },
     {"rssiStats",           "get current rssi stats",                           cmd_rssiStats       },
     {"showControls",        "display active controls",                          cmd_ShowControls    },
-    {"snrStats",            "get current SNR stats",                            cmd_snrStats        }, 
+    {"snrStats",            "get current SNR stats",                            cmd_snrStats        },
+    {"stack",               "get thread stack usage stats",                     cmd_stack           }, 
     {"stats",               "get current mDot statistics",                      cmd_stats           },
     {NULL, NULL, NULL}
 };
@@ -311,3 +313,51 @@
 
     printf("\r\n");
 }
+
+void cmd_stack(int argc, char **argv)
+{
+    if ( GLOBAL_analyticsLogger_thread ) {
+        printf("\r AnalyticsLogger        size/free/used/max = %u/%u/%u/%u\n", 
+            GLOBAL_analyticsLogger_thread->stack_size(),
+            GLOBAL_analyticsLogger_thread->free_stack(),
+            GLOBAL_analyticsLogger_thread->used_stack(),
+            GLOBAL_analyticsLogger_thread->max_stack());
+    }
+    if ( GLOBAL_BLE_thread ) {
+        printf("\r BLEHandler             size/free/used/max = %u/%u/%u/%u\n", 
+            GLOBAL_BLE_thread->stack_size(),
+            GLOBAL_BLE_thread->free_stack(),
+            GLOBAL_BLE_thread->used_stack(),
+            GLOBAL_BLE_thread->max_stack());
+    }
+    if ( GLOBAL_CDH_thread ) {
+        printf("\r CloudDataHandler       size/free/used/max = %u/%u/%u/%u\n", 
+            GLOBAL_CDH_thread->stack_size(),
+            GLOBAL_CDH_thread->free_stack(),
+            GLOBAL_CDH_thread->used_stack(),
+            GLOBAL_CDH_thread->max_stack());
+    }
+    if ( GLOBAL_configHandler_thread ) {
+        printf("\r ConfigHandler          size/free/used/max = %u/%u/%u/%u\n", 
+            GLOBAL_configHandler_thread->stack_size(),
+            GLOBAL_configHandler_thread->free_stack(),
+            GLOBAL_configHandler_thread->used_stack(),
+            GLOBAL_configHandler_thread->max_stack());
+    }
+    if ( GLOBAL_controlTask_thread ) {
+        printf("\r ControlTask            size/free/used/max = %u/%u/%u/%u\n", 
+            GLOBAL_controlTask_thread->stack_size(),
+            GLOBAL_controlTask_thread->free_stack(),
+            GLOBAL_controlTask_thread->used_stack(),
+            GLOBAL_controlTask_thread->max_stack());
+    }
+    if ( GLOBAL_modbusMaster_thread ) {
+        printf("\r ModbusMaster           size/free/used/max = %u/%u/%u/%u\n", 
+            GLOBAL_modbusMaster_thread->stack_size(),
+            GLOBAL_modbusMaster_thread->free_stack(),
+            GLOBAL_modbusMaster_thread->used_stack(),
+            GLOBAL_modbusMaster_thread->max_stack());
+    }
+    
+    printf("\r\n");
+}