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: mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP
Fork of SystemManagement by
Diff: Libs/Xbee/Xbee.cpp
- Revision:
- 31:7eaa5e881b56
- Parent:
- 30:91af74a299e1
- Child:
- 32:e70407021ad2
--- a/Libs/Xbee/Xbee.cpp Thu Nov 13 10:53:10 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-#include "Xbee.h"
-
-Xbee::Xbee(PinName tx, PinName rx, int baudrate, int bufferSize, char _delim) : xbee(tx, rx, bufferSize) {
- xbee.baud(baudrate);
- charCounter = 0;
- numMessagesIn = 0;
- numMessagesOut = 0;
- delim = _delim;
-
- // Attach callback when a new message delimiter character arrives
- xbee.autoDetectChar(delim);
- xbee.attach(this, &Xbee::newMsg, MODSERIAL::RxAutoDetect);
-}
-bool Xbee::send(CANMessage& msg) {
- if (!xbee.writeable()) return false; // Exit, txBuffer full
-
- // Format as string
- char str[100];
-
- // Will it fit?
- if (xbee.txBufferGetSize(0) - xbee.txBufferGetCount() > strlen(str)){
- xbee.printf("%s\n", str);
- numMessagesOut++;
- return true;
-
- // Don't send
- } else {
- return false;
- }
-}
-bool Xbee::receive(CANMessage& msg) {
- char str[100];
- unsigned int i = 0;
-
- if (charCounter == 0) return false; // No messages yet
- else {
- while (xbee.readable()) { // Build string until buffer is empty or delimiter char is found
- char c = xbee.getc();
- str[i] = c;
- i++;
- if (c == delim) {
- charCounter--;
- str[i-1] = '\0'; // Null terminator in place of delimiter char
- break;
- }
- }
- }
-
- // Process string into CAN Message
- int len = strlen(str);
-
- numMessagesIn++;
- return true;
-}
-void Xbee::newMsg(MODSERIAL_IRQ_INFO *q) {
- charCounter++;
-}
\ No newline at end of file
