Simple UHD Transceiver Class

I wrote a simple transceiver class for the USRP1 (GNURadio) using the new UHD interface.

The class allows you to send and receive data.  What you fill in for the data is up to you.  Currently, the class performs simple energy detection (sends a 100 sample burst with constant envelope) and works when you hook the RX up to the TX on the Basic RX/TX boards (make sure you have proper attenuation as to not break the daughterboards).  But, with some simple modification, you can have it do more sophisticated processing.

The class creates two queues and three threads.

One queue is the TX queue and the other the RX queue. The TX queue is a vector of pointers to complex float vectors (variable length) and are waveforms to be transmitted. The RX queue is a vector of pointers to complex float vectors (const size) and are the data blocks received from the radio.

The three threads are the TX thread, the RX thread, and the processing thread.

The TX thread wakes up every 100ms and looks at the TX queue and sends any waveforms that are present.  The RX thread runs continuously and receives datablocks from the radio. The processing thread checks the RX queue and processes any blocks that are present on it.  Having an RX queue, RX thread, and processing thread allows the software to continually receive data without dropping packets and leaves the choice up to the software as to which packets to process.  For example, if the processing thread runs slower than the samples coming in (slower than real time), it may choose to intelligently process the remaining blocks instead of dropping data on the floor.  This would allow the processing thread to “catch up.”

The TX thread can be modified as to send the waveforms out immediately instead of on a queue for servicing.

I hope all this makes sense.

The code can be downloaded here.  I used this to compile:

g++ main.cpp SimpleTransceiver.cpp -lboost_thread -luhd -I/opt/uhd/include -L/opt/uhd/lib

Bugs, questions, comments welcomed.

Enjoy!