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

    Class SerialTransportService

    Abstract serial Modbus transport service tag.

    Represents a serial (RS-232/485) Modbus transport backed by either ASCII or RTU framing. Use this tag when you need a serial transport but don't care about the specific framing protocol.

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

    // Provide with ASCII framing
    Layer.provide(SerialTransportService.fromAscii({ path: "/dev/ttyUSB0", baudRate: 9600 }))

    // Provide with RTU framing
    Layer.provide(SerialTransportService.fromRtu({ path: "/dev/ttyUSB0", baudRate: 9600 }))

    Hierarchy

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

      • _: never

      Returns SerialTransportService

    • Creates a mock Layer that provides SerialTransportService 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: (AsciiTransportOpenOptions | RtuTransportOpenOptions) & TransportResilienceOptions & MockFaultOptions,
      ) => Layer<SerialTransportService>

      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.