From 6ab59ad3c52312fa650976e0ac4d9a26fd396f24 Mon Sep 17 00:00:00 2001 From: Victor Antonovich Date: Fri, 20 Aug 2021 20:16:37 +0300 Subject: [PATCH 1/8] Fix rigctl server to work with WSJT-X --- rigctl_server/src/main.cpp | 115 ++++++++++++++++++++++++++++++++----- 1 file changed, 102 insertions(+), 13 deletions(-) diff --git a/rigctl_server/src/main.cpp b/rigctl_server/src/main.cpp index f92875db..aa6218df 100644 --- a/rigctl_server/src/main.cpp +++ b/rigctl_server/src/main.cpp @@ -427,20 +427,22 @@ private: return; } - // if number of arguments isn't correct or the VFO is not "VFO", return error + // if number of arguments isn't correct, return error if (parts.size() != 3) { resp = "RPRT 1\n"; client->write(resp.size(), (uint8_t*)resp.c_str()); return; } - // Check that the bandwidth is an integer + // Check that the bandwidth is an integer (0 or -1 for default bandwidth) + int pos = 0; for (char c : parts[2]) { - if (!std::isdigit(c)) { + if (!std::isdigit(c) && !(c == '-' && !pos)) { resp = "RPRT 1\n"; client->write(resp.size(), (uint8_t*)resp.c_str()); return; } + pos++; } float newBandwidth = std::atoi(parts[2].c_str()); @@ -479,7 +481,7 @@ private: // If tuning is enabled, set the mode and optionally the bandwidth if (!selectedVfo.empty() && core::modComManager.getModuleName(selectedVfo) == "radio" && tuningEnabled) { core::modComManager.callInterface(selectedVfo, RADIO_IFACE_CMD_SET_MODE, &newMode, NULL); - if (newBandwidth) { + if (newBandwidth > 0) { core::modComManager.callInterface(selectedVfo, RADIO_IFACE_CMD_SET_BANDWIDTH, &newBandwidth, NULL); } } @@ -488,32 +490,32 @@ private: } else if (parts[0] == "m" || parts[0] == "\\get_mode") { std::lock_guard lck(vfoMtx); - resp = "RAW "; + resp = "RAW\n"; if (!selectedVfo.empty() && core::modComManager.getModuleName(selectedVfo) == "radio") { int mode; core::modComManager.callInterface(selectedVfo, RADIO_IFACE_CMD_GET_MODE, NULL, &mode); if (mode == RADIO_IFACE_MODE_NFM) { - resp = "FM "; + resp = "FM\n"; } else if (mode == RADIO_IFACE_MODE_WFM) { - resp = "WFM "; + resp = "WFM\n"; } else if (mode == RADIO_IFACE_MODE_AM) { - resp = "AM "; + resp = "AM\n"; } else if (mode == RADIO_IFACE_MODE_DSB) { - resp = "DSB "; + resp = "DSB\n"; } else if (mode == RADIO_IFACE_MODE_USB) { - resp = "USB "; + resp = "USB\n"; } else if (mode == RADIO_IFACE_MODE_CW) { - resp = "CW "; + resp = "CW\n"; } else if (mode == RADIO_IFACE_MODE_LSB) { - resp = "LSB "; + resp = "LSB\n"; } } @@ -551,6 +553,21 @@ private: resp = "VFO\n"; client->write(resp.size(), (uint8_t*)resp.c_str()); } + else if (parts[0] == "\\chk_vfo") { + std::lock_guard lck(vfoMtx); + resp = "CHKVFO 0\n"; + client->write(resp.size(), (uint8_t*)resp.c_str()); + } + else if (parts[0] == "s") { + std::lock_guard lck(vfoMtx); + resp = "0\nVFOA\n"; + client->write(resp.size(), (uint8_t*)resp.c_str()); + } + else if (parts[0] == "S") { + std::lock_guard lck(vfoMtx); + resp = "RPRT 0\n"; + client->write(resp.size(), (uint8_t*)resp.c_str()); + } else if (parts[0] == "AOS" || parts[0] == "\\recorder_start") { std::lock_guard lck(recorderMtx); @@ -591,13 +608,85 @@ private: core::modComManager.callInterface(selectedRecorder, RECORDER_IFACE_CMD_STOP, NULL, NULL); } - // Respond with a sucess + // Respond with a success resp = "RPRT 0\n"; client->write(resp.size(), (uint8_t*)resp.c_str()); } else if (parts[0] == "q" || parts[0] == "\\quit") { // Will close automatically } + else if (parts[0] == "\\dump_state") { + std::lock_guard lck(vfoMtx); + resp = + /* rigctl protocol version */ + "0\n" + /* rigctl model */ + "2\n" + /* ITU region */ + "1\n" + /* RX/TX frequency ranges + * start, end, modes, low_power, high_power, vfo, ant + * start/end - Start/End frequency [Hz] + * modes - Bit field of RIG_MODE's (AM|AMS|CW|CWR|USB|LSB|FM|WFM) + * low_power/high_power - Lower/Higher RF power in mW, + * -1 for no power (ie. rx list) + * vfo - VFO list equipped with this range (RIG_VFO_A) + * ant - Antenna list equipped with this range, 0 means all + * FIXME: get limits from receiver + */ + "0.000000 10000000000.000000 0x2ef -1 -1 0x1 0x0\n" + /* End of RX frequency ranges. */ + "0 0 0 0 0 0 0\n" + /* End of TX frequency ranges. The SDR++ is reciver only. */ + "0 0 0 0 0 0 0\n" + /* Tuning steps: modes, tuning_step */ + "0xef 1\n" + "0xef 0\n" + /* End of tuning steps */ + "0 0\n" + /* Filter sizes: modes, width + * FIXME: get filter sizes from presets + */ + "0x82 500\n" /* CW | CWR normal */ + "0x82 200\n" /* CW | CWR narrow */ + "0x82 2000\n" /* CW | CWR wide */ + "0x221 10000\n" /* AM | AMS | FM normal */ + "0x221 5000\n" /* AM | AMS | FM narrow */ + "0x221 20000\n" /* AM | AMS | FM wide */ + "0x0c 2700\n" /* SSB normal */ + "0x0c 1400\n" /* SSB narrow */ + "0x0c 3900\n" /* SSB wide */ + "0x40 160000\n" /* WFM normal */ + "0x40 120000\n" /* WFM narrow */ + "0x40 200000\n" /* WFM wide */ + /* End of filter sizes */ + "0 0\n" + /* max_rit */ + "0\n" + /* max_xit */ + "0\n" + /* max_ifshift */ + "0\n" + /* Announces (bit field list) */ + "0\n" /* RIG_ANN_NONE */ + /* Preamp list in dB, 0 terminated */ + "0\n" + /* Attenuator list in dB, 0 terminated */ + "0\n" + /* Bit field list of get functions */ + "0\n" /* RIG_FUNC_NONE */ + /* Bit field list of set functions */ + "0\n" /* RIG_FUNC_NONE */ + /* Bit field list of get level */ + "0x40000020\n" /* RIG_LEVEL_SQL | RIG_LEVEL_STRENGTH */ + /* Bit field list of set level */ + "0x20\n" /* RIG_LEVEL_SQL */ + /* Bit field list of get parm */ + "0\n" /* RIG_PARM_NONE */ + /* Bit field list of set parm */ + "0\n" /* RIG_PARM_NONE */; + client->write(resp.size(), (uint8_t*)resp.c_str()); + } else { // If command is not recognized, return error spdlog::error("Rigctl client sent invalid command: '{0}'", cmd); From b2ce47d975a43b19180e79ba9336a47ff149e8d5 Mon Sep 17 00:00:00 2001 From: Ryzerth Date: Fri, 20 Aug 2021 20:40:14 +0200 Subject: [PATCH 2/8] Fixed radio bandwidth not adjusted when the menu is closed or hidden --- core/src/gui/widgets/waterfall.cpp | 1 + core/src/gui/widgets/waterfall.h | 2 ++ core/src/signal_path/vfo_manager.h | 5 +++-- radio/src/am_demod.h | 36 +++++++++++++++++++----------- radio/src/cw_demod.h | 35 +++++++++++++++++++---------- radio/src/dsb_demod.h | 36 +++++++++++++++++++----------- radio/src/fm_demod.h | 36 +++++++++++++++++++----------- radio/src/lsb_demod.h | 35 +++++++++++++++++++---------- radio/src/raw_demod.h | 4 ++-- radio/src/usb_demod.h | 35 +++++++++++++++++++---------- radio/src/wfm_demod.h | 27 ++++++++++++++-------- 11 files changed, 164 insertions(+), 88 deletions(-) diff --git a/core/src/gui/widgets/waterfall.cpp b/core/src/gui/widgets/waterfall.cpp index aba95566..970388ef 100644 --- a/core/src/gui/widgets/waterfall.cpp +++ b/core/src/gui/widgets/waterfall.cpp @@ -322,6 +322,7 @@ namespace ImGui { } hzDist = std::clamp(hzDist, relatedVfo->minBandwidth, relatedVfo->maxBandwidth); relatedVfo->setBandwidth(hzDist); + relatedVfo->onUserChangedBandwidth.emit(hzDist); return; } diff --git a/core/src/gui/widgets/waterfall.h b/core/src/gui/widgets/waterfall.h index 43622811..55e4c798 100644 --- a/core/src/gui/widgets/waterfall.h +++ b/core/src/gui/widgets/waterfall.h @@ -67,6 +67,8 @@ namespace ImGui { bool bandwidthLocked; ImU32 color = IM_COL32(255, 255, 255, 50); + + Event onUserChangedBandwidth; }; class WaterFall { diff --git a/core/src/signal_path/vfo_manager.h b/core/src/signal_path/vfo_manager.h index bd4e452b..e932eb1f 100644 --- a/core/src/signal_path/vfo_manager.h +++ b/core/src/signal_path/vfo_manager.h @@ -30,10 +30,11 @@ public: friend class VFOManager; - private: - std::string name; dsp::VFO* dspVFO; ImGui::WaterfallVFO* wtfVFO; + + private: + std::string name; }; diff --git a/radio/src/am_demod.h b/radio/src/am_demod.h index 4144a2ff..56152e99 100644 --- a/radio/src/am_demod.h +++ b/radio/src/am_demod.h @@ -55,6 +55,11 @@ public: resamp.updateWindow(&win); m2s.init(&resamp.out); + + onUserChangedBandwidthHandler.handler = vfoUserChangedBandwidthHandler; + onUserChangedBandwidthHandler.ctx = this; + + _vfo->wtfVFO->onUserChangedBandwidth.bindHandler(&onUserChangedBandwidthHandler); } void start() { @@ -89,6 +94,7 @@ public: void setVFO(VFOManager::VFO* vfo) { _vfo = vfo; squelch.setInput(_vfo->output); + _vfo->wtfVFO->onUserChangedBandwidth.bindHandler(&onUserChangedBandwidthHandler); } VFOManager::VFO* getVFO() { @@ -130,15 +136,6 @@ public: _config->conf[uiPrefix]["AM"]["bandwidth"] = bw; _config->release(true); } - if (running) { - if (_vfo->getBandwidthChanged()) { - bw = _vfo->getBandwidth(); - setBandwidth(bw, false); - _config->acquire(); - _config->conf[uiPrefix]["AM"]["bandwidth"] = bw; - _config->release(true); - } - } ImGui::Text("Snap Interval"); ImGui::SameLine(); @@ -160,7 +157,18 @@ public: _config->conf[uiPrefix]["AM"]["squelchLevel"] = squelchLevel; _config->release(true); } - } + } + + static void vfoUserChangedBandwidthHandler(double newBw, void* ctx) { + AMDemodulator* _this = (AMDemodulator*)ctx; + if (_this->running) { + _this->bw = newBw; + _this->setBandwidth(_this->bw, false); + _this->_config->acquire(); + _this->_config->conf[_this->uiPrefix]["AM"]["bandwidth"] = _this->bw; + _this->_config->release(true); + } + } void setBandwidth(float bandWidth, bool updateWaterfall = true) { bandWidth = std::clamp(bandWidth, bwMin, bwMax); @@ -175,9 +183,9 @@ public: void saveParameters(bool lock = true) { if (lock) { _config->acquire(); } - _config->conf[uiPrefix]["WFM"]["bandwidth"] = bw; - _config->conf[uiPrefix]["WFM"]["snapInterval"] = snapInterval; - _config->conf[uiPrefix]["WFM"]["squelchLevel"] = squelchLevel; + _config->conf[uiPrefix]["AM"]["bandwidth"] = bw; + _config->conf[uiPrefix]["AM"]["snapInterval"] = snapInterval; + _config->conf[uiPrefix]["AM"]["squelchLevel"] = squelchLevel; if (lock) { _config->release(true); } } @@ -208,4 +216,6 @@ private: ConfigManager* _config; + EventHandler onUserChangedBandwidthHandler; + }; \ No newline at end of file diff --git a/radio/src/cw_demod.h b/radio/src/cw_demod.h index 93c3bc4f..79a01b05 100644 --- a/radio/src/cw_demod.h +++ b/radio/src/cw_demod.h @@ -57,6 +57,11 @@ public: resamp.updateWindow(&win); m2s.init(&resamp.out); + + onUserChangedBandwidthHandler.handler = vfoUserChangedBandwidthHandler; + onUserChangedBandwidthHandler.ctx = this; + + _vfo->wtfVFO->onUserChangedBandwidth.bindHandler(&onUserChangedBandwidthHandler); } void start() { @@ -93,6 +98,7 @@ public: void setVFO(VFOManager::VFO* vfo) { _vfo = vfo; squelch.setInput(_vfo->output); + _vfo->wtfVFO->onUserChangedBandwidth.bindHandler(&onUserChangedBandwidthHandler); } VFOManager::VFO* getVFO() { @@ -133,14 +139,6 @@ public: _config->acquire(); _config->conf[uiPrefix]["CW"]["bandwidth"] = bw; _config->release(true); - }if (running) { - if (_vfo->getBandwidthChanged()) { - bw = _vfo->getBandwidth(); - setBandwidth(bw, false); - _config->acquire(); - _config->conf[uiPrefix]["CW"]["bandwidth"] = bw; - _config->release(true); - } } ImGui::Text("Snap Interval"); @@ -163,7 +161,18 @@ public: _config->conf[uiPrefix]["CW"]["squelchLevel"] = squelchLevel; _config->release(true); } - } + } + + static void vfoUserChangedBandwidthHandler(double newBw, void* ctx) { + CWDemodulator* _this = (CWDemodulator*)ctx; + if (_this->running) { + _this->bw = newBw; + _this->setBandwidth(_this->bw, false); + _this->_config->acquire(); + _this->_config->conf[_this->uiPrefix]["CW"]["bandwidth"] = _this->bw; + _this->_config->release(true); + } + } void setBandwidth(float bandWidth, bool updateWaterfall = true) { bandWidth = std::clamp(bandWidth, bwMin, bwMax); @@ -178,9 +187,9 @@ public: void saveParameters(bool lock = true) { if (lock) { _config->acquire(); } - _config->conf[uiPrefix]["WFM"]["bandwidth"] = bw; - _config->conf[uiPrefix]["WFM"]["snapInterval"] = snapInterval; - _config->conf[uiPrefix]["WFM"]["squelchLevel"] = squelchLevel; + _config->conf[uiPrefix]["CW"]["bandwidth"] = bw; + _config->conf[uiPrefix]["CW"]["snapInterval"] = snapInterval; + _config->conf[uiPrefix]["CW"]["squelchLevel"] = squelchLevel; if (lock) { _config->release(true); } } @@ -212,4 +221,6 @@ private: ConfigManager* _config; + EventHandler onUserChangedBandwidthHandler; + }; \ No newline at end of file diff --git a/radio/src/dsb_demod.h b/radio/src/dsb_demod.h index aa686570..bd9e880e 100644 --- a/radio/src/dsb_demod.h +++ b/radio/src/dsb_demod.h @@ -55,6 +55,11 @@ public: resamp.updateWindow(&win); m2s.init(&resamp.out); + + onUserChangedBandwidthHandler.handler = vfoUserChangedBandwidthHandler; + onUserChangedBandwidthHandler.ctx = this; + + _vfo->wtfVFO->onUserChangedBandwidth.bindHandler(&onUserChangedBandwidthHandler); } void start() { @@ -89,6 +94,7 @@ public: void setVFO(VFOManager::VFO* vfo) { _vfo = vfo; squelch.setInput(_vfo->output); + _vfo->wtfVFO->onUserChangedBandwidth.bindHandler(&onUserChangedBandwidthHandler); } VFOManager::VFO* getVFO() { @@ -130,15 +136,6 @@ public: _config->conf[uiPrefix]["DSB"]["bandwidth"] = bw; _config->release(true); } - if (running) { - if (_vfo->getBandwidthChanged()) { - bw = _vfo->getBandwidth(); - setBandwidth(bw, false); - _config->acquire(); - _config->conf[uiPrefix]["DSB"]["bandwidth"] = bw; - _config->release(true); - } - } ImGui::Text("Snap Interval"); ImGui::SameLine(); @@ -160,7 +157,18 @@ public: _config->conf[uiPrefix]["DSB"]["squelchLevel"] = squelchLevel; _config->release(true); } - } + } + + static void vfoUserChangedBandwidthHandler(double newBw, void* ctx) { + DSBDemodulator* _this = (DSBDemodulator*)ctx; + if (_this->running) { + _this->bw = newBw; + _this->setBandwidth(_this->bw, false); + _this->_config->acquire(); + _this->_config->conf[_this->uiPrefix]["DSB"]["bandwidth"] = _this->bw; + _this->_config->release(true); + } + } void setBandwidth(float bandWidth, bool updateWaterfall = true) { bandWidth = std::clamp(bandWidth, bwMin, bwMax); @@ -170,9 +178,9 @@ public: void saveParameters(bool lock = true) { if (lock) { _config->acquire(); } - _config->conf[uiPrefix]["WFM"]["bandwidth"] = bw; - _config->conf[uiPrefix]["WFM"]["snapInterval"] = snapInterval; - _config->conf[uiPrefix]["WFM"]["squelchLevel"] = squelchLevel; + _config->conf[uiPrefix]["DSB"]["bandwidth"] = bw; + _config->conf[uiPrefix]["DSB"]["snapInterval"] = snapInterval; + _config->conf[uiPrefix]["DSB"]["squelchLevel"] = squelchLevel; if (lock) { _config->release(true); } } @@ -203,4 +211,6 @@ private: ConfigManager* _config; + EventHandler onUserChangedBandwidthHandler; + }; \ No newline at end of file diff --git a/radio/src/fm_demod.h b/radio/src/fm_demod.h index 7d7cfe53..1bea3520 100644 --- a/radio/src/fm_demod.h +++ b/radio/src/fm_demod.h @@ -51,6 +51,11 @@ public: resamp.init(&demod.out, &win, bbSampRate, audioSampRate); win.setSampleRate(bbSampRate * resamp.getInterpolation()); resamp.updateWindow(&win); + + onUserChangedBandwidthHandler.handler = vfoUserChangedBandwidthHandler; + onUserChangedBandwidthHandler.ctx = this; + + _vfo->wtfVFO->onUserChangedBandwidth.bindHandler(&onUserChangedBandwidthHandler); } void start() { @@ -81,6 +86,7 @@ public: void setVFO(VFOManager::VFO* vfo) { _vfo = vfo; squelch.setInput(_vfo->output); + _vfo->wtfVFO->onUserChangedBandwidth.bindHandler(&onUserChangedBandwidthHandler); } VFOManager::VFO* getVFO() { @@ -122,15 +128,6 @@ public: _config->conf[uiPrefix]["FM"]["bandwidth"] = bw; _config->release(true); } - if (running) { - if (_vfo->getBandwidthChanged()) { - bw = _vfo->getBandwidth(); - setBandwidth(bw, false); - _config->acquire(); - _config->conf[uiPrefix]["FM"]["bandwidth"] = bw; - _config->release(true); - } - } ImGui::Text("Snap Interval"); ImGui::SameLine(); @@ -152,7 +149,18 @@ public: _config->conf[uiPrefix]["FM"]["squelchLevel"] = squelchLevel; _config->release(true); } - } + } + + static void vfoUserChangedBandwidthHandler(double newBw, void* ctx) { + FMDemodulator* _this = (FMDemodulator*)ctx; + if (_this->running) { + _this->bw = newBw; + _this->setBandwidth(_this->bw, false); + _this->_config->acquire(); + _this->_config->conf[_this->uiPrefix]["FM"]["bandwidth"] = _this->bw; + _this->_config->release(true); + } + } void setBandwidth(float bandWidth, bool updateWaterfall = true) { bandWidth = std::clamp(bandWidth, bwMin, bwMax); @@ -164,9 +172,9 @@ public: void saveParameters(bool lock = true) { if (lock) { _config->acquire(); } - _config->conf[uiPrefix]["WFM"]["bandwidth"] = bw; - _config->conf[uiPrefix]["WFM"]["snapInterval"] = snapInterval; - _config->conf[uiPrefix]["WFM"]["squelchLevel"] = squelchLevel; + _config->conf[uiPrefix]["FM"]["bandwidth"] = bw; + _config->conf[uiPrefix]["FM"]["snapInterval"] = snapInterval; + _config->conf[uiPrefix]["FM"]["squelchLevel"] = squelchLevel; if (lock) { _config->release(true); } } @@ -195,4 +203,6 @@ private: ConfigManager* _config; + EventHandler onUserChangedBandwidthHandler; + }; \ No newline at end of file diff --git a/radio/src/lsb_demod.h b/radio/src/lsb_demod.h index 0d68b1ff..563d0ef8 100644 --- a/radio/src/lsb_demod.h +++ b/radio/src/lsb_demod.h @@ -55,6 +55,11 @@ public: resamp.updateWindow(&win); m2s.init(&resamp.out); + + onUserChangedBandwidthHandler.handler = vfoUserChangedBandwidthHandler; + onUserChangedBandwidthHandler.ctx = this; + + _vfo->wtfVFO->onUserChangedBandwidth.bindHandler(&onUserChangedBandwidthHandler); } void start() { @@ -89,6 +94,7 @@ public: void setVFO(VFOManager::VFO* vfo) { _vfo = vfo; squelch.setInput(_vfo->output); + _vfo->wtfVFO->onUserChangedBandwidth.bindHandler(&onUserChangedBandwidthHandler); } VFOManager::VFO* getVFO() { @@ -129,14 +135,6 @@ public: _config->acquire(); _config->conf[uiPrefix]["LSB"]["bandwidth"] = bw; _config->release(true); - }if (running) { - if (_vfo->getBandwidthChanged()) { - bw = _vfo->getBandwidth(); - setBandwidth(bw, false); - _config->acquire(); - _config->conf[uiPrefix]["LSB"]["bandwidth"] = bw; - _config->release(true); - } } ImGui::Text("Snap Interval"); @@ -159,7 +157,18 @@ public: _config->conf[uiPrefix]["LSB"]["squelchLevel"] = squelchLevel; _config->release(true); } - } + } + + static void vfoUserChangedBandwidthHandler(double newBw, void* ctx) { + LSBDemodulator* _this = (LSBDemodulator*)ctx; + if (_this->running) { + _this->bw = newBw; + _this->setBandwidth(_this->bw, false); + _this->_config->acquire(); + _this->_config->conf[_this->uiPrefix]["LSB"]["bandwidth"] = _this->bw; + _this->_config->release(true); + } + } void setBandwidth(float bandWidth, bool updateWaterfall = true) { bandWidth = std::clamp(bandWidth, bwMin, bwMax); @@ -175,9 +184,9 @@ public: void saveParameters(bool lock = true) { if (lock) { _config->acquire(); } - _config->conf[uiPrefix]["WFM"]["bandwidth"] = bw; - _config->conf[uiPrefix]["WFM"]["snapInterval"] = snapInterval; - _config->conf[uiPrefix]["WFM"]["squelchLevel"] = squelchLevel; + _config->conf[uiPrefix]["LSB"]["bandwidth"] = bw; + _config->conf[uiPrefix]["LSB"]["snapInterval"] = snapInterval; + _config->conf[uiPrefix]["LSB"]["squelchLevel"] = squelchLevel; if (lock) { _config->release(true); } } @@ -208,4 +217,6 @@ private: ConfigManager* _config; + EventHandler onUserChangedBandwidthHandler; + }; \ No newline at end of file diff --git a/radio/src/raw_demod.h b/radio/src/raw_demod.h index 057a4e92..53602df8 100644 --- a/radio/src/raw_demod.h +++ b/radio/src/raw_demod.h @@ -120,8 +120,8 @@ public: void saveParameters(bool lock = true) { if (lock) { _config->acquire(); } - _config->conf[uiPrefix]["WFM"]["snapInterval"] = snapInterval; - _config->conf[uiPrefix]["WFM"]["squelchLevel"] = squelchLevel; + _config->conf[uiPrefix]["RAW"]["snapInterval"] = snapInterval; + _config->conf[uiPrefix]["RAW"]["squelchLevel"] = squelchLevel; if (lock) { _config->release(true); } } diff --git a/radio/src/usb_demod.h b/radio/src/usb_demod.h index 4347643e..205ba845 100644 --- a/radio/src/usb_demod.h +++ b/radio/src/usb_demod.h @@ -55,6 +55,11 @@ public: resamp.updateWindow(&win); m2s.init(&resamp.out); + + onUserChangedBandwidthHandler.handler = vfoUserChangedBandwidthHandler; + onUserChangedBandwidthHandler.ctx = this; + + _vfo->wtfVFO->onUserChangedBandwidth.bindHandler(&onUserChangedBandwidthHandler); } void start() { @@ -89,6 +94,7 @@ public: void setVFO(VFOManager::VFO* vfo) { _vfo = vfo; squelch.setInput(_vfo->output); + _vfo->wtfVFO->onUserChangedBandwidth.bindHandler(&onUserChangedBandwidthHandler); } VFOManager::VFO* getVFO() { @@ -129,14 +135,6 @@ public: _config->acquire(); _config->conf[uiPrefix]["USB"]["bandwidth"] = bw; _config->release(true); - }if (running) { - if (_vfo->getBandwidthChanged()) { - bw = _vfo->getBandwidth(); - setBandwidth(bw, false); - _config->acquire(); - _config->conf[uiPrefix]["USB"]["bandwidth"] = bw; - _config->release(true); - } } ImGui::Text("Snap Interval"); @@ -159,7 +157,18 @@ public: _config->conf[uiPrefix]["USB"]["squelchLevel"] = squelchLevel; _config->release(true); } - } + } + + static void vfoUserChangedBandwidthHandler(double newBw, void* ctx) { + USBDemodulator* _this = (USBDemodulator*)ctx; + if (_this->running) { + _this->bw = newBw; + _this->setBandwidth(_this->bw, false); + _this->_config->acquire(); + _this->_config->conf[_this->uiPrefix]["USB"]["bandwidth"] = _this->bw; + _this->_config->release(true); + } + } void setBandwidth(float bandWidth, bool updateWaterfall = true) { bandWidth = std::clamp(bandWidth, bwMin, bwMax); @@ -175,9 +184,9 @@ public: void saveParameters(bool lock = true) { if (lock) { _config->acquire(); } - _config->conf[uiPrefix]["WFM"]["bandwidth"] = bw; - _config->conf[uiPrefix]["WFM"]["snapInterval"] = snapInterval; - _config->conf[uiPrefix]["WFM"]["squelchLevel"] = squelchLevel; + _config->conf[uiPrefix]["USB"]["bandwidth"] = bw; + _config->conf[uiPrefix]["USB"]["snapInterval"] = snapInterval; + _config->conf[uiPrefix]["USB"]["squelchLevel"] = squelchLevel; if (lock) { _config->release(true); } } @@ -208,4 +217,6 @@ private: ConfigManager* _config; + EventHandler onUserChangedBandwidthHandler; + }; \ No newline at end of file diff --git a/radio/src/wfm_demod.h b/radio/src/wfm_demod.h index 9047a99f..bd5d67c7 100644 --- a/radio/src/wfm_demod.h +++ b/radio/src/wfm_demod.h @@ -72,6 +72,10 @@ public: if (deempId == 2) { deemp.bypass = true; } + onUserChangedBandwidthHandler.handler = vfoUserChangedBandwidthHandler; + onUserChangedBandwidthHandler.ctx = this; + + _vfo->wtfVFO->onUserChangedBandwidth.bindHandler(&onUserChangedBandwidthHandler); } void start() { @@ -114,6 +118,7 @@ public: void setVFO(VFOManager::VFO* vfo) { _vfo = vfo; squelch.setInput(_vfo->output); + _vfo->wtfVFO->onUserChangedBandwidth.bindHandler(&onUserChangedBandwidthHandler); } VFOManager::VFO* getVFO() { @@ -158,15 +163,6 @@ public: _config->conf[uiPrefix]["WFM"]["bandwidth"] = bw; _config->release(true); } - if (running) { - if (_vfo->getBandwidthChanged()) { - bw = _vfo->getBandwidth(); - setBandwidth(bw, false); - _config->acquire(); - _config->conf[uiPrefix]["WFM"]["bandwidth"] = bw; - _config->release(true); - } - } ImGui::Text("Snap Interval"); ImGui::SameLine(); @@ -208,6 +204,17 @@ public: } } + static void vfoUserChangedBandwidthHandler(double newBw, void* ctx) { + WFMDemodulator* _this = (WFMDemodulator*)ctx; + if (_this->running) { + _this->bw = newBw; + _this->setBandwidth(_this->bw, false); + _this->_config->acquire(); + _this->_config->conf[_this->uiPrefix]["WFM"]["bandwidth"] = _this->bw; + _this->_config->release(true); + } + } + void setDeempIndex(int id) { if (id >= 2 || id < 0) { deemp.bypass = true; @@ -286,4 +293,6 @@ private: ConfigManager* _config; + EventHandler onUserChangedBandwidthHandler; + }; \ No newline at end of file From 271d1f924099c781dca669037570c7cd3d8c8325 Mon Sep 17 00:00:00 2001 From: AlexandreRouma Date: Fri, 20 Aug 2021 20:41:54 +0200 Subject: [PATCH 3/8] Update main.cpp --- rigctl_server/src/main.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/rigctl_server/src/main.cpp b/rigctl_server/src/main.cpp index aa6218df..4440ad69 100644 --- a/rigctl_server/src/main.cpp +++ b/rigctl_server/src/main.cpp @@ -490,32 +490,32 @@ private: } else if (parts[0] == "m" || parts[0] == "\\get_mode") { std::lock_guard lck(vfoMtx); - resp = "RAW\n"; + resp = "RAW "; if (!selectedVfo.empty() && core::modComManager.getModuleName(selectedVfo) == "radio") { int mode; core::modComManager.callInterface(selectedVfo, RADIO_IFACE_CMD_GET_MODE, NULL, &mode); if (mode == RADIO_IFACE_MODE_NFM) { - resp = "FM\n"; + resp = "FM "; } else if (mode == RADIO_IFACE_MODE_WFM) { - resp = "WFM\n"; + resp = "WFM "; } else if (mode == RADIO_IFACE_MODE_AM) { - resp = "AM\n"; + resp = "AM "; } else if (mode == RADIO_IFACE_MODE_DSB) { - resp = "DSB\n"; + resp = "DSB "; } else if (mode == RADIO_IFACE_MODE_USB) { - resp = "USB\n"; + resp = "USB "; } else if (mode == RADIO_IFACE_MODE_CW) { - resp = "CW\n"; + resp = "CW "; } else if (mode == RADIO_IFACE_MODE_LSB) { - resp = "LSB\n"; + resp = "LSB "; } } From dbf1fb790fdfe72baec90dc9ae7f34f1fe035fc4 Mon Sep 17 00:00:00 2001 From: AlexandreRouma Date: Fri, 20 Aug 2021 21:45:07 +0200 Subject: [PATCH 4/8] Changed back to PR --- rigctl_server/src/main.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/rigctl_server/src/main.cpp b/rigctl_server/src/main.cpp index 4440ad69..aa6218df 100644 --- a/rigctl_server/src/main.cpp +++ b/rigctl_server/src/main.cpp @@ -490,32 +490,32 @@ private: } else if (parts[0] == "m" || parts[0] == "\\get_mode") { std::lock_guard lck(vfoMtx); - resp = "RAW "; + resp = "RAW\n"; if (!selectedVfo.empty() && core::modComManager.getModuleName(selectedVfo) == "radio") { int mode; core::modComManager.callInterface(selectedVfo, RADIO_IFACE_CMD_GET_MODE, NULL, &mode); if (mode == RADIO_IFACE_MODE_NFM) { - resp = "FM "; + resp = "FM\n"; } else if (mode == RADIO_IFACE_MODE_WFM) { - resp = "WFM "; + resp = "WFM\n"; } else if (mode == RADIO_IFACE_MODE_AM) { - resp = "AM "; + resp = "AM\n"; } else if (mode == RADIO_IFACE_MODE_DSB) { - resp = "DSB "; + resp = "DSB\n"; } else if (mode == RADIO_IFACE_MODE_USB) { - resp = "USB "; + resp = "USB\n"; } else if (mode == RADIO_IFACE_MODE_CW) { - resp = "CW "; + resp = "CW\n"; } else if (mode == RADIO_IFACE_MODE_LSB) { - resp = "LSB "; + resp = "LSB\n"; } } From 9a2794a0ddd4b2e3605b7d84c36bb9860e97c07e Mon Sep 17 00:00:00 2001 From: Victor Antonovich Date: Sat, 21 Aug 2021 09:41:40 +0300 Subject: [PATCH 5/8] Set SO_REUSEADDR option to listen sockets on non-Windows systems --- core/src/utils/networking.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/src/utils/networking.cpp b/core/src/utils/networking.cpp index 5ee56ce9..07887103 100644 --- a/core/src/utils/networking.cpp +++ b/core/src/utils/networking.cpp @@ -371,6 +371,18 @@ namespace net { return NULL; } +#ifndef _WIN32 + // Allow port reusing if the app was killed or crashed + // and the socket is stuck in TIME_WAIT state. + // This option has a different meaning on Windows, + // so we use it only for non-Windows systems + int enable = 1; + if (setsockopt(listenSock, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof (int)) < 0) { + throw std::runtime_error("Could not configure socket"); + return NULL; + } +#endif + // Get address from hostname/ip hostent* remoteHost = gethostbyname(host.c_str()); if (remoteHost == NULL || remoteHost->h_addr_list[0] == NULL) { From f01cb4af9ffc35bf2b9d8c36264faedb9215041e Mon Sep 17 00:00:00 2001 From: Ryzerth Date: Sat, 21 Aug 2021 17:45:21 +0200 Subject: [PATCH 6/8] Added support for OpenGL 2.1 and OpenGL ES 3.0 with no modifications to the code necessary by the user --- core/src/core.cpp | 86 ++++++++++++++++++++++++++++++--------- core/src/version.h | 2 +- root/res/themes/grey.json | 10 ++--- 3 files changed, 72 insertions(+), 26 deletions(-) diff --git a/core/src/core.cpp b/core/src/core.cpp index 8b41579a..9616241b 100644 --- a/core/src/core.cpp +++ b/core/src/core.cpp @@ -37,6 +37,32 @@ #endif #endif +const char* OPENGL_VERSIONS_GLSL[] = { + "#version 120", + "#version 300 es", + "#version 120" +}; + +const int OPENGL_VERSIONS_MAJOR[] = { + 3, + 3, + 2 +}; + +const int OPENGL_VERSIONS_MINOR[] = { + 0, + 1, + 1 +}; + +const bool OPENGL_VERSIONS_IS_ES[] = { + false, + true, + false +}; + +#define OPENGL_VERSION_COUNT (sizeof(OPENGL_VERSIONS_GLSL) / sizeof(char*)) + namespace core { ConfigManager configManager; ModuleManager moduleManager; @@ -258,26 +284,6 @@ int sdrpp_main(int argc, char *argv[]) { if (options::opts.serverMode) { return server_main(); } - // Setup window - glfwSetErrorCallback(glfw_error_callback); - if (!glfwInit()) { - return 1; - } - -#ifdef __APPLE__ - // GL 3.2 + GLSL 150 - const char* glsl_version = "#version 150"; - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); - glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // 3.2+ only - glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // Required on Mac -#else - // GL 3.0 + GLSL 120 - const char* glsl_version = "#version 120"; - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); -#endif - core::configManager.acquire(); int winWidth = core::configManager.conf["windowSize"]["w"]; int winHeight = core::configManager.conf["windowSize"]["h"]; @@ -291,13 +297,53 @@ int sdrpp_main(int argc, char *argv[]) { return 1; } + + // Setup window + glfwSetErrorCallback(glfw_error_callback); + if (!glfwInit()) { + return 1; + } + +#ifdef __APPLE__ + // GL 3.2 + GLSL 150 + const char* glsl_version = "#version 150"; + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // 3.2+ only + glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // Required on Mac + // Create window with graphics context GLFWmonitor* monitor = glfwGetPrimaryMonitor(); core::window = glfwCreateWindow(winWidth, winHeight, "SDR++ v" VERSION_STR " (Built at " __TIME__ ", " __DATE__ ")", NULL, NULL); if (core::window == NULL) return 1; glfwMakeContextCurrent(core::window); +#else + const char* glsl_version = "#version 120"; + GLFWmonitor* monitor = NULL; + for (int i = 0; i < OPENGL_VERSION_COUNT; i++) { + glsl_version = OPENGL_VERSIONS_GLSL[i]; + if (OPENGL_VERSIONS_IS_ES[i]) { + glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API); + } + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, OPENGL_VERSIONS_MAJOR[i]); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, OPENGL_VERSIONS_MINOR[i]); + // Create window with graphics context + monitor = glfwGetPrimaryMonitor(); + core::window = glfwCreateWindow(winWidth, winHeight, "SDR++ v" VERSION_STR " (Built at " __TIME__ ", " __DATE__ ")", NULL, NULL); + if (core::window == NULL) { + spdlog::info("OpenGL {0}.{1} {2}was not supported", OPENGL_VERSIONS_MAJOR[i], OPENGL_VERSIONS_MINOR[i], OPENGL_VERSIONS_IS_ES[i] ? "ES ": ""); + continue; + } + spdlog::info("Using OpenGL {0}.{1}{2}", OPENGL_VERSIONS_MAJOR[i], OPENGL_VERSIONS_MINOR[i], OPENGL_VERSIONS_IS_ES[i] ? " ES": ""); + glfwMakeContextCurrent(core::window); + break; + } + +#endif + + // Add callback for max/min if GLFW supports it #if (GLFW_VERSION_MAJOR == 3) && (GLFW_VERSION_MINOR >= 3) if (maximized) { glfwMaximizeWindow(core::window); diff --git a/core/src/version.h b/core/src/version.h index 10090799..b36d6104 100644 --- a/core/src/version.h +++ b/core/src/version.h @@ -1,3 +1,3 @@ #pragma once -#define VERSION_STR "1.0.3" \ No newline at end of file +#define VERSION_STR "1.0.4" \ No newline at end of file diff --git a/root/res/themes/grey.json b/root/res/themes/grey.json index ddb5c01c..7e0f8819 100644 --- a/root/res/themes/grey.json +++ b/root/res/themes/grey.json @@ -1,6 +1,6 @@ { - "name": "Grey", - "author": "Paul (PD0SWL)", + "name": "Marine Grey", + "author": "PD0SWL", "Border": "#6D6D7F7F", "BorderShadow": "#00000000", "Button": "#00000066", @@ -10,11 +10,11 @@ "ChildBg": "#FFFFFF00", "DragDropTarget": "#0000FFE5", "FrameBg": "#33353889", - "FrameBgActive": "#00000089", - "FrameBgHovered": "#00000089", + "FrameBgActive": "#70707089", + "FrameBgHovered": "#70707089", "Header": "#5E5E4C4F", "HeaderActive": "#5E5E4C4F", - "HeaderHovered": "#5E5E4C66", + "HeaderHovered": "#70707089", "MenuBarBg": "#232323FF", "ModalWindowDimBg": "#33333359", "NavHighlight": "#666666FF", From 8502bae236e1c96ceb5a698f64004fecb87f7f6c Mon Sep 17 00:00:00 2001 From: Ryzerth Date: Sat, 21 Aug 2021 18:03:34 +0200 Subject: [PATCH 7/8] Added basic dependencies to the debian/ubuntu packages --- docker_builds/debian_bullseye/do_build.sh | 2 +- docker_builds/debian_buster/do_build.sh | 2 +- docker_builds/debian_sid/do_build.sh | 2 +- docker_builds/ubuntu_focal/do_build.sh | 2 +- docker_builds/ubuntu_groovy/do_build.sh | 2 +- docker_builds/ubuntu_hirsute/do_build.sh | 2 +- make_debian_package.sh | 3 ++- 7 files changed, 8 insertions(+), 7 deletions(-) diff --git a/docker_builds/debian_bullseye/do_build.sh b/docker_builds/debian_bullseye/do_build.sh index 3eba9cdd..b980347a 100644 --- a/docker_builds/debian_bullseye/do_build.sh +++ b/docker_builds/debian_bullseye/do_build.sh @@ -21,4 +21,4 @@ cmake .. -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD make -j2 cd .. -sh make_debian_package.sh ./build \ No newline at end of file +sh make_debian_package.sh ./build libfftw3-dev libglfw3-dev libglew-dev libvolk2-dev \ No newline at end of file diff --git a/docker_builds/debian_buster/do_build.sh b/docker_builds/debian_buster/do_build.sh index 4c378b6f..a0b294a0 100644 --- a/docker_builds/debian_buster/do_build.sh +++ b/docker_builds/debian_buster/do_build.sh @@ -21,4 +21,4 @@ cmake .. -DOPT_BUILD_SDRPLAY_SOURCE=ON -DOPT_BUILD_BLADERF_SOURCE=OFF -DOPT_BUIL make -j2 cd .. -sh make_debian_package.sh ./build \ No newline at end of file +sh make_debian_package.sh ./build libfftw3-dev libglfw3-dev libglew-dev libvolk1-dev \ No newline at end of file diff --git a/docker_builds/debian_sid/do_build.sh b/docker_builds/debian_sid/do_build.sh index 3eba9cdd..b980347a 100644 --- a/docker_builds/debian_sid/do_build.sh +++ b/docker_builds/debian_sid/do_build.sh @@ -21,4 +21,4 @@ cmake .. -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD make -j2 cd .. -sh make_debian_package.sh ./build \ No newline at end of file +sh make_debian_package.sh ./build libfftw3-dev libglfw3-dev libglew-dev libvolk2-dev \ 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 3eba9cdd..b980347a 100644 --- a/docker_builds/ubuntu_focal/do_build.sh +++ b/docker_builds/ubuntu_focal/do_build.sh @@ -21,4 +21,4 @@ cmake .. -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD make -j2 cd .. -sh make_debian_package.sh ./build \ No newline at end of file +sh make_debian_package.sh ./build libfftw3-dev libglfw3-dev libglew-dev libvolk2-dev \ No newline at end of file diff --git a/docker_builds/ubuntu_groovy/do_build.sh b/docker_builds/ubuntu_groovy/do_build.sh index 3eba9cdd..b980347a 100644 --- a/docker_builds/ubuntu_groovy/do_build.sh +++ b/docker_builds/ubuntu_groovy/do_build.sh @@ -21,4 +21,4 @@ cmake .. -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD make -j2 cd .. -sh make_debian_package.sh ./build \ No newline at end of file +sh make_debian_package.sh ./build libfftw3-dev libglfw3-dev libglew-dev libvolk2-dev \ No newline at end of file diff --git a/docker_builds/ubuntu_hirsute/do_build.sh b/docker_builds/ubuntu_hirsute/do_build.sh index 3eba9cdd..b980347a 100644 --- a/docker_builds/ubuntu_hirsute/do_build.sh +++ b/docker_builds/ubuntu_hirsute/do_build.sh @@ -21,4 +21,4 @@ cmake .. -DOPT_BUILD_BLADERF_SOURCE=ON -DOPT_BUILD_LIMESDR_SOURCE=ON -DOPT_BUILD make -j2 cd .. -sh make_debian_package.sh ./build \ No newline at end of file +sh make_debian_package.sh ./build libfftw3-dev libglfw3-dev libglew-dev libvolk2-dev \ No newline at end of file diff --git a/make_debian_package.sh b/make_debian_package.sh index 271a8fd7..e25552da 100644 --- a/make_debian_package.sh +++ b/make_debian_package.sh @@ -8,10 +8,11 @@ mkdir sdrpp_debian_amd64/DEBIAN # Create package info echo Create package info echo Package: sdrpp >> sdrpp_debian_amd64/DEBIAN/control -echo Version: 0.2.5$BUILD_NO >> sdrpp_debian_amd64/DEBIAN/control +echo Version: 1.0.4$BUILD_NO >> sdrpp_debian_amd64/DEBIAN/control echo Maintainer: Ryzerth >> sdrpp_debian_amd64/DEBIAN/control echo Architecture: all >> sdrpp_debian_amd64/DEBIAN/control echo Description: Bloat-free SDR receiver software >> sdrpp_debian_amd64/DEBIAN/control +echo Depends: $2 >> sdrpp_debian_amd64/DEBIAN/control # Copying files ORIG_DIR=$PWD From 2fd91459fd97562a7c1130edb69d77c0eaaab5b9 Mon Sep 17 00:00:00 2001 From: Ryzerth Date: Sat, 21 Aug 2021 23:13:38 +0200 Subject: [PATCH 8/8] Fixed bug --- core/src/core.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/core/src/core.cpp b/core/src/core.cpp index 9616241b..2c2f7baf 100644 --- a/core/src/core.cpp +++ b/core/src/core.cpp @@ -323,9 +323,7 @@ int sdrpp_main(int argc, char *argv[]) { GLFWmonitor* monitor = NULL; for (int i = 0; i < OPENGL_VERSION_COUNT; i++) { glsl_version = OPENGL_VERSIONS_GLSL[i]; - if (OPENGL_VERSIONS_IS_ES[i]) { - glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API); - } + glfwWindowHint(GLFW_CLIENT_API, OPENGL_VERSIONS_IS_ES[i] ? GLFW_OPENGL_ES_API : GLFW_OPENGL_API); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, OPENGL_VERSIONS_MAJOR[i]); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, OPENGL_VERSIONS_MINOR[i]);