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>
28 lines
1.1 KiB
C#
28 lines
1.1 KiB
C#
namespace Nonemm.Keying;
|
|
|
|
/// Something that sends a message on the air: a CW keyer, or a voice keyer
|
|
/// playing a recording.
|
|
public interface MessageSender : IDisposable
|
|
{
|
|
bool IsReady { get; }
|
|
|
|
/// True when the keyer tells us the message has gone out. Alternating CQ
|
|
/// needs it: timing a message from the length of its text is a guess that
|
|
/// goes wrong exactly when the contest is busy.
|
|
bool ReportsCompletion { get; }
|
|
|
|
/// Everything sent has now gone out on the air. Never raised by a keyer
|
|
/// whose `ReportsCompletion` is false. It arrives on whatever thread the
|
|
/// keyer reads on, so a handler that touches the screen has to post.
|
|
event EventHandler? Finished;
|
|
|
|
/// Sends the text. Whatever is already going out is finished first unless
|
|
/// `Abort` is called.
|
|
Task SendAsync(string text, CancellationToken cancellation = default);
|
|
|
|
/// Stops sending straight away, which is what Escape does mid-message.
|
|
Task AbortAsync(CancellationToken cancellation = default);
|
|
|
|
Task SetSpeedAsync(int wordsPerMinute, CancellationToken cancellation = default);
|
|
}
|