protocol 2 fix

This commit is contained in:
2026-04-14 22:06:31 +03:00
parent dde80e5696
commit 6ca18411cf
13 changed files with 1135 additions and 1024 deletions
+75
View File
@@ -185,3 +185,78 @@ This file records the Protocol 2 related work completed in this repository so fu
- `doc/openHPSDR Ethernet Protocol v4.3.docx`
- Highest value next task:
- implement proper `Alex1/BPF2/RX2` handling for Protocol 2 boards that support a second Alex register.
## Additional Fixes On 2026-04-14
### 1. Protocol 2 control-timing corrections
- Re-read the local protocol document and verified the command timing requirements again:
- `High Priority` / C&C must be sent at least once per second,
- `100 ms` is the recommended periodic rate,
- packets should also be sent when relevant data changes.
- Updated `src/DataEngine/cusdr_protocol2_io.cpp` so Protocol 2 now reacts immediately to settings changes instead of relying only on the `100 ms` heartbeat:
- center/VFO frequency changes,
- current receiver changes,
- band changes,
- Alex config/state changes,
- sample-rate changes,
- DDC dither/random changes,
- number-of-receivers changes.
- `General`, `DDC Specific`, and `High Priority` packets are now refreshed according to the type of change, and DDC sockets are rebuilt if the active RX count changes.
### 2. Protocol 2 wideband support integrated
- Re-read the `Wideband` sections of `doc/openHPSDR Ethernet Protocol v4.3.docx`.
- Implemented Protocol 2 wideband receive support in:
- `src/DataEngine/cusdr_protocol2_io.h`
- `src/DataEngine/cusdr_protocol2_io.cpp`
- Added Protocol 2 wideband socket handling:
- bind UDP wideband receive socket on base port `1027`,
- receive raw ADC wideband packets,
- track per-port sequence numbers,
- reassemble a full wideband block into `io->wb_queue` for the existing wideband DSP/display pipeline.
- Updated Protocol 2 `General packet` wideband fields from the document:
- bytes `21..22`: wideband base port `1027`,
- byte `23`: enable bit for ADC0 wideband,
- bytes `24..25`: `512` samples per packet,
- byte `26`: `16`-bit samples,
- byte `27`: `20 ms` update rate,
- byte `28`: packets per frame from `Settings::getWidebandBuffers()`.
- Added live handling for `widebandDataChanged(...)` so Protocol 2 can enable/disable wideband by resending the `General packet` while running.
- When wideband is disabled, the partial Protocol 2 wideband accumulator is cleared and the wideband spectrum display is reset.
### 3. UI wideband button now controls the actual stream
- Investigated the existing UI and found the `Wideband` button only showed/hid the dock widget.
- It did **not** previously toggle the actual hardware wideband data stream.
- Updated `src/cusdr_mainWidget.cpp` so the `Wideband` button now:
- sets `widebandData`,
- sets `widebandStatus`,
- shows/hides the dock.
- Updated dock visibility handling so manual close/open remains synchronized with both UI state and data-stream state.
- Also removed the old behavior where the button stayed disabled merely because `widebandData` was off in the saved settings.
### 4. Protocol 1 live wideband toggle aligned with UI
- Updated `src/DataEngine/cusdr_dataEngine.h` and `src/DataEngine/cusdr_dataEngine.cpp` so `widebandDataChanged(...)` now reissues the legacy start command while the data engine is already running:
- `0x03` with wideband,
- `0x01` without wideband.
- Protocol 2 keeps its own separate live wideband handling inside `Protocol2DataPath`, so the legacy restart command is skipped for Protocol 2 devices.
### 5. Build re-check
- Rebuilt after the wideband work:
- `make -j4`
- success
### Current status after wideband integration
- Protocol 2 now has:
- periodic and change-driven command refresh,
- integrated wideband receive path,
- UI-triggered wideband enable/disable behavior.
- This is compile-verified.
- Runtime validation on real Protocol 2 hardware is still required for:
- actual wideband packet cadence,
- live on/off switching while running,
- board-specific wideband constraints such as fixed packets-per-frame behavior on some hardware.