From 936c99dc40c333045684135bc813e9ae076d2d07 Mon Sep 17 00:00:00 2001 From: AlexandreRouma Date: Sat, 8 Jun 2024 08:38:33 +0200 Subject: [PATCH] windows debug build --- .github/workflows/build_all.yml | 4 +-- core/src/gui/widgets/symbol_diagram.cpp | 11 +++++++ core/src/gui/widgets/symbol_diagram.h | 4 +++ .../pager_decoder/src/pocsag/decoder.h | 29 +++++++++++++------ docker_builds/ubuntu_bionic/do_build.sh | 2 +- docker_builds/ubuntu_focal/do_build.sh | 2 +- docker_builds/ubuntu_jammy/do_build.sh | 2 +- docker_builds/ubuntu_mantic/do_build.sh | 2 +- docker_builds/ubuntu_noble/do_build.sh | 2 +- source_modules/rfnm_source/src/main.cpp | 21 +++++++++++++- 10 files changed, 62 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build_all.yml b/.github/workflows/build_all.yml index fc06bcfa..e4c5ef53 100644 --- a/.github/workflows/build_all.yml +++ b/.github/workflows/build_all.yml @@ -68,11 +68,11 @@ jobs: - name: Prepare CMake working-directory: ${{runner.workspace}}/build - run: cmake "$Env:GITHUB_WORKSPACE" "-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_PERSEUS_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON + run: cmake "$Env:GITHUB_WORKSPACE" "-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" -DCMAKE_BUILD_TYPE=Debug -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD_PERSEUS_SOURCE=ON -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_NEW_PORTAUDIO_SINK=ON -DOPT_BUILD_M17_DECODER=ON - name: Build working-directory: ${{runner.workspace}}/build - run: cmake --build . --config Release --verbose + run: cmake --build . --config Debug --verbose - name: Create Archive working-directory: ${{runner.workspace}} diff --git a/core/src/gui/widgets/symbol_diagram.cpp b/core/src/gui/widgets/symbol_diagram.cpp index fded9f6f..15191593 100644 --- a/core/src/gui/widgets/symbol_diagram.cpp +++ b/core/src/gui/widgets/symbol_diagram.cpp @@ -52,4 +52,15 @@ namespace ImGui { bufferMtx.unlock(); } + void SymbolDiagram::setCount(int count) { + std::lock_guard lck(bufferMtx); + delete[] buffer; + buffer = new float[count]; + sampleCount = count; + memset(buffer, 0, sampleCount * sizeof(float)); + } + + int SymbolDiagram::getCount() { + return sampleCount; + } } \ No newline at end of file diff --git a/core/src/gui/widgets/symbol_diagram.h b/core/src/gui/widgets/symbol_diagram.h index dbb08bf7..ab26637c 100644 --- a/core/src/gui/widgets/symbol_diagram.h +++ b/core/src/gui/widgets/symbol_diagram.h @@ -18,6 +18,10 @@ namespace ImGui { void releaseBuffer(); + void setCount(int count); + + int getCount(); + std::vector lines; private: diff --git a/decoder_modules/pager_decoder/src/pocsag/decoder.h b/decoder_modules/pager_decoder/src/pocsag/decoder.h index ce0da317..5a8492cd 100644 --- a/decoder_modules/pager_decoder/src/pocsag/decoder.h +++ b/decoder_modules/pager_decoder/src/pocsag/decoder.h @@ -8,15 +8,15 @@ #include "dsp.h" #include "pocsag.h" -#define BAUDRATE 2400 -#define SAMPLERATE (BAUDRATE*10) - class POCSAGDecoder : public Decoder { public: - POCSAGDecoder(const std::string& name, VFOManager::VFO* vfo) : diag(0.6, BAUDRATE) { + POCSAGDecoder(const std::string& name, VFOManager::VFO* vfo) : diag(0.6, 2400) { this->name = name; this->vfo = vfo; + // Default baudrate (TODO: Load from config) + baudrate = 2400; + // Define baudrate options baudrates.define(512, "512 Baud", 512); baudrates.define(1200, "1200 Baud", 1200); @@ -24,9 +24,9 @@ public: // Init DSP vfo->setBandwidthLimits(12500, 12500, true); - vfo->setSampleRate(SAMPLERATE, 12500); - dsp.init(vfo->output, SAMPLERATE, BAUDRATE); - reshape.init(&dsp.soft, BAUDRATE, (BAUDRATE / 30.0) - BAUDRATE); + vfo->setSampleRate(baudrate*10.0, 12500); + dsp.init(vfo->output, baudrate*10.0, baudrate); + reshape.init(&dsp.soft, baudrate, (baudrate / 30.0) - baudrate); dataHandler.init(&dsp.out, _dataHandler, this); diagHandler.init(&reshape.out, _diagHandler, this); @@ -42,7 +42,7 @@ public: ImGui::LeftLabel("Baudrate"); ImGui::FillWidth(); if (ImGui::Combo(("##pager_decoder_pocsag_br_" + name).c_str(), &brId, baudrates.txt)) { - // TODO + setBaudrate(baudrates.value(brId)); } ImGui::FillWidth(); @@ -79,7 +79,8 @@ private: static void _diagHandler(float* data, int count, void* ctx) { POCSAGDecoder* _this = (POCSAGDecoder*)ctx; float* buf = _this->diag.acquireBuffer(); - memcpy(buf, data, count * sizeof(float)); + int maxCount = std::min(count, _this->diag.getCount()); + memcpy(buf, data, maxCount * sizeof(float)); _this->diag.releaseBuffer(); } @@ -87,6 +88,15 @@ private: flog::debug("[{}]: '{}'", (uint32_t)addr, msg); } + void setBaudrate(double baudrate) { + vfo->setSampleRate(baudrate*10.0, 12500); + stop(); + reshape.setKeep(baudrate); + reshape.setSkip((baudrate / 30.0) - baudrate); + diag.setCount(baudrate); + start(); + } + std::string name; VFOManager::VFO* vfo; @@ -100,6 +110,7 @@ private: ImGui::SymbolDiagram diag; int brId = 2; + double baudrate = 2400; OptionList baudrates; }; \ No newline at end of file diff --git a/docker_builds/ubuntu_bionic/do_build.sh b/docker_builds/ubuntu_bionic/do_build.sh index 97731104..32bd2f6c 100644 --- a/docker_builds/ubuntu_bionic/do_build.sh +++ b/docker_builds/ubuntu_bionic/do_build.sh @@ -71,4 +71,4 @@ make VERBOSE=1 -j2 # Generate package cd .. -sh make_debian_package.sh ./build 'libfftw3-dev, libglfw3-dev, libvolk1-dev, librtaudio-dev, libzstd-dev' \ No newline at end of file +sh make_debian_package.sh ./build 'libfftw3-bin, libglfw3, libvolk1-bin, librtaudio6, libzstd1' \ No newline at end of file diff --git a/docker_builds/ubuntu_focal/do_build.sh b/docker_builds/ubuntu_focal/do_build.sh index 4b714082..160b23d6 100644 --- a/docker_builds/ubuntu_focal/do_build.sh +++ b/docker_builds/ubuntu_focal/do_build.sh @@ -32,4 +32,4 @@ cmake .. -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD make VERBOSE=1 -j2 cd .. -sh make_debian_package.sh ./build 'libfftw3-dev, libglfw3-dev, libvolk2-dev, librtaudio-dev, libzstd-dev' \ No newline at end of file +sh make_debian_package.sh ./build 'libfftw3-bin, libglfw3, libvolk2-bin, librtaudio6, libzstd1' \ No newline at end of file diff --git a/docker_builds/ubuntu_jammy/do_build.sh b/docker_builds/ubuntu_jammy/do_build.sh index 4b714082..160b23d6 100644 --- a/docker_builds/ubuntu_jammy/do_build.sh +++ b/docker_builds/ubuntu_jammy/do_build.sh @@ -32,4 +32,4 @@ cmake .. -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD make VERBOSE=1 -j2 cd .. -sh make_debian_package.sh ./build 'libfftw3-dev, libglfw3-dev, libvolk2-dev, librtaudio-dev, libzstd-dev' \ No newline at end of file +sh make_debian_package.sh ./build 'libfftw3-bin, libglfw3, libvolk2-bin, librtaudio6, libzstd1' \ No newline at end of file diff --git a/docker_builds/ubuntu_mantic/do_build.sh b/docker_builds/ubuntu_mantic/do_build.sh index 67cd5960..74cf10d2 100644 --- a/docker_builds/ubuntu_mantic/do_build.sh +++ b/docker_builds/ubuntu_mantic/do_build.sh @@ -32,4 +32,4 @@ cmake .. -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD make VERBOSE=1 -j2 cd .. -sh make_debian_package.sh ./build 'libfftw3-dev, libglfw3-dev, libvolk-dev, librtaudio-dev, libzstd-dev' \ No newline at end of file +sh make_debian_package.sh ./build 'libfftw3-bin, libglfw3, libvolk-bin, librtaudio6, libzstd1' \ No newline at end of file diff --git a/docker_builds/ubuntu_noble/do_build.sh b/docker_builds/ubuntu_noble/do_build.sh index 67cd5960..74cf10d2 100644 --- a/docker_builds/ubuntu_noble/do_build.sh +++ b/docker_builds/ubuntu_noble/do_build.sh @@ -32,4 +32,4 @@ cmake .. -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD make VERBOSE=1 -j2 cd .. -sh make_debian_package.sh ./build 'libfftw3-dev, libglfw3-dev, libvolk-dev, librtaudio-dev, libzstd-dev' \ No newline at end of file +sh make_debian_package.sh ./build 'libfftw3-bin, libglfw3, libvolk-bin, librtaudio6, libzstd1' \ No newline at end of file diff --git a/source_modules/rfnm_source/src/main.cpp b/source_modules/rfnm_source/src/main.cpp index da431355..711a01bd 100644 --- a/source_modules/rfnm_source/src/main.cpp +++ b/source_modules/rfnm_source/src/main.cpp @@ -61,7 +61,8 @@ public: } private: - void refresh() { + void refresh() { +#ifndef __ANDROID__ devices.clear(); auto list = librfnm::find(librfnm_transport::LIBRFNM_TRANSPORT_USB); for (const auto& info : list) { @@ -75,6 +76,16 @@ private: // Save device devices.define((char*)info.motherboard.serial_number, devName, (char*)info.motherboard.serial_number); } +#else + // Check for device presence + int vid, pid; + devFd = backend::getDeviceFD(vid, pid, backend::RFNM_VIDPIDS); + if (devFd < 0) { return; } + + // Get device info + std::string fakeName = "RFNM USB"; + devices.define(fakeName, fakeName, fakeName); +#endif } void select(const std::string& serial) { @@ -142,7 +153,11 @@ private: if (_this->running) { return; } // Open the device +#ifndef __ANDROID__ _this->openDev = new librfnm(librfnm_transport::LIBRFNM_TRANSPORT_USB, _this->selectedSerial); +#else + _this->openDev = new librfnm(_this->devFd); +#endif // Configure the device _this->openDev->librfnm_s->rx.ch[0].enable = RFNM_CH_ON; @@ -323,6 +338,10 @@ private: int bufferSize = -1; librfnm_rx_buf rxBuf[LIBRFNM_MIN_RX_BUFCNT]; +#ifdef __ANDROID__ + int devFd = 0; +#endif + std::thread workerThread; };