Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed
Fork of ICE by
Diff: src/CommandParser/cmd.cpp
- Revision:
- 186:16912aa18c2a
- Parent:
- 180:b548e289b648
- Child:
- 188:d35a74bf4e92
--- a/src/CommandParser/cmd.cpp Tue Oct 04 20:51:39 2016 +0000
+++ b/src/CommandParser/cmd.cpp Wed Oct 05 20:47:21 2016 +0000
@@ -66,6 +66,7 @@
{"create-mn", "create a manual control", cmd_createManual },
{"create-sp", "create a setpoint control", cmd_createSetpoint },
{"create-tm", "create a timer control", cmd_createTimer },
+ {"create-temp", "create temperature input", cmd_createTemp },
{"deep", "dump EEP", cmd_deep },
{"demo", "create phase-1 demo files", cmd_demo },
{"destroy-control", "destroy a control", cmd_destroy },
@@ -1238,17 +1239,17 @@
"{ "
"\"id\": \"i_bdcond01\","
"\"name\": \"Tower Conductivity\", "
- "\"units\": \"uS\", "
- "\"min\": \"0\", "
- "\"max\": \"6000\", "
- "\"node\": \"5\", "
- "\"reg\": \"9\", "
- "\"rtype\": \"1\", "
- "\"type\": \"0\", "
- "\"size\": \"2\", "
- "\"order\": \"2\", "
- "\"fmt\": \"%%.2f\", "
- "\"vcmd\": \"\", "
+ "\"units\": \"uS\","
+ "\"min\": \"0\","
+ "\"max\": \"6000\","
+ "\"node\": \"21\","
+ "\"reg\": \"18\","
+ "\"rtype\": \"1\","
+ "\"type\": \"1\","
+ "\"size\": \"2\","
+ "\"order\": \"2\","
+ "\"fmt\": \"%%.2f\","
+ "\"vcmd\": \"\","
"\"rfreq\": \"5\" }");
rc = GLOBAL_mdot->saveUserFile("input_i_bdcond01.json", (void *)buf, MAX_FILE_SIZE);
if ( rc != true ) {
@@ -1260,7 +1261,39 @@
mail = ModbusMasterMailBox.alloc();
mail->action = ACTION_READ_FILE;
- strncpy( mail->controlFile, "input_i_tra02.json", (sizeof(mail->controlFile)-1));
+ strncpy( mail->controlFile, "input_i_bdcond01.json", (sizeof(mail->controlFile)-1));
+ ModbusMasterMailBox.put(mail);
+
+ Thread::wait(1000);
+
+ // INPUT: Conductivity Temperature
+ snprintf(buf, sizeof(buf),
+ "{ "
+ "\"id\": \"i_temp01\","
+ "\"name\": \"Temp Conductivity\","
+ "\"units\": \"C\","
+ "\"min\": \"0\","
+ "\"max\": \"80\","
+ "\"node\": \"21\","
+ "\"reg\": \"10\","
+ "\"rtype\": \"1\","
+ "\"type\": \"1\","
+ "\"size\": \"2\","
+ "\"order\": \"2\","
+ "\"fmt\": \"%%.2f\","
+ "\"vcmd\": \"\","
+ "\"rfreq\": \"5\" }");
+ rc = GLOBAL_mdot->saveUserFile("input_i_temp01.json", (void *)buf, MAX_FILE_SIZE);
+ if ( rc != true ) {
+ printf("\rFailed to save input_i_temp01.json\n");
+ return;
+ } else {
+ printf("\r...generated input_i_temp01.json\n");
+ }
+
+ mail = ModbusMasterMailBox.alloc();
+ mail->action = ACTION_READ_FILE;
+ strncpy( mail->controlFile, "input_i_temp01.json", (sizeof(mail->controlFile)-1));
ModbusMasterMailBox.put(mail);
Thread::wait(1000);
@@ -1418,4 +1451,90 @@
MailBox.put(sp_msg);
Thread::wait(1000);
+}
+
+/*****************************************************************************
+ * Function: cmd_createTemp
+ * Description: create input file
+ *
+ * @param argc-> number of args
+ * @param argv-> filename
+ * @return none
+ *****************************************************************************/
+void cmd_createTemp(int argc, char **argv)
+{
+ char data_buf[MAX_FILE_SIZE];
+ snprintf(data_buf, sizeof(data_buf),
+ "{ "
+ "\"id\": \"i_temp01\", "
+ "\"name\": \"Temp Conductivity\", "
+ "\"units\": \"C\", "
+ "\"min\": \"0\", "
+ "\"max\": \"300\", "
+ "\"node\": \"21\", "
+ "\"reg\": \"10\", "
+ "\"rtype\": \"1\", "
+ "\"type\": \"1\", "
+ "\"size\": \"2\", "
+ "\"order\": \"2\", "
+ "\"rfreq\": \"5\", "
+ "\"vcmd\": \"\","
+ "\"fmt\": \"%%.2f\" } ");
+
+ bool status = GLOBAL_mdot->saveUserFile("input_i_temp01.json", (void *)data_buf, MAX_FILE_SIZE);
+ if( status != true ) {
+ logInfo("(%d)save file failed, status=%d", __LINE__, status);
+ }
+
+ logInfo("Sending Mail To ModbusMasterMailBox, filename=%s", "input_i_temp01.json");
+ Message_t *mail = ModbusMasterMailBox.alloc();
+ mail->action = ACTION_READ_FILE;
+ strncpy( mail->controlFile, "input_i_temp01.json", (sizeof(mail->controlFile)-1));
+ ModbusMasterMailBox.put(mail);
+}
+
+/*****************************************************************************
+ * Function: cmd_createBDCond
+ * Description: create input file
+ *
+ * @param argc-> number of args
+ * @param argv-> filename
+ * @return none
+ *****************************************************************************/
+void cmd_createBDCond(int argc, char **argv)
+{
+ if ( argc != 6 ) {
+ printf("\rusage: createBDCond <fname> <input> <name> <node> <reg>\n");
+ printf("\rexample: createBDCond input_i_bdcond.json i_bdcond01 TowerConductivity 21 18\n");
+ return;
+ }
+
+ char data_buf[MAX_FILE_SIZE];
+ snprintf(data_buf, sizeof(data_buf),
+ "{ "
+ "\"id\": \"%s\", "
+ "\"name\": \"%s\", "
+ "\"units\": \"uS\", "
+ "\"min\": \"0\", "
+ "\"max\": \"300\", "
+ "\"node\": \"%s\", "
+ "\"reg\": \"%s\", "
+ "\"rtype\": \"1\", "
+ "\"type\": \"0\", "
+ "\"size\": \"2\", "
+ "\"order\": \"2\", "
+ "\"rfreq\": \"5\", "
+ "\"vcmd\": \"\","
+ "\"fmt\": \"%%.2f\" } ", argv[2], argv[3], argv[4], argv[5]);
+
+ bool status = GLOBAL_mdot->saveUserFile(argv[1], (void *)data_buf, MAX_FILE_SIZE);
+ if( status != true ) {
+ logInfo("(%d)save file failed, status=%d", __LINE__, status);
+ }
+
+ logInfo("Sending Mail To ModbusMasterMailBox, filename=%s", argv[1]);
+ Message_t *mail = ModbusMasterMailBox.alloc();
+ mail->action = ACTION_READ_FILE;
+ strncpy( mail->controlFile, argv[1], (sizeof(mail->controlFile)-1));
+ ModbusMasterMailBox.put(mail);
}
\ No newline at end of file
