File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -174,6 +174,24 @@ fn port_type(d: &libudev::Device) -> Result<SerialPortType> {
174174 Ok ( SerialPortType :: PciPort )
175175 }
176176 }
177+ None => {
178+ let p = d. parent ( ) . unwrap ( ) ;
179+ let parent_driver = p. driver ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
180+ let parent_subsystem = p. subsystem ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
181+
182+ if parent_driver == "cdc_acm" && parent_subsystem == "usb" {
183+ let product_code = p. property_value ( "PRODUCT" ) . and_then ( OsStr :: to_str) . unwrap ( ) ;
184+ Ok ( SerialPortType :: UsbPort ( UsbPortInfo {
185+ vid : u16:: from_str_radix ( & product_code[ 0 ..4 ] , 16 ) . unwrap ( ) ,
186+ pid : u16:: from_str_radix ( & product_code[ 5 ..9 ] , 16 ) . unwrap ( ) ,
187+ serial_number : None ,
188+ manufacturer : None ,
189+ product : None ,
190+ } ) )
191+ } else {
192+ Ok ( SerialPortType :: Unknown )
193+ }
194+ }
177195 _ => Ok ( SerialPortType :: Unknown ) ,
178196 }
179197}
You can’t perform that action at this time.
0 commit comments