Skip to content

fix: preserve rtty_mark_default when radio resets mark on band change#1968

Merged
ten9876 merged 2 commits intoten9876:mainfrom
chibondking:fix/rtty-mark-band-change-reset
Apr 26, 2026
Merged

fix: preserve rtty_mark_default when radio resets mark on band change#1968
ten9876 merged 2 commits intoten9876:mainfrom
chibondking:fix/rtty-mark-band-change-reset

Conversation

@chibondking
Copy link
Copy Markdown
Collaborator

When rtty_mark_default is set to a non-standard value (e.g. 915 Hz), changing bands while in RTTY mode caused the slice rtty_mark to snap back to 2125 Hz. Audio channel offset and TX mark frequency were wrong until the user changed mode away from RTTY and back.

Root cause: the radio always resets a slice's rtty_mark to 2125 in the status broadcast that follows a band change, regardless of the configured rtty_mark_default. SliceModel::applyStatus() accepted this value blindly, overwriting the user's configured mark frequency.

Changes:

SliceModel: add m_rttyMarkDefault member (default 2125) and setRttyMarkDefault() setter. In applyStatus(), when rtty_mark=2125 arrives but m_rttyMarkDefault differs, push the correct value back to the radio with "slice set rtty_mark=" and update the local model to the default rather than the factory-reset value.

RadioModel: call s->setRttyMarkDefault(m_rttyMarkDefault) immediately after constructing a new SliceModel so the correct default is in place before the first applyStatus() call. Also propagate the value to all existing slices whenever the radio status updates rtty_mark_default.

When rtty_mark_default is set to a non-standard value (e.g. 915 Hz), changing
bands while in RTTY mode caused the slice rtty_mark to snap back to 2125 Hz.
Audio channel offset and TX mark frequency were wrong until the user changed
mode away from RTTY and back.

Root cause: the radio always resets a slice's rtty_mark to 2125 in the status
broadcast that follows a band change, regardless of the configured
rtty_mark_default. SliceModel::applyStatus() accepted this value blindly,
overwriting the user's configured mark frequency.

Changes:

SliceModel: add m_rttyMarkDefault member (default 2125) and setRttyMarkDefault()
setter. In applyStatus(), when rtty_mark=2125 arrives but m_rttyMarkDefault
differs, push the correct value back to the radio with
"slice set <id> rtty_mark=<default>" and update the local model to the default
rather than the factory-reset value.

RadioModel: call s->setRttyMarkDefault(m_rttyMarkDefault) immediately after
constructing a new SliceModel so the correct default is in place before the
first applyStatus() call. Also propagate the value to all existing slices
whenever the radio status updates rtty_mark_default.
@chibondking chibondking requested a review from ten9876 as a code owner April 25, 2026 17:59
Copy link
Copy Markdown
Contributor

@aethersdr-agent aethersdr-agent Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix, @chibondking — the root cause analysis is solid and the change is well-scoped. A few observations:

Looks good:

  • Setting m_rttyMarkDefault before the first applyStatus() call on new slices is correct — the ordering in handleSliceStatus ensures the default is in place before status parsing.
  • Propagating the default to all existing slices when rtty_mark_default changes in handleRadioStatus handles mid-session profile changes.
  • No loop risk: the correction command will echo back with the non-2125 value, so the guard won't re-trigger.

One concern — the v == 2125 heuristic:

The condition v == 2125 && m_rttyMarkDefault != 2125 assumes that any incoming rtty_mark=2125 is a radio reset rather than an intentional value. Consider this sequence:

  1. User has rtty_mark_default=915
  2. User manually sets rtty_mark to 2125 via setRttyMark(2125) (e.g., switching to a standard RTTY net)
  3. Radio echoes rtty_mark=2125 in the next status broadcast
  4. applyStatus() sees v == 2125 with default 915, overrides it back to 915

This would fight the user's explicit choice. In practice this may be rare (if your default is non-standard, you probably don't manually set 2125), but it's worth considering. A possible mitigation: track a m_rttyMarkUserOverride flag that gets set in setRttyMark() and cleared on band change, so the heuristic only fires when the user hasn't explicitly chosen 2125. That said, this is a judgment call — if the real-world use case is narrow enough, the current approach is pragmatic and you could address it later if users report it.

No other issues found — the changes stay within scope, no null-pointer risks, and the new member is properly initialized. Thanks for the contribution!

When rtty_mark_default is set to a non-standard value (e.g. 915 Hz), changing
bands while in RTTY mode caused the slice rtty_mark to snap back to 2125 Hz.
Audio channel offset and TX mark frequency were wrong until the user changed
mode away from RTTY and back.

Root cause: the radio always resets a slice's rtty_mark to 2125 in the status
broadcast that follows a band change, regardless of the configured
rtty_mark_default. SliceModel::applyStatus() accepted this value blindly,
overwriting the user's configured mark frequency.

Changes:

SliceModel: add m_rttyMarkDefault (seeded by RadioModel) and
m_rttyMarkUserOverride members. In applyStatus(), when rtty_mark=2125 arrives
but m_rttyMarkDefault differs and the user has not explicitly chosen 2125, push
the configured default back to the radio. The override flag is set in
setRttyMark() when the user intentionally picks 2125 while the default is
non-standard, preventing a fight between the correction logic and the user's
explicit choice. The flag is cleared whenever RF_frequency changes (band
change), so the restore fires correctly on the next band hop.

RadioModel: call s->setRttyMarkDefault(m_rttyMarkDefault) immediately after
constructing a new SliceModel so the correct default is in place before the
first applyStatus() call. Also propagate the value to all existing slices
whenever the radio status updates rtty_mark_default.
@chibondking
Copy link
Copy Markdown
Collaborator Author

@AetherClaude suggestions added. One flag from you "setRttyMark(2125) (e.g., switching to a standard RTTY net)" should be a standard RTTY offset, not a RTTY net.

@aethersdr-agent
Copy link
Copy Markdown
Contributor

Good catch @chibondking, thanks for the correction. You're right — 2125 Hz is the standard RTTY mark frequency (offset), not a "RTTY net." That was sloppy wording on my part. If that appeared in a code comment or doc string in the PR, it should read something like "e.g., restoring the standard 2125 Hz mark frequency" instead. Appreciate the careful review.

@ten9876 ten9876 merged commit d8331d2 into ten9876:main Apr 26, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants