Serial channel mode commands never applied the selected mode - #2
Open
xmutantson wants to merge 1 commit into
Open
Serial channel mode commands never applied the selected mode#2xmutantson wants to merge 1 commit into
xmutantson wants to merge 1 commit into
Conversation
Serial channel-profile commands (WGN/MPG/MPM/MPP/MPD) validated the requested mode and updated the target S:N, but never assigned the global intMode: ParseSetSimParameter's intMode parameter shadows the global of the same name, so an acknowledged command left the running channel profile unchanged. The main loop keeps configuring tap delays and Doppler updates from the stale global, so for example MPP:9 answered OK while the simulator stayed in whichever mode the front-panel encoder had last selected. ParseSetParameter's parameter shadows the global the same way, so nothing on the serial path ever wrote it. Assign the global mode and clear blnInitialized in the serial dispatch before applying the parameter update, so the next loop pass configures the selected profile through the same initialization path a front-panel mode change uses. Applied to both firmware variants, with a regression test over both sources.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The defect
Selecting a channel profile over the USB serial port (
WGN:,MPG:,MPM:,MPP:,MPD:) answersOKbut does not change the running channel profile. Only the targetS:N number is updated; the simulator keeps whichever profile the front-panel encoder
last selected (or WGN after power-on).
Cause:
ParseSetSimParameter(String strParameter, int intMode)takes a parameter namedintMode, which shadows the globalintMode. For modes 0-4 it validates the requestand sets
intTargetSN, but the global mode index is never assigned. The follow-up callParseSetParameter(strParameter, intSerialCmdMode)has the same parameter shadowing,so it updates the display text and S:N only. The main loop configures the IQ tap delays
and the Doppler update cadence from the unchanged global
intMode, so the physicalsignal path never switches. Both firmware variants (
src/HFSim_BFD_2_03andhardware/Alternate hardware platforms/.../HFSim_BFD_2_03_Proto) have the samedispatch code and the same defect.
How it was found
Driving the simulator from a Raspberry Pi over USB serial for automated modem testing:
WGN:40, the received tone showed slow amplitude fading andmeasured about 18.5 dB SNR in a setup that had previously measured about 43 dB on a
genuinely clean WGN channel — the profile was still a multipath/fading mode from
earlier front-panel use.
MPP:9, independent SNR estimators disagreed by ~12 dB because thechannel was not actually in the commanded profile.
profile, which is what pointed at the dispatch rather than the signal path.
The fix
In the successful serial dispatch, assign the global mode and clear
blnInitializedbefore applying the parameter update:
Clearing
blnInitializedmakes the nextloop()pass run the exact mode-entryinitialization a front-panel mode change runs (tap delays, path mixer gains, display),
and the Doppler update cadence follows the global
intModefrom then on. The targetS:N set by the command is preserved. Front-panel behavior, EEPROM handling, and the
BUSY-mode command path are untouched. Applied identically to both firmware variants.
tests/test_serial_mode_dispatch.py(plainpython -m unittest tests.test_serial_mode_dispatch) guards the dispatch block of both sources: it failson the previous code and passes with the fix.
Validation on hardware
Flashed the fixed firmware to the Teensy 4.0 unit on the same Raspberry Pi bench and
re-ran the failing sequence:
WGN:40: measured 43.9 dB SNR with a flat envelope (std 0.003 dB, Doppler-bandenergy fraction 0.0005) — the clean channel is actually delivered. Before the fix the same
command measured 18.5 dB with visible slow fading.
MPP:9: fading now genuinely present — envelope std 5.3 dB, p95-p05 spread17.5 dB, Doppler-band energy fraction 0.79, and the serial debug echo
Line 1014 SetIQTapDelays: intMode = 3confirms the global mode assignment on dispatch.WGN:40again: 44.2 dB, flat — live re-switching works in both directionswithout a power cycle.
before the fix now agree within 0.13 dB on it.
RESETthe unit boots to WGN as before (modes aredeliberately not persisted), with the same banner and serial number.