• Download
  • Demo
  • Buy
  • API
  • Docs
  • Support
  • About
  • Contact
  • Login
API Home
Namespaces
qzapiconfigsfilehidnetworkingprinterssecurityserialsocketusbwebsocket
API Home
Namespaces
qzapiconfigsfilehidnetworkingprinterssecurityserialsocketusbwebsocket

Namespace: usb

qz.usb

Calls related to interaction with USB devices.
Source:
  • qz-tray.js, line 1899

Methods

(static) claimDevice(deviceInfo) → {Promise.<(null|Error)>}

Claim a USB device's interface to enable sending/reading data across an endpoint.
Parameters:
Name Type Description
deviceInfo object Config details of the HID device.
Properties
Name Type Description
vendorId Hex string of USB device's vendor ID.
productId Hex string of USB device's product ID.
interface Hex string of interface on the USB device to claim.
Source:
  • qz-tray.js, line 1978
Returns:
Type
Promise.<(null|Error)>

(static) closeStream(deviceInfo) → {Promise.<(null|Error)>}

Stops the stream of read data from a claimed USB device.
Parameters:
Name Type Description
deviceInfo object Config details of the HID device.
Properties
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:
  • qz-tray.js, line 2115
Returns:
Type
Promise.<(null|Error)>

(static) isClaimed(deviceInfo) → {Promise.<(boolean|Error)>}

Check the current claim state of a USB device.
Parameters:
Name Type Description
deviceInfo object Config details of the HID device.
Properties
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:
  • qz-tray.js, line 2002
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:
  • qz-tray.js, line 1913
Returns:
Array of JSON objects containing information on connected USB devices.
Type
Promise.<(Array.<Object>|Error)>

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

Parameters:
Name Type Description
deviceInfo object Config details of the HID device.
Properties
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:
  • qz-tray.js, line 1940
Returns:
List of available (hexadecimal) endpoints on a USB device's interface.
Type
Promise.<(Array.<string>|Error)>

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

Parameters:
Name Type Description
deviceInfo object Config details of the HID device.
Properties
Name Type Description
vendorId Hex string of USB device's vendor ID.
productId Hex string of USB device's product ID.
Source:
  • qz-tray.js, line 1925
Returns:
List of available (hexadecimal) interfaces on a USB device.
Type
Promise.<(Array.<string>|Error)>

(static) openStream(deviceInfo) → {Promise.<(null|Error)>}

Provides a continuous stream of read data from a claimed USB device.
Parameters:
Name Type Description
deviceInfo object Config details of the HID device.
Properties
Name Type 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 100 Frequency to send read data back, in milliseconds.
Source:
  • qz-tray.js, line 2089
See:
  • qz.usb.setUsbCallbacks
Returns:
Type
Promise.<(null|Error)>

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

Read data from a claimed USB device.
Parameters:
Name Type Description
deviceInfo object Config details of the HID device.
Properties
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:
  • qz-tray.js, line 2060
Returns:
List of (hexadecimal) bytes received from the USB device.
Type
Promise.<(Array.<string>|Error)>

(static) releaseDevice(deviceInfo) → {Promise.<(null|Error)>}

Release a claimed USB device to free resources after sending/reading data.
Parameters:
Name Type Description
deviceInfo object Config details of the HID device.
Properties
Name Type Description
vendorId Hex string of USB device's vendor ID.
productId Hex string of USB device's product ID.
Source:
  • qz-tray.js, line 2138
Returns:
Type
Promise.<(null|Error)>

(static) sendData(deviceInfo) → {Promise.<(null|Error)>}

Send data to a claimed USB device.
Parameters:
Name Type Description
deviceInfo object Config details of the HID device.
Properties
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.
data Bytes to send over specified endpoint.
type string <optional>
'PLAIN' Valid values [FILE | PLAIN | HEX | BASE64]
Source:
  • qz-tray.js, line 2021
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:
  • qz-tray.js, line 1963
Documentation generated by JSDoc 3.6.11

© 2025 qz | Privacy Policy