Skip to main content

Echo Loopback

When hardware has not arrived, or the field site does not allow arbitrary commands, use a virtual channel to verify “send -> receive -> display”.

await using var app = ZeusHost.Create(b => b.AddVirtualChannel("loop"));
var loop = app.Channels.Get("loop");
var tcs = new TaskCompletionSource<byte[]>();
loop.DataReceived += (_, e) => tcs.TrySetResult(e.Data.ToArray());

await app.StartAsync();
await loop.WriteAsync("PING"u8.ToArray());
var echoed = await tcs.Task;

When hardware is ready, replace AddVirtualChannel with AddSerialPort; the subscription code stays the same. If you have a physical loopback plug, a real serial port can run the same test.