Erick / Mbed 2 deprecated ICE_BLE_TEST

Dependencies:   NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed

Fork of ICE by Erick

Revision:
42:c703a60993b1
Parent:
39:9287c7d59016
Child:
45:3b9e1923cb15
--- a/src/ModbusMaster/ModbusMaster.cpp	Fri Sep 09 19:39:03 2016 +0000
+++ b/src/ModbusMaster/ModbusMaster.cpp	Fri Sep 09 20:44:19 2016 +0000
@@ -18,31 +18,35 @@
  * @param                (IN) args (user-defined arguments)
  * @return               none
  *****************************************************************************/
-
+char ModbusMasterScratchBuf[1024];
 void ModbusMaster(void const *args)
 {
     logInfo("%s ModbusMaster has started...", __func__);
-    char scratch_buf[1024];
     bool status;
     MbedJSONValue json_value;
 
     while( true ) {
 
+        logInfo("Top Of Modbus Master Loop");
+
         // configure modbus registers based in all files that start with "input"
         std::vector<mDot::mdot_file> file_list = GLOBAL_mdot->listUserFiles();
         for (std::vector<mDot::mdot_file>::iterator i = file_list.begin(); i != file_list.end(); ++i) {
-            if( strncmp( i->name, "input", strlen("input")) == 0 ) {
 
-                printf("\r(%d)FOUND INPUT FILE: %s\n", __LINE__, i->name);
+            logInfo("\r(%d)FOUND INPUT FILE: %s\n", __LINE__, i->name);
+
+            if( strncmp( i->name, "input", (strlen("input")-1)) == 0 ) {
 
-                bool status = GLOBAL_mdot->readUserFile(i->name, (void *)scratch_buf, 1024);
+                logInfo("\r(%d)FOUND INPUT FILE: %s\n", __LINE__, i->name);
+
+                status = GLOBAL_mdot->readUserFile(i->name, (void *)ModbusMasterScratchBuf, 1024);
                 if( status != true ) {
-                    printf("\r(%d)read file failed, status=%d\n", __LINE__, status);
+                    logInfo("\r(%d)read file failed, status=%d\n", __LINE__, status);
                 } else {
-                    printf("\r(%d)Read File SUCCESS: %s\n", __LINE__, scratch_buf );
+                    logInfo("\r(%d)Read File SUCCESS: %s\n", __LINE__, ModbusMasterScratchBuf );
                 }
 
-                parse( json_value, scratch_buf );
+                parse( json_value, ModbusMasterScratchBuf );
 
                 std::string id = json_value["id"].get<std::string>().c_str();
                 ModbusRegisterMap[id].name = json_value["name"].get<std::string>().c_str();
@@ -64,7 +68,7 @@
 
             std::map<std::string, ModbusRegister>::iterator iter;
             for (iter = ModbusRegisterMap.begin(); iter != ModbusRegisterMap.end(); ++iter) {
-                printf("\rReading node=%d, reg=%d, size=%d, order=%d\n", iter->second.node, iter->second.reg, iter->second.size, iter->second.order );
+                logInfo("Reading node=%d, reg=%d, size=%d, order=%d", iter->second.node, iter->second.reg, iter->second.size, iter->second.order );
                 SendModbusCommand(iter->second.node, iter->second.reg, iter->second.size);
                 osDelay(30);
 
@@ -100,7 +104,7 @@
             } else {
                 logInfo("No Mail");
             }
-            osDelay(1000);
+            osDelay(5000);
         }
     }
 }