Skip to content

Commit

Permalink
Try find port type in parent device
Browse files Browse the repository at this point in the history
  • Loading branch information
soiamsoNG committed Mar 28, 2024
1 parent 84f6066 commit 78ab552
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/posix/enumerate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,24 @@ fn port_type(d: &libudev::Device) -> Result<SerialPortType> {
Ok(SerialPortType::PciPort)
}
}
None => {
let p = d.parent().unwrap();
let parent_driver = p.driver().unwrap().to_str().unwrap();
let parent_subsystem = p.subsystem().unwrap().to_str().unwrap();

if parent_driver == "cdc_acm" && parent_subsystem == "usb" {
let product_code = p.property_value("PRODUCT").and_then(OsStr::to_str).unwrap();
Ok(SerialPortType::UsbPort(UsbPortInfo {

Check failure on line 184 in src/posix/enumerate.rs

View workflow job for this annotation

GitHub Actions / lint

missing field `interface` in initializer of `UsbPortInfo`
vid: u16::from_str_radix(&product_code[0..4], 16).unwrap(),
pid: u16::from_str_radix(&product_code[5..9], 16).unwrap(),
serial_number: None,
manufacturer: None,
product: None,
}))
} else {
Ok(SerialPortType::Unknown)
}
}
_ => Ok(SerialPortType::Unknown),
}
}
Expand Down

0 comments on commit 78ab552

Please sign in to comment.