Serial port, baud rate, unit ID, etc.
Callback functions that handle incoming Modbus requests (same ServerHandlers shape as the native TCP/serial servers).
A Layer that fails with ModbusError on bind failure.
import { Effect, Layer } from "effect";
import { wasmSerialRtuServerLayer } from "@flux-control/effect-modbus-rs";
const port = await navigator.serial.requestPort(); // user-gesture gated
const ServerLive = wasmSerialRtuServerLayer(
{ serialPort: port, unitId: 1, baudRate: 19200 },
{ onReadCoils: (req) => [false, false] },
);
Layer.launch(ServerLive).pipe(Effect.runPromise);
A scoped Layer that starts a browser Modbus RTU server over the Web Serial API (experimental upstream surface).
options.serialPortis the rawSerialPortobject obtained from the consumer's own app code vianavigator.serial.requestPort()(which has thedomlib types available) — not this package's requestSerialPort helper, which returns theWasmSerialPortHandlewrapper used only by the client-side transports (WasmRtuTransportService/WasmAsciiTransportService).Like wasmWsServerLayer, the WASM server requires a continuously-awaited
serve()call to drive its request loop; this layer forks that call into the scope automatically so the returnedLayer"just works".