Use the chrome.usb API to interact with connected USB devices. This API provides access to USB operations from within the context of an app. Using this API, apps can function as drivers for hardware devices.
Errors generated by this API are reported by setting 'runtime.lastError' and executing the function's regular callback. The callback's regular parameters will be undefined in this case.
Use the chrome.usb API to interact with connected USB devices. This API provides access to USB operations from within the context of an app. Using this API, apps can function as drivers for hardware devices. Errors generated by this API are reported by setting 'runtime.lastError' and executing the function's regular callback. The callback's regular parameters will be undefined in this case. * available since Chrome 36 * https://developer.chrome.com/apps/usb
(bulk-transfer handle transfer-info)
Performs a bulk transfer on the specified device.
|handle| - An open connection to the device. |transfer-info| - The transfer parameters.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [info] where:
|info| - https://developer.chrome.com/apps/usb#property-callback-info.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
Performs a bulk transfer on the specified device. |handle| - An open connection to the device. |transfer-info| - The transfer parameters. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [info] where: |info| - https://developer.chrome.com/apps/usb#property-callback-info. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/usb#method-bulkTransfer.
(claim-interface handle interface-number)
Claims an interface on a USB device. Before data can be transfered to an interface or associated endpoints the interface must be claimed. Only one connection handle can claim an interface at any given time. If the interface is already claimed, this call will fail.'releaseInterface' should be called when the interface is no longer needed.
|handle| - An open connection to the device. |interface-number| - The interface to be claimed.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [].
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
https://developer.chrome.com/apps/usb#method-claimInterface.
Claims an interface on a USB device. Before data can be transfered to an interface or associated endpoints the interface must be claimed. Only one connection handle can claim an interface at any given time. If the interface is already claimed, this call will fail.'releaseInterface' should be called when the interface is no longer needed. |handle| - An open connection to the device. |interface-number| - The interface to be claimed. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is []. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/usb#method-claimInterface.
(close-device handle)
Closes a connection handle. Invoking operations on a handle after it has been closed is a safe operation but causes no action to be taken.
|handle| - The 'ConnectionHandle' to close.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [].
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
Closes a connection handle. Invoking operations on a handle after it has been closed is a safe operation but causes no action to be taken. |handle| - The 'ConnectionHandle' to close. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is []. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/usb#method-closeDevice.
(control-transfer handle transfer-info)
Performs a control transfer on the specified device.Control transfers refer to either the device, an interface or an endpoint. Transfers to an interface or endpoint require the interface to be claimed.
|handle| - An open connection to the device. |transfer-info| - https://developer.chrome.com/apps/usb#property-controlTransfer-transferInfo.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [info] where:
|info| - https://developer.chrome.com/apps/usb#property-callback-info.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
https://developer.chrome.com/apps/usb#method-controlTransfer.
Performs a control transfer on the specified device.Control transfers refer to either the device, an interface or an endpoint. Transfers to an interface or endpoint require the interface to be claimed. |handle| - An open connection to the device. |transfer-info| - https://developer.chrome.com/apps/usb#property-controlTransfer-transferInfo. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [info] where: |info| - https://developer.chrome.com/apps/usb#property-callback-info. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/usb#method-controlTransfer.
(find-devices options)
Finds USB devices specified by the vendor, product and (optionally) interface IDs and if permissions allow opens them for use.If the access request is rejected or the device fails to be opened a connection handle will not be created or returned.Calling this method is equivalent to calling 'getDevices' followed by 'openDevice' for each device.
|options| - The properties to search for on target devices.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [handles] where:
|handles| - https://developer.chrome.com/apps/usb#property-callback-handles.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
Finds USB devices specified by the vendor, product and (optionally) interface IDs and if permissions allow opens them for use.If the access request is rejected or the device fails to be opened a connection handle will not be created or returned.Calling this method is equivalent to calling 'getDevices' followed by 'openDevice' for each device. |options| - The properties to search for on target devices. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [handles] where: |handles| - https://developer.chrome.com/apps/usb#property-callback-handles. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/usb#method-findDevices.
(get-configuration handle)
Gets the configuration descriptor for the currently selected configuration.
|handle| - An open connection to the device.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [config] where:
|config| - https://developer.chrome.com/apps/usb#property-callback-config.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
https://developer.chrome.com/apps/usb#method-getConfiguration.
Gets the configuration descriptor for the currently selected configuration. |handle| - An open connection to the device. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [config] where: |config| - https://developer.chrome.com/apps/usb#property-callback-config. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/usb#method-getConfiguration.
(get-configurations device)
Returns the full set of device configuration descriptors.
|device| - The 'Device' to fetch descriptors from.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [configs] where:
|configs| - https://developer.chrome.com/apps/usb#property-callback-configs.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
https://developer.chrome.com/apps/usb#method-getConfigurations.
Returns the full set of device configuration descriptors. |device| - The 'Device' to fetch descriptors from. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [configs] where: |configs| - https://developer.chrome.com/apps/usb#property-callback-configs. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/usb#method-getConfigurations.
(get-devices options)
Enumerates connected USB devices.
|options| - The properties to search for on target devices.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [devices] where:
|devices| - https://developer.chrome.com/apps/usb#property-callback-devices.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
Enumerates connected USB devices. |options| - The properties to search for on target devices. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [devices] where: |devices| - https://developer.chrome.com/apps/usb#property-callback-devices. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/usb#method-getDevices.
(get-user-selected-devices options)
Presents a device picker to the user and returns the 'Device's selected. If the user cancels the picker devices will be empty. A user gesture is required for the dialog to display. Without a user gesture, the callback will run as though the user cancelled.
|options| - Configuration of the device picker dialog box.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [devices] where:
|devices| - https://developer.chrome.com/apps/usb#property-callback-devices.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
https://developer.chrome.com/apps/usb#method-getUserSelectedDevices.
Presents a device picker to the user and returns the 'Device's selected. If the user cancels the picker devices will be empty. A user gesture is required for the dialog to display. Without a user gesture, the callback will run as though the user cancelled. |options| - Configuration of the device picker dialog box. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [devices] where: |devices| - https://developer.chrome.com/apps/usb#property-callback-devices. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/usb#method-getUserSelectedDevices.
(interrupt-transfer handle transfer-info)
Performs an interrupt transfer on the specified device.
|handle| - An open connection to the device. |transfer-info| - The transfer parameters.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [info] where:
|info| - https://developer.chrome.com/apps/usb#property-callback-info.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
https://developer.chrome.com/apps/usb#method-interruptTransfer.
Performs an interrupt transfer on the specified device. |handle| - An open connection to the device. |transfer-info| - The transfer parameters. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [info] where: |info| - https://developer.chrome.com/apps/usb#property-callback-info. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/usb#method-interruptTransfer.
(isochronous-transfer handle transfer-info)
Performs an isochronous transfer on the specific device.
|handle| - An open connection to the device. |transfer-info| - https://developer.chrome.com/apps/usb#property-isochronousTransfer-transferInfo.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [info] where:
|info| - https://developer.chrome.com/apps/usb#property-callback-info.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
https://developer.chrome.com/apps/usb#method-isochronousTransfer.
Performs an isochronous transfer on the specific device. |handle| - An open connection to the device. |transfer-info| - https://developer.chrome.com/apps/usb#property-isochronousTransfer-transferInfo. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [info] where: |info| - https://developer.chrome.com/apps/usb#property-callback-info. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/usb#method-isochronousTransfer.
(list-interfaces handle)
Lists all interfaces on a USB device.
|handle| - An open connection to the device.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [descriptors] where:
|descriptors| - https://developer.chrome.com/apps/usb#property-callback-descriptors.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
https://developer.chrome.com/apps/usb#method-listInterfaces.
Lists all interfaces on a USB device. |handle| - An open connection to the device. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [descriptors] where: |descriptors| - https://developer.chrome.com/apps/usb#property-callback-descriptors. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/usb#method-listInterfaces.
(open-device device)
Opens a USB device returned by 'getDevices'.
|device| - The 'Device' to open.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [handle] where:
|handle| - https://developer.chrome.com/apps/usb#property-callback-handle.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
Opens a USB device returned by 'getDevices'. |device| - The 'Device' to open. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [handle] where: |handle| - https://developer.chrome.com/apps/usb#property-callback-handle. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/usb#method-openDevice.
(release-interface handle interface-number)
Releases a claimed interface.
|handle| - An open connection to the device. |interface-number| - The interface to be released.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [].
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
https://developer.chrome.com/apps/usb#method-releaseInterface.
Releases a claimed interface. |handle| - An open connection to the device. |interface-number| - The interface to be released. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is []. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/usb#method-releaseInterface.
(request-access device interface-id)
Requests access from the permission broker to a device claimed by Chrome OS if the given interface on the device is not claimed.
|device| - The 'Device' to request access to. |interface-id| - The particular interface requested.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [success] where:
|success| - https://developer.chrome.com/apps/usb#property-callback-success.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
Requests access from the permission broker to a device claimed by Chrome OS if the given interface on the device is not claimed. |device| - The 'Device' to request access to. |interface-id| - The particular interface requested. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [success] where: |success| - https://developer.chrome.com/apps/usb#property-callback-success. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/usb#method-requestAccess.
(reset-device handle)
Tries to reset the USB device. If the reset fails, the given connection handle will be closed and the USB device will appear to be disconnected then reconnected. In this case 'getDevices' or 'findDevices' must be called again to acquire the device.
|handle| - A connection handle to reset.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [success] where:
|success| - https://developer.chrome.com/apps/usb#property-callback-success.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
Tries to reset the USB device. If the reset fails, the given connection handle will be closed and the USB device will appear to be disconnected then reconnected. In this case 'getDevices' or 'findDevices' must be called again to acquire the device. |handle| - A connection handle to reset. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [success] where: |success| - https://developer.chrome.com/apps/usb#property-callback-success. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/usb#method-resetDevice.
(set-configuration handle configuration-value)
Select a device configuration.This function effectively resets the device by selecting one of the device's available configurations. Only configuration values greater than 0 are valid however some buggy devices have a working configuration 0 and so this value is allowed.
|handle| - An open connection to the device. |configuration-value| - https://developer.chrome.com/apps/usb#property-setConfiguration-configurationValue.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [].
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
https://developer.chrome.com/apps/usb#method-setConfiguration.
Select a device configuration.This function effectively resets the device by selecting one of the device's available configurations. Only configuration values greater than 0 are valid however some buggy devices have a working configuration 0 and so this value is allowed. |handle| - An open connection to the device. |configuration-value| - https://developer.chrome.com/apps/usb#property-setConfiguration-configurationValue. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is []. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/usb#method-setConfiguration.
(set-interface-alternate-setting handle interface-number alternate-setting)
Selects an alternate setting on a previously claimed interface.
|handle| - An open connection to the device where this interface has been claimed. |interface-number| - The interface to configure. |alternate-setting| - The alternate setting to configure.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [].
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
https://developer.chrome.com/apps/usb#method-setInterfaceAlternateSetting.
Selects an alternate setting on a previously claimed interface. |handle| - An open connection to the device where this interface has been claimed. |interface-number| - The interface to configure. |alternate-setting| - The alternate setting to configure. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is []. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/usb#method-setInterfaceAlternateSetting.
(set-interface-alternate-setting* config
handle
interface-number
alternate-setting)
(tap-all-events chan)
Taps all valid non-deprecated events in chromex.app.usb namespace.
Taps all valid non-deprecated events in chromex.app.usb namespace.
(tap-on-device-added-events channel & args)
Event generated when a device is added to the system. Events are only broadcast to apps and extensions that have permission to access the device. Permission may have been granted at install time, when the user accepted an optional permission (see 'permissions.request'), or through 'getUserSelectedDevices'.
Events will be put on the |channel| with signature [::on-device-added [device]] where:
|device| - https://developer.chrome.com/apps/usb#property-onDeviceAdded-device.
Note: |args| will be passed as additional parameters into Chrome event's .addListener call.
Event generated when a device is added to the system. Events are only broadcast to apps and extensions that have permission to access the device. Permission may have been granted at install time, when the user accepted an optional permission (see 'permissions.request'), or through 'getUserSelectedDevices'. Events will be put on the |channel| with signature [::on-device-added [device]] where: |device| - https://developer.chrome.com/apps/usb#property-onDeviceAdded-device. Note: |args| will be passed as additional parameters into Chrome event's .addListener call. https://developer.chrome.com/apps/usb#event-onDeviceAdded.
(tap-on-device-removed-events channel & args)
Event generated when a device is removed from the system. See 'onDeviceAdded' for which events are delivered.
Events will be put on the |channel| with signature [::on-device-removed [device]] where:
|device| - https://developer.chrome.com/apps/usb#property-onDeviceRemoved-device.
Note: |args| will be passed as additional parameters into Chrome event's .addListener call.
https://developer.chrome.com/apps/usb#event-onDeviceRemoved.
Event generated when a device is removed from the system. See 'onDeviceAdded' for which events are delivered. Events will be put on the |channel| with signature [::on-device-removed [device]] where: |device| - https://developer.chrome.com/apps/usb#property-onDeviceRemoved-device. Note: |args| will be passed as additional parameters into Chrome event's .addListener call. https://developer.chrome.com/apps/usb#event-onDeviceRemoved.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close