Yoshito Onishi / XBee

Fork of XBee by Suga koubou

Revision:
6:dc1f35defd71
Parent:
4:f6d73acc1f75
--- a/XBee.cpp	Tue Mar 13 09:11:35 2012 +0000
+++ b/XBee.cpp	Fri Jan 18 17:00:51 2013 +0000
@@ -25,7 +25,7 @@
  * @brief XBee library for mbed
  */
 
-//#define DEBUG
+#define DEBUG
 #include "dbg.h"
 
 #include "mbed.h"
@@ -857,7 +857,7 @@
                 continue;
             }
         }
-        DBG("%02x_", b);
+        //DBG("%02x_", b);
 
         if (_escape == true) {
             b = 0x20 ^ b;
@@ -1396,6 +1396,16 @@
 //    _frame = frame;
 //}
 
+void flushSerialBuffer(Serial &device) 
+{ 
+    char c = 0; 
+    while (device.readable()) { 
+        c = device.getc(); 
+        c = c;//escape warning
+    }
+    return; 
+}
+
 void XBee::send(XBeeRequest &request) {
     // the new new deal
 
@@ -1437,7 +1447,9 @@
     // send packet
     Serial.flush();
 */
-    DBG("\r\n");
+    flushSerialBuffer(_xbee);
+
+//    DBG("\r\n");
 }
 
 void XBee::sendByte(uint8_t b, bool escape) {
@@ -1449,6 +1461,6 @@
     } else {
         _xbee.putc(b);
     }
-    DBG("%02x ", b);
+//    DBG("%02x ", b);
 }