potential fix for #1361

This commit is contained in:
AlexandreRouma 2024-04-08 16:37:03 +02:00
parent db1682a2ac
commit d12021fc2f

View File

@ -81,8 +81,15 @@ public:
private: private:
void refresh() { void refresh() {
devList = SoapySDR::Device::enumerate();
txtDevList = ""; txtDevList = "";
try {
devList = SoapySDR::Device::enumerate();
}
catch (const std::exception& e) {
flog::error("Could not list devices: {}", e.what());
return;
}
int i = 0; int i = 0;
for (auto& dev : devList) { for (auto& dev : devList) {
txtDevList += dev["label"] != "" ? dev["label"] : dev["driver"]; txtDevList += dev["label"] != "" ? dev["label"] : dev["driver"];
@ -153,7 +160,14 @@ private:
return; return;
} }
SoapySDR::Device* dev = SoapySDR::Device::make(devArgs); SoapySDR::Device* dev = NULL;
try {
dev = SoapySDR::Device::make(devArgs);
}
catch (const std::exception& e) {
flog::error("Could not open device: {}", e.what());
return;
}
antennaList = dev->listAntennas(SOAPY_SDR_RX, channelId); antennaList = dev->listAntennas(SOAPY_SDR_RX, channelId);
txtAntennaList = ""; txtAntennaList = "";
@ -307,7 +321,13 @@ private:
return; return;
} }
try {
_this->dev = SoapySDR::Device::make(_this->devArgs); _this->dev = SoapySDR::Device::make(_this->devArgs);
}
catch (const std::exception& e) {
flog::error("Failed to open device: {}", e.what());
return;
}
_this->dev->setSampleRate(SOAPY_SDR_RX, _this->channelId, _this->sampleRate); _this->dev->setSampleRate(SOAPY_SDR_RX, _this->channelId, _this->sampleRate);