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: CANBuffer mbed SystemManagement mbed-rtos
XBee_Lib.h
00001 /* 00002 Test Code 00003 //#include "XBee_Lib.h" 00004 #include "mbed.h" 00005 #include<sstream> 00006 #include <cstring> 00007 #include <string> 00008 Serial xbee(p28,p27); 00009 Serial pc(USBTX,USBRX); 00010 DigitalOut led1(LED1); 00011 DigitalOut led2(LED2); 00012 DigitalOut reset(p5); 00013 DigitalIn CTS(p6, PullNone); 00014 DigitalIn in(p21, PullDown); 00015 00016 int main() 00017 { 00018 //char a[]="Hello....."; 00019 //int i=0; 00020 //while(a[i]!='\0') 00021 xbee.baud(250000); 00022 char a[63]; 00023 char b[100]; 00024 00025 a[0]='\x31'; 00026 for(int j=1; j<=60; j++) 00027 { 00028 if(a[j-1]=='\x39') 00029 { 00030 a[j]='\x41'; 00031 } 00032 else if(a[j-1]=='\x5A') 00033 { 00034 a[j]='\x61'; 00035 } 00036 else 00037 a[j]=a[j-1]+1; 00038 } 00039 a[61]='\n'; 00040 a[62]='\r'; 00041 char data[8]=""; 00042 data[0]='a'; 00043 data[1]='b'; 00044 data[2]='c'; 00045 string stri; 00046 00047 //pc.printf("%s",a); 00048 reset=0; 00049 wait_ms(1); 00050 reset=1; 00051 wait_ms(1); 00052 00053 00054 std::ostringstream ostr; 00055 ostr<<data; 00056 stri=ostr.str(); 00057 std::strcpy (b, (ostr.str()).c_str()); 00058 pc.printf("%s",b); 00059 while(1) 00060 { 00061 while(in.read()) 00062 { 00063 pc.printf("Sending Data...\n\r"); 00064 xbee.printf("%s",b); 00065 00066 if(CTS.read()==1) 00067 { 00068 pc.printf("DI buffer full\n\r"); 00069 led2=1; 00070 //break; 00071 while(CTS.read()){} 00072 pc.printf("DI buffer has place\n\r"); 00073 led2=0; 00074 //i=0; 00075 } 00076 00077 //wait_ms(1000); 00078 led1=!led1; 00079 //++i; 00080 } 00081 } 00082 } 00083 */ 00084 #ifndef XBEE_LIB_H 00085 #define XBEE_LIB_H 00086 00087 #include"LPCDigitalOut.h" 00088 #include"mbed.h" 00089 #include<sstream> 00090 00091 Serial Xbee_e1(p9,p10); 00092 Serial Xbee_e2(p13,p14); 00093 00094 // Used for wireless communications with Xbee 00095 00096 //Include the send function only in the main code. 00097 class XBee250x 00098 { 00099 public: 00100 XBee250x() 00101 { 00102 Xbee_e1.baud(250000); 00103 Xbee_e2.baud(250000); 00104 } 00105 00106 void send(CANMessage Rxmsg) 00107 { 00108 Xbee_e1.printf("%c \t %d \t %s \n\r",Rxmsg.id, Rxmsg.len, Rxmsg.data); 00109 Xbee_e2.printf("%c \t %d \t %s \n\r",Rxmsg.id, Rxmsg.len, Rxmsg.data); 00110 } 00111 }; 00112 #endif /*XBEE_LIB_H*/
Generated on Sat Aug 13 2022 03:42:38 by
1.7.2