Read split from the radio, and read two of them

Split. RadioState carries a transmit frequency, zero meaning the radio
transmits where it listens, so split is not a second flag that can disagree
with it. The contact stores it in N1MM's QSX column, the entry window shows
14008.00 followed by the transmit frequency, and the bandmap draws a red bar
there. SetSplitAsync sets the frequency before turning split on, or a radio
last split somewhere else transmits there.

Every command now goes out with a + in front, asking rigctld for its extended
answer: named fields ended by an RPRT line. The raw answer is bare values with
no terminator, so the client had to know how many lines each command returns —
there was a `command == "m"` special case for the one that returns two. Add a
third such command and get the count wrong once, and every later answer is read
against the wrong command for the rest of the session. RigctldReply parses the
extended form and is tested on its own.

A radio that cannot do split answers RPRT -11. That is an answer, not a broken
connection, so the frequency and mode it did report still count.

Two radios. Settings hold a list rather than one host and port, with the single
radio an older settings file holds carried into it. Both radios are read and
both show on the bandmap, the active one green and the other orange, but only
the active one drives the entry window: the second radio moving must not drag
the operator off the station being worked. Ctrl+Tab swaps, and a contact
records which radio made it.

This is not a full two-radio operating position — no second entry window, no
alternating CQ, no audio switching. It is two radios read and logged correctly.

Tested against a stand-in for rigctld over a real socket, and looked at under
Xvfb with two fake radios, one of them split.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-27 16:40:42 +00:00
parent da9884ebf5
commit 43be3816c3
19 changed files with 706 additions and 98 deletions

View File

@@ -1,18 +1,30 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="Nonemm.App.Dialogs.RadioDialog"
Title="Radio" Width="420" SizeToContent="Height"
Title="Radios" Width="460" SizeToContent="Height"
WindowStartupLocation="CenterOwner" CanResize="False">
<StackPanel Margin="14" Spacing="6">
<TextBlock TextWrapping="Wrap" FontSize="11" Opacity="0.75"
Text="The logger reads and tunes the radio through hamlib's rigctld, which is started separately for whichever radio is on the desk, for example: rigctld -m 2028 -r /dev/ttyUSB0" />
<Grid ColumnDefinitions="*,8,110" RowDefinitions="Auto,Auto">
<TextBlock Text="Host" FontSize="11" Opacity="0.7" Margin="0,6,0,1" />
<TextBox Name="HostBox" Grid.Row="1" />
<TextBlock Grid.Column="2" Text="Port" FontSize="11" Opacity="0.7" Margin="0,6,0,1" />
<TextBox Name="PortBox" Grid.Row="1" Grid.Column="2" />
Text="The logger reads and tunes each radio through its own hamlib rigctld, started separately for whichever radio is on the desk, for example: rigctld -m 2028 -r /dev/ttyUSB0 -t 4532" />
<Grid ColumnDefinitions="70,*,8,90" RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto"
Margin="0,8,0,0">
<TextBlock Grid.Column="1" Text="Host" FontSize="11" Opacity="0.7" />
<TextBlock Grid.Column="3" Text="Port" FontSize="11" Opacity="0.7" />
<TextBlock Grid.Row="1" Text="Radio 1" VerticalAlignment="Center" />
<TextBox Grid.Row="1" Grid.Column="1" Name="HostBox" />
<TextBox Grid.Row="1" Grid.Column="3" Name="PortBox" />
<CheckBox Grid.Row="2" Grid.Column="1" Name="EnabledBox" Content="Follow this radio"
Margin="0,2,0,8" />
<TextBlock Grid.Row="3" Text="Radio 2" VerticalAlignment="Center" />
<TextBox Grid.Row="3" Grid.Column="1" Name="SecondHostBox" />
<TextBox Grid.Row="3" Grid.Column="3" Name="SecondPortBox" />
<CheckBox Grid.Row="4" Grid.Column="1" Name="SecondEnabledBox" Content="Follow this radio"
Margin="0,2,0,0" />
</Grid>
<CheckBox Name="EnabledBox" Content="Follow the radio" Margin="0,6,0,0" />
<TextBlock TextWrapping="Wrap" FontSize="11" Opacity="0.75" Margin="0,8,0,0"
Text="With a second radio the station is SO2R: both are read and both show on the bandmap, but only the one you are on drives the entry window. Ctrl+Tab moves you to the other." />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Spacing="6" Margin="0,8,0,0">
<Button Content="Cancel" Click="OnCancel" />
<Button Content="Save" Click="OnSave" IsDefault="True" />

View File

@@ -4,26 +4,46 @@ using Nonemm.App.Configuration;
namespace Nonemm.App.Dialogs;
/// The radios on the desk, one rigctld each.
public sealed partial class RadioDialog : Window
{
private const int DefaultPort = 4532;
private readonly Settings settings;
public RadioDialog(Settings settings)
{
this.settings = settings;
InitializeComponent();
HostBox.Text = settings.RigctldHost;
PortBox.Text = settings.RigctldPort.ToString();
EnabledBox.IsChecked = settings.RadioEnabled;
Show(0, HostBox, PortBox, EnabledBox);
Show(1, SecondHostBox, SecondPortBox, SecondEnabledBox);
}
private void Show(int at, TextBox host, TextBox port, CheckBox enabled)
{
StoredRadio radio = at < settings.Radios.Count
? settings.Radios[at]
: new StoredRadio { Port = DefaultPort + at };
host.Text = radio.Host;
port.Text = radio.Port.ToString();
enabled.IsChecked = radio.IsEnabled;
}
private void OnSave(object? sender, RoutedEventArgs e) => Close(settings with
{
RigctldHost = (HostBox.Text ?? "127.0.0.1").Trim(),
RigctldPort = int.TryParse(PortBox.Text, out int port) ? port : 4532,
RadioEnabled = EnabledBox.IsChecked == true,
Radios =
[
Read(HostBox, PortBox, EnabledBox),
Read(SecondHostBox, SecondPortBox, SecondEnabledBox),
],
});
private static StoredRadio Read(TextBox host, TextBox port, CheckBox enabled) => new()
{
Host = (host.Text ?? "127.0.0.1").Trim(),
Port = int.TryParse(port.Text, out int number) ? number : DefaultPort,
IsEnabled = enabled.IsChecked == true,
};
private void OnCancel(object? sender, RoutedEventArgs e) => Close(null);
}