From 705a34832605f100686ba1386461cdd482290952 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Fri, 13 Sep 2019 16:51:48 +0200 Subject: LMSDevice: Return previous txGain/rxGain if setting value failed Change-Id: I11e853e11bec99fc88e81642f9b2cd87d5815398 --- Transceiver52M/device/lms/LMSDevice.cpp | 12 ++++++++---- Transceiver52M/device/lms/LMSDevice.h | 4 ++-- 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 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 **/ -- cgit v1.2.3