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:
- 179:a31ea334e2b7
- Parent:
- 176:492cfa856521
- Child:
- 180:b548e289b648
--- a/src/ModbusMaster/ModbusMaster.cpp Tue Oct 04 15:05:33 2016 +0000
+++ b/src/ModbusMaster/ModbusMaster.cpp Tue Oct 04 16:07:16 2016 +0000
@@ -31,7 +31,6 @@
logInfo("%s ModbusMaster has started...", __func__);
bool status;
RegisterType_t regType;
- bool move_up = true;
modbus_init(MB_BAUD_RATE);
DigitalOut flu_power(PA_11);
@@ -116,24 +115,29 @@
std::map<std::string, ModbusRegister>::iterator iter;
for (iter = ModbusRegisterMap.begin(); iter != ModbusRegisterMap.end(); ++iter) {
if( iter->second.simulated == true ) {
-// logInfo("simulating input=%s, min=%2.2f, max=%2.2f, start_value=%2.2f, up_step=%2.2f, down_step=%2.2f",iter->first.c_str(), SimulateInputMap[iter->first].min, SimulateInputMap[iter->first].max, SimulateInputMap[iter->first].start_value, SimulateInputMap[iter->first].up_step, SimulateInputMap[iter->first].down_step);
+ printf("\r\nsimulating input=%s, min=%2.2f, max=%2.2f, start_value=%2.2f, up_step=%2.2f, down_step=%2.2f moving_up=%d\r\n",iter->first.c_str(), SimulateInputMap[iter->first].min, SimulateInputMap[iter->first].max, SimulateInputMap[iter->first].start_value, SimulateInputMap[iter->first].up_step, SimulateInputMap[iter->first].down_step, SimulateInputMap[iter->first].moving_up);
if( (SimulateInputMap[iter->first].min == 0) && (SimulateInputMap[iter->first].max == 0) ) {
ModbusRegisterMap[iter->first].float_value = SimulateInputMap[iter->first].start_value;
+ printf("simulating input=%s, value=%2.2f\r\n",iter->first.c_str(), ModbusRegisterMap[iter->first].float_value);
} else {
if( ModbusRegisterMap[iter->first].float_value >= SimulateInputMap[iter->first].max ) {
- move_up = false;
+ SimulateInputMap[iter->first].moving_up = false;
+ printf("simulating down input=%s, value=%2.2f - %2.2f\r\n",iter->first.c_str(), ModbusRegisterMap[iter->first].float_value, SimulateInputMap[iter->first].down_step);
ModbusRegisterMap[iter->first].float_value = ModbusRegisterMap[iter->first].float_value - SimulateInputMap[iter->first].down_step;
} else if( ModbusRegisterMap[iter->first].float_value <= SimulateInputMap[iter->first].min ) {
- move_up = true;
+ SimulateInputMap[iter->first].moving_up = true;
+ printf("simulating up input=%s, value=%2.2f + %2.2f\r\n",iter->first.c_str(), ModbusRegisterMap[iter->first].float_value, SimulateInputMap[iter->first].up_step);
ModbusRegisterMap[iter->first].float_value = ModbusRegisterMap[iter->first].float_value + SimulateInputMap[iter->first].up_step;
} else {
- if( move_up == true ) {
+ if( SimulateInputMap[iter->first].moving_up == true ) {
+ printf("continue simulate up input=%s, value=%2.2f + %2.2f\r\n",iter->first.c_str(), ModbusRegisterMap[iter->first].float_value, SimulateInputMap[iter->first].up_step);
ModbusRegisterMap[iter->first].float_value = ModbusRegisterMap[iter->first].float_value + SimulateInputMap[iter->first].up_step;
} else {
+ printf("continue simulate down input=%s, value=%2.2f - %2.2f\r\n",iter->first.c_str(), ModbusRegisterMap[iter->first].float_value, SimulateInputMap[iter->first].down_step);
ModbusRegisterMap[iter->first].float_value = ModbusRegisterMap[iter->first].float_value - SimulateInputMap[iter->first].down_step;
}
}
- printf("simulating input=%s, value=%2.2f\r\n",iter->first.c_str(), ModbusRegisterMap[iter->first].float_value);
+ printf("simulating input=%s, value=%2.2f\r\n\r\n",iter->first.c_str(), ModbusRegisterMap[iter->first].float_value);
}
continue;
}
