uhd: move non-52MHz transceiver to common radio device interface
Use the same header files for the device and start moving toward a commmon transceiver without so much redundant code. Signed-off-by: Thomas Tsou <ttsou@vt.edu>
This commit is contained in:
parent
258ad91549
commit
8c86da79c0
|
@ -1,91 +0,0 @@
|
|||
/*
|
||||
* Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* This software is distributed under the terms of the GNU Affero Public License.
|
||||
* See the COPYING file in the main directory for details.
|
||||
*
|
||||
* This use of this software may be subject to additional restrictions.
|
||||
* See the LEGAL file in the main directory for details.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _DEVICE_H_
|
||||
#define _DEVICE_H_
|
||||
|
||||
/** a 64-bit virtual timestamp for device data */
|
||||
typedef unsigned long long TIMESTAMP;
|
||||
|
||||
class Device {
|
||||
public:
|
||||
/** Factory method */
|
||||
static Device *make(double desiredSampleRate, bool skipRx = false);
|
||||
|
||||
/** Open, start, and stop the device
|
||||
@return success or fail
|
||||
*/
|
||||
virtual bool open() = 0;
|
||||
virtual bool start() = 0;
|
||||
virtual bool stop() = 0;
|
||||
virtual void setPriority() = 0;
|
||||
|
||||
/** Read samples from the USRP.
|
||||
@param buf preallocated buf to contain read result
|
||||
@param len number of samples desired
|
||||
@param overrun set if read buffer has been overrun
|
||||
@param timestamp time of the first samples to be read
|
||||
@param underrun set if USRP does not have data to transmit
|
||||
@param RSSI received signal strength of the read result
|
||||
@return number of samples actually read
|
||||
*/
|
||||
virtual int readSamples(short *buf, int len, bool *overrun,
|
||||
TIMESTAMP timestamp = 0xffffffff,
|
||||
bool *underrun = 0,
|
||||
unsigned *RSSI = 0) = 0;
|
||||
|
||||
/** Write samples to the USRP.
|
||||
@param buf contains the data to be written
|
||||
@param len number of samples to write
|
||||
@param underrun set if USRP does not have data to transmit
|
||||
@param timestamp time of the first sample of the data buffer
|
||||
@param isControl set if data is a control packet
|
||||
@return number of samples actually written
|
||||
*/
|
||||
virtual int writeSamples(short *buf, int len, bool *underrun,
|
||||
TIMESTAMP timestamp = 0xffffffff,
|
||||
bool isControl = false) = 0;
|
||||
|
||||
/** Update the alignment between the read and write timestamps
|
||||
@return success or fail
|
||||
*/
|
||||
virtual bool updateAlignment(TIMESTAMP timestamp) = 0;
|
||||
|
||||
/** Set transmit and receive frequencies
|
||||
@param freq desired frequency
|
||||
@return success or fail
|
||||
*/
|
||||
virtual bool setTxFreq(double freq) = 0;
|
||||
virtual bool setRxFreq(double freq) = 0;
|
||||
|
||||
/** Return internal status values */
|
||||
virtual double getSampleRate() = 0;
|
||||
virtual double numberRead() = 0;
|
||||
virtual double numberWritten() = 0;
|
||||
|
||||
/** Virtual destructor */
|
||||
virtual ~Device() { }
|
||||
};
|
||||
|
||||
#endif // _DEVICE_H_
|
|
@ -55,8 +55,7 @@ noinst_HEADERS = \
|
|||
sendLPF_961.h \
|
||||
sigProcLib.h \
|
||||
Transceiver.h \
|
||||
USRPDevice.h \
|
||||
Device.h
|
||||
USRPDevice.h
|
||||
|
||||
USRPping_SOURCES = USRPping.cpp
|
||||
USRPping_LDADD = \
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
*/
|
||||
|
||||
#include "Device.h"
|
||||
#include "../Transceiver52M/radioDevice.h"
|
||||
#include "Threads.h"
|
||||
#include "Logger.h"
|
||||
#include <uhd/usrp/single_usrp.hpp>
|
||||
|
@ -133,7 +133,7 @@ private:
|
|||
Events and errors such as underruns are reported asynchronously
|
||||
by the device and received in a separate thread.
|
||||
*/
|
||||
class uhd_device : public Device {
|
||||
class uhd_device : public RadioDevice {
|
||||
public:
|
||||
uhd_device(double rate, bool skip_rx);
|
||||
~uhd_device();
|
||||
|
@ -819,7 +819,7 @@ std::string smpl_buf::str_code(ssize_t code)
|
|||
}
|
||||
}
|
||||
|
||||
Device *Device::make(double smpl_rt, bool skip_rx)
|
||||
RadioDevice *RadioDevice::make(double smpl_rt, bool skip_rx)
|
||||
{
|
||||
return new uhd_device(smpl_rt, skip_rx);
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ int main(int argc, char *argv[]) {
|
|||
else gLogInit("INFO");
|
||||
if (argc>2) gSetLogFile(argv[2]);
|
||||
|
||||
Device *usrp = Device::make(400e3);
|
||||
RadioDevice *usrp = RadioDevice::make(400e3);
|
||||
if (!usrp->open()) {
|
||||
cerr << "Device open failed. Exiting..." << endl;
|
||||
exit(1);
|
||||
|
|
|
@ -38,7 +38,7 @@ GSM::Time VectorQueue::nextTime() const
|
|||
return retVal;
|
||||
}
|
||||
|
||||
RadioInterface::RadioInterface(Device *wUsrp,
|
||||
RadioInterface::RadioInterface(RadioDevice *wUsrp,
|
||||
int wReceiveOffset,
|
||||
int wSamplesPerSymbol,
|
||||
GSM::Time wStartTime)
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
|
||||
#include "sigProcLib.h"
|
||||
#include "Device.h"
|
||||
#include "../Transceiver52M/radioDevice.h"
|
||||
#include "GSMCommon.h"
|
||||
#include "Interthread.h"
|
||||
|
||||
|
@ -119,7 +119,7 @@ private:
|
|||
signalVector* sendHistory; ///< block of previous transmitted samples
|
||||
signalVector* rcvHistory; ///< block of previous received samples
|
||||
|
||||
Device *usrp; ///< the USRP object
|
||||
RadioDevice *usrp; ///< the USRP object
|
||||
|
||||
signalVector* sendBuffer; ///< block of samples to be transmitted
|
||||
signalVector* rcvBuffer; ///< block of received samples to be processed
|
||||
|
@ -160,7 +160,7 @@ public:
|
|||
void start();
|
||||
|
||||
/** constructor */
|
||||
RadioInterface(Device* wUsrp = NULL,
|
||||
RadioInterface(RadioDevice* wUsrp = NULL,
|
||||
int receiveOffset = 3,
|
||||
int wSamplesPerSymbol = SAMPSPERSYM,
|
||||
GSM::Time wStartTime = GSM::Time(0));
|
||||
|
@ -172,7 +172,7 @@ public:
|
|||
bool isUnderrun() { bool retVal = underrun; underrun = false; return retVal;}
|
||||
|
||||
/** attach an existing USRP to this interface */
|
||||
void attach(Device *wUsrp) {if (!mOn) usrp = wUsrp;}
|
||||
void attach(RadioDevice *wUsrp) {if (!mOn) usrp = wUsrp;}
|
||||
|
||||
/** return the transmit FIFO */
|
||||
VectorFIFO* transmitFIFO() { return &mTransmitFIFO;}
|
||||
|
|
|
@ -49,7 +49,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
srandom(time(NULL));
|
||||
|
||||
Device *usrp = Device::make(400.0e3);
|
||||
RadioDevice *usrp = RadioDevice::make(400.0e3);
|
||||
if (!usrp->open()) {
|
||||
cerr << "Device open failed. Exiting..." << endl;
|
||||
exit(1);
|
||||
|
|
|
@ -39,6 +39,7 @@ class RadioDevice {
|
|||
public:
|
||||
static RadioDevice *make(double desiredSampleRate, bool skipRx = false);
|
||||
|
||||
/** Initialize the USRP */
|
||||
virtual bool open()=0;
|
||||
|
||||
/** Start the USRP */
|
||||
|
@ -47,6 +48,9 @@ class RadioDevice {
|
|||
/** Stop the USRP */
|
||||
virtual bool stop()=0;
|
||||
|
||||
/** Enable thread priority */
|
||||
virtual void setPriority()=0;
|
||||
|
||||
/**
|
||||
Read samples from the radio.
|
||||
@param buf preallocated buf to contain read result
|
||||
|
|
Reference in New Issue