Skip to content

Commit

Permalink
take_while rather than filter for nusb extra descriptors
Browse files Browse the repository at this point in the history
  • Loading branch information
tuna-f1sh committed Oct 16, 2024
1 parent 0cca2d3 commit 315bf67
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/profiler/nusb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ impl NusbProfiler {
let endpoint_extra = endpoint
.descriptors()
.skip(1)
// no filter as all are endpoint descriptors
// no filter as all _should_ be endpoint descriptors at this point
.flat_map(|d| d.to_vec())
.collect::<Vec<u8>>();

Expand Down Expand Up @@ -378,9 +378,7 @@ impl NusbProfiler {
.descriptors()
.skip(1)
// only want device and interface descriptors - nusb has everything trailing including endpoint
.filter(|d| {
(d.descriptor_type() & 0x0F) == 0x04 || (d.descriptor_type() & 0x0F) == 0x01
})
.take_while(|d| d.descriptor_type() != 0x05)
.flat_map(|d| d.to_vec())
.collect::<Vec<u8>>();

Expand Down Expand Up @@ -452,12 +450,8 @@ impl NusbProfiler {
let config_extra = c
.descriptors()
.skip(1)
// only config, otg, interface association, security, and encryption type - printed by lsusb
// nusb has everything trailing including interfaces and endpoints
.filter(|d| match d.descriptor_type() {
0x02 | 0x09 | 0x0b | 0x0c | 0x0e => true,
_ => false,
})
// nusb has everything trailing so take until interfaces
.take_while(|d| d.descriptor_type() != 0x04)
.flat_map(|d| d.to_vec())
.collect::<Vec<u8>>();
let total_length = u16::from_le_bytes(config_desc[2..4].try_into().unwrap());
Expand Down

0 comments on commit 315bf67

Please sign in to comment.