aboutsummaryrefslogtreecommitdiffstats
path: root/Transceiver52M
diff options
context:
space:
mode:
Diffstat (limited to 'Transceiver52M')
-rw-r--r--Transceiver52M/Transceiver.cpp24
-rw-r--r--Transceiver52M/Transceiver.h2
-rw-r--r--Transceiver52M/device/common/radioDevice.h12
-rw-r--r--Transceiver52M/device/lms/LMSDevice.cpp12
-rw-r--r--Transceiver52M/device/lms/LMSDevice.h9
-rw-r--r--Transceiver52M/device/uhd/UHDDevice.cpp20
-rw-r--r--Transceiver52M/device/uhd/UHDDevice.h1
-rw-r--r--Transceiver52M/device/usrp1/USRPDevice.cpp11
-rw-r--r--Transceiver52M/device/usrp1/USRPDevice.h4
-rw-r--r--Transceiver52M/osmo-trx.cpp10
-rw-r--r--Transceiver52M/radioInterface.cpp53
-rw-r--r--Transceiver52M/radioInterface.h23
-rw-r--r--Transceiver52M/radioInterfaceMulti.cpp39
-rw-r--r--Transceiver52M/radioInterfaceResamp.cpp14
14 files changed, 142 insertions, 92 deletions
diff --git a/Transceiver52M/Transceiver.cpp b/Transceiver52M/Transceiver.cpp
index 3901997..2f4018c 100644
--- a/Transceiver52M/Transceiver.cpp
+++ b/Transceiver52M/Transceiver.cpp
@@ -587,9 +587,11 @@ void writeToFile(radioVector *radio_burst, size_t chan)
/*
* Pull bursts from the FIFO and handle according to the slot
* and burst correlation type. Equalzation is currently disabled.
- * returns true on success (bi filled), false on error (bi content undefined).
+ * returns 0 on success (bi filled), negative on error (bi content undefined):
+ * -ENOENT: timeslot is off (fn and tn in bi are filled),
+ * -EIO: read error
*/
-bool Transceiver::pullRadioVector(size_t chan, struct trx_ul_burst_ind *bi)
+int Transceiver::pullRadioVector(size_t chan, struct trx_ul_burst_ind *bi)
{
int rc;
struct estim_burst_params ebp;
@@ -605,7 +607,7 @@ bool Transceiver::pullRadioVector(size_t chan, struct trx_ul_burst_ind *bi)
radioVector *radio_burst = mReceiveFIFO[chan]->read();
if (!radio_burst) {
LOGCHAN(chan, DMAIN, ERROR) << "ReceiveFIFO->read() returned no burst";
- return false;
+ return -EIO;
}
/* Set time and determine correlation type */
@@ -635,7 +637,7 @@ bool Transceiver::pullRadioVector(size_t chan, struct trx_ul_burst_ind *bi)
* Not even power level or noise calculation. */
if (type == OFF) {
delete radio_burst;
- return false;
+ return -ENOENT;
}
/* Select the diversity channel with highest energy */
@@ -702,12 +704,12 @@ bool Transceiver::pullRadioVector(size_t chan, struct trx_ul_burst_ind *bi)
delete rxBurst;
delete radio_burst;
- return true;
+ return 0;
ret_idle:
bi->idle = true;
delete radio_burst;
- return true;
+ return 0;
}
void Transceiver::reset()
@@ -1032,9 +1034,15 @@ void Transceiver::logRxBurst(size_t chan, const struct trx_ul_burst_ind *bi)
bool Transceiver::driveReceiveFIFO(size_t chan)
{
struct trx_ul_burst_ind bi;
+ int rc;
- if (!pullRadioVector(chan, &bi))
- return false;
+ if ((rc = pullRadioVector(chan, &bi)) < 0) {
+ if (rc == -ENOENT) { /* timeslot off, continue processing */
+ LOGCHAN(chan, DMAIN, DEBUG) << unsigned(bi.tn) << ":" << bi.fn << " timeslot is off";
+ return true;
+ }
+ return false; /* other errors: we want to stop the process */
+ }
if (!bi.idle)
logRxBurst(chan, &bi);
diff --git a/Transceiver52M/Transceiver.h b/Transceiver52M/Transceiver.h
index 0d09854..30f6a60 100644
--- a/Transceiver52M/Transceiver.h
+++ b/Transceiver52M/Transceiver.h
@@ -182,7 +182,7 @@ private:
void pushRadioVector(GSM::Time &nowTime);
/** Pull and demodulate a burst from the receive FIFO */
- bool pullRadioVector(size_t chan, struct trx_ul_burst_ind *ind);
+ int pullRadioVector(size_t chan, struct trx_ul_burst_ind *ind);
/** Set modulus for specific timeslot */
void setModulus(size_t timeslot, size_t chan);
diff --git a/Transceiver52M/device/common/radioDevice.h b/Transceiver52M/device/common/radioDevice.h
index b4928f2..d27a52c 100644
--- a/Transceiver52M/device/common/radioDevice.h
+++ b/Transceiver52M/device/common/radioDevice.h
@@ -131,6 +131,9 @@ class RadioDevice {
/** sets the transmit chan gain, returns the gain setting **/
virtual double setTxGain(double dB, size_t chan = 0) = 0;
+ /** get transmit gain */
+ virtual double getTxGain(size_t chan = 0) = 0;
+
/** return maximum Tx Gain **/
virtual double maxTxGain(void) = 0;
@@ -168,12 +171,17 @@ class RadioDevice {
std::vector<std::string> tx_paths, rx_paths;
std::vector<struct device_counters> m_ctr;
- RadioDevice(size_t tx_sps, size_t rx_sps, InterfaceType type, size_t chans, double offset,
+ RadioDevice(size_t tx_sps, size_t rx_sps, InterfaceType type, size_t chan_num, double offset,
const std::vector<std::string>& tx_paths,
const std::vector<std::string>& rx_paths):
- tx_sps(tx_sps), rx_sps(rx_sps), iface(type), chans(chans), lo_offset(offset),
+ tx_sps(tx_sps), rx_sps(rx_sps), iface(type), chans(chan_num), lo_offset(offset),
tx_paths(tx_paths), rx_paths(rx_paths)
{
+ if (iface == MULTI_ARFCN) {
+ LOGC(DDEV, INFO) << "Multi-ARFCN: "<< chan_num << " logical chans -> 1 physical chans";
+ chans = 1;
+ }
+
m_ctr.resize(chans);
for (size_t i = 0; i < chans; i++) {
memset(&m_ctr[i], 0, sizeof(m_ctr[i]));
diff --git a/Transceiver52M/device/lms/LMSDevice.cpp b/Transceiver52M/device/lms/LMSDevice.cpp
index b7cb31d..feeb646 100644
--- a/Transceiver52M/device/lms/LMSDevice.cpp
+++ b/Transceiver52M/device/lms/LMSDevice.cpp
@@ -55,6 +55,8 @@ LMSDevice::LMSDevice(size_t tx_sps, size_t rx_sps, InterfaceType iface, size_t c
m_lms_stream_rx.resize(chans);
m_lms_stream_tx.resize(chans);
+ rx_gains.resize(chans);
+ tx_gains.resize(chans);
rx_buffers.resize(chans);
}
@@ -412,8 +414,9 @@ double LMSDevice::setTxGain(double dB, size_t chan)
if (LMS_SetGaindB(m_lms_dev, LMS_CH_TX, chan, dB) < 0)
LOGCHAN(chan, DDEV, ERR) << "Error setting TX gain to " << dB << " dB";
-
- return dB;
+ else
+ tx_gains[chan] = dB;
+ return tx_gains[chan];
}
double LMSDevice::setRxGain(double dB, size_t chan)
@@ -427,8 +430,9 @@ double LMSDevice::setRxGain(double dB, size_t chan)
if (LMS_SetGaindB(m_lms_dev, LMS_CH_RX, chan, dB) < 0)
LOGCHAN(chan, DDEV, ERR) << "Error setting RX gain to " << dB << " dB";
-
- return dB;
+ else
+ rx_gains[chan] = dB;
+ return rx_gains[chan];
}
void LMSDevice::log_ant_list(bool dir_tx, size_t chan, std::ostringstream& os)
diff --git a/Transceiver52M/device/lms/LMSDevice.h b/Transceiver52M/device/lms/LMSDevice.h
index ab45b08..1464c53 100644
--- a/Transceiver52M/device/lms/LMSDevice.h
+++ b/Transceiver52M/device/lms/LMSDevice.h
@@ -58,7 +58,7 @@ private:
TIMESTAMP ts_initial, ts_offset;
- double rxGain;
+ std::vector<double> tx_gains, rx_gains;
double maxTxGainClamp;
bool do_calib(size_t chan);
@@ -150,7 +150,7 @@ public:
/** get the current receive gain */
double getRxGain(size_t chan = 0) {
- return rxGain;
+ return rx_gains[chan];
}
/** return maximum Rx Gain **/
@@ -162,6 +162,11 @@ public:
/** sets the transmit chan gain, returns the gain setting **/
double setTxGain(double dB, size_t chan = 0);
+ /** get transmit gain */
+ double getTxGain(size_t chan = 0) {
+ return tx_gains[chan];
+ }
+
/** return maximum Tx Gain **/
double maxTxGain(void);
diff --git a/Transceiver52M/device/uhd/UHDDevice.cpp b/Transceiver52M/device/uhd/UHDDevice.cpp
index 5b38df4..604bb44 100644
--- a/Transceiver52M/device/uhd/UHDDevice.cpp
+++ b/Transceiver52M/device/uhd/UHDDevice.cpp
@@ -247,9 +247,6 @@ void uhd_device::set_rates()
double uhd_device::setTxGain(double db, size_t chan)
{
- if (iface == MULTI_ARFCN)
- chan = 0;
-
if (chan >= tx_gains.size()) {
LOGC(DDEV, ALERT) << "Requested non-existent channel" << chan;
return 0.0f;
@@ -281,9 +278,6 @@ double uhd_device::setTxGain(double db, size_t chan)
double uhd_device::setRxGain(double db, size_t chan)
{
- if (iface == MULTI_ARFCN)
- chan = 0;
-
if (chan >= rx_gains.size()) {
LOGC(DDEV, ALERT) << "Requested non-existent channel " << chan;
return 0.0f;
@@ -299,9 +293,6 @@ double uhd_device::setRxGain(double db, size_t chan)
double uhd_device::getRxGain(size_t chan)
{
- if (iface == MULTI_ARFCN)
- chan = 0;
-
if (chan >= rx_gains.size()) {
LOGC(DDEV, ALERT) << "Requested non-existent channel " << chan;
return 0.0f;
@@ -310,6 +301,16 @@ double uhd_device::getRxGain(size_t chan)
return rx_gains[chan];
}
+double uhd_device::getTxGain(size_t chan)
+{
+ if (chan >= tx_gains.size()) {
+ LOGC(DDEV, ALERT) << "Requested non-existent channel " << chan;
+ return 0.0f;
+ }
+
+ return tx_gains[chan];
+}
+
/*
Parse the UHD device tree and mboard name to find out what device we're
dealing with. We need the window type so that the transceiver knows how to
@@ -381,7 +382,6 @@ void uhd_device::set_channels(bool swap)
if (dev_type != B200 && dev_type != B210)
throw std::invalid_argument("Device does not support MCBTS");
dev_type = B2XX_MCBTS;
- chans = 1;
}
if (chans > dev_param_map.at(dev_key(dev_type, tx_sps, rx_sps)).channels)
diff --git a/Transceiver52M/device/uhd/UHDDevice.h b/Transceiver52M/device/uhd/UHDDevice.h
index 944578a..44f7ebb 100644
--- a/Transceiver52M/device/uhd/UHDDevice.h
+++ b/Transceiver52M/device/uhd/UHDDevice.h
@@ -96,6 +96,7 @@ public:
double minRxGain(void) { return rx_gain_min; }
double setTxGain(double db, size_t chan);
+ double getTxGain(size_t chan = 0);
double maxTxGain(void) { return tx_gain_max; }
double minTxGain(void) { return tx_gain_min; }
diff --git a/Transceiver52M/device/usrp1/USRPDevice.cpp b/Transceiver52M/device/usrp1/USRPDevice.cpp
index 63debee..03a4f80 100644
--- a/Transceiver52M/device/usrp1/USRPDevice.cpp
+++ b/Transceiver52M/device/usrp1/USRPDevice.cpp
@@ -71,6 +71,7 @@ USRPDevice::USRPDevice(size_t tx_sps, size_t rx_sps, InterfaceType iface,
decimRate = (unsigned int) round(masterClockRate/((GSMRATE) * (double) tx_sps));
actualSampleRate = masterClockRate/decimRate;
rxGain = 0;
+ txGain = 0;
/*
* Undetermined delay b/w ping response timestamp and true
@@ -279,10 +280,11 @@ double USRPDevice::setTxGain(double dB, size_t chan)
if (!m_dbTx->set_gain(dB))
LOGC(DDEV, ERR) << "Error setting TX gain";
-
+ else
+ txGain = dB;
writeLock.unlock();
- return dB;
+ return txGain;
}
@@ -305,10 +307,11 @@ double USRPDevice::setRxGain(double dB, size_t chan)
if (!m_dbRx->set_gain(dB))
LOGC(DDEV, ERR) << "Error setting RX gain";
-
+ else
+ rxGain = dB;
writeLock.unlock();
- return dB;
+ return rxGain;
}
bool USRPDevice::setRxAntenna(const std::string &ant, size_t chan)
diff --git a/Transceiver52M/device/usrp1/USRPDevice.h b/Transceiver52M/device/usrp1/USRPDevice.h
index 4123c7d..bb70648 100644
--- a/Transceiver52M/device/usrp1/USRPDevice.h
+++ b/Transceiver52M/device/usrp1/USRPDevice.h
@@ -80,6 +80,7 @@ private:
unsigned long lastPktTimestamp;
double rxGain;
+ double txGain;
#ifdef SWLOOPBACK
short loopbackBuffer[1000000];
@@ -170,6 +171,9 @@ private:
/** sets the transmit chan gain, returns the gain setting **/
double setTxGain(double dB, size_t chan = 0);
+ /** get transmit gain */
+ double getTxGain(size_t chan = 0) { return txGain; }
+
/** return maximum Tx Gain **/
double maxTxGain(void);
diff --git a/Transceiver52M/osmo-trx.cpp b/Transceiver52M/osmo-trx.cpp
index ab0b631..6b83988 100644
--- a/Transceiver52M/osmo-trx.cpp
+++ b/Transceiver52M/osmo-trx.cpp
@@ -571,14 +571,16 @@ int main(int argc, char *argv[])
#endif
#endif
- if (!log_mutex_init()) {
- fprintf(stderr, "Failed to initialize log mutex!\n");
- exit(2);
- }
+#ifndef HAVE_ATOMIC_OPS
+#pragma message ("Built without atomic operation support. Using Mutex, it may affect performance!")
+ printf("Built without atomic operation support. Using Mutex, it may affect performance!\n");
+#endif
+
convolve_init();
convert_init();
osmo_init_logging2(tall_trx_ctx, &log_info);
+ log_enable_multithread();
osmo_stats_init(tall_trx_ctx);
vty_init(&g_vty_info);
ctrl_vty_init(tall_trx_ctx);
diff --git a/Transceiver52M/radioInterface.cpp b/Transceiver52M/radioInterface.cpp
index 0d33f22..fbcacf1 100644
--- a/Transceiver52M/radioInterface.cpp
+++ b/Transceiver52M/radioInterface.cpp
@@ -24,6 +24,7 @@
#include "radioInterface.h"
#include "Resampler.h"
#include <Logger.h>
+#include <Threads.h>
extern "C" {
#include "convert.h"
@@ -32,10 +33,10 @@ extern "C" {
#define CHUNK 625
#define NUMCHUNKS 4
-RadioInterface::RadioInterface(RadioDevice *wRadio, size_t tx_sps,
+RadioInterface::RadioInterface(RadioDevice *wDevice, size_t tx_sps,
size_t rx_sps, size_t chans,
int wReceiveOffset, GSM::Time wStartTime)
- : mRadio(wRadio), mSPSTx(tx_sps), mSPSRx(rx_sps), mChans(chans),
+ : mDevice(wDevice), mSPSTx(tx_sps), mSPSRx(rx_sps), mChans(chans),
underrun(false), overrun(false), writeTimestamp(0), readTimestamp(0),
receiveOffset(wReceiveOffset), mOn(false)
{
@@ -93,11 +94,11 @@ void RadioInterface::close()
}
double RadioInterface::fullScaleInputValue(void) {
- return mRadio->fullScaleInputValue();
+ return mDevice->fullScaleInputValue();
}
double RadioInterface::fullScaleOutputValue(void) {
- return mRadio->fullScaleOutputValue();
+ return mDevice->fullScaleOutputValue();
}
int RadioInterface::setPowerAttenuation(int atten, size_t chan)
@@ -112,8 +113,8 @@ int RadioInterface::setPowerAttenuation(int atten, size_t chan)
if (atten < 0.0)
atten = 0.0;
- rfGain = mRadio->setTxGain(mRadio->maxTxGain() - (double) atten, chan);
- digAtten = (double) atten - mRadio->maxTxGain() + rfGain;
+ rfGain = setTxGain(mDevice->maxTxGain() - (double) atten, chan);
+ digAtten = (double) atten - mDevice->maxTxGain() + rfGain;
if (digAtten < 1.0)
powerScaling[chan] = 1.0;
@@ -148,12 +149,12 @@ int RadioInterface::unRadioifyVector(signalVector *newVector, size_t chan)
bool RadioInterface::tuneTx(double freq, size_t chan)
{
- return mRadio->setTxFreq(freq, chan);
+ return mDevice->setTxFreq(freq, chan);
}
bool RadioInterface::tuneRx(double freq, size_t chan)
{
- return mRadio->setRxFreq(freq, chan);
+ return mDevice->setRxFreq(freq, chan);
}
/** synchronization thread loop */
@@ -169,7 +170,7 @@ void *AlignRadioServiceLoopAdapter(RadioInterface *radioInterface)
}
void RadioInterface::alignRadio() {
- mRadio->updateAlignment(writeTimestamp+ (TIMESTAMP) 10000);
+ mDevice->updateAlignment(writeTimestamp+ (TIMESTAMP) 10000);
}
bool RadioInterface::start()
@@ -178,12 +179,12 @@ bool RadioInterface::start()
return true;
LOG(INFO) << "Starting radio device";
- if (mRadio->requiresRadioAlign())
+ if (mDevice->requiresRadioAlign())
mAlignRadioServiceLoopThread.start(
(void * (*)(void*))AlignRadioServiceLoopAdapter,
(void*)this);
- if (!mRadio->start())
+ if (!mDevice->start())
return false;
for (size_t i = 0; i < mChans; i++) {
@@ -191,11 +192,11 @@ bool RadioInterface::start()
recvBuffer[i]->reset();
}
- writeTimestamp = mRadio->initialWriteTimestamp();
- readTimestamp = mRadio->initialReadTimestamp();
+ writeTimestamp = mDevice->initialWriteTimestamp();
+ readTimestamp = mDevice->initialReadTimestamp();
- mRadio->updateAlignment(writeTimestamp-10000);
- mRadio->updateAlignment(writeTimestamp-10000);
+ mDevice->updateAlignment(writeTimestamp-10000);
+ mDevice->updateAlignment(writeTimestamp-10000);
mOn = true;
LOG(INFO) << "Radio started";
@@ -211,7 +212,7 @@ bool RadioInterface::start()
*/
bool RadioInterface::stop()
{
- if (!mOn || !mRadio->stop())
+ if (!mOn || !mDevice->stop())
return false;
mOn = false;
@@ -288,9 +289,9 @@ int RadioInterface::driveReceiveRadio()
bool RadioInterface::isUnderrun()
{
- bool retVal = underrun;
- underrun = false;
-
+ bool retVal;
+ /* atomically get previous value of "underrun" and set the var to false */
+ retVal = osmo_trx_sync_fetch_and_and(&underrun, false);
return retVal;
}
@@ -304,12 +305,12 @@ VectorFIFO* RadioInterface::receiveFIFO(size_t chan)
double RadioInterface::setRxGain(double dB, size_t chan)
{
- return mRadio->setRxGain(dB, chan);
+ return mDevice->setRxGain(dB, chan);
}
-double RadioInterface::getRxGain(size_t chan)
+double RadioInterface::setTxGain(double dB, size_t chan)
{
- return mRadio->getRxGain(chan);
+ return mDevice->setTxGain(dB, chan);
}
/* Receive a timestamped chunk from the device */
@@ -323,7 +324,7 @@ int RadioInterface::pullBuffer()
return -1;
/* Outer buffer access size is fixed */
- numRecv = mRadio->readSamples(convertRecvBuffer,
+ numRecv = mDevice->readSamples(convertRecvBuffer,
segmentLen,
&overrun,
readTimestamp,
@@ -340,7 +341,7 @@ int RadioInterface::pullBuffer()
segmentLen * 2);
}
- underrun |= local_underrun;
+ osmo_trx_sync_or_and_fetch(&underrun, local_underrun);
readTimestamp += numRecv;
return 0;
}
@@ -362,11 +363,11 @@ bool RadioInterface::pushBuffer()
}
/* Send the all samples in the send buffer */
- numSent = mRadio->writeSamples(convertSendBuffer,
+ numSent = mDevice->writeSamples(convertSendBuffer,
segmentLen,
&local_underrun,
writeTimestamp);
- underrun |= local_underrun;
+ osmo_trx_sync_or_and_fetch(&underrun, local_underrun);
writeTimestamp += numSent;
return true;
diff --git a/Transceiver52M/radioInterface.h b/Transceiver52M/radioInterface.h
index dcfb67f..d72fb69 100644
--- a/Transceiver52M/radioInterface.h
+++ b/Transceiver52M/radioInterface.h
@@ -36,7 +36,7 @@ protected:
std::vector<VectorFIFO> mReceiveFIFO; ///< FIFO that holds receive bursts
- RadioDevice *mRadio; ///< the USRP object
+ RadioDevice *mDevice; ///< the USRP object
size_t mSPSTx;
size_t mSPSRx;
@@ -48,7 +48,7 @@ protected:
std::vector<short *> convertRecvBuffer;
std::vector<short *> convertSendBuffer;
std::vector<float> powerScaling;
- bool underrun; ///< indicates writes to USRP are too slow
+ int underrun; ///< indicates writes to USRP are too slow
bool overrun; ///< indicates reads from USRP are too slow
TIMESTAMP writeTimestamp; ///< sample timestamp of next packet written to USRP
TIMESTAMP readTimestamp; ///< sample timestamp of next packet read from USRP
@@ -84,7 +84,7 @@ public:
virtual void close();
/** constructor */
- RadioInterface(RadioDevice* wRadio, size_t tx_sps, size_t rx_sps,
+ RadioInterface(RadioDevice* wDevice, size_t tx_sps, size_t rx_sps,
size_t chans = 1, int receiveOffset = 3,
GSM::Time wStartTime = GSM::Time(0));
@@ -107,10 +107,7 @@ public:
virtual bool tuneRx(double freq, size_t chan = 0);
/** set receive gain */
- double setRxGain(double dB, size_t chan = 0);
-
- /** get receive gain */
- double getRxGain(size_t chan = 0);
+ virtual double setRxGain(double dB, size_t chan = 0);
/** drive transmission of GSM bursts */
void driveTransmitRadio(std::vector<signalVector *> &bursts,
@@ -128,15 +125,18 @@ public:
double fullScaleOutputValue();
/** get transport window type of attached device */
- enum RadioDevice::TxWindowType getWindowType() { return mRadio->getWindowType(); }
+ enum RadioDevice::TxWindowType getWindowType() { return mDevice->getWindowType(); }
/** Minimum latency that the device can achieve */
- GSM::Time minLatency() { return mRadio->minLatency(); }
+ GSM::Time minLatency() { return mDevice->minLatency(); }
protected:
/** drive synchronization of Tx/Rx of USRP */
void alignRadio();
+ /** set transmit gain */
+ virtual double setTxGain(double dB, size_t chan = 0);
+
friend void *AlignRadioServiceLoopAdapter(RadioInterface*);
};
@@ -149,7 +149,7 @@ private:
int pullBuffer();
public:
- RadioInterfaceResamp(RadioDevice* wRadio, size_t tx_sps, size_t rx_sps);
+ RadioInterfaceResamp(RadioDevice* wDevice, size_t tx_sps, size_t rx_sps);
~RadioInterfaceResamp();
bool init(int type);
@@ -160,6 +160,7 @@ class RadioInterfaceMulti : public RadioInterface {
private:
bool pushBuffer();
int pullBuffer();
+ virtual double setTxGain(double dB, size_t chan);
signalVector *outerSendBuffer;
signalVector *outerRecvBuffer;
@@ -181,5 +182,5 @@ public:
bool tuneTx(double freq, size_t chan);
bool tuneRx(double freq, size_t chan);
- double setRxGain(double dB, size_t chan);
+ virtual double setRxGain(double dB, size_t chan);
};
diff --git a/Transceiver52M/radioInterfaceMulti.cpp b/Transceiver52M/radioInterfaceMulti.cpp
index 0208e82..668305c 100644
--- a/Transceiver52M/radioInterfaceMulti.cpp
+++ b/Transceiver52M/radioInterfaceMulti.cpp
@@ -238,7 +238,7 @@ int RadioInterfaceMulti::pullBuffer()
return -1;
/* Outer buffer access size is fixed */
- num = mRadio->readSamples(convertRecvBuffer,
+ num = mDevice->readSamples(convertRecvBuffer,
outerRecvBuffer->size(),
&overrun,
readTimestamp,
@@ -251,7 +251,7 @@ int RadioInterfaceMulti::pullBuffer()
convert_short_float((float *) outerRecvBuffer->begin(),
convertRecvBuffer[0], 2 * outerRecvBuffer->size());
- underrun |= local_underrun;
+ osmo_trx_sync_or_and_fetch(&underrun, local_underrun);
readTimestamp += num;
channelizer->rotate((float *) outerRecvBuffer->begin(),
@@ -288,7 +288,7 @@ int RadioInterfaceMulti::pullBuffer()
complex *dst = history[lchan]->begin();
float *fsrc = &buf[2 * (cLen - hLen)];
for (i = 0; i < hLen; i++) {
- *dst = complex(fdst[0], fdst[1]);
+ *dst = complex(fsrc[0], fsrc[1]);
fsrc += 2;
dst++;
}
@@ -309,6 +309,7 @@ int RadioInterfaceMulti::pullBuffer()
/* Send a timestamped chunk to the device */
bool RadioInterfaceMulti::pushBuffer()
{
+ bool local_underrun;
if (sendBuffer[0]->getAvailSegments() <= 0)
return false;
@@ -339,14 +340,15 @@ bool RadioInterfaceMulti::pushBuffer()
(float *) outerSendBuffer->begin(),
1.0 / (float) mChans, 2 * outerSendBuffer->size());
- size_t num = mRadio->writeSamples(convertSendBuffer,
+ size_t num = mDevice->writeSamples(convertSendBuffer,
outerSendBuffer->size(),
- &underrun,
+ &local_underrun,
writeTimestamp);
if (num != outerSendBuffer->size()) {
LOG(ALERT) << "Transmit error " << num;
}
+ osmo_trx_sync_or_and_fetch(&underrun, local_underrun);
writeTimestamp += num;
return true;
@@ -368,11 +370,11 @@ bool RadioInterfaceMulti::tuneTx(double freq, size_t chan)
double shift = (double) getFreqShift(mChans);
if (!chan)
- return mRadio->setTxFreq(freq + shift * MCBTS_SPACING);
+ return mDevice->setTxFreq(freq + shift * MCBTS_SPACING);
- double center = mRadio->getTxFreq();
+ double center = mDevice->getTxFreq();
if (!fltcmp(freq, center + (double) (chan - shift) * MCBTS_SPACING)) {
- LOG(NOTICE) << "Channel " << chan << " RF frequency offset is "
+ LOG(NOTICE) << "Channel " << chan << " RF Tx frequency offset is "
<< freq / 1e6 << " MHz";
}
@@ -387,11 +389,11 @@ bool RadioInterfaceMulti::tuneRx(double freq, size_t chan)
double shift = (double) getFreqShift(mChans);
if (!chan)
- return mRadio->setRxFreq(freq + shift * MCBTS_SPACING);
+ return mDevice->setRxFreq(freq + shift * MCBTS_SPACING);
- double center = mRadio->getRxFreq();
+ double center = mDevice->getRxFreq();
if (!fltcmp(freq, center + (double) (chan - shift) * MCBTS_SPACING)) {
- LOG(NOTICE) << "Channel " << chan << " RF frequency offset is "
+ LOG(NOTICE) << "Channel " << chan << " RF Rx frequency offset is "
<< freq / 1e6 << " MHz";
}
@@ -400,8 +402,17 @@ bool RadioInterfaceMulti::tuneRx(double freq, size_t chan)
double RadioInterfaceMulti::setRxGain(double db, size_t chan)
{
- if (!chan)
- return mRadio->setRxGain(db);
+ if (chan == 0)
+ return mDevice->setRxGain(db);
else
- return mRadio->getRxGain();
+ return mDevice->getRxGain();
+}
+
+double RadioInterfaceMulti::setTxGain(double dB, size_t chan)
+{
+ if (chan == 0)
+ return mDevice->setTxGain(dB);
+ else
+ return mDevice->getTxGain();
+
}
diff --git a/Transceiver52M/radioInterfaceResamp.cpp b/Transceiver52M/radioInterfaceResamp.cpp
index e2f69f2..b92432f 100644
--- a/Transceiver52M/radioInterfaceResamp.cpp
+++ b/Transceiver52M/radioInterfaceResamp.cpp
@@ -59,9 +59,9 @@ static size_t resamp_inchunk = 0;
static size_t resamp_outrate = 0;
static size_t resamp_outchunk = 0;
-RadioInterfaceResamp::RadioInterfaceResamp(RadioDevice *wRadio,
+RadioInterfaceResamp::RadioInterfaceResamp(RadioDevice *wDevice,
size_t tx_sps, size_t rx_sps)
- : RadioInterface(wRadio, tx_sps, rx_sps, 1),
+ : RadioInterface(wDevice, tx_sps, rx_sps, 1),
outerSendBuffer(NULL), outerRecvBuffer(NULL)
{
}
@@ -171,7 +171,7 @@ int RadioInterfaceResamp::pullBuffer()
return -1;
/* Outer buffer access size is fixed */
- num_recv = mRadio->readSamples(convertRecvBuffer,
+ num_recv = mDevice->readSamples(convertRecvBuffer,
resamp_outchunk,
&overrun,
readTimestamp,
@@ -184,7 +184,7 @@ int RadioInterfaceResamp::pullBuffer()
convert_short_float((float *) outerRecvBuffer->begin(),
convertRecvBuffer[0], 2 * resamp_outchunk);
- underrun |= local_underrun;
+ osmo_trx_sync_or_and_fetch(&underrun, local_underrun);
readTimestamp += (TIMESTAMP) resamp_outchunk;
/* Write to the end of the inner receive buffer */
@@ -204,6 +204,7 @@ int RadioInterfaceResamp::pullBuffer()
/* Send a timestamped chunk to the device */
bool RadioInterfaceResamp::pushBuffer()
{
+ bool local_underrun;
int rc;
size_t numSent;
@@ -223,14 +224,15 @@ bool RadioInterfaceResamp::pushBuffer()
(float *) outerSendBuffer->begin(),
powerScaling[0], 2 * resamp_outchunk);
- numSent = mRadio->writeSamples(convertSendBuffer,
+ numSent = mDevice->writeSamples(convertSendBuffer,
resamp_outchunk,
- &underrun,
+ &local_underrun,
writeTimestamp);
if (numSent != resamp_outchunk) {
LOG(ALERT) << "Transmit error " << numSent;
}
+ osmo_trx_sync_or_and_fetch(&underrun, local_underrun);
writeTimestamp += resamp_outchunk;
return true;