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. |
Example
const device = new WebSerialDevice();
Methods
# async requestConnection() → {Promise}
Opens a request to connect to a serial device.
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. |