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.
Dependents: Aigamozu_Robot_ver3_1 Aigamozu_Robot_ver3_2 Aigamozu_Robot_ver3_3 Aigamozu_Robot_ver3_4 ... more
Fork of XBee by
Diff: XBee.cpp
- Revision:
- 3:8573b122fa84
- Parent:
- 2:6efb3541af61
- Child:
- 4:f6d73acc1f75
--- a/XBee.cpp Fri Jul 29 16:22:15 2011 +0000
+++ b/XBee.cpp Thu Mar 08 17:41:29 2012 +0000
@@ -21,6 +21,13 @@
* along with XBee-Arduino. If not, see <http://www.gnu.org/licenses/>.
*/
+/** @file
+ * @brief XBee library for mbed
+ */
+
+//#define DEBUG
+#include "dbg.h"
+
#include "mbed.h"
#include "XBee.h"
@@ -666,6 +673,18 @@
_escape = false;
_checksumTotal = 0;
_nextFrameId = 0;
+ _cts = NULL;
+
+ _response.init();
+ _response.setFrameData(_responseFrameData);
+}
+
+XBee::XBee(PinName p_tx, PinName p_rx, PinName p_cts): _xbee(p_tx, p_rx) {
+ _pos = 0;
+ _escape = false;
+ _checksumTotal = 0;
+ _nextFrameId = 0;
+ _cts = new DigitalIn(p_cts);
_response.init();
_response.setFrameData(_responseFrameData);
@@ -727,6 +746,7 @@
while (int((millis() - start)) < timeout) {
*/
+ t.reset();
t.start();
while (t.read_ms() < timeout) {
readPacket();
@@ -772,6 +792,7 @@
continue;
}
}
+ DBG("%02x_", b);
if (_escape == true) {
b = 0x20 ^ b;
@@ -1348,16 +1369,21 @@
// send packet
Serial.flush();
*/
+ DBG("\r\n");
}
void XBee::sendByte(uint8_t b, bool escape) {
if (escape && (b == START_BYTE || b == ESCAPE || b == XON || b == XOFF)) {
// std::cout << "escaping byte [" << toHexString(b) << "] " << std::endl;
+ if (_cts) while (_cts->read() != 0);
_xbee.putc(ESCAPE);
+ if (_cts) while (_cts->read() != 0);
_xbee.putc(b ^ 0x20);
} else {
+ if (_cts) while (_cts->read() != 0);
_xbee.putc(b);
}
+ DBG("%02x ", b);
}
