From 90c26f8c1b318c1f78ae17e96f285fb2cf9ad689 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 23 Mar 2023 22:36:44 +0100 Subject: [PATCH 1/2] Fix crash in LimeSDR start when the device is disconnected This fixes crash when a device which was enumerated on the application startup gets disconnected prior to the attempt to start the radio. The check is done after the existing work around for the LimeSuite bug. The idea is to give it the best possible chance for the radio to start. Possibly, the check needs needs to happen in the second LMS_Open() but ideally this needs to be verified against the original workaround scenario. --- source_modules/limesdr_source/src/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source_modules/limesdr_source/src/main.cpp b/source_modules/limesdr_source/src/main.cpp index 5f7f4508..51eded74 100644 --- a/source_modules/limesdr_source/src/main.cpp +++ b/source_modules/limesdr_source/src/main.cpp @@ -330,7 +330,9 @@ private: if (err) { LMS_Close(_this->openDev); LMS_Open(&_this->openDev, _this->devList[_this->devId], NULL); - LMS_Init(_this->openDev); + if (LMS_Init(_this->openDev) != 0) { + return; + } } flog::warn("Channel count: {0}", LMS_GetNumChannels(_this->openDev, false)); From 9a3414b847da82e8d7db0e062009826a832a5888 Mon Sep 17 00:00:00 2001 From: AlexandreRouma Date: Thu, 23 Mar 2023 23:19:05 +0100 Subject: [PATCH 2/2] Made the code more useful to the user maybe just yeeting out of the start function with no indication to the user is a bad idea? --- source_modules/limesdr_source/src/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source_modules/limesdr_source/src/main.cpp b/source_modules/limesdr_source/src/main.cpp index 51eded74..620d467b 100644 --- a/source_modules/limesdr_source/src/main.cpp +++ b/source_modules/limesdr_source/src/main.cpp @@ -330,7 +330,8 @@ private: if (err) { LMS_Close(_this->openDev); LMS_Open(&_this->openDev, _this->devList[_this->devId], NULL); - if (LMS_Init(_this->openDev) != 0) { + if (err = LMS_Init(_this->openDev)) { + flog::error("Failed to re-initialize device ({})", err); return; } }