Let MMTTY hold the text waiting to go out, behind a setting

MMTTY has a type-ahead buffer of its own: characters go into it, a backspace
takes back one it has not transmitted, and TxBufLen says how many are left. Used
that way it paces itself, so there is no gap between characters to tune and no
baud rate to keep in step with the engine.

EngineTypeAhead does that, and Config > Digital picks between it and the pump
that is there now. Off is still the default: three things it rests on have never
been seen with a real engine.

tools/Nonemm.EngineProbe asks the engine those three questions and writes the
answers to a file. It starts MMTTY through the bridge, pushes a message, polls
TxBufLen while it goes out, backspaces over text that has and has not been
transmitted, and logs what came back on the receive side and when.

The bridge learns one verb for it: `buffer` reads TxBufLen and answers with the
count, or -1 when the control will not say. A property the control does not know
is a log line rather than an error, since it stops nothing.

TypeAhead and EngineTypeAhead share the TransmitBuffer interface, which is what
the digital window now works through, so the window does not know which one it
has.

docs/unfinished.md states what each buffer assumes and how to run the probe.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RtspmWmS7f8kUvcyaHpRWZ
This commit is contained in:
2026-09-01 22:41:18 +00:00
parent da7f7fb3f5
commit 54b9181c06
25 changed files with 1311 additions and 68 deletions

View File

@@ -333,7 +333,10 @@ public sealed class AppSession : IDisposable
MmttyEngine started = new(channel, options);
await started.StartAsync();
digital = started;
digitalSender = new DigitalEngineSender(started, Settings.DigitalBaud);
digitalSender = new DigitalEngineSender(
started,
Settings.DigitalBaud,
Settings.DigitalEngineHoldsBuffer);
Changed?.Invoke(this, EventArgs.Empty);
return started;
}

View File

@@ -260,6 +260,12 @@ public sealed record Settings
/// MMTTY's own default, and what nearly every RTTY contest runs at.
public double DigitalBaud { get; init; } = 45.45;
/// The engine holds the text waiting to go out instead of Nonemm feeding it
/// a couple of characters at a time. MMTTY has a buffer of its own and can
/// say how much of it is left; see `docs/unfinished.md` for what has been
/// checked against a real engine and what has not.
public bool DigitalEngineHoldsBuffer { get; init; }
/// N1MM caps the receive pane's font at 14 points.
public int DigitalFontSize { get; init; } = 12;

View File

@@ -114,6 +114,10 @@
<TextBox Name="BaudBox" Width="120" HorizontalAlignment="Left" />
<TextBlock Classes="label" TextWrapping="Wrap"
Text="The speed the engine transmits at, which paces the transmit pane. Set it to the same speed as the engine: 45.45 baud unless the contest says otherwise." />
<CheckBox Name="EngineBufferBox" Margin="0,8,0,0"
Content="Let the engine hold the text waiting to go out" />
<TextBlock Classes="label" TextWrapping="Wrap"
Text="MMTTY keeps its own type-ahead buffer and says how much of it is left, so the transmit pane can push everything to it and take back what has not been transmitted. The baud rate is then MMTTY's business and this setting stops pacing anything. Untested against a real engine." />
</StackPanel>
</Border>
</HeaderedContentControl>

View File

@@ -89,6 +89,7 @@ public sealed partial class DigitalDialog : Window
BackgroundHighlightBox.IsChecked = settings.DigitalHighlightBackground;
MarkBox.Text = settings.DigitalMarkHertz.ToString(CultureInfo.InvariantCulture);
BaudBox.Text = settings.DigitalBaud.ToString(CultureInfo.InvariantCulture);
EngineBufferBox.IsChecked = settings.DigitalEngineHoldsBuffer;
WindowBox.ItemsSource = WindowSizes;
WindowBox.SelectedItem =
WindowSizes.FirstOrDefault(s => s == settings.DigitalEngineWindow) ?? WindowSizes[0];
@@ -305,6 +306,7 @@ public sealed partial class DigitalDialog : Window
out double baud) && baud > 0
? baud
: settings.DigitalBaud,
DigitalEngineHoldsBuffer = EngineBufferBox.IsChecked == true,
DigitalEngineWindow = WindowBox.SelectedItem as string ?? "Normal",
DigitalEngineOnTop = OnTopBox.IsChecked == true,
DigitalEnabled = (EngineBox.Text?.Trim().Length ?? 0) > 0,

View File

@@ -157,7 +157,7 @@ public sealed partial class DigitalWindow
{
return;
}
keyer.TypeAhead.Rewrite(TransmitBox.Text ?? "", CursorInBox());
keyer.Buffer.Rewrite(TransmitBox.Text ?? "", CursorInBox());
}
/// The cursor holds the pump back: nothing behind it goes out, so the
@@ -169,7 +169,7 @@ public sealed partial class DigitalWindow
{
if (session.DigitalKeyer is { } keyer)
{
keyer.TypeAhead.Cursor = TransmitBox.IsFocused ? CursorInBox() : TypeAhead.NoCursor;
keyer.Buffer.Cursor = TransmitBox.IsFocused ? CursorInBox() : TransmitBuffer.NoCursor;
}
}
@@ -188,8 +188,8 @@ public sealed partial class DigitalWindow
showingBuffer = true;
try
{
SentText.Text = keyer.TypeAhead.Sent;
string pending = keyer.TypeAhead.Pending;
SentText.Text = keyer.Buffer.Sent;
string pending = keyer.Buffer.Pending;
string was = TransmitBox.Text ?? "";
if (was == pending)
{
@@ -275,7 +275,7 @@ public sealed partial class DigitalWindow
private void OnClearTransmit(object? sender, RoutedEventArgs e)
{
session.DigitalKeyer?.TypeAhead.Clear();
session.DigitalKeyer?.Buffer.Clear();
ShowBuffer();
}

View File

@@ -60,7 +60,7 @@ public sealed partial class DigitalWindow : RefreshableWindow
private bool showingBuffer;
/// The buffer this window is drawing, or null while no engine is running.
private TypeAhead? buffer;
private TransmitBuffer? buffer;
/// Where the next line goes in a non-scrolling pane. It walks down the
/// window and starts again at the top; -1 is before the first line.
@@ -107,9 +107,9 @@ public sealed partial class DigitalWindow : RefreshableWindow
SentText.Foreground = Transmitted;
SentText.FontSize = Settings.DigitalFontSize;
TransmitBox.FontSize = Settings.DigitalFontSize;
if (buffer is not null)
if (buffer is TypeAhead paced)
{
buffer.Baud = Settings.DigitalBaud;
paced.Baud = Settings.DigitalBaud;
}
FollowRunAndFrequency();
ShowState();
@@ -147,10 +147,13 @@ public sealed partial class DigitalWindow : RefreshableWindow
}
Detach();
engine = started;
buffer = session.DigitalKeyer?.TypeAhead;
buffer = session.DigitalKeyer?.Buffer;
if (buffer is TypeAhead paced)
{
paced.Baud = Settings.DigitalBaud;
}
if (buffer is not null)
{
buffer.Baud = Settings.DigitalBaud;
buffer.Changed += WhenBufferChanged;
}
started.Received += WhenReceived;