From f67fa0c66c9e24b822e6f66e2fd840cda92445ad Mon Sep 17 00:00:00 2001 From: AlexandreRouma Date: Sun, 20 Jul 2025 20:33:07 +0200 Subject: [PATCH] Fix DSP source block initialization and add linux support to hydrasdr_source --- core/src/dsp/source.h | 2 -- source_modules/hydrasdr_source/CMakeLists.txt | 13 ++++++++- source_modules/hydrasdr_source/src/main.cpp | 27 +++++++++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/core/src/dsp/source.h b/core/src/dsp/source.h index 24ed64cc..18d6bda9 100644 --- a/core/src/dsp/source.h +++ b/core/src/dsp/source.h @@ -5,8 +5,6 @@ namespace dsp { template class Source : public block { public: - Source() {} - Source() { init(); } virtual ~Source() {} diff --git a/source_modules/hydrasdr_source/CMakeLists.txt b/source_modules/hydrasdr_source/CMakeLists.txt index eb86e936..5789797c 100644 --- a/source_modules/hydrasdr_source/CMakeLists.txt +++ b/source_modules/hydrasdr_source/CMakeLists.txt @@ -14,5 +14,16 @@ if (MSVC) elseif (ANDROID) # TODO else (MSVC) - # TODO + find_package(PkgConfig) + + pkg_check_modules(LIBHYDRASDR REQUIRED libhydrasdr) + + target_include_directories(hydrasdr_source PRIVATE ${LIBHYDRASDR_INCLUDE_DIRS}) + target_link_directories(hydrasdr_source PRIVATE ${LIBHYDRASDR_LIBRARY_DIRS}) + target_link_libraries(hydrasdr_source PRIVATE ${LIBHYDRASDR_LIBRARIES}) + + # Include it because for some reason pkgconfig doesn't look here? + if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + target_include_directories(hydrasdr_source PRIVATE "/usr/local/include") + endif() endif () \ No newline at end of file diff --git a/source_modules/hydrasdr_source/src/main.cpp b/source_modules/hydrasdr_source/src/main.cpp index 0b034390..1e047043 100644 --- a/source_modules/hydrasdr_source/src/main.cpp +++ b/source_modules/hydrasdr_source/src/main.cpp @@ -36,6 +36,9 @@ public: ports.define("rx1", "RX1", RF_PORT_RX1); ports.define("rx2", "RX2", RF_PORT_RX2); + regStr[0] = 0; + valStr[0] = 0; + sampleRate = 10000000.0; handler.ctx = this; @@ -567,8 +570,32 @@ private: config.release(true); } } + + SmGui::LeftLabel("Reg"); + SmGui::FillWidth(); + SmGui::InputText(CONCAT("##_badgesdr_reg_", _this->name), _this->regStr, 256); + SmGui::LeftLabel("Value"); + SmGui::FillWidth(); + SmGui::InputText(CONCAT("##_badgesdr_val_", _this->name), _this->valStr, 256); + SmGui::FillWidth(); + if (ImGui::Button(CONCAT("Read##_badgesdr_rd_", _this->name))) { + if (_this->running) { + uint8_t val; + hydrasdr_r82x_read(_this->openDev, std::stoi(_this->regStr, NULL, 16), &val); + sprintf(_this->valStr, "%02X", val); + } + } + SmGui::FillWidth(); + if (ImGui::Button(CONCAT("Write##_badgesdr_wr_", _this->name))) { + if (_this->running) { + hydrasdr_r82x_write(_this->openDev, std::stoi(_this->regStr, NULL, 16), std::stoi(_this->valStr, NULL, 16)); + } + } } + char valStr[256]; + char regStr[256]; + static int callback(hydrasdr_transfer_t* transfer) { HydraSDRSourceModule* _this = (HydraSDRSourceModule*)transfer->ctx; memcpy(_this->stream.writeBuf, transfer->samples, transfer->sample_count * sizeof(dsp::complex_t));