Nathaniel Honka / Mbed 2 deprecated Data-Management-Honka

Dependencies:   ExoController MODSERIAL SDFileSystem_HelloWorld UI-Honka mbed

Fork of Data Management by HEL's Angels

Files at this revision

API Documentation at this revision

Comitter:
perr1940
Date:
Mon Nov 24 03:28:44 2014 +0000
Parent:
2:b87aaf1bc803
Child:
4:46d4917f2464
Commit message:
Sharing for Michael... going to Italy!!!

Changed in this revision

BluetoothComm.lib Show annotated file Show diff for this revision Revisions of this file
UI/UI.cpp Show annotated file Show diff for this revision Revisions of this file
initDatabed/initDatabed.cpp Show annotated file Show diff for this revision Revisions of this file
initDatabed/initDatabed.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BluetoothComm.lib	Mon Nov 24 03:28:44 2014 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/perr1940/code/BluetoothComm/#5395aee79fee
--- a/UI/UI.cpp	Sat Nov 22 00:58:11 2014 +0000
+++ b/UI/UI.cpp	Mon Nov 24 03:28:44 2014 +0000
@@ -84,7 +84,7 @@
     }
 
     dataCnt=0;
-    memset(xbeeBuffer,1,250);
+    memset(xbeeBuffer,0xF,250);
 }
 
 void initializeUI()
--- a/initDatabed/initDatabed.cpp	Sat Nov 22 00:58:11 2014 +0000
+++ b/initDatabed/initDatabed.cpp	Mon Nov 24 03:28:44 2014 +0000
@@ -1,5 +1,6 @@
 #include "mbed.h"
 #include "MODSERIAL.h"
+#include "BluetoothComm.h"
 
 MODSERIAL xbeeUI(p28, p27); //XBee UI crutch communication
 
@@ -24,6 +25,10 @@
 DigitalIn leftFault(p21);
 DigitalIn rightFault(p22);
 
+BluetoothComm phone(p9, p10);
+CAN BMS(p30, p29);
+CANMessage msg;
+
 void initializeDatabed() {
     xbeeUI.baud(115200);
     pc.baud(921600);
@@ -32,6 +37,7 @@
     comm.format(8,1);
     inhibit_L=1;
     inhibit_R=1;
+    BMS.frequency(250000);
 
     wait(1);
     pc.printf("Starting databed...\r\n");
--- a/initDatabed/initDatabed.h	Sat Nov 22 00:58:11 2014 +0000
+++ b/initDatabed/initDatabed.h	Mon Nov 24 03:28:44 2014 +0000
@@ -3,6 +3,7 @@
 
 #include "mbed.h"
 #include "MODSERIAL.h"
+#include "BluetoothComm.h"
 
 extern MODSERIAL xbeeUI;  // left xbee
 
@@ -22,6 +23,10 @@
 extern DigitalIn leftFault;
 extern DigitalIn rightFault;
 
+extern BluetoothComm phone;
+extern CAN BMS;
+extern CANMessage msg;
+
 
 #endif
 
--- a/main.cpp	Sat Nov 22 00:58:11 2014 +0000
+++ b/main.cpp	Mon Nov 24 03:28:44 2014 +0000
@@ -7,7 +7,7 @@
 
 int main()
 {
-    int dataIn[3], dataOut[3];
+    int dataIn[4], dataOut[4], buffer;
     dataOut[0]=7;
     dataOut[1]=30;
     mainPower=1;//Don't turn on for initial testing
@@ -15,11 +15,12 @@
     comm.reply(dataOut[0]);//make this the first message
     pc.printf("DataBed On!\r\n");
     int counter=0;
+    int ii=0;
     //float blah=1;
     //t_debug.start();
     while (1) { //Run these functions as fast as possible
 
-        if(comm.receive()) {
+        /*if(comm.receive()) {
             dataIn[0] = comm.read();
             comm.reply(UI);         // Make this the next reply
             while(dataIn[0]==7) {
@@ -39,15 +40,44 @@
                     dataIn[1]=0;
                     break;
                 }
+            }*/
+        if(comm.receive()) {
+            buffer = comm.read();
+            if(buffer==0xFE) { //end of message
+                ii=0;
+                dataIn[3]=buffer;
+                comm.reply(5);
+                counter++;
+                if(BMS.read(msg)) {
+                    if(msg.id==0x18FF8320) {
+                        pc.printf("%x\r\n",msg.data[0]);
+                    }
+                }
+                phone.attachment();
+            } else if(buffer==0xFF) { //beginning of message
+                ii=1;
+                dataIn[0]=buffer;
+                comm.reply(UI);
+            } else if(ii==1) {
+                ii++;
+                dataIn[1]=buffer;
+                comm.reply(52);
+            } else if(ii==2) {
+                ii++;
+                dataIn[2]=buffer;
+                comm.reply(25);
             }
-            if(counter>=100) {
-                UI=0;//set the UI to 0 unless it's changed in checkUI_Xbee()
-                readBuffer();
-                checkUI_XBee(); //check UI from Xbee
-                counter=0;
-            }
-            counter++;
+
         }
+        if(counter>=10) {
+            UI=0;//set the UI to 0 unless it's changed in checkUI_Xbee()
+            readBuffer();
+            checkUI_XBee(); //check UI from Xbee
+            xbeeUI.rxBufferFlush();
+            counter=0;
+        }
+        //counter++;
+        //}
 
     }
 }
\ No newline at end of file