aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2019-09-13 16:51:48 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2019-09-13 17:33:14 +0200
commit705a34832605f100686ba1386461cdd482290952 (patch)
treec27585fd431369d10d4238de4582431cf7b4fc72
parent331c88ae82d730991a8d687df9542c6a1e2f8b29 (diff)
LMSDevice: Return previous txGain/rxGain if setting value failed
-rw-r--r--Transceiver52M/device/lms/LMSDevice.cpp12
-rw-r--r--Transceiver52M/device/lms/LMSDevice.h4
2 files changed, 10 insertions, 6 deletions
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..71a706c 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 **/