xbee communication for UWB quadcopter project
Diff: com.cpp
- Revision:
- 4:7cdf299ea7a4
- Parent:
- 3:f8e953201251
- Child:
- 5:4d96c8776442
--- a/com.cpp Tue Apr 22 05:43:33 2014 +0000 +++ b/com.cpp Tue Apr 22 06:28:49 2014 +0000 @@ -31,6 +31,7 @@ xbeeTx.baud(BAUDRATE); // Setup the serial baud rate. xbeeRx.baud(BAUDRATE); // Setup the serial baud rate. rxBuffer = new queue(); // Point to the rxQueue. + txBuffer = new queue(); signalStrength = 0; xbeeRx.attach( this, &com::callback ); // Set callback as the interrupt handler. #ifdef DEBUG @@ -95,20 +96,25 @@ } } -/*************************** char read() ********************************/ +/*************************** char ackCheck() ********************************/ /* */ /*************************************************************************/ void com::ackCheck() { - if( !txBuffer->isEmpty()) + if( !txBuffer->isEmpty() && xbeeTx.writeable()) { - short * pkt = rxBuffer->pop(); - write(pkt[0],pkt[1]); + short * pkt = txBuffer->pop(); + write(pkt[0],pkt[1]); //may need to disable interrupt + delete[] pkt; } } +bool com::rdy2ack() +{ + return !txBuffer->isEmpty(); +} /*************************** char read() ********************************/ /* */