SendInput declared its parameter as Span<INPUT>, which cannot be marshalled (MarshalDirectiveException) — the first keyboard/mouse output threw on the serial read thread and killed the link. Pass a blittable INPUT[] instead; add a regression test. Also: defend the runtime so a faulty output sink can never tear down the serial link (output is best-effort), and dim lit lamps on the first reply from the board rather than in Start() — lamp commands sent in the first ms after the DTR reset (on port open) are dropped before the board has booted. Verified end-to-end against the partial RIO on COM1 (keypad types to the PC, joystick feeds, comms stay up; lit MFD buttons come up dim). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
22 lines
636 B
C#
22 lines
636 B
C#
using RioJoy.Core.Output;
|
|
using Xunit;
|
|
|
|
namespace RioJoy.Core.Tests.Output;
|
|
|
|
public class SendInputSinkTests
|
|
{
|
|
[Fact]
|
|
public void SendInput_DoesNotThrow_OnMarshalling()
|
|
{
|
|
var sink = new SendInputSink();
|
|
|
|
// A zero relative mouse move is a no-op, but it exercises the same SendInput
|
|
// INPUT[] marshalling path that previously threw MarshalDirectiveException with
|
|
// a Span<INPUT> parameter — which killed the serial read thread when a button
|
|
// with output enabled was pressed.
|
|
Exception? ex = Record.Exception(() => sink.MouseMove(0, 0));
|
|
|
|
Assert.Null(ex);
|
|
}
|
|
}
|