Erick / Mbed 2 deprecated ICE_BLE_TEST

Dependencies:   NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed

Fork of ICE by Erick

Revision:
37:7e6986b77f01
Parent:
36:f240f5a6d0ed
Child:
41:e8946fc01ea4
--- a/src/CommandParser/cmd.cpp	Fri Sep 09 15:24:18 2016 +0000
+++ b/src/CommandParser/cmd.cpp	Fri Sep 09 18:59:39 2016 +0000
@@ -55,6 +55,8 @@
     {"create",              "create a control",                                 cmd_create          },
     {"destroy",             "destroy a control",                                cmd_destroy         },
     {"ccf",                 "create a test control file",                       cmd_ccf             },
+    {"cif",                 "create a test input file",                         cmd_cif             },
+    {"cof",                 "create a test output file",                        cmd_cof             },
     {"heap",                "show heap statistics",                             cmd_heap            },
     {"help",                "help command",                                     cmd_help            },
     {"log-level",           "get/set mDot log level",                           cmd_logLevel        },
@@ -342,7 +344,7 @@
 
 /*****************************************************************************
  * Function:        cmd_ccf
- * Description:     create a control file
+ * Description:     create control file
  *
  * @param           argc-> number of args
  * @param           argv-> filename
@@ -358,17 +360,17 @@
     char data_buf[1024];
     snprintf(data_buf, sizeof(data_buf),
              "{ "
-             "\"id\":\"SP\", "
-             "\"name\":\"TRASAR\", "
-             "\"priority\":\"800\", "
-             "\"input\":\"i_tra01\", "
-             "\"output\":\"o_r05\", "
-             "\"prodfact\":\"100\", "
-             "\"halert\":\"115\", "
-             "\"lalert\":\"85\", "
-             "\"hfs\":\"130\", "
-             "\"lfs\":\"70\", "
-             "\"tol\":\"5\" } "
+             "\"id\":       \"SP\", "
+             "\"name\":     \"TRASAR\", "
+             "\"priority\": \"800\", "
+             "\"input\":    \"i_tra01\", "
+             "\"output\":   \"o_r05\", "
+             "\"prodfact\": \"100\", "
+             "\"halert\":   \"115\", "
+             "\"lalert\":   \"85\", "
+             "\"hfs\":      \"130\", "
+             "\"lfs\":      \"70\", "
+             "\"tol\":      \"5\" } "
             );
 
     bool status = GLOBAL_mdot->saveUserFile(argv[1], (void *)data_buf, 1024);
@@ -378,6 +380,81 @@
 }
 
 /*****************************************************************************
+ * Function:        cmd_cif
+ * Description:     create input file
+ *
+ * @param           argc-> number of args
+ * @param           argv-> filename
+ * @return          none
+ *****************************************************************************/
+void cmd_cif(int argc, char **argv)
+{
+    if ( argc != 2 ) {
+        printf("\rusage: cif <filename>\r\n");
+        return;
+    }
+
+    char data_buf[1024];
+    snprintf(data_buf, sizeof(data_buf),
+             "{ "
+             "\"id\":       \"i_tra1\", "
+             "\"name\":     \"TRASAR\", "
+             "\"units\":    \"PPM\", "
+             "\"min\":      \"0\", "
+             "\"max\":      \"300\", "
+             "\"node\":     \"20\", "
+             "\"reg\":      \"21\", "
+             "\"rtype\":    \"1\", "
+             "\"type\":     \"16\", "
+             "\"fmt\":      \"%%.2f\" } "
+            );
+
+    bool status = GLOBAL_mdot->saveUserFile(argv[1], (void *)data_buf, 1024);
+    if( status != true ) {
+        logInfo("(%d)save file failed, status=%d", __LINE__, status);
+    }
+}
+
+/*****************************************************************************
+ * Function:        cmd_cof
+ * Description:     create output file
+ *
+ * @param           argc-> number of args
+ * @param           argv-> filename
+ * @return          none
+ *****************************************************************************/
+void cmd_cof(int argc, char **argv)
+{
+    if ( argc != 2 ) {
+        printf("\rusage: cof <filename>\r\n");
+        return;
+    }
+
+    char data_buf[1024];
+    snprintf(data_buf, sizeof(data_buf),
+             "{ "
+             "\"id\":       \"i_tra1\", "
+             "\"name\":     \"TRASAR\", "
+             "\"units\":    \"PPM\", "
+             "\"min\":      \"0\", "
+             "\"max\":      \"300\", "
+             "\"node\":     \"20\", "
+             "\"reg\":      \"21\", "
+             "\"rtype\":    \"1\", "
+             "\"type\":     \"16\", "
+             "\"fmt\":      \"%%.2f\", "
+             "\"toperiod\": \"0\", "
+             "\"scalelo\":  \"0\", "
+             "\"scalehi\":  \"100\" }"
+             );
+
+    bool status = GLOBAL_mdot->saveUserFile(argv[1], (void *)data_buf, 1024);
+    if( status != true ) {
+        logInfo("(%d)save file failed, status=%d", __LINE__, status);
+    }
+}
+
+/*****************************************************************************
  * Function:        cmd_heap
  * Description:     display heap statistics
  *