diff --git a/source_modules/limesdr_source/src/main.cpp b/source_modules/limesdr_source/src/main.cpp index 0d083eae..b7306d14 100644 --- a/source_modules/limesdr_source/src/main.cpp +++ b/source_modules/limesdr_source/src/main.cpp @@ -323,12 +323,20 @@ private: // Open device _this->openDev = NULL; LMS_Open(&_this->openDev, _this->devList[_this->devId], NULL); - LMS_Init(_this->openDev); + int err = LMS_Init(_this->openDev); + + // On open fail, retry (work around for LimeSuite bug) + if (err) { + LMS_Close(_this->openDev); + LMS_Open(&_this->openDev, _this->devList[_this->devId], NULL); + LMS_Init(_this->openDev); + } spdlog::warn("Channel count: {0}", LMS_GetNumChannels(_this->openDev, false)); // Set options LMS_EnableChannel(_this->openDev, false, _this->chanId, true); + LMS_SetAntenna(_this->openDev, false, _this->chanId, _this->antennaId); LMS_SetSampleRate(_this->openDev, _this->sampleRate, 0); LMS_SetLOFrequency(_this->openDev, false, _this->chanId, _this->freq); LMS_SetGaindB(_this->openDev, false, _this->chanId, _this->gain); @@ -364,6 +372,7 @@ private: LMS_StopStream(&_this->devStream); LMS_DestroyStream(_this->openDev, &_this->devStream); + LMS_EnableChannel(_this->openDev, false, _this->chanId, false); LMS_Close(_this->openDev);