Skip to content

Commit

Permalink
Display interface classes.
Browse files Browse the repository at this point in the history
Alternate settings are abbreviated to an "N alt M" format to leave more
space for the interface class text.
  • Loading branch information
martinling committed Oct 11, 2024
1 parent a2e28e7 commit be24322
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 32 deletions.
6 changes: 4 additions & 2 deletions src/capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2112,11 +2112,13 @@ impl ItemSource<DeviceItem, DeviceViewMode> for CaptureReader {
FunctionDescriptorField(desc, field) => desc.field_text(*field),
Interface(_conf, desc) => {
let num = desc.interface_number;
let class = usb_ids::Class::from_id(desc.interface_class)
.map_or("Unknown", |c| c.name());
match desc.alternate_setting {
InterfaceAlt(0) => format!(
"Interface {num}"),
"Interface {num}: {class}"),
InterfaceAlt(alt) => format!(
"Interface {num} (alternate {alt})"),
"Interface {num} alt {alt}: {class}"),
}
},
InterfaceDescriptor(_) =>
Expand Down
2 changes: 1 addition & 1 deletion tests/analyzer-test-bad-cable/devices-reference.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Device 1: USB Analyzer Test Device
Configuration string: (none)
Attributes: 0x80
Max power: 500mA
Interface 0
Interface 0: Vendor Specific Class
Interface descriptor
Length: 9 bytes
Type: 0x04
Expand Down
12 changes: 6 additions & 6 deletions tests/emf2022-badge/devices-reference.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Device 1: USB JTAG/serial debug unit\u{0}
Function subclass: 0x02: Abstract (modem)
Function protocol: 0x00: None
Function number: 0
Interface 0
Interface 0: Communications
Interface descriptor
Length: 9 bytes
Type: 0x04
Expand All @@ -55,7 +55,7 @@ Device 1: USB JTAG/serial debug unit\u{0}
Attributes: 0x03
Max packet size: 64 bytes
Interval: 0x01
Interface 1
Interface 1: CDC Data
Interface descriptor
Length: 9 bytes
Type: 0x04
Expand All @@ -82,7 +82,7 @@ Device 1: USB JTAG/serial debug unit\u{0}
Attributes: 0x02
Max packet size: 64 bytes
Interval: 0x01
Interface 2
Interface 2: Vendor Specific Class
Interface descriptor
Length: 9 bytes
Type: 0x04
Expand Down Expand Up @@ -144,7 +144,7 @@ Device 2: TiDAL
Function subclass: 0x02: Abstract (modem)
Function protocol: 0x00: None
Function number: 0
Interface 0
Interface 0: Communications
Interface descriptor
Length: 9 bytes
Type: 0x04
Expand All @@ -166,7 +166,7 @@ Device 2: TiDAL
Attributes: 0x03
Max packet size: 8 bytes
Interval: 0x10
Interface 1
Interface 1: CDC Data
Interface descriptor
Length: 9 bytes
Type: 0x04
Expand All @@ -193,7 +193,7 @@ Device 2: TiDAL
Attributes: 0x02
Max packet size: 64 bytes
Interval: 0x00
Interface 2
Interface 2: Human Interface Device
Interface descriptor
Length: 9 bytes
Type: 0x04
Expand Down
2 changes: 1 addition & 1 deletion tests/hackrf-connect/devices-reference.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Device 29: HackRF One
Configuration string: #3 'Transceiver'
Attributes: 0x80
Max power: 500mA
Interface 0
Interface 0: Vendor Specific Class
Interface descriptor
Length: 9 bytes
Type: 0x04
Expand Down
2 changes: 1 addition & 1 deletion tests/hackrf-dfu-enum/devices-reference.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Device 11: LPC
Configuration string: (none)
Attributes: 0xC0
Max power: 100mA
Interface 0
Interface 0: Application Specific Interface
Interface descriptor
Length: 9 bytes
Type: 0x04
Expand Down
18 changes: 9 additions & 9 deletions tests/iso-unambiguous/devices-reference.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Device 27: Ksoloti Core
Function subclass: 0x00
Function protocol: 0x20
Function number: 0
Interface 0
Interface 0: Audio
Interface descriptor
Length: 9 bytes
Type: 0x04
Expand All @@ -51,7 +51,7 @@ Device 27: Ksoloti Core
Class descriptor 0x24, 12 bytes
Class descriptor 0x24, 17 bytes
Class descriptor 0x24, 12 bytes
Interface 1
Interface 1: Audio
Interface descriptor
Length: 9 bytes
Type: 0x04
Expand All @@ -62,7 +62,7 @@ Device 27: Ksoloti Core
Subclass: 0x02: Streaming
Protocol: 0x20
Interface string: (none)
Interface 1 (alternate 1)
Interface 1 alt 1: Audio
Interface descriptor
Length: 9 bytes
Type: 0x04
Expand All @@ -84,7 +84,7 @@ Device 27: Ksoloti Core
Max packet size: 196 bytes
Interval: 0x01
Class descriptor 0x25, 8 bytes
Interface 1 (alternate 2)
Interface 1 alt 2: Audio
Interface descriptor
Length: 9 bytes
Type: 0x04
Expand All @@ -106,7 +106,7 @@ Device 27: Ksoloti Core
Max packet size: 392 bytes
Interval: 0x01
Class descriptor 0x25, 8 bytes
Interface 2
Interface 2: Audio
Interface descriptor
Length: 9 bytes
Type: 0x04
Expand All @@ -117,7 +117,7 @@ Device 27: Ksoloti Core
Subclass: 0x02: Streaming
Protocol: 0x20
Interface string: (none)
Interface 2 (alternate 1)
Interface 2 alt 1: Audio
Interface descriptor
Length: 9 bytes
Type: 0x04
Expand All @@ -139,7 +139,7 @@ Device 27: Ksoloti Core
Max packet size: 196 bytes
Interval: 0x01
Class descriptor 0x25, 8 bytes
Interface 2 (alternate 2)
Interface 2 alt 2: Audio
Interface descriptor
Length: 9 bytes
Type: 0x04
Expand All @@ -161,7 +161,7 @@ Device 27: Ksoloti Core
Max packet size: 392 bytes
Interval: 0x01
Class descriptor 0x25, 8 bytes
Interface 3
Interface 3: Audio
Interface descriptor
Length: 9 bytes
Type: 0x04
Expand Down Expand Up @@ -203,7 +203,7 @@ Device 27: Ksoloti Core
Function subclass: 0x00
Function protocol: 0x00
Function number: 4
Interface 4
Interface 4: Vendor Specific Class
Interface descriptor
Length: 9 bytes
Type: 0x04
Expand Down
18 changes: 9 additions & 9 deletions tests/ksolti-core-enum/devices-reference.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Device 27: Ksoloti Core
Function subclass: 0x00
Function protocol: 0x20
Function number: 0
Interface 0
Interface 0: Audio
Interface descriptor
Length: 9 bytes
Type: 0x04
Expand All @@ -51,7 +51,7 @@ Device 27: Ksoloti Core
Class descriptor 0x24, 12 bytes
Class descriptor 0x24, 17 bytes
Class descriptor 0x24, 12 bytes
Interface 1
Interface 1: Audio
Interface descriptor
Length: 9 bytes
Type: 0x04
Expand All @@ -62,7 +62,7 @@ Device 27: Ksoloti Core
Subclass: 0x02: Streaming
Protocol: 0x20
Interface string: (none)
Interface 1 (alternate 1)
Interface 1 alt 1: Audio
Interface descriptor
Length: 9 bytes
Type: 0x04
Expand All @@ -84,7 +84,7 @@ Device 27: Ksoloti Core
Max packet size: 196 bytes
Interval: 0x01
Class descriptor 0x25, 8 bytes
Interface 1 (alternate 2)
Interface 1 alt 2: Audio
Interface descriptor
Length: 9 bytes
Type: 0x04
Expand All @@ -106,7 +106,7 @@ Device 27: Ksoloti Core
Max packet size: 392 bytes
Interval: 0x01
Class descriptor 0x25, 8 bytes
Interface 2
Interface 2: Audio
Interface descriptor
Length: 9 bytes
Type: 0x04
Expand All @@ -117,7 +117,7 @@ Device 27: Ksoloti Core
Subclass: 0x02: Streaming
Protocol: 0x20
Interface string: (none)
Interface 2 (alternate 1)
Interface 2 alt 1: Audio
Interface descriptor
Length: 9 bytes
Type: 0x04
Expand All @@ -139,7 +139,7 @@ Device 27: Ksoloti Core
Max packet size: 196 bytes
Interval: 0x01
Class descriptor 0x25, 8 bytes
Interface 2 (alternate 2)
Interface 2 alt 2: Audio
Interface descriptor
Length: 9 bytes
Type: 0x04
Expand All @@ -161,7 +161,7 @@ Device 27: Ksoloti Core
Max packet size: 392 bytes
Interval: 0x01
Class descriptor 0x25, 8 bytes
Interface 3
Interface 3: Audio
Interface descriptor
Length: 9 bytes
Type: 0x04
Expand Down Expand Up @@ -203,7 +203,7 @@ Device 27: Ksoloti Core
Function subclass: 0x00
Function protocol: 0x00
Function number: 4
Interface 4
Interface 4: Vendor Specific Class
Interface descriptor
Length: 9 bytes
Type: 0x04
Expand Down
2 changes: 1 addition & 1 deletion tests/mouse/devices-reference.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Device 4: USB Optical Mouse
Configuration string: (none)
Attributes: 0xA0
Max power: 98mA
Interface 0
Interface 0: Human Interface Device
Interface descriptor
Length: 9 bytes
Type: 0x04
Expand Down
4 changes: 2 additions & 2 deletions tests/split-enum/devices-reference.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Device 14: USB Device
Configuration string: (none)
Attributes: 0xA0
Max power: 100mA
Interface 0
Interface 0: Human Interface Device
Interface descriptor
Length: 9 bytes
Type: 0x04
Expand All @@ -45,7 +45,7 @@ Device 14: USB Device
Attributes: 0x03
Max packet size: 8 bytes
Interval: 0x0A
Interface 1
Interface 1: Human Interface Device
Interface descriptor
Length: 9 bytes
Type: 0x04
Expand Down

0 comments on commit be24322

Please sign in to comment.