-
EventTarget
↳
default
- baudRate
- break
- bufferSize
- clearToSend
- dataBits
- dataCarrierDetect
- dataSetReady
- dataTerminalReady
- flowControl
- isAvailable
- isClosing
- isConnected
- isOpen
- parity
- requestToSend
- ringIndicator
- stopBits
- usbProductId
- usbVendorId
• new default(): default
VueSerial instance constructor
EventTarget.constructor
• get
baudRate(): number
A positive, non-zero value indicating the baud rate at which serial communication should be established
number
• set
baudRate(value
): void
Name | Type |
---|---|
value |
number |
void
• get
break(): boolean
Break output signal value
boolean
• set
break(value
): void
Name | Type |
---|---|
value |
boolean |
void
Remarks
This will be set asynchronously. Prefer await serial.setSignals({ break: ... })
for precise asynchronous control
• get
bufferSize(): number
A positive, non-zero value indicating the size of the read and write buffers that should be created.
number
• set
bufferSize(value
): void
Name | Type |
---|---|
value |
number |
void
• get
clearToSend(): boolean
Clear To Send (CTS) input signal value
boolean
Remarks
This value must be refreshed manually by calling serial.getSignals() or automatically with serial.startSignalsPolling(...)
• get
dataBits(): number
The number of data bits per frame (either 7 or 8)
number
• set
dataBits(value
): void
Name | Type |
---|---|
value |
number |
void
• get
dataCarrierDetect(): boolean
Data Carrier Detect (DCD) input signal value
boolean
Remarks
This value must be refreshed manually by calling serial.getSignals() or automatically with serial.startSignalsPolling(...)
• get
dataSetReady(): boolean
Data Set Ready (DSR) input signal value
boolean
Remarks
This value must be refreshed manually by calling serial.getSignals()
or automatically with serial.startSignalsPolling(...)
• get
dataTerminalReady(): boolean
Data Terminal Ready (DTR) output signal value
boolean
• set
dataTerminalReady(value
): void
Name | Type |
---|---|
value |
boolean |
void
Remarks
This will be set asynchronously. Prefer await serial.setSignals({ dataTerminalReady: ... })
for precise asynchronous control
• get
flowControl(): FlowControlType
The flow control mode (either "hardware" or "none")
FlowControlType
• set
flowControl(value
): void
Name | Type |
---|---|
value |
FlowControlType |
void
• get
isAvailable(): boolean
Constant property indicating if the serial feature is available on the client navigator (Web Serial API is implemented and page is served using HTTPS)
boolean
• get
isClosing(): boolean
Becomes true when the device is currently closing (after the close() function has been called)
boolean
• get
isConnected(): boolean
Becomes false if the open device has been disconnected
boolean
• get
isOpen(): boolean
Tracks the active state of the serial port
boolean
• get
parity(): ParityType
The parity mode (either "none", "even" or "odd")
ParityType
• set
parity(value
): void
Name | Type |
---|---|
value |
ParityType |
void
• get
requestToSend(): boolean
Request To Send (RTS) output signal value
boolean
• set
requestToSend(value
): void
Name | Type |
---|---|
value |
boolean |
void
Remarks
This will be set asynchronously. Prefer await serial.setSignals({ requestToSend: ... })
for precise asynchronous control
• get
ringIndicator(): boolean
Ring Indicator (RI) input signal value
boolean
Remarks
This value must be refreshed manually by calling serial.getSignals() or automatically with serial.startSignalsPolling(...)
• get
stopBits(): number
The number of stop bits per frame (either 1 or 2)
number
• set
stopBits(value
): void
Name | Type |
---|---|
value |
number |
void
• get
usbProductId(): undefined
| number
Current port USB product ID
undefined
| number
• get
usbVendorId(): undefined
| number
Current port USB vendor ID
undefined
| number
â–¸ close(): Promise
<void
>
Close the current port if open
Promise
<void
>
â–¸ connect(filters
): Promise
<void
>
Ask the user to select the serial port and open it
Name | Type | Description |
---|---|---|
filters |
undefined | SerialPortFilter [] |
A list of objects containing vendor and product IDs used to search for attached devices. |
Promise
<void
>
â–¸ getSignals(): Promise
<SerialInputSignals
>
Get the DCD, CTS, RI and DSR signals (alternative to use built-in polling)
Promise
<SerialInputSignals
>
Object containing "dataCarrierDetect", "clearToSend", "ringIndicator" and "dataSetReady" booleans
Note
You can also get the same values in serial.dataCarrierDetect, serial.clearToSend, serial.ringIndicator and serial.dataSetReady
â–¸ restoreDefaults(): void
Restore defaults settings
void
â–¸ setSignals(signals
): Promise
<void
>
Set the DTR, RTS and break signals
Name | Type | Description |
---|---|---|
signals |
SerialOutputSignals |
object containing either "dataTerminalReady", "requestToSend" and/or "break" booleans |
Promise
<void
>
Note
You can also set the serial.dataTerminalReady, serial.requestToSend, and serial.break variables if you don't need asynchronous control
â–¸ startSignalsPolling(interval_ms
): void
Start listening for signals changes and update the corresponding variables
Name | Type | Description |
---|---|---|
interval_ms |
null | number |
Polling interval in ms (100ms if not specified) |
void
â–¸ stopSignalsPolling(): void
Stop listening for signal changes
void
â–¸ write(value
): Promise
<void
>
Send data to the open serial port
Name | Type | Description |
---|---|---|
value |
Iterable <number > |
The content to send |
Promise
<void
>
â–ª Static
read: string
Event which is triggered when data is received from the open device port.
Call serial.addEventListener("read", ({ value }) => { ... })
to read incoming data.