Serial port options (path, baud rate, unit ID, etc.).
Callback functions that handle incoming Modbus requests.
A layer that starts the server; bind failures enter the ModbusError channel. Scope finalization shuts it down, and shutdown failures are ignored.
import { Effect, Layer } from "effect";
import { serialRtuServerLayer } from "@flux-control/effect-modbus-rs";
const ServerLive = serialRtuServerLayer(
{ portPath: "/dev/ttyUSB0", baudRate: 9600, unitId: 1 },
{ onReadCoils: (req) => [false, false] },
);
Layer.launch(ServerLive).pipe(Effect.runPromise);
A scoped Layer that starts a Modbus serial RTU server.