UART
Extends:
Wraps a SerialPort or similar object; provides convenience methods for interaction with a Nextion over UART.
Static Method Summary
Static Public Methods | ||
public static |
from(port: string | Duplex | Serialport, opts: NextionOptions): Promise<UART> Convenience wrapper of UART.fromPort and UART.fromSerial. |
|
public static |
fromPort(portName: string | NextionOptions, opts: NextionOptions): Promise<UART> Given a serial port name or path, or object containing one, create a Serialport instance, open the serial port, then return a {@link UART} instance. |
|
public static |
fromSerial(serialPort: Serialport | Duplex | *, opts: NextionOptions): Promise<UART> Given a Serialport-like object, create a UART wrapper. |
Constructor Summary
Public Constructor | ||
public |
constructor(port: EventEmitter | Duplex, opts: NextionOptions) Sets some default options |
Member Summary
Public Members | ||
public |
|
Method Summary
Public Methods | ||
public |
bind(port: EventEmitter | Duplex): Promise<UART> Begins listening for data on the open serial port. |
|
public |
request(commands: string[] | string, timeout: number): Promise<ResponseResult[]|ResponseResult, Error> Makes a request to a Nextion device, expecting a response. |
|
public |
setValue(variableName: string, value: *): Promise<ResponseResult, Error> Set variable |
Static Public Methods
public static from(port: string | Duplex | Serialport, opts: NextionOptions): Promise<UART> source
Convenience wrapper of UART.fromPort and UART.fromSerial.
Params:
Name | Type | Attribute | Description |
port | string | Duplex | Serialport |
|
Port name or object |
opts | NextionOptions |
|
Options |
public static fromPort(portName: string | NextionOptions, opts: NextionOptions): Promise<UART> source
Given a serial port name or path, or object containing one, create a Serialport instance, open the serial port, then return a {@link UART} instance. If no port name is present, we'll try to autodetect the port.
Params:
Name | Type | Attribute | Description |
portName | string | NextionOptions |
|
Serial port name or path, or options |
opts | NextionOptions |
|
Options |
public static fromSerial(serialPort: Serialport | Duplex | *, opts: NextionOptions): Promise<UART> source
Given a Serialport-like object, create a UART wrapper. Synchronous, but returns a Promise for consistency.
Params:
Name | Type | Attribute | Description |
serialPort | Serialport | Duplex | * | Serialport-like object |
|
opts | NextionOptions |
|
Options |
Public Constructors
public constructor(port: EventEmitter | Duplex, opts: NextionOptions) source
Sets some default options
Params:
Name | Type | Attribute | Description |
port | EventEmitter | Duplex | Serial port interface |
|
opts | NextionOptions |
|
Options |
Public Members
Public Methods
public bind(port: EventEmitter | Duplex): Promise<UART> source
Begins listening for data on the open serial port. If an event is emitted from the Nextion device, an event with a human-readable name will be emitted, along with any extra data, if present. Errors bubble up from the serial port object thru the UART instance.
Params:
Name | Type | Attribute | Description |
port | EventEmitter | Duplex |
|
|
public request(commands: string[] | string, timeout: number): Promise<ResponseResult[]|ResponseResult, Error> source
Makes a request to a Nextion device, expecting a response.
Return:
Promise<ResponseResult[]|ResponseResult, Error> | Result or array of results, or Error if device is not ready. |
public setValue(variableName: string, value: *): Promise<ResponseResult, Error> source
Set variable variableName
to value value
.
Boolean values true
and false
become 1
and 0
, respectively.
Params:
Name | Type | Attribute | Description |
variableName | string | Name of variable, component, system var, page, etc. |
|
value | * |
|
Will be coerced to a string. |