SerialPort

The SerialPort interface of the Web Serial API provides access to a serial port on the host device. Available only in secure contexts.

MDN Reference

Properties

Link copied to clipboard

The connected read-only property of the SerialPort interface returns a boolean value that indicates whether the port is logically connected to the device.

Link copied to clipboard

The readable read-only property of the SerialPort interface returns a ReadableStream for receiving data from the device connected to the port. Chunks read from this stream are instances of Uint8Array. This property is non-null as long as the port is open and has not encountered a fatal error.

Link copied to clipboard

The writable read-only property of the SerialPort interface returns a WritableStream for sending data to the device connected to the port. Chunks written to this stream must be instances of ArrayBuffer, TypedArray, or DataView. This property is non-null as long as the port is open and has not encountered a fatal error.

Functions

Link copied to clipboard
inline suspend fun SerialPort.close()

The SerialPort.close() method of the SerialPort interface returns a Promise that resolves when the port closes.

Link copied to clipboard

The SerialPort.close() method of the SerialPort interface returns a Promise that resolves when the port closes.

Link copied to clipboard
open fun dispatchEvent(event: Event): Boolean
Link copied to clipboard
inline suspend fun SerialPort.forget()

The SerialPort.forget() method of the SerialPort interface returns a Promise that resolves when access to the serial port is revoked.

Link copied to clipboard

The SerialPort.forget() method of the SerialPort interface returns a Promise that resolves when access to the serial port is revoked.

Link copied to clipboard

The getInfo() method of the SerialPort interface returns an object containing identifying information for the device available via the port.

Link copied to clipboard

The SerialPort.getSignals() method of the SerialPort interface returns a Promise that resolves with an object containing the current state of the port's control signals.

Link copied to clipboard

The SerialPort.getSignals() method of the SerialPort interface returns a Promise that resolves with an object containing the current state of the port's control signals.

Link copied to clipboard
inline suspend fun SerialPort.open(options: SerialOptions)

The open() method of the SerialPort interface returns a Promise that resolves when the port is opened. By default the port is opened with 8 data bits, 1 stop bit and no parity checking. The baudRate parameter is required.

Link copied to clipboard

The open() method of the SerialPort interface returns a Promise that resolves when the port is opened. By default the port is opened with 8 data bits, 1 stop bit and no parity checking. The baudRate parameter is required.

Link copied to clipboard
inline suspend fun SerialPort.setSignals()
inline suspend fun SerialPort.setSignals(signals: SerialOutputSignals)

The setSignals() method of the SerialPort interface sets control signals on the port and returns a Promise that resolves when they are set.

Link copied to clipboard
fun setSignalsAsync(signals: SerialOutputSignals = definedExternally): Promise<Void>

The setSignals() method of the SerialPort interface sets control signals on the port and returns a Promise that resolves when they are set.

Link copied to clipboard