Alternate CQ between the two radios

Ctrl+B calls CQ on one radio, and when that message has gone out, moves to the
other and calls there. The keyboard, the entry window and the SO2R box follow
each turn. N1MM calls this dueling CQs and puts it on the same key.

The turn is taken when the keyer says the message has ended, not when a timer
guesses it has. So MessageSender grew a Finished event and a ReportsCompletion
flag, and both keyers fill them in: cwdaemon answers the <ESC>h reply request
that now goes out in front of every message, and a WinKeyer clears the busy bit
in the status bytes it sends of its own accord. The status-byte reading is in
WinkeyerStatus, away from the serial port, because that is the half that can be
tested without a keyer on the desk. A keyer that reports nothing refuses to
start alternating CQ rather than keying the second radio over the first.

AlternatingCq itself takes the keyer, a callback that calls CQ on a radio, the
gap and a wait function, so the alternation is tested without sleeping. The gap
is in Config ▸ Keyer and messages and will not go below 100 ms, which is N1MM's
floor too: an SO2R box works relays.

docs/keying.md writes down why cwdaemon does the timing and we do not. N1MM
keys DTR itself with a coarse sleep, a busy-wait and a margin that grows every
time the sleep overshoots, and it raises the thread to TIME_CRITICAL for the
length of the message. The busy-wait ports to Linux; the priority does not,
without CAP_SYS_NICE, and a garbage collection mid-element is audible. A direct
serial keyer stays a reasonable third option, to be taken knowingly.

Running it against a fake daemon that takes 1.5 seconds to play a message: six
CQs went out back to back and the keyboard moved between the two entry windows
each time. Escape stopped it, let the message in flight finish, and started
nothing further.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-27 23:28:57 +00:00
parent d084789ed2
commit ae48c04e71
17 changed files with 721 additions and 18 deletions

View File

@@ -15,6 +15,13 @@
<TextBlock Grid.Column="4" Text="Speed" FontSize="11" Opacity="0.7" Margin="0,6,0,1" />
<TextBox Name="SpeedBox" Grid.Row="1" Grid.Column="4" />
</Grid>
<Grid ColumnDefinitions="150,8,*" RowDefinitions="Auto,Auto">
<TextBlock Text="Alternating CQ gap (ms)" FontSize="11" Opacity="0.7" Margin="0,6,0,1" />
<TextBox Name="AlternatingGapBox" Grid.Row="1" />
<TextBlock Grid.Column="2" Grid.Row="1" FontSize="11" Opacity="0.7"
VerticalAlignment="Center" TextWrapping="Wrap"
Text="Ctrl+B starts calling CQ on one radio and then the other. Needs two radios." />
</Grid>
<TextBlock Text="Messages" FontSize="11" Opacity="0.7" Margin="0,10,0,1" />
<StackPanel Orientation="Horizontal" Spacing="6">
<RadioButton Name="CwButton" Content="CW" GroupName="mode" IsChecked="True" />

View File

@@ -22,6 +22,7 @@ public sealed partial class KeyerDialog : Window
KindBox.SelectedItem = settings.KeyerKind;
KindBox.SelectionChanged += (_, _) => ShowTarget();
SpeedBox.Text = settings.KeyerSpeed.ToString();
AlternatingGapBox.Text = settings.AlternatingCqGapMs.ToString();
CwButton.IsCheckedChanged += (_, _) => ShowMessages();
ShowTarget();
BuildMessageBoxes();
@@ -91,6 +92,10 @@ public sealed partial class KeyerDialog : Window
? port
: settings.KeyerPort,
KeyerSpeed = int.TryParse(SpeedBox.Text, out int speed) ? speed : settings.KeyerSpeed,
// N1MM will not go below 100 ms either: the box works relays
AlternatingCqGapMs = int.TryParse(AlternatingGapBox.Text, out int gap)
? Math.Max(100, gap)
: settings.AlternatingCqGapMs,
CwMessages = cwMessages,
PhoneMessages = phoneMessages,
});