From 35d079beb1d75320b272b3f00042d020bd6a66bf Mon Sep 17 00:00:00 2001 From: Ryzerth Date: Mon, 8 Feb 2021 20:27:05 +0100 Subject: [PATCH] Maybe fixed airspy and airspyhf crash --- airspy_source/src/main.cpp | 15 +++++++++++---- airspyhf_source/src/main.cpp | 17 +++++++++++++---- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/airspy_source/src/main.cpp b/airspy_source/src/main.cpp index 1c530cc0..42324db4 100644 --- a/airspy_source/src/main.cpp +++ b/airspy_source/src/main.cpp @@ -106,13 +106,20 @@ public: void selectBySerial(uint64_t serial) { airspy_device* dev; - int err = airspy_open_sn(&dev, serial); - if (err != 0) { + try { + int err = airspy_open_sn(&dev, serial); + if (err != 0) { + char buf[1024]; + sprintf(buf, "%016" PRIX64, serial); + spdlog::error("Could not open Airspy HF+ {0}", buf); + selectedSerial = 0; + return; + } + } + catch (std::exception e) { char buf[1024]; sprintf(buf, "%016" PRIX64, serial); spdlog::error("Could not open Airspy HF+ {0}", buf); - selectedSerial = 0; - return; } selectedSerial = serial; diff --git a/airspyhf_source/src/main.cpp b/airspyhf_source/src/main.cpp index d290eab8..9bf471cc 100644 --- a/airspyhf_source/src/main.cpp +++ b/airspyhf_source/src/main.cpp @@ -109,15 +109,24 @@ public: } void selectBySerial(uint64_t serial) { - selectedSerial = serial; airspyhf_device_t* dev; - int err = airspyhf_open_sn(&dev, selectedSerial); - if (err != 0) { + try { + int err = airspyhf_open_sn(&dev, selectedSerial); + if (err != 0) { + char buf[1024]; + sprintf(buf, "%016" PRIX64, selectedSerial); + spdlog::error("Could not open Airspy HF+ {0}", buf); + selectedSerial = 0; + return; + } + } + catch (std::exception e) { char buf[1024]; sprintf(buf, "%016" PRIX64, selectedSerial); spdlog::error("Could not open Airspy HF+ {0}", buf); - return; } + + selectedSerial = serial; uint32_t sampleRates[256]; airspyhf_get_samplerates(dev, sampleRates, 0);