fix: auto-call CW gap started before the message had finished

Reported: a 6 s auto-call gap gives clearly less than 6 s between the end of one
CQ and the start of the next.

The wait after sending watched only the keyer's busy signal. That signal travels
from the keyer to the window as an event, and the code gave it one second to
appear before giving up — if it had not arrived and cleared by then, the wait
ended immediately and the gap ran from the START of the call. A 6 s gap after a
4 s CQ becomes about 2 s of silence, which is exactly what was heard.

The message's own duration is now a FLOOR: the wait runs at least the estimated
sending time, and the busy signal only extends it (slow link, long buffer),
capped as before. The estimate can only be approximate, but it cannot be skipped
by a late event, and erring long costs a slightly wider gap rather than a call
that steps on the previous one.
This commit is contained in:
2026-07-29 22:28:18 +02:00
parent b0da6a3d14
commit 3ab6b95ff8
2 changed files with 19 additions and 7 deletions
+15 -5
View File
@@ -2602,11 +2602,21 @@ export default function App() {
if (isRig) {
await waitMs(Math.round(estimateCwMs(resolved, wkWpm)) + 600);
} else {
// WinKeyer: watch the busy echo, capped by the estimate (+slack) since
// over a remote/serial-over-IP link that echo can lag tens of seconds.
const capMs = Math.round(estimateCwMs(resolved, wkWpm) * 1.4) + 2500;
for (let i = 0; i < 20 && !wkBusyRef.current && !aborted(); i++) await sleep(50); // ≤1s to start
const deadline = Date.now() + capMs;
// WinKeyer / serial keyer: the message takes AT LEAST its own length to
// send, so the estimate is a floor and the busy signal only extends it.
//
// Waiting on busy alone made the auto-call gap start early: busy travels
// from the keyer to this window as an event, and if it had not arrived
// and cleared within the one-second start window the wait simply ended.
// A 6 s gap then ran from the START of the CQ — about 2 s of silence
// after a 4 s call, which is what an operator hears as "clearly not 6".
const estMs = Math.round(estimateCwMs(resolved, wkWpm));
const started = Date.now();
const capMs = Math.round(estMs * 1.4) + 2500;
const deadline = started + capMs;
// The message's own duration, first — this is the part that must not be skipped.
while (Date.now() - started < estMs && !aborted()) await sleep(50);
// Then let a still-sending keyer finish (slow link, long buffer), capped.
while (wkBusyRef.current && !aborted() && Date.now() < deadline) await sleep(50);
}
}