Penn Electric Racing / Mbed 2 deprecated SystemManagement

Dependencies:   mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP

Fork of SystemManagement by Martin Deng

Revision:
0:e516fcccccda
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XBee/XBee_Lib.h	Wed Oct 01 12:52:26 2014 +0000
@@ -0,0 +1,112 @@
+/*
+Test Code
+//#include "XBee_Lib.h"
+#include "mbed.h"
+#include<sstream>
+#include <cstring>
+#include <string>
+Serial xbee(p28,p27);
+Serial pc(USBTX,USBRX);
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+DigitalOut reset(p5);
+DigitalIn CTS(p6, PullNone);
+DigitalIn in(p21, PullDown);
+
+int main() 
+{
+    //char a[]="Hello.....";
+    //int i=0;
+    //while(a[i]!='\0')
+    xbee.baud(250000);
+    char a[63];
+    char b[100];
+    
+    a[0]='\x31';
+    for(int j=1; j<=60; j++)
+    {
+        if(a[j-1]=='\x39')
+        {
+            a[j]='\x41';
+        }
+        else if(a[j-1]=='\x5A')
+        {
+            a[j]='\x61';
+        } 
+        else   
+         a[j]=a[j-1]+1;
+    }
+    a[61]='\n';
+    a[62]='\r';
+    char data[8]="";
+    data[0]='a';
+    data[1]='b';
+    data[2]='c';
+    string stri;
+    
+    //pc.printf("%s",a);
+    reset=0;
+    wait_ms(1);
+    reset=1;
+    wait_ms(1);         
+    
+      
+    std::ostringstream ostr;
+    ostr<<data;
+    stri=ostr.str(); 
+    std::strcpy (b, (ostr.str()).c_str());
+    pc.printf("%s",b);
+    while(1)
+    {
+        while(in.read())
+        {
+            pc.printf("Sending Data...\n\r");
+            xbee.printf("%s",b);
+            
+            if(CTS.read()==1)
+            {
+                pc.printf("DI buffer full\n\r");
+                led2=1;
+                //break;
+                while(CTS.read()){}
+                pc.printf("DI buffer has place\n\r");
+                led2=0;
+                //i=0;
+            } 
+               
+            //wait_ms(1000);
+            led1=!led1;
+            //++i;
+        }
+    }
+}
+*/
+#ifndef XBEE_LIB_H
+#define XBEE_LIB_H
+    
+#include"LPCDigitalOut.h"
+#include"mbed.h"
+#include<sstream>
+
+Serial Xbee_e1(p9,p10);
+Serial Xbee_e2(p13,p14);          
+
+// Used for wireless communications with Xbee
+
+//Include the send function only in the main code.
+class XBee250x
+{
+    public:     
+        XBee250x()
+        {
+            Xbee_e1.baud(250000);
+            Xbee_e2.baud(250000);
+        }    
+                
+        void send(CANMessage Rxmsg)
+        {
+            Xbee_e1.printf("%c \t %d \t %s \n\r",Rxmsg.id, Rxmsg.len, Rxmsg.data);
+            Xbee_e2.printf("%c \t %d \t %s \n\r",Rxmsg.id, Rxmsg.len, Rxmsg.data);
+        }    
+};    
+#endif  /*XBEE_LIB_H*/
\ No newline at end of file