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/ModbusMaster/ModbusMaster.cpp
- Revision:
- 31:4b1587034318
- Parent:
- 23:03bf3d549002
- Child:
- 39:9287c7d59016
--- a/src/ModbusMaster/ModbusMaster.cpp Thu Sep 08 18:39:29 2016 +0000
+++ b/src/ModbusMaster/ModbusMaster.cpp Thu Sep 08 21:15:11 2016 +0000
@@ -6,6 +6,7 @@
*****************************************************************************/
#include "global.h"
#include <stdio.h>
+#include "MTSLog.h"
#include "BLEDataHandler.h"
#include "ModbusMaster.h"
#include "MbedJSONValue.h"
@@ -20,7 +21,7 @@
void ModbusMaster(void const *args)
{
- printf("\r%s ModbusMaster has started...\n", __func__);
+ logInfo("%s ModbusMaster has started...", __func__);
char scratch_buf[1024];
bool status;
MbedJSONValue json_value;
@@ -69,8 +70,7 @@
case TYPE_32BIT_FLOAT:
float float_value;
status = ReadModbus_32bit_float( &float_value, iter->second.order );
- if( status == true )
- {
+ if( status == true ) {
ModbusRegisterMap[iter->first].float_value = float_value;
}
break;
@@ -86,6 +86,17 @@
break;
}
}
+
+ logInfo("Checking for MAIL");
+ osEvent evt = ModbusMasterMailBox.get(50);
+ if (evt.status == osEventMail) {
+ Message_t *mail = (Message_t*)evt.value.p;
+ logInfo("Mail Received: Action: %d, New Input File: %s", mail->action, mail->controlFile);
+ ModbusMasterMailBox.free(mail);
+ } else {
+ logInfo("No Mail");
+ }
+ osDelay(1000);
}
}
@@ -185,13 +196,13 @@
bool ReadModbus_32bit_float( float *float_value, int order )
{
MR_REGISTER_32_BIT_FLOAT value;
-
+
if (mbInterruptComplete() != true ) {
return false;
}
switch( order ) {
- case BigEndian:
+ case BigEndian:
value.b.lo_lo = modbus_input_buffer[6];
value.b.lo_hi = modbus_input_buffer[5];
value.b.hi_lo = modbus_input_buffer[4];
