aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <vyanitskiy@sysmocom.de>2020-06-29 17:39:35 +0700
committerpespin <pespin@sysmocom.de>2020-06-29 12:43:06 +0000
commit68d8db4d8c2b1b7951b76439699fc1e07bb472cb (patch)
tree201c9c2b101056a663a623151a20085cb20ff63b
parent58d80a014e01cb9d76724c66e1875308027f0470 (diff)
UHDDevice: catch LookupError/IndexError in set{Rx,Tx}Antenna()
Currently configuring 3 channels in multi-ARFCN mode makes the process crash during the Rx/Tx antenna configuration due to uncaught UHD specific LookupError/IndexError exceptions: terminate called after throwing an instance of 'uhd::index_error' what(): LookupError: IndexError: multi_usrp: TX channel 2 out of range for configured TX frontends Let's catch them and terminate gracefully. Change-Id: If66305f2787c6292375e4bfbd60c1d3d764cffd4 Related: OS#4636
-rw-r--r--Transceiver52M/device/uhd/UHDDevice.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/Transceiver52M/device/uhd/UHDDevice.cpp b/Transceiver52M/device/uhd/UHDDevice.cpp
index 0eb79fc..854ed2e 100644
--- a/Transceiver52M/device/uhd/UHDDevice.cpp
+++ b/Transceiver52M/device/uhd/UHDDevice.cpp
@@ -1097,7 +1097,14 @@ bool uhd_device::setRxAntenna(const std::string &ant, size_t chan)
return false;
}
- avail = usrp_dev->get_rx_antennas(chan);
+ /* UHD may throw a LookupError/IndexError here (see OS#4636) */
+ try {
+ avail = usrp_dev->get_rx_antennas(chan);
+ } catch (const uhd::index_error &e) {
+ LOGC(DDEV, ALERT) << "UHD Error: " << e.what();
+ return false;
+ }
+
if (std::find(avail.begin(), avail.end(), ant) == avail.end()) {
LOGC(DDEV, ALERT) << "Requested non-existent Rx antenna " << ant << " on channel " << chan;
LOGC(DDEV, INFO) << "Available Rx antennas: ";
@@ -1133,7 +1140,14 @@ bool uhd_device::setTxAntenna(const std::string &ant, size_t chan)
return false;
}
- avail = usrp_dev->get_tx_antennas(chan);
+ /* UHD may throw a LookupError/IndexError here (see OS#4636) */
+ try {
+ avail = usrp_dev->get_tx_antennas(chan);
+ } catch (const uhd::index_error &e) {
+ LOGC(DDEV, ALERT) << "UHD Error: " << e.what();
+ return false;
+ }
+
if (std::find(avail.begin(), avail.end(), ant) == avail.end()) {
LOGC(DDEV, ALERT) << "Requested non-existent Tx antenna " << ant << " on channel " << chan;
LOGC(DDEV, INFO) << "Available Tx antennas: ";