Move device specific code out of radioInterface

This way code of radioInterface is independent of the device and doesn't
need to be rebuild for each device.

Change-Id: Id104e1edef02f863b6465ced5b4241050dc188f9
This commit is contained in:
Pau Espin 2018-04-24 17:48:52 +02:00
parent a4316ee4c5
commit 0fc20d14b3
6 changed files with 36 additions and 28 deletions

View File

@ -148,6 +148,9 @@ class RadioDevice {
/** return the used RX path */
virtual std::string getTxAntenna(size_t chan = 0) = 0;
/** return whether user drives synchronization of Tx/Rx of USRP */
virtual bool requiresRadioAlign() = 0;
/** Return internal status values */
virtual double getTxFreq(size_t chan = 0) = 0;
virtual double getRxFreq(size_t chan = 0) = 0;

View File

@ -255,6 +255,8 @@ public:
bool setTxAntenna(const std::string &ant, size_t chan);
std::string getTxAntenna(size_t chan);
bool requiresRadioAlign();
inline double getSampleRate() { return tx_rate; }
inline double numberRead() { return rx_pkt_cnt; }
inline double numberWritten() { return 0; }
@ -1282,6 +1284,11 @@ std::string uhd_device::getTxAntenna(size_t chan)
return usrp_dev->get_tx_antenna(chan);
}
bool uhd_device::requiresRadioAlign()
{
return false;
}
/*
* Only allow sampling the Rx path lower than Tx and not vice-versa.
* Using Tx with 4 SPS and Rx at 1 SPS is the only allowed mixed

View File

@ -353,6 +353,10 @@ std::string USRPDevice::getTxAntenna(size_t chan)
return "";
}
bool USRPDevice::requiresRadioAlign()
{
return true;
}
// NOTE: Assumes sequential reads
int USRPDevice::readSamples(std::vector<short *> &bufs, int len, bool *overrun,

View File

@ -191,6 +191,9 @@ private:
/* return the used RX path */
std::string getTxAntenna(size_t chan = 0);
/** return whether user drives synchronization of Tx/Rx of USRP */
bool requiresRadioAlign();
/** Return internal status values */
inline double getTxFreq(size_t chan = 0) { return 0; }
inline double getRxFreq(size_t chan = 0) { return 0; }

View File

@ -145,16 +145,31 @@ bool RadioInterface::tuneRx(double freq, size_t chan)
return mRadio->setRxFreq(freq, chan);
}
/** synchronization thread loop */
void *AlignRadioServiceLoopAdapter(RadioInterface *radioInterface)
{
while (1) {
sleep(60);
radioInterface->alignRadio();
pthread_testcancel();
}
return NULL;
}
void RadioInterface::alignRadio() {
mRadio->updateAlignment(writeTimestamp+ (TIMESTAMP) 10000);
}
bool RadioInterface::start()
{
if (mOn)
return true;
LOG(INFO) << "Starting radio device";
#ifdef DEVICE_USRP1
mAlignRadioServiceLoopThread.start((void * (*)(void*))AlignRadioServiceLoopAdapter,
(void*)this);
#endif
if (mRadio->requiresRadioAlign())
mAlignRadioServiceLoopThread.start(
(void * (*)(void*))AlignRadioServiceLoopAdapter,
(void*)this);
if (!mRadio->start())
return false;
@ -191,22 +206,6 @@ bool RadioInterface::stop()
return true;
}
#ifdef DEVICE_USRP1
void *AlignRadioServiceLoopAdapter(RadioInterface *radioInterface)
{
while (1) {
radioInterface->alignRadio();
pthread_testcancel();
}
return NULL;
}
void RadioInterface::alignRadio() {
sleep(60);
mRadio->updateAlignment(writeTimestamp+ (TIMESTAMP) 10000);
}
#endif
void RadioInterface::driveTransmitRadio(std::vector<signalVector *> &bursts,
std::vector<bool> &zeros)
{

View File

@ -133,21 +133,13 @@ public:
/** get transport window type of attached device */
enum RadioDevice::TxWindowType getWindowType() { return mRadio->getWindowType(); }
#if DEVICE_USRP1
protected:
/** drive synchronization of Tx/Rx of USRP */
void alignRadio();
friend void *AlignRadioServiceLoopAdapter(RadioInterface*);
#endif
};
#if DEVICE_USRP1
/** synchronization thread loop */
void *AlignRadioServiceLoopAdapter(RadioInterface*);
#endif
class RadioInterfaceResamp : public RadioInterface {
private:
signalVector *outerSendBuffer;