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

    Function requestSerialPort

    • Requests a browser serial port handle via the Web Serial API, for use with WasmSerialTransportService.fromRtu / .fromAscii (or WasmRtuTransportService.make / WasmAsciiTransportService.make directly).

      Call this from a browser user-gesture handler, such as a click handler, because the Web Serial API may require transient user activation to show its chooser. The helper loads the browser binding before requesting the port, so it does not itself call the browser API synchronously in the handler.

      Returns Effect<WasmSerialPortHandle, ModbusError>

      An effect that succeeds with the selected opaque port handle or fails with ModbusError when the browser request or binding fails.

      button.addEventListener("click", () => {
      Effect.runPromise(
      requestSerialPort().pipe(
      Effect.flatMap((port) => Effect.provide(program, WasmRtuTransportService.make({ port, baudRate: 19200 }))),
      ),
      );
      });

      WasmSerialPortHandle — Opaque handle returned by modbus-rs's WASM bindings.