Namespace: serial

qz.serial

Calls related to interaction with serial ports.
Source:

Methods

(static) closePort(port) → {Promise.<(null|Error)>}

Parameters:
Name Type Description
port string Name of port to close.
Source:
Returns:
Type
Promise.<(null|Error)>

(static) findPorts() → {Promise.<(Array.<string>|Error)>}

Source:
Returns:
Communication (RS232, COM, TTY) ports available on connected system.
Type
Promise.<(Array.<string>|Error)>

(static) openPort(port, optionsopt) → {Promise.<(null|Error)>}

Opens a serial port for sending and receiving data
Parameters:
Name Type Attributes Description
port string Name of serial port to open.
options Object <optional>
Serial port configurations.
Properties
Name Type Attributes Default Description
baudRate number <optional>
9600 Serial port speed. Set to 0 for auto negotiation.
dataBits number <optional>
8 Serial port data bits. Set to 0 for auto negotiation.
stopBits number <optional>
1 Serial port stop bits. Set to 0 for auto negotiation.
parity string <optional>
'NONE' Serial port parity. Set to AUTO for auto negotiation. Valid values [NONE | EVEN | ODD | MARK | SPACE | AUTO]
flowControl string <optional>
'NONE' Serial port flow control. Set to AUTO for auto negotiation. Valid values [NONE | XONXOFF | XONXOFF_OUT | XONXOFF_IN | RTSCTS | RTSCTS_OUT | RTSCTS_IN | AUTO]
encoding string <optional>
'UTF-8' Character set for communications.
start string <optional>
0x0002 DEPRECATED: Legacy character denoting start of serial response. Use options.rx.start instead.
end string <optional>
0x000D DEPRECATED: Legacy character denoting end of serial response. Use options.rx.end instead.
width number <optional>
DEPRECATED: Legacy use for fixed-width response serial communication. Use options.rx.width instead.
rx Object <optional>
Serial communications response definitions. If an object is passed but no options are defined, all response data will be sent back as it is received unprocessed.
Properties
Name Type Attributes Default Description
start string | Array.<string> <optional>
Character(s) denoting start of response bytes. Used in conjunction with `end`, `width`, or `lengthbit` property.
end string <optional>
Character denoting end of response bytes. Used in conjunction with `start` property.
width number <optional>
Fixed width size of response bytes (not including header if `start` is set). Used alone or in conjunction with `start` property.
untilNewline boolean <optional>
Returns data between newline characters (`\n` or `\r`) Truncates empty responses. Overrides `start`, `end`, `width`.
lengthBytes number | Object <optional>
If a number is passed it is treated as the length index. Other values are left as their defaults.
Properties
Name Type Attributes Default Description
index number <optional>
0 Position of the response byte (not including response `start` bytes) used to denote the length of the remaining response data.
length number <optional>
1 Length of response length bytes after response header.
endian string <optional>
'BIG' Byte endian for multi-byte length values. Valid values [BIG | LITTLE]
crcBytes number | Object <optional>
If a number is passed it is treated as the crc length. Other values are left as their defaults.
Properties
Name Type Attributes Default Description
index number <optional>
0 Position after the response data (not including length or data bytes) used to denote the crc.
length number <optional>
1 Length of response crc bytes after the response data length.
includeHeader boolean <optional>
false Whether any of the header bytes (`start` bytes and any length bytes) should be included in the processed response.
encoding string <optional>
Override the encoding used for response data. Uses the same value as options.encoding otherwise.
Source:
Returns:
Type
Promise.<(null|Error)>

(static) sendData(port, data, options) → {Promise.<(null|Error)>}

Send commands over a serial port. Any responses from the device will be sent to serial callback functions.
Parameters:
Name Type Description
port string An open serial port to send data.
data string | Array.<string> | Object Data to be sent to the serial device.
Properties
Name Type Attributes Default Description
type string <optional>
'PLAIN' Valid values [FILE | PLAIN | HEX | BASE64]
data string | Array.<string> Data to be sent to the serial device.
options Object Serial port configuration updates. See qz.serial.openPort `options` docs for available values. For best performance, it is recommended to only set these values on the port open call.
Source:
See:
Returns:
Type
Promise.<(null|Error)>

(static) setSerialCallbacks(calls)

List of functions called for any response from open serial ports. Event data will contain {string} portName for all types. For RECEIVE types, {string} output. For ERROR types, {string} exception.
Parameters:
Name Type Description
calls function | Array.<function()> Single or array of Function({object} streamEvent) calls.
Source: