@flux-control/effect-modbus-rs
    Preparing search index...

    Function serialAsciiServerLayer

    • A scoped Layer that starts a Modbus serial ASCII server.

      Parameters

      • options: SerialServerOptions

        Serial port options (path, baud rate, unit ID, etc.).

      • handlers: ServerHandlers

        Callback functions that handle incoming Modbus requests.

      Returns Layer<never, ModbusError>

      A Layer that fails with ModbusError on bind failure.

      import { Effect, Layer } from "effect";
      import { serialAsciiServerLayer } from "@flux-control/effect-modbus-rs";

      const ServerLive = serialAsciiServerLayer(
      { portPath: "/dev/ttyUSB0", baudRate: 9600, unitId: 1 },
      { onReadCoils: (req) => [false, false] },
      );

      Layer.launch(ServerLive).pipe(Effect.runPromise);
      • SerialServerOptions — Options accepted by the upstream serial server.
      • ServerHandlers — Interface for request handler callbacks.