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: mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP
Fork of SystemManagement by
Diff: SysMngmt.cpp
- Revision:
- 12:e0adb697fcdb
- Parent:
- 11:1d086618dd18
- Child:
- 13:fbd9b3f5a07c
--- a/SysMngmt.cpp Sun Oct 19 22:50:30 2014 +0000
+++ b/SysMngmt.cpp Tue Oct 21 23:44:15 2014 +0000
@@ -19,12 +19,15 @@
#include "CurrentMonitor.h"
CANBuffer rxBuffer(CAN1, MEDIUM);
+Watchdog wdt;
XBee250x XbeeTx;
Serial pc1(USBTX,USBRX);
-char sys_src_id = 4; // source address of system management
+char sys_src_id = 0x4; // source address of system management
char reset_id = 0x010;
+int SYSMGMT_ERROR_ID = 0x400;
+
extern "C" void mbed_reset();
void soft_reset(){
@@ -32,9 +35,22 @@
mbed_reset();
}
+void error_update(void const *arg){
+ char data[1] = {0};
+ while(1){
+ data[0] = 0;
+ if(wdt.checkFlag())
+ {
+ data[0] |= 0x2;
+ }
+ CANMessage txErrorMessage(SYSMGMT_ERROR_ID, data, 1);
+ rxBuffer.txWrite(txErrorMessage);
+ Thread::wait(10);
+ }
+}
+
int main() {
CANMessage rx_msg;
- Watchdog wdt;
wdt.kick(10.0);
pc1.baud(115200);
@@ -51,6 +67,8 @@
imdMonitor.start_update();
curMonitor.start_update();
+ Thread error_thread(error_update);
+
while(1)
{
if(rxBuffer.rxRead(rx_msg)){
@@ -63,9 +81,26 @@
char cont_id = (rx_msg.id & 0x00FF); // get bits 7:0
// only control fans of dc_dc converter is on
+ if(cont_id == RX_PUMP_ID && dc_dc.is_on())
+ {
+ float temp_float;
+
+ memcpy(&rx_msg.data[0], &temp_float, sizeof(float));
+ fanPump.set_fan_pump(Pump1, temp_float);
+
+ memcpy(&rx_msg.data[4], &temp_float, sizeof(float));
+ fanPump.set_fan_pump(Pump2, temp_float);
+ }
+
if(cont_id == RX_FAN_ID && dc_dc.is_on())
{
- fanPump.set_fan((FanSelect)rx_msg.data[0], rx_msg.data[1]);
+ float temp_float;
+
+ memcpy(&rx_msg.data[0], &temp_float, sizeof(float));
+ fanPump.set_fan_pump(Fan1, temp_float);
+
+ memcpy(&rx_msg.data[4], &temp_float, sizeof(float));
+ fanPump.set_fan_pump(Fan2, temp_float);
}
if(cont_id == RX_DC_DC_ID){
