Class

WebSerialDevice

WebSerialDevice(baudRateopt, serialopt)

Small convenience class for easily connecting to a serial device from a browser using the Web Serial API.

Constructor

# new WebSerialDevice(baudRateopt, serialopt)

Create a new WebSerialDevice.

Parameters:
Name Type Attributes Default Description
baudRate Number <optional>
115200

Communication rate.

serial Serial <optional>
navigator.serial

Web Serial API interface.

View Source devices/web-serial-device.js, line 5

Example
const device = new WebSerialDevice();

Methods

# async requestConnection() → {Promise}

Opens a request to connect to a serial device.

View Source devices/web-serial-device.js, line 45

a promise that resolves when the device is connected, and rejects if the device failed to connect.

Promise
Example
const device = new WebSerialDevice();
device.requestConnection().then(() => {
  // ...
});

# write(output)

Write output to the device.

Parameters:
Name Type Description
output String

string to send to the device.

View Source devices/web-serial-device.js, line 98