OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 module device.usb; | 5 module device.usb; |
6 | 6 |
7 enum OpenDeviceError { | 7 enum OpenDeviceError { |
8 // Opening the device succeeded. | 8 // Opening the device succeeded. |
9 OK, | 9 OK, |
10 | 10 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 132 |
133 // The transfer succeeded, but the device sent more data than was requested. | 133 // The transfer succeeded, but the device sent more data than was requested. |
134 // This applies only to inbound transfers. | 134 // This applies only to inbound transfers. |
135 BABBLE, | 135 BABBLE, |
136 | 136 |
137 // The transfer succeeded, but the device sent less data than was requested. | 137 // The transfer succeeded, but the device sent less data than was requested. |
138 // This applies only to inbound transfers. | 138 // This applies only to inbound transfers. |
139 SHORT_PACKET, | 139 SHORT_PACKET, |
140 }; | 140 }; |
141 | 141 |
142 struct IsochronousPacket { | |
143 uint32 length; | |
144 uint32 transferred_length; | |
145 TransferStatus status; | |
146 }; | |
147 | |
148 interface Device { | 142 interface Device { |
149 // Retrieve a DeviceInfo struct containing metadata about the device, | 143 // Retrieve a DeviceInfo struct containing metadata about the device, |
150 // including the set of all available device configurations. | 144 // including the set of all available device configurations. |
151 GetDeviceInfo() => (DeviceInfo? info); | 145 GetDeviceInfo() => (DeviceInfo? info); |
152 | 146 |
153 // Retrieves the |configuration_value| of the device's currently active | 147 // Retrieves the |configuration_value| of the device's currently active |
154 // configuration. Will return 0 if the device is unconfigured. | 148 // configuration. Will return 0 if the device is unconfigured. |
155 GetConfiguration() => (uint8 value); | 149 GetConfiguration() => (uint8 value); |
156 | 150 |
157 // Opens the device. Methods below require the device be opened first. | 151 // Opens the device. Methods below require the device be opened first. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 // completed or otherwise terminated. | 231 // completed or otherwise terminated. |
238 GenericTransferOut(uint8 endpoint_number, array<uint8> data, uint32 timeout) | 232 GenericTransferOut(uint8 endpoint_number, array<uint8> data, uint32 timeout) |
239 => (TransferStatus status); | 233 => (TransferStatus status); |
240 | 234 |
241 // Initiates an inbound isochronous transfer request on a specific endpoint. | 235 // Initiates an inbound isochronous transfer request on a specific endpoint. |
242 // The interface to which |endpoint_number| belongs must be claimed, and the | 236 // The interface to which |endpoint_number| belongs must be claimed, and the |
243 // appropriate alternate setting must be set on that interface before | 237 // appropriate alternate setting must be set on that interface before |
244 // transfers can be initiated on the endpoint. The endpoint must be of type | 238 // transfers can be initiated on the endpoint. The endpoint must be of type |
245 // ISOCHRONOUS. | 239 // ISOCHRONOUS. |
246 // | 240 // |
247 // |packet_lengths| specifies the maximum expected number of bytes to receive | 241 // |packet_length| specifies the maximum expected number of bytes to receive |
248 // for each packet in this transfer. | 242 // for each packet in this transfer. |num_packets| specifies the maximum total |
| 243 // number of packets to receive. |
249 // | 244 // |
250 // |timeout| specifies the request timeout in milliseconds. A timeout of 0 | 245 // |timeout| specifies the request timeout in milliseconds. A timeout of 0 |
251 // indicates no timeout: the request will remain pending indefinitely until | 246 // indicates no timeout: the request will remain pending indefinitely until |
252 // completed or otherwise terminated. | 247 // completed or otherwise terminated. |
253 // | 248 // |
254 // |data| contains the data received from the device, if any. |packets| | 249 // |packets| contains the set of packets received from the device, in order. |
255 // contains the status of each packet received from the device, in order. The | 250 // No received packet's size will exceed |packet_length|, and will be null |
256 // length of the packet indicates its position in |data| while it's | 251 // if |status| is neither COMPLETED, BABBLE, or SHORT_PACKET. |
257 // transferred length gives the amount of data actually received from the | |
258 // device. | |
259 IsochronousTransferIn(uint8 endpoint_number, | 252 IsochronousTransferIn(uint8 endpoint_number, |
260 array<uint32> packet_lengths, | 253 uint32 num_packets, |
| 254 uint32 packet_length, |
261 uint32 timeout) | 255 uint32 timeout) |
262 => (array<uint8>? data, array<IsochronousPacket> packets); | 256 => (TransferStatus status, array<array<uint8>>? packets); |
263 | 257 |
264 // Initiates an outbound isochronous transfer request on a specific endpoint. | 258 // Initiates an outbound isochronous transfer request on a specific endpoint. |
265 // The interface to which |endpoint_number| belongs must be claimed, and the | 259 // The interface to which |endpoint_number| belongs must be claimed, and the |
266 // appropriate alternate setting must be set on that interface before | 260 // appropriate alternate setting must be set on that interface before |
267 // transfers can be initiated on the endpoint. The endpoint must be of type | 261 // transfers can be initiated on the endpoint. The endpoint must be of type |
268 // ISOCHRONOUS. | 262 // ISOCHRONOUS. |
269 // | 263 // |
270 // |data| specifies the bytes to send to the device. | 264 // |packets| specifies the series of data packets to send to the device for |
271 // | 265 // this transfer. |
272 // |packet_lengths| specifies how |data| should be separated into packets when | |
273 // it is sent to the device. | |
274 // | 266 // |
275 // |timeout| specifies the request timeout in milliseconds. A timeout of 0 | 267 // |timeout| specifies the request timeout in milliseconds. A timeout of 0 |
276 // indicates no timeout: the request will remain pending indefinitely until | 268 // indicates no timeout: the request will remain pending indefinitely until |
277 // completed or otherwise terminated. | 269 // completed or otherwise terminated. |
278 | |
279 // |packets| contains the status of each packet sent to the device, in order. | |
280 IsochronousTransferOut(uint8 endpoint_number, | 270 IsochronousTransferOut(uint8 endpoint_number, |
281 array<uint8> data, | 271 array<array<uint8>> packets, |
282 array<uint32> packet_lengths, | |
283 uint32 timeout) | 272 uint32 timeout) |
284 => (array<IsochronousPacket> packets); | 273 => (TransferStatus status); |
285 }; | 274 }; |
OLD | NEW |