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

    Class WasmSerialTransportService

    Abstract browser (WASM) serial Modbus transport service tag.

    Represents a Web Serial-based Modbus transport backed by either ASCII or RTU framing. Use this tag when you need a browser serial transport but don't care about the specific framing protocol.

    Consumers yield* WasmSerialTransportService to obtain a TransportServiceApi and satisfy the tag via one of the static provider methods:

    // Provide with ASCII framing
    Layer.provide(WasmSerialTransportService.fromAscii({ port, baudRate: 9600 }))

    // Provide with RTU framing
    Layer.provide(WasmSerialTransportService.fromRtu({ port, baudRate: 9600 }))

    requestSerialPort — Obtains the port handle both providers need (must be called from a user gesture).

    Hierarchy

    • TagClassShape<"WasmSerialTransportService", TransportServiceApi, this>
      • WasmSerialTransportService
    Index
    • Parameters

      • _: never

      Returns WasmSerialTransportService

    • Creates a mock Layer that provides WasmSerialTransportService for tests or development.

      The devices parameter is an array of SlaveDeviceDefinition. Each definition gives the coil map and the register map of one simulated slave.

      The option set is the same as the option set of the concrete tags. Thus a test that keeps the framing abstract can also set retry, reconnect, fault, and reconnectFault.

      Parameters

      • devices: readonly {
            coils: readonly { address: number; default: boolean }[];
            discreteInputs: readonly { address: number; default: boolean }[];
            holdingRegisters: readonly { address: number; default: number }[];
            inputRegisters: readonly { address: number; default: number }[];
            unitId: number;
        }[]

        The slave device definitions for the mock.

      Returns (
          options: (WasmRtuTransportOpenOptions | WasmAsciiTransportOpenOptions) & TransportResilienceOptions & MockFaultOptions,
      ) => Layer<WasmSerialTransportService>

      A function that takes the mock options and gives a scoped Layer that provides the mock service.

      • MockFaultOptions — The fault hook and the reconnectFault hook.
      • makeMockTransport — The mock factory that this method uses.