OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Use the <code>chrome.usb</code> API to interact with connected USB | 5 // Use the <code>chrome.usb</code> API to interact with connected USB |
6 // devices. This API provides access to USB operations from within the context | 6 // devices. This API provides access to USB operations from within the context |
7 // of an app. Using this API, apps can function as drivers for hardware devices. | 7 // of an app. Using this API, apps can function as drivers for hardware devices. |
8 // | 8 // |
9 // Errors generated by this API are reported by setting | 9 // Errors generated by this API are reported by setting |
10 // $(ref:runtime.lastError) and executing the function's regular callback. The | 10 // $(ref:runtime.lastError) and executing the function's regular callback. The |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 // Transfer direction. | 53 // Transfer direction. |
54 Direction direction; | 54 Direction direction; |
55 // Maximum packet size. | 55 // Maximum packet size. |
56 long maximumPacketSize; | 56 long maximumPacketSize; |
57 // Transfer synchronization mode (isochronous only). | 57 // Transfer synchronization mode (isochronous only). |
58 SynchronizationType? synchronization; | 58 SynchronizationType? synchronization; |
59 // Endpoint usage hint. | 59 // Endpoint usage hint. |
60 UsageType? usage; | 60 UsageType? usage; |
61 // Polling interval (interrupt and isochronous only). | 61 // Polling interval (interrupt and isochronous only). |
62 long? pollingInterval; | 62 long? pollingInterval; |
| 63 // Extra descriptor data associated with this endpoint. |
| 64 ArrayBuffer extra_data; |
63 }; | 65 }; |
64 | 66 |
65 [noinline_doc] dictionary InterfaceDescriptor { | 67 [noinline_doc] dictionary InterfaceDescriptor { |
66 // The interface number. | 68 // The interface number. |
67 long interfaceNumber; | 69 long interfaceNumber; |
68 // The interface alternate setting number (defaults to <code>0</code). | 70 // The interface alternate setting number (defaults to <code>0</code). |
69 long alternateSetting; | 71 long alternateSetting; |
70 // The USB interface class. | 72 // The USB interface class. |
71 long interfaceClass; | 73 long interfaceClass; |
72 // The USB interface sub-class. | 74 // The USB interface sub-class. |
73 long interfaceSubclass; | 75 long interfaceSubclass; |
74 // The USB interface protocol. | 76 // The USB interface protocol. |
75 long interfaceProtocol; | 77 long interfaceProtocol; |
76 // Description of the interface. | 78 // Description of the interface. |
77 DOMString? description; | 79 DOMString? description; |
78 // Available endpoints. | 80 // Available endpoints. |
79 EndpointDescriptor[] endpoints; | 81 EndpointDescriptor[] endpoints; |
| 82 // Extra descriptor data associated with this interface. |
| 83 ArrayBuffer extra_data; |
| 84 }; |
| 85 |
| 86 [noinline_doc] dictionary ConfigDescriptor { |
| 87 // The configuration number. |
| 88 long configurationValue; |
| 89 // Description of the configuration. |
| 90 DOMString? description; |
| 91 // The device is self-powered. |
| 92 boolean selfPowered; |
| 93 // The device supports remote wakeup. |
| 94 boolean remoteWakeup; |
| 95 // The maximum power needed by this device in milliamps (mA). |
| 96 long maxPower; |
| 97 // Available interfaces. |
| 98 InterfaceDescriptor[] interfaces; |
| 99 // Extra descriptor data associated with this configuration. |
| 100 ArrayBuffer extra_data; |
80 }; | 101 }; |
81 | 102 |
82 dictionary ControlTransferInfo { | 103 dictionary ControlTransferInfo { |
83 // The transfer direction (<code>"in"</code> or <code>"out"</code>). | 104 // The transfer direction (<code>"in"</code> or <code>"out"</code>). |
84 Direction direction; | 105 Direction direction; |
85 | 106 |
86 // The transfer target. The target given by <code>index</code> must be | 107 // The transfer target. The target given by <code>index</code> must be |
87 // claimed if <code>"interface"</code> or <code>"endpoint"</code>. | 108 // claimed if <code>"interface"</code> or <code>"endpoint"</code>. |
88 Recipient recipient; | 109 Recipient recipient; |
89 | 110 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 // The interface ID to request access to. | 195 // The interface ID to request access to. |
175 // Only available on ChromeOS. It has no effect on other platforms. | 196 // Only available on ChromeOS. It has no effect on other platforms. |
176 long? interfaceId; | 197 long? interfaceId; |
177 }; | 198 }; |
178 | 199 |
179 callback VoidCallback = void (); | 200 callback VoidCallback = void (); |
180 callback GetDevicesCallback = void (Device[] devices); | 201 callback GetDevicesCallback = void (Device[] devices); |
181 callback RequestAccessCallback = void (boolean success); | 202 callback RequestAccessCallback = void (boolean success); |
182 callback OpenDeviceCallback = void (ConnectionHandle handle); | 203 callback OpenDeviceCallback = void (ConnectionHandle handle); |
183 callback FindDevicesCallback = void (ConnectionHandle[] handles); | 204 callback FindDevicesCallback = void (ConnectionHandle[] handles); |
| 205 callback GetConfigurationCallback = void (ConfigDescriptor config); |
184 callback ListInterfacesCallback = void (InterfaceDescriptor[] descriptors); | 206 callback ListInterfacesCallback = void (InterfaceDescriptor[] descriptors); |
185 callback CloseDeviceCallback = void (); | 207 callback CloseDeviceCallback = void (); |
186 callback TransferCallback = void (TransferResultInfo info); | 208 callback TransferCallback = void (TransferResultInfo info); |
187 callback ResetDeviceCallback = void(boolean success); | 209 callback ResetDeviceCallback = void(boolean success); |
188 | 210 |
189 interface Functions { | 211 interface Functions { |
190 // Enumerates connected USB devices. | 212 // Enumerates connected USB devices. |
191 // |options|: The properties to search for on target devices. | 213 // |options|: The properties to search for on target devices. |
192 static void getDevices(EnumerateDevicesOptions options, | 214 static void getDevices(EnumerateDevicesOptions options, |
193 GetDevicesCallback callback); | 215 GetDevicesCallback callback); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 // |options|: The properties to search for on target devices. | 247 // |options|: The properties to search for on target devices. |
226 static void findDevices(EnumerateDevicesAndRequestAccessOptions options, | 248 static void findDevices(EnumerateDevicesAndRequestAccessOptions options, |
227 FindDevicesCallback callback); | 249 FindDevicesCallback callback); |
228 | 250 |
229 // Closes a connection handle. Invoking operations on a handle after it | 251 // Closes a connection handle. Invoking operations on a handle after it |
230 // has been closed is a safe operation but causes no action to be taken. | 252 // has been closed is a safe operation but causes no action to be taken. |
231 // |handle|: The $(ref:ConnectionHandle) to close. | 253 // |handle|: The $(ref:ConnectionHandle) to close. |
232 static void closeDevice(ConnectionHandle handle, | 254 static void closeDevice(ConnectionHandle handle, |
233 optional CloseDeviceCallback callback); | 255 optional CloseDeviceCallback callback); |
234 | 256 |
| 257 // Gets the configuration descriptor for the currently selected |
| 258 // configuration. |
| 259 // |handle|: An open connection to the device. |
| 260 static void getConfiguration(ConnectionHandle handle, |
| 261 GetConfigurationCallback callback); |
| 262 |
235 // Lists all interfaces on a USB device. | 263 // Lists all interfaces on a USB device. |
236 // |handle|: An open connection to the device. | 264 // |handle|: An open connection to the device. |
237 static void listInterfaces(ConnectionHandle handle, | 265 static void listInterfaces(ConnectionHandle handle, |
238 ListInterfacesCallback callback); | 266 ListInterfacesCallback callback); |
239 | 267 |
240 // Claims an interface on a USB device. | 268 // Claims an interface on a USB device. |
241 // Before data can be transfered to an interface or associated endpoints the | 269 // Before data can be transfered to an interface or associated endpoints the |
242 // interface must be claimed. Only one connection handle can claim an | 270 // interface must be claimed. Only one connection handle can claim an |
243 // interface at any given time. If the interface is already claimed, this | 271 // interface at any given time. If the interface is already claimed, this |
244 // call will fail. | 272 // call will fail. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 // If the reset fails, the given connection handle will be closed and the | 330 // If the reset fails, the given connection handle will be closed and the |
303 // USB device will appear to be disconnected then reconnected. | 331 // USB device will appear to be disconnected then reconnected. |
304 // In this case $(ref:getDevices) or $(ref:findDevices) must be called again | 332 // In this case $(ref:getDevices) or $(ref:findDevices) must be called again |
305 // to acquire the device. | 333 // to acquire the device. |
306 // | 334 // |
307 // |handle|: A connection handle to reset. | 335 // |handle|: A connection handle to reset. |
308 static void resetDevice(ConnectionHandle handle, | 336 static void resetDevice(ConnectionHandle handle, |
309 ResetDeviceCallback callback); | 337 ResetDeviceCallback callback); |
310 }; | 338 }; |
311 }; | 339 }; |
OLD | NEW |