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>
60 lines
1.6 KiB
C#
60 lines
1.6 KiB
C#
namespace Nonemm.Rig.Tests;
|
|
|
|
public class RigctldReplyTests
|
|
{
|
|
[Fact]
|
|
public void FieldsAreReadOffAnExtendedAnswer()
|
|
{
|
|
RigctldReply reply = RigctldReply.Parse([
|
|
"get_split_vfo:",
|
|
"Split: 1",
|
|
"TX VFO: VFOB",
|
|
"RPRT 0",
|
|
]);
|
|
|
|
Assert.True(reply.IsOk);
|
|
Assert.Equal(1, reply.Number("Split"));
|
|
Assert.Equal("VFOB", reply.Value("TX VFO"));
|
|
}
|
|
|
|
/// A radio that cannot do what was asked answers -11. That is an answer,
|
|
/// not a broken connection.
|
|
[Fact]
|
|
public void ARadioThatCannotDoItAnswersWithACode()
|
|
{
|
|
RigctldReply reply = RigctldReply.Parse(["RPRT -11"]);
|
|
|
|
Assert.False(reply.IsOk);
|
|
Assert.Equal(-11, reply.Result);
|
|
Assert.Null(reply.Number("Split"));
|
|
}
|
|
|
|
[Fact]
|
|
public void TheEchoedCommandIsNotAField()
|
|
{
|
|
RigctldReply reply = RigctldReply.Parse(["get_freq:", "Frequency: 14025000", "RPRT 0"]);
|
|
|
|
Assert.Equal(14_025_000, reply.Number("Frequency"));
|
|
Assert.Null(reply.Value("get_freq"));
|
|
}
|
|
|
|
[Fact]
|
|
public void ASetCommandEchoesItsArgumentAndReportsSuccess()
|
|
{
|
|
RigctldReply reply = RigctldReply.Parse(["set_freq: 14025000", "RPRT 0"]);
|
|
|
|
Assert.True(reply.IsOk);
|
|
Assert.Equal(14_025_000, reply.Number("set_freq"));
|
|
}
|
|
|
|
[Fact]
|
|
public void ATextValueThatIsNotANumberReadsBackAsNull()
|
|
{
|
|
RigctldReply reply = RigctldReply.Parse(["get_mode:", "Mode: CW", "Passband: 500", "RPRT 0"]);
|
|
|
|
Assert.Equal("CW", reply.Value("Mode"));
|
|
Assert.Null(reply.Number("Mode"));
|
|
Assert.Equal(500, reply.Number("Passband"));
|
|
}
|
|
}
|