From 6583104a966d8683353c27065ff0143ae39a3ec7 Mon Sep 17 00:00:00 2001 From: Maxime Biette Date: Mon, 12 Jul 2021 17:53:38 -0400 Subject: [PATCH] Add error details on libhackrf open/close --- hackrf_source/src/main.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hackrf_source/src/main.cpp b/hackrf_source/src/main.cpp index 3bcba7ea..f1f4b184 100644 --- a/hackrf_source/src/main.cpp +++ b/hackrf_source/src/main.cpp @@ -228,9 +228,9 @@ private: return; } - int err = hackrf_open_by_serial(_this->selectedSerial.c_str(), &_this->openDev); - if (err != 0) { - spdlog::error("Could not open HackRF {0}", _this->selectedSerial); + auto err = static_cast(hackrf_open_by_serial(_this->selectedSerial.c_str(), &_this->openDev)); + if (err != hackrf_error::HACKRF_SUCCESS) { + spdlog::error("Could not open HackRF {0}: {1}", _this->selectedSerial, hackrf_error_name(err)); return; } @@ -257,7 +257,10 @@ private: _this->running = false; _this->stream.stopWriter(); // TODO: Stream stop - hackrf_close(_this->openDev); + auto err = static_cast(hackrf_close(_this->openDev)); + if (err != hackrf_error::HACKRF_SUCCESS) { + spdlog::error("Could not close HackRF {0}: {1}", _this->selectedSerial, hackrf_error_name(err)); + } _this->stream.clearWriteStop(); spdlog::info("HackRFSourceModule '{0}': Stop!", _this->name); }