Namespace: usb

qz.usb

Calls related to interaction with USB devices.
Source:

Methods

(static) claimDevice(vendorId, productId, iface) → {Promise.<(null|Error)>}

Claim a USB device's interface to enable sending/reading data across an endpoint.
Parameters:
Name Type Description
vendorId Hex string of USB device's vendor ID.
productId Hex string of USB device's product ID.
iface Hex string of interface on the USB device to claim.
Source:
Returns:
Type
Promise.<(null|Error)>

(static) closeStream(vendorId, productId, endpoint) → {Promise.<(null|Error)>}

Stops the stream of read data from a claimed USB device.
Parameters:
Name Type Description
vendorId Hex string of USB device's vendor ID.
productId Hex string of USB device's product ID.
endpoint Hex string of endpoint on the claimed interface for the USB device.
Source:
Returns:
Type
Promise.<(null|Error)>

(static) isClaimed(vendorId, productId) → {Promise.<(boolean|Error)>}

Check the current claim state of a USB device.
Parameters:
Name Type Description
vendorId Hex string of USB device's vendor ID.
productId Hex string of USB device's product ID.
Since:
  • 2.0.2
Source:
Returns:
Type
Promise.<(boolean|Error)>

(static) listDevices(includeHubs) → {Promise.<(Array.<Object>|Error)>}

List of available USB devices. Includes (hexadecimal) vendor ID, (hexadecimal) product ID, and hub status. If supported, also returns manufacturer and product descriptions.
Parameters:
Name Type Description
includeHubs Whether to include USB hubs.
Source:
Returns:
Array of JSON objects containing information on connected USB devices.
Type
Promise.<(Array.<Object>|Error)>

(static) listEndpoints(vendorId, productId, iface) → {Promise.<(Array.<string>|Error)>}

Parameters:
Name Type Description
vendorId Hex string of USB device's vendor ID.
productId Hex string of USB device's product ID.
iface Hex string of interface on the USB device to search.
Source:
Returns:
List of available (hexadecimal) endpoints on a USB device's interface.
Type
Promise.<(Array.<string>|Error)>

(static) listInterfaces(vendorId, productId) → {Promise.<(Array.<string>|Error)>}

Parameters:
Name Type Description
vendorId Hex string of USB device's vendor ID.
productId Hex string of USB device's product ID.
Source:
Returns:
List of available (hexadecimal) interfaces on a USB device.
Type
Promise.<(Array.<string>|Error)>

(static) openStream(vendorId, productId, endpoint, responseSize, intervalopt) → {Promise.<(null|Error)>}

Provides a continuous stream of read data from a claimed USB device.
Parameters:
Name Type Attributes Default Description
vendorId Hex string of USB device's vendor ID.
productId Hex string of USB device's product ID.
endpoint Hex string of endpoint on the claimed interface for the USB device.
responseSize Size of the byte array to receive a response in.
interval <optional>
100 Frequency to send read data back, in milliseconds.
Source:
See:
Returns:
Type
Promise.<(null|Error)>

(static) readData(vendorId, productId, endpoint, responseSize) → {Promise.<(Array.<string>|Error)>}

Read data from a claimed USB device.
Parameters:
Name Type Description
vendorId Hex string of USB device's vendor ID.
productId Hex string of USB device's product ID.
endpoint Hex string of endpoint on the claimed interface for the USB device.
responseSize Size of the byte array to receive a response in.
Source:
Returns:
List of (hexadecimal) bytes received from the USB device.
Type
Promise.<(Array.<string>|Error)>

(static) releaseDevice(vendorId, productId) → {Promise.<(null|Error)>}

Release a claimed USB device to free resources after sending/reading data.
Parameters:
Name Type Description
vendorId Hex string of USB device's vendor ID.
productId Hex string of USB device's product ID.
Source:
Returns:
Type
Promise.<(null|Error)>

(static) sendData(vendorId, productId, endpoint, data) → {Promise.<(null|Error)>}

Send data to a claimed USB device.
Parameters:
Name Type Description
vendorId Hex string of USB device's vendor ID.
productId Hex string of USB device's product ID.
endpoint Hex string of endpoint on the claimed interface for the USB device.
data Bytes to send over specified endpoint.
Source:
Returns:
Type
Promise.<(null|Error)>

(static) setUsbCallbacks(calls)

List of functions called for any response from open usb devices. Event data will contain {string} vendorId and {string} productId for all types. For RECEIVE types, {Array} output (in hexadecimal format). For ERROR types, {string} exception.
Parameters:
Name Type Description
calls function | Array.<function()> Single or array of Function({Object} eventData) calls.
Source: