Serial port options (path, baud rate, unit ID, etc.).
Callback functions that handle incoming Modbus requests.
A Layer that fails with ModbusError on bind failure.
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.