Skip to content

Commit

Permalink
potential fix for #1361
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreRouma committed Apr 8, 2024
1 parent db1682a commit d12021f
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions source_modules/soapy_source/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,15 @@ class SoapyModule : public ModuleManager::Instance {

private:
void refresh() {
devList = SoapySDR::Device::enumerate();
txtDevList = "";
try {
devList = SoapySDR::Device::enumerate();
}
catch (const std::exception& e) {
flog::error("Could not list devices: {}", e.what());
return;
}

int i = 0;
for (auto& dev : devList) {
txtDevList += dev["label"] != "" ? dev["label"] : dev["driver"];
Expand Down Expand Up @@ -153,7 +160,14 @@ class SoapyModule : public ModuleManager::Instance {
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);
txtAntennaList = "";
Expand Down Expand Up @@ -307,7 +321,13 @@ class SoapyModule : public ModuleManager::Instance {
return;
}

_this->dev = SoapySDR::Device::make(_this->devArgs);
try {
_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);

Expand Down

0 comments on commit d12021f

Please sign in to comment.