Erick / Mbed 2 deprecated ICE_BLE_TEST

Dependencies:   NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed

Fork of ICE by Erick

Revision:
81:d45bfa16953a
Parent:
77:43e0a3d9e536
Child:
82:f3e495a98877
Child:
86:189c125d8878
--- a/src/CommandParser/cmd.cpp	Tue Sep 20 12:49:58 2016 +0000
+++ b/src/CommandParser/cmd.cpp	Tue Sep 20 13:41:31 2016 +0000
@@ -75,6 +75,8 @@
     {"stack",               "get thread stack usage stats",                     cmd_stack           },
     {"stats",               "get current mDot statistics",                      cmd_stats           },
     {"time",                "get current time",                                 cmd_time            },
+    {"sout",                "set output",                                       cmd_sout            },
+
     {NULL, NULL, NULL}
 };
 
@@ -448,9 +450,9 @@
  *****************************************************************************/
 void cmd_cof(int argc, char **argv)
 {
-    if ( argc != 3 ) {
-        printf("\rusage: cof <filename> <output>\r\n");
-        printf("\rexample: cof output_rly1.json o_rly1\n");
+    if ( argc != 5 ) {
+        printf("\rusage: cof <filename> <output> <name> <reg>\r\n");
+        printf("\rexample: cof output_rly1.json o_rly1 Relay1 1\r\n");
         return;
     }
 
@@ -476,18 +478,22 @@
     snprintf(data_buf, sizeof(data_buf),
              "{ "
              "\"id\":       \"%s\", "
-             "\"name\":     \"Relay 5\", "
+             "\"name\":     \"%s\", "
+             "\"units\":    \"\", "
              "\"min\":      \"0\", "
              "\"max\":      \"300\", "
-             "\"node\":     \"20\", "
-             "\"reg\":      \"21\", "
+             "\"node\":     \"0\", "
+             "\"reg\":      \"%s\", "
              "\"rtype\":    \"1\", "
              "\"type\":     \"16\", "
+             "\"size\":     \"2\", "
+             "\"order\":    \"2\", "
              "\"fmt\":      \"%%.2f\", "
+             "\"rfreq\":    \"5\", "
              "\"toperiod\": \"0\", "
              "\"scalelo\":  \"0\", "
-             "\"scalehi\":  \"100\" }", argv[2]);
-        
+             "\"scalehi\":  \"100\" }", argv[2], argv[3], argv[4]);
+
     bool status = GLOBAL_mdot->saveUserFile(argv[1], (void *)data_buf, 1024);
     if( status != true ) {
         logInfo("(%d)save file failed, status=%d", __LINE__, status);
@@ -549,7 +555,7 @@
 {
     UNUSED(argc);
     UNUSED(argv);
-    
+
     mDot::mdot_stats stats = GLOBAL_mdot->getStats();
 
     printf("\r                        Up: %u\n", stats.Up);
@@ -663,7 +669,7 @@
 void cmd_stack(int argc, char **argv)
 {
     vector<pair<string, Thread*> > taskList;
-    
+
     const char *mapper[] = { "Inactive",
                              "Ready",
                              "Running",
@@ -673,7 +679,8 @@
                              "WaitingAnd",
                              "WaitingSempahore",
                              "WaitingMailbox",
-                             "WaitingMutex" }; 
+                             "WaitingMutex"
+                           };
 
     //simply add your task to the list...
     taskList.push_back(make_pair((string)"AnalyticsLogger",  GLOBAL_analyticsLogger_thread));
@@ -738,4 +745,24 @@
     UNUSED(argv);
 
     DisplayOutputs();
+}
+
+/*****************************************************************************
+ * Function:        cmd_sout
+ * Description:     set output
+ *
+ * @param           argc-> number of args
+ * @param           argv-> output
+ * @return          none
+ *****************************************************************************/
+void cmd_sout(int argc, char **argv)
+{
+    float value = atof( argv[2] );
+    
+    if ( argc != 3 ) {
+        printf("\rusage: sout <output> <value>\r\n");
+        printf("\rexample: sout o_rly1 1\r\n");
+        return;
+    }
+    ModbusRegisterMap[argv[1]].float_value = value;
 }
\ No newline at end of file