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.
Diff: Xbee.cpp
- Revision:
- 22:03acadc5ad70
- Parent:
- 21:bb89b0fca63d
- Child:
- 23:90a94bb22d71
--- a/Xbee.cpp Sat Nov 28 04:26:35 2015 +0000 +++ b/Xbee.cpp Sat Nov 28 05:06:21 2015 +0000 @@ -1,7 +1,7 @@ #pragma once #include "Xbee.h" -Serial pc(USBTX, USBRX); +//Serial pc(USBTX, USBRX); Xbee::Xbee(PinName tx, PinName rx , PinName rst):_xbee(tx,rx),_rst(rst) { @@ -19,31 +19,27 @@ void Xbee::Send(const char& buffer) { - while(1) + while(!_xbee.readable()) { - _xbee.putc('.'); - _xbee.putc(buffer); - - if(_xbee.readable()) + if(_xbee.writeable()) { - if(_xbee.getc() == '.') - { - break; - } + _xbee.putc(buffer); } } } void Xbee::Recv(char& buffer) { - while(1) + if(_xbee.readable()) { - if(_xbee.readable()) + buffer = _xbee.getc(); + + while(!_xbee.readable()) { - if(_xbee.getc()=='.') - buffer = _xbee.getc(); - _xbee.putc('.'); - break; + if(_xbee.writeable()) + { + _xbee.putc('.'); + } } } } \ No newline at end of file