fixed limesdr antenna not set on startup and worked around limesuite bug

This commit is contained in:
AlexandreRouma 2022-07-16 02:36:03 +02:00
parent 25f09a355e
commit 277d399e48

View File

@ -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);