transceiver: separate radio clock and vector interfaces
Remove radio clock and vector interfaces into their own files. This clears up and simplifies the radio interface and, additionaly, prepares for a further split of the I/O portion for optional resampler use. Signed-off-by: Thomas Tsou <ttsou@vt.edu>
This commit is contained in:
parent
285b0a481c
commit
f5575b9240
|
@ -39,11 +39,16 @@ EXTRA_DIST = \
|
|||
|
||||
noinst_LTLIBRARIES = libtransceiver.la
|
||||
|
||||
libtransceiver_la_SOURCES = \
|
||||
COMMON_SOURCES = \
|
||||
radioInterface.cpp \
|
||||
radioVector.cpp \
|
||||
radioClock.cpp \
|
||||
sigProcLib.cpp \
|
||||
Transceiver.cpp
|
||||
|
||||
libtransceiver_la_SOURCES = \
|
||||
$(COMMON_SOURCES)
|
||||
|
||||
noinst_PROGRAMS = \
|
||||
USRPping \
|
||||
transceiver \
|
||||
|
@ -52,6 +57,8 @@ noinst_PROGRAMS = \
|
|||
noinst_HEADERS = \
|
||||
Complex.h \
|
||||
radioInterface.h \
|
||||
radioVector.h \
|
||||
radioClock.h \
|
||||
radioDevice.h \
|
||||
sigProcLib.h \
|
||||
Transceiver.h \
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Written by Thomas Tsou <ttsou@vt.edu>
|
||||
* Based on code by Harvind S Samra <hssamra@kestrelsp.com>
|
||||
*
|
||||
* Copyright 2011 Free Software Foundation, Inc.
|
||||
*
|
||||
* 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/>.
|
||||
* See the COPYING file in the main directory for details.
|
||||
*/
|
||||
|
||||
#include "radioClock.h"
|
||||
|
||||
void RadioClock::set(const GSM::Time& wTime)
|
||||
{
|
||||
mLock.lock();
|
||||
mClock = wTime;
|
||||
updateSignal.signal();
|
||||
mLock.unlock();
|
||||
}
|
||||
|
||||
void RadioClock::incTN()
|
||||
{
|
||||
mLock.lock();
|
||||
mClock.incTN();
|
||||
updateSignal.signal();
|
||||
mLock.unlock();
|
||||
}
|
||||
|
||||
GSM::Time RadioClock::get()
|
||||
{
|
||||
mLock.lock();
|
||||
GSM::Time retVal = mClock;
|
||||
mLock.unlock();
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
void RadioClock::wait()
|
||||
{
|
||||
mLock.lock();
|
||||
updateSignal.wait(mLock,1);
|
||||
mLock.unlock();
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Written by Thomas Tsou <ttsou@vt.edu>
|
||||
* Based on code by Harvind S Samra <hssamra@kestrelsp.com>
|
||||
*
|
||||
* Copyright 2011 Free Software Foundation, Inc.
|
||||
*
|
||||
* 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/>.
|
||||
* See the COPYING file in the main directory for details.
|
||||
*/
|
||||
|
||||
#ifndef RADIOCLOCK_H
|
||||
#define RADIOCLOCK_H
|
||||
|
||||
#include "GSMCommon.h"
|
||||
|
||||
class RadioClock {
|
||||
public:
|
||||
void set(const GSM::Time& wTime);
|
||||
void incTN();
|
||||
GSM::Time get();
|
||||
void wait();
|
||||
|
||||
private:
|
||||
GSM::Time mClock;
|
||||
Mutex mLock;
|
||||
Signal updateSignal;
|
||||
};
|
||||
|
||||
#endif /* RADIOCLOCK_H */
|
|
@ -25,54 +25,6 @@
|
|||
#include "radioInterface.h"
|
||||
#include <Logger.h>
|
||||
|
||||
|
||||
GSM::Time VectorQueue::nextTime() const
|
||||
{
|
||||
GSM::Time retVal;
|
||||
mLock.lock();
|
||||
while (mQ.size()==0) mWriteSignal.wait(mLock);
|
||||
retVal = mQ.top()->time();
|
||||
mLock.unlock();
|
||||
return retVal;
|
||||
}
|
||||
|
||||
radioVector* VectorQueue::getStaleBurst(const GSM::Time& targTime)
|
||||
{
|
||||
mLock.lock();
|
||||
if ((mQ.size()==0)) {
|
||||
mLock.unlock();
|
||||
return NULL;
|
||||
}
|
||||
if (mQ.top()->time() < targTime) {
|
||||
radioVector* retVal = mQ.top();
|
||||
mQ.pop();
|
||||
mLock.unlock();
|
||||
return retVal;
|
||||
}
|
||||
mLock.unlock();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
radioVector* VectorQueue::getCurrentBurst(const GSM::Time& targTime)
|
||||
{
|
||||
mLock.lock();
|
||||
if ((mQ.size()==0)) {
|
||||
mLock.unlock();
|
||||
return NULL;
|
||||
}
|
||||
if (mQ.top()->time() == targTime) {
|
||||
radioVector* retVal = mQ.top();
|
||||
mQ.pop();
|
||||
mLock.unlock();
|
||||
return retVal;
|
||||
}
|
||||
mLock.unlock();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RadioInterface::RadioInterface(RadioDevice *wRadio,
|
||||
int wReceiveOffset,
|
||||
int wRadioOversampling,
|
||||
|
|
|
@ -28,105 +28,14 @@
|
|||
#include "GSMCommon.h"
|
||||
#include "LinkedLists.h"
|
||||
#include "radioDevice.h"
|
||||
#include "radioVector.h"
|
||||
#include "radioClock.h"
|
||||
|
||||
/** samples per GSM symbol */
|
||||
#define SAMPSPERSYM 1
|
||||
#define INCHUNK 625
|
||||
#define OUTCHUNK 625
|
||||
|
||||
/** class used to organize GSM bursts by GSM timestamps */
|
||||
class radioVector : public signalVector {
|
||||
|
||||
private:
|
||||
|
||||
GSM::Time mTime; ///< the burst's GSM timestamp
|
||||
|
||||
public:
|
||||
/** constructor */
|
||||
radioVector(const signalVector& wVector,
|
||||
GSM::Time& wTime): signalVector(wVector),mTime(wTime) {};
|
||||
|
||||
/** timestamp read and write operators */
|
||||
GSM::Time time() const { return mTime;}
|
||||
void time(const GSM::Time& wTime) { mTime = wTime;}
|
||||
|
||||
/** comparison operator, used for sorting */
|
||||
bool operator>(const radioVector& other) const {return mTime > other.mTime;}
|
||||
|
||||
};
|
||||
|
||||
/** a priority queue of radioVectors, i.e. GSM bursts, sorted so that earliest element is at top */
|
||||
class VectorQueue : public InterthreadPriorityQueue<radioVector> {
|
||||
|
||||
public:
|
||||
|
||||
/** the top element of the queue */
|
||||
GSM::Time nextTime() const;
|
||||
|
||||
/**
|
||||
Get stale burst, if any.
|
||||
@param targTime The target time.
|
||||
@return Pointer to burst older than target time, removed from queue, or NULL.
|
||||
*/
|
||||
radioVector* getStaleBurst(const GSM::Time& targTime);
|
||||
|
||||
/**
|
||||
Get current burst, if any.
|
||||
@param targTime The target time.
|
||||
@return Pointer to burst at the target time, removed from queue, or NULL.
|
||||
*/
|
||||
radioVector* getCurrentBurst(const GSM::Time& targTime);
|
||||
|
||||
|
||||
};
|
||||
|
||||
/** a FIFO of radioVectors */
|
||||
class VectorFIFO {
|
||||
|
||||
private:
|
||||
PointerFIFO mQ;
|
||||
|
||||
public:
|
||||
|
||||
unsigned size() {return mQ.size();}
|
||||
|
||||
void put(radioVector *ptr) {mQ.put((void*) ptr);}
|
||||
|
||||
radioVector *get() {return (radioVector*) mQ.get();}
|
||||
|
||||
};
|
||||
|
||||
|
||||
/** the basestation clock class */
|
||||
class RadioClock {
|
||||
|
||||
private:
|
||||
|
||||
GSM::Time mClock;
|
||||
Mutex mLock;
|
||||
Signal updateSignal;
|
||||
|
||||
public:
|
||||
|
||||
/** Set clock */
|
||||
void set(const GSM::Time& wTime) { mLock.lock(); mClock = wTime; updateSignal.signal(); mLock.unlock();}
|
||||
//void set(const GSM::Time& wTime) { mLock.lock(); mClock = wTime; updateSignal.broadcast(); mLock.unlock();}
|
||||
|
||||
/** Increment clock */
|
||||
void incTN() { mLock.lock(); mClock.incTN(); updateSignal.signal(); mLock.unlock();}
|
||||
//void incTN() { mLock.lock(); mClock.incTN(); updateSignal.broadcast(); mLock.unlock();}
|
||||
|
||||
/** Get clock value */
|
||||
GSM::Time get() { mLock.lock(); GSM::Time retVal = mClock; mLock.unlock(); return retVal;}
|
||||
|
||||
/** Wait until clock has changed */
|
||||
void wait() {mLock.lock(); updateSignal.wait(mLock,1); mLock.unlock();}
|
||||
// FIXME -- If we take away the timeout, a lot of threads don't start. Why?
|
||||
//void wait() {mLock.lock(); updateSignal.wait(mLock); mLock.unlock();}
|
||||
|
||||
};
|
||||
|
||||
|
||||
/** class to interface the transceiver with the USRP */
|
||||
class RadioInterface {
|
||||
|
||||
|
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* Written by Thomas Tsou <ttsou@vt.edu>
|
||||
* Based on code by Harvind S Samra <hssamra@kestrelsp.com>
|
||||
*
|
||||
* Copyright 2011 Free Software Foundation, Inc.
|
||||
*
|
||||
* 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/>.
|
||||
* See the COPYING file in the main directory for details.
|
||||
*/
|
||||
|
||||
#include "radioVector.h"
|
||||
|
||||
radioVector::radioVector(const signalVector& wVector, GSM::Time& wTime)
|
||||
: signalVector(wVector), mTime(wTime)
|
||||
{
|
||||
}
|
||||
|
||||
GSM::Time radioVector::time() const
|
||||
{
|
||||
return mTime;
|
||||
}
|
||||
|
||||
void radioVector::setTime(const GSM::Time& wTime)
|
||||
{
|
||||
mTime = wTime;
|
||||
}
|
||||
|
||||
bool radioVector::operator>(const radioVector& other) const
|
||||
{
|
||||
return mTime > other.mTime;
|
||||
}
|
||||
|
||||
unsigned VectorFIFO::size()
|
||||
{
|
||||
return mQ.size();
|
||||
}
|
||||
|
||||
void VectorFIFO::put(radioVector *ptr)
|
||||
{
|
||||
mQ.put((void*) ptr);
|
||||
}
|
||||
|
||||
radioVector *VectorFIFO::get()
|
||||
{
|
||||
return (radioVector*) mQ.get();
|
||||
}
|
||||
|
||||
GSM::Time VectorQueue::nextTime() const
|
||||
{
|
||||
GSM::Time retVal;
|
||||
mLock.lock();
|
||||
|
||||
while (mQ.size()==0)
|
||||
mWriteSignal.wait(mLock);
|
||||
|
||||
retVal = mQ.top()->time();
|
||||
mLock.unlock();
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
radioVector* VectorQueue::getStaleBurst(const GSM::Time& targTime)
|
||||
{
|
||||
mLock.lock();
|
||||
if ((mQ.size()==0)) {
|
||||
mLock.unlock();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (mQ.top()->time() < targTime) {
|
||||
radioVector* retVal = mQ.top();
|
||||
mQ.pop();
|
||||
mLock.unlock();
|
||||
return retVal;
|
||||
}
|
||||
mLock.unlock();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
radioVector* VectorQueue::getCurrentBurst(const GSM::Time& targTime)
|
||||
{
|
||||
mLock.lock();
|
||||
if ((mQ.size()==0)) {
|
||||
mLock.unlock();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (mQ.top()->time() == targTime) {
|
||||
radioVector* retVal = mQ.top();
|
||||
mQ.pop();
|
||||
mLock.unlock();
|
||||
return retVal;
|
||||
}
|
||||
mLock.unlock();
|
||||
|
||||
return NULL;
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Written by Thomas Tsou <ttsou@vt.edu>
|
||||
* Based on code by Harvind S Samra <hssamra@kestrelsp.com>
|
||||
*
|
||||
* Copyright 2011 Free Software Foundation, Inc.
|
||||
*
|
||||
* 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/>.
|
||||
* See the COPYING file in the main directory for details.
|
||||
*/
|
||||
|
||||
#ifndef RADIOVECTOR_H
|
||||
#define RADIOVECTOR_H
|
||||
|
||||
#include "sigProcLib.h"
|
||||
#include "GSMCommon.h"
|
||||
|
||||
class radioVector : public signalVector {
|
||||
public:
|
||||
radioVector(const signalVector& wVector, GSM::Time& wTime);
|
||||
GSM::Time time() const;
|
||||
void setTime(const GSM::Time& wTime);
|
||||
bool operator>(const radioVector& other) const;
|
||||
|
||||
private:
|
||||
GSM::Time mTime;
|
||||
};
|
||||
|
||||
class VectorFIFO {
|
||||
public:
|
||||
unsigned size();
|
||||
void put(radioVector *ptr);
|
||||
radioVector *get();
|
||||
|
||||
private:
|
||||
PointerFIFO mQ;
|
||||
};
|
||||
|
||||
class VectorQueue : public InterthreadPriorityQueue<radioVector> {
|
||||
public:
|
||||
GSM::Time nextTime() const;
|
||||
radioVector* getStaleBurst(const GSM::Time& targTime);
|
||||
radioVector* getCurrentBurst(const GSM::Time& targTime);
|
||||
};
|
||||
|
||||
#endif /* RADIOVECTOR_H */
|
|
@ -22,7 +22,8 @@
|
|||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SIGPROCLIB_H
|
||||
#define SIGPROCLIB_H
|
||||
|
||||
#include "Vector.h"
|
||||
#include "Complex.h"
|
||||
|
@ -390,3 +391,5 @@ SoftVector *equalizeBurst(signalVector &rxBurst,
|
|||
int samplesPerSymbol,
|
||||
signalVector &w,
|
||||
signalVector &b);
|
||||
|
||||
#endif /* SIGPROCLIB_H */
|
||||
|
|
Reference in New Issue