|
1 | 1 | use crate::device::*;
|
2 | 2 | use rand::prelude::*;
|
3 |
| -use rusb::{request_type, Direction, Recipient, RequestType}; |
| 3 | +use rusb::{request_type, Direction, Recipient, RequestType, TransferType}; |
4 | 4 | use std::cmp::max;
|
5 | 5 | use std::fmt::Write;
|
6 | 6 | use std::time::{Duration, Instant};
|
@@ -163,6 +163,40 @@ fn interface_descriptor(dev, _out) {
|
163 | 163 | test_class::INTERFACE_STRING);
|
164 | 164 | }
|
165 | 165 |
|
| 166 | +fn iso_endpoint_descriptors(dev, _out) { |
| 167 | + // Tests that an isochronous endpoint descriptor is present in the first |
| 168 | + // alternate setting, but not in the default setting. |
| 169 | + let iface = dev.config_descriptor |
| 170 | + .interfaces() |
| 171 | + .find(|i| i.number() == 0) |
| 172 | + .expect("interface not found"); |
| 173 | + |
| 174 | + let mut iso_ep_count = 0; |
| 175 | + for iface_descriptor in iface.descriptors() { |
| 176 | + if iface_descriptor.setting_number() == 0 { |
| 177 | + // Default setting - no isochronous endpoints allowed. Per USB 2.0 |
| 178 | + // spec rev 2.0, 5.6.3 Isochronous Transfer Packet Size Constraints: |
| 179 | + // |
| 180 | + // All device default interface settings must not include any |
| 181 | + // isochronous endpoints with non-zero data payload sizes (specified |
| 182 | + // via wMaxPacketSize in the endpoint descriptor) |
| 183 | + let issue = iface_descriptor |
| 184 | + .endpoint_descriptors() |
| 185 | + .find(|ep| ep.transfer_type() == TransferType::Isochronous |
| 186 | + && ep.max_packet_size() != 0); |
| 187 | + if let Some(ep) = issue { |
| 188 | + panic!("Endpoint {} is isochronous and in the default setting", |
| 189 | + ep.number()); |
| 190 | + } |
| 191 | + } else { |
| 192 | + iso_ep_count += iface_descriptor.endpoint_descriptors() |
| 193 | + .filter(|ep| ep.transfer_type() == TransferType::Isochronous) |
| 194 | + .count(); |
| 195 | + } |
| 196 | + } |
| 197 | + assert!(iso_ep_count > 0, "At least one isochronous endpoint is expected"); |
| 198 | +} |
| 199 | + |
166 | 200 | fn bulk_loopback(dev, _out) {
|
167 | 201 | let mut lens = vec![0, 1, 2, 32, 63, 64, 65, 127, 128, 129];
|
168 | 202 | if dev.is_high_speed() {
|
|
0 commit comments