Skip to content

Latest commit

 

History

History
569 lines (311 loc) · 8.93 KB

default.md

File metadata and controls

569 lines (311 loc) · 8.93 KB

Class: default

Hierarchy

  • EventTarget

    ↳ default

Table of contents

Constructors

Accessors

Methods

Events

Constructors

constructor

• new default(): default

VueSerial instance constructor

Returns

default

Overrides

EventTarget.constructor

Accessors

baudRate

• get baudRate(): number

A positive, non-zero value indicating the baud rate at which serial communication should be established

Returns

number

• set baudRate(value): void

Parameters

Name Type
value number

Returns

void


break

• get break(): boolean

Break output signal value

Returns

boolean

• set break(value): void

Parameters

Name Type
value boolean

Returns

void

Remarks

This will be set asynchronously. Prefer await serial.setSignals({ break: ... }) for precise asynchronous control


bufferSize

• get bufferSize(): number

A positive, non-zero value indicating the size of the read and write buffers that should be created.

Returns

number

• set bufferSize(value): void

Parameters

Name Type
value number

Returns

void


clearToSend

• get clearToSend(): boolean

Clear To Send (CTS) input signal value

Returns

boolean

Remarks

This value must be refreshed manually by calling serial.getSignals() or automatically with serial.startSignalsPolling(...)


dataBits

• get dataBits(): number

The number of data bits per frame (either 7 or 8)

Returns

number

• set dataBits(value): void

Parameters

Name Type
value number

Returns

void


dataCarrierDetect

• get dataCarrierDetect(): boolean

Data Carrier Detect (DCD) input signal value

Returns

boolean

Remarks

This value must be refreshed manually by calling serial.getSignals() or automatically with serial.startSignalsPolling(...)


dataSetReady

• get dataSetReady(): boolean

Data Set Ready (DSR) input signal value

Returns

boolean

Remarks

This value must be refreshed manually by calling serial.getSignals() or automatically with serial.startSignalsPolling(...)


dataTerminalReady

• get dataTerminalReady(): boolean

Data Terminal Ready (DTR) output signal value

Returns

boolean

• set dataTerminalReady(value): void

Parameters

Name Type
value boolean

Returns

void

Remarks

This will be set asynchronously. Prefer await serial.setSignals({ dataTerminalReady: ... }) for precise asynchronous control


flowControl

• get flowControl(): FlowControlType

The flow control mode (either "hardware" or "none")

Returns

FlowControlType

• set flowControl(value): void

Parameters

Name Type
value FlowControlType

Returns

void


isAvailable

• 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)

Returns

boolean


isClosing

• get isClosing(): boolean

Becomes true when the device is currently closing (after the close() function has been called)

Returns

boolean


isConnected

• get isConnected(): boolean

Becomes false if the open device has been disconnected

Returns

boolean


isOpen

• get isOpen(): boolean

Tracks the active state of the serial port

Returns

boolean


parity

• get parity(): ParityType

The parity mode (either "none", "even" or "odd")

Returns

ParityType

• set parity(value): void

Parameters

Name Type
value ParityType

Returns

void


requestToSend

• get requestToSend(): boolean

Request To Send (RTS) output signal value

Returns

boolean

• set requestToSend(value): void

Parameters

Name Type
value boolean

Returns

void

Remarks

This will be set asynchronously. Prefer await serial.setSignals({ requestToSend: ... }) for precise asynchronous control


ringIndicator

• get ringIndicator(): boolean

Ring Indicator (RI) input signal value

Returns

boolean

Remarks

This value must be refreshed manually by calling serial.getSignals() or automatically with serial.startSignalsPolling(...)


stopBits

• get stopBits(): number

The number of stop bits per frame (either 1 or 2)

Returns

number

• set stopBits(value): void

Parameters

Name Type
value number

Returns

void


usbProductId

• get usbProductId(): undefined | number

Current port USB product ID

Returns

undefined | number


usbVendorId

• get usbVendorId(): undefined | number

Current port USB vendor ID

Returns

undefined | number

Methods

close

â–¸ close(): Promise<void>

Close the current port if open

Returns

Promise<void>


connect

â–¸ connect(filters): Promise<void>

Ask the user to select the serial port and open it

Parameters

Name Type Description
filters undefined | SerialPortFilter[] A list of objects containing vendor and product IDs used to search for attached devices.

Returns

Promise<void>


getSignals

â–¸ getSignals(): Promise<SerialInputSignals>

Get the DCD, CTS, RI and DSR signals (alternative to use built-in polling)

Returns

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

â–¸ restoreDefaults(): void

Restore defaults settings

Returns

void


setSignals

â–¸ setSignals(signals): Promise<void>

Set the DTR, RTS and break signals

Parameters

Name Type Description
signals SerialOutputSignals object containing either "dataTerminalReady", "requestToSend" and/or "break" booleans

Returns

Promise<void>

Note

You can also set the serial.dataTerminalReady, serial.requestToSend, and serial.break variables if you don't need asynchronous control


startSignalsPolling

â–¸ startSignalsPolling(interval_ms): void

Start listening for signals changes and update the corresponding variables

Parameters

Name Type Description
interval_ms null | number Polling interval in ms (100ms if not specified)

Returns

void


stopSignalsPolling

â–¸ stopSignalsPolling(): void

Stop listening for signal changes

Returns

void


write

â–¸ write(value): Promise<void>

Send data to the open serial port

Parameters

Name Type Description
value Iterable<number> The content to send

Returns

Promise<void>

Events

read

â–ª 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.