Skip to content

Commit 17b2121

Browse files
author
Dilawar Singh
committed
chore: Adds manufactoror on linux
1 parent 9bc62a0 commit 17b2121

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/common.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@ pub struct UsbDevice {
1818
pub serial_number: Option<String>,
1919
/// Class (bDeviceBaseClass) of device.
2020
pub base_class: Option<DeviceBaseClass>,
21+
/// Class as string
22+
pub class: Option<String>,
2123
/// Manufacturer
2224
pub manufacturer: Option<String>,
2325
}
2426

2527
/// See <https://www.usb.org/defined-class-codes>
2628
#[repr(u8)]
2729
#[derive(Hash, Eq, Debug, Clone, PartialEq, TryFromPrimitive)]
30+
#[allow(dead_code)]
2831
pub enum DeviceBaseClass {
2932
UseClassCodeFromInterfaceDescriptors = 0x00,
3033
Audio = 0x01,

src/linux.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,29 @@ pub fn enumerate_platform(vid: Option<u16>, pid: Option<u16>) -> Vec<UsbDevice>
6767
.attribute_value("bDeviceClass")
6868
.and_then(|x| x.to_str()?.parse::<u8>().ok());
6969

70+
let friendly_name = device
71+
.property_value("ID_MODEL_FROM_DATABASE")
72+
.and_then(|s| s.to_str())
73+
.map(|x| x.to_string());
74+
let manufacturer = device
75+
.property_value("ID_VENDOR_FROM_DATABASE")
76+
.and_then(|s| s.to_str())
77+
.map(|x| x.to_string());
78+
let class = device
79+
.property_value("ID_PCI_CLASS_FROM_DATABASE")
80+
.and_then(|s| s.to_str())
81+
.map(|x| x.to_string());
82+
7083
output.push(UsbDevice {
7184
id,
7285
vendor_id,
7386
product_id,
7487
description,
7588
serial_number,
7689
base_class: bclass.and_then(|bc| DeviceBaseClass::try_from(bc).ok()),
90+
class,
91+
friendly_name,
92+
manufacturer,
7793
});
7894

7995
Ok(())

0 commit comments

Comments
 (0)