Soft Serial is working, barely and grossly.
Dependencies: SoftSerial mbed-rtos mbed
main.cpp
00001 #include "mbed.h" 00002 #include "SoftSerial.h" 00003 #include "rtos.h" 00004 #include <sstream> 00005 00006 /* --------- I/O INFORMATION --------- 00007 USB Debugging Pins: tx = D1(PA2), rx = D0(PA3) 00008 XBEE Board Pins: 00009 DOUT (rx) <- D3 (PB3) 00010 DIN (tx) <- D2 (PA10) 00011 GND <- GND 00012 5V <- 5V 00013 00014 */ 00015 00016 Serial pc(D1, D0); // PA2, PA3 00017 00018 const int nodeID = 0; 00019 //void initialize_node(SoftSerial &xbee); 00020 void initialize_node(SoftSerial &xbee); 00021 00022 int uptime = 0; 00023 00024 int main() 00025 { 00026 SoftSerial xbee(D3, D2); // tx, rx 00027 initialize_node(xbee); 00028 pc.printf("ECHOOOOOO"); 00029 00030 char data; 00031 00032 while(true) { 00033 00034 // Continuous transmit 00035 /* 00036 std::stringstream s; 00037 s << 'H' << 'E' << 'L' << 'L' << 'O'; 00038 xbee.printf(s.str().c_str()); 00039 */ 00040 00041 //xbee.printf("%d", nodeID); 00042 xbee.printf("Times Through Loop: %d\n", uptime); 00043 //pc.printf("%d", nodeID); 00044 uptime++; 00045 wait(0.1); 00046 00047 //Requested transmit 00048 if(xbee.readable()) { 00049 data = xbee.getc(); 00050 if(data == 'p'){ 00051 xbee.printf("%d", nodeID); 00052 } else if (data == 'u') { 00053 xbee.printf("uptime = %d\n", uptime); 00054 } 00055 } 00056 00057 } 00058 } 00059 00060 // Change back to SoftSerial 00061 void initialize_node(SoftSerial &xbee){ 00062 // Eventually put stuff here. 00063 } 00064 00065 /* 00066 int main(){ 00067 pc.printf("Echoes back to the screen anything you type\n"); 00068 while(1){ 00069 if(pc.readable()){ 00070 pc.putc(pc.getc()+1); 00071 pc.printf("\n"); 00072 } 00073 00074 wait(0.1); 00075 pc.printf("E"); 00076 } 00077 } 00078 */ 00079 00080 00081 00082 00083 00084 00085 00086 00087
Generated on Fri Jul 22 2022 17:25:20 by 1.7.2