Skip to content

Commit

Permalink
Merge pull request #74 from tuna-f1sh/max_packet_size
Browse files Browse the repository at this point in the history
Add bMaxPacketSize0 to DeviceInfo
  • Loading branch information
kevinmehall authored Aug 10, 2024
2 parents cc721c4 + cf2ecf0 commit 137e8a3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/enumeration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ pub struct DeviceInfo {
pub(crate) subclass: u8,
pub(crate) protocol: u8,

pub(crate) max_packet_size_0: u8,

pub(crate) speed: Option<Speed>,

pub(crate) manufacturer_string: Option<String>,
Expand Down Expand Up @@ -187,6 +189,12 @@ impl DeviceInfo {
self.protocol
}

/// Maximum packet size for endpoint zero.
#[doc(alias = "bMaxPacketSize0")]
pub fn max_packet_size_0(&self) -> u8 {
self.max_packet_size_0
}

/// Connection speed
pub fn speed(&self) -> Option<Speed> {
self.speed
Expand Down Expand Up @@ -264,6 +272,7 @@ impl std::fmt::Debug for DeviceInfo {
.field("class", &format_args!("0x{:02X}", self.class))
.field("subclass", &format_args!("0x{:02X}", self.subclass))
.field("protocol", &format_args!("0x{:02X}", self.protocol))
.field("max_packet_size_0", &self.max_packet_size_0)
.field("speed", &self.speed)
.field("manufacturer_string", &self.manufacturer_string)
.field("product_string", &self.product_string)
Expand Down
1 change: 1 addition & 0 deletions src/platform/linux_usbfs/enumeration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ pub fn probe_device(path: SysfsPath) -> Result<DeviceInfo, SysfsError> {
class: path.read_attr_hex("bDeviceClass")?,
subclass: path.read_attr_hex("bDeviceSubClass")?,
protocol: path.read_attr_hex("bDeviceProtocol")?,
max_packet_size_0: path.read_attr("bMaxPacketSize0")?,
speed: path
.read_attr::<String>("speed")
.ok()
Expand Down
1 change: 1 addition & 0 deletions src/platform/macos_iokit/enumeration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub(crate) fn probe_device(device: IoService) -> Option<DeviceInfo> {
class: get_integer_property(&device, "bDeviceClass")? as u8,
subclass: get_integer_property(&device, "bDeviceSubClass")? as u8,
protocol: get_integer_property(&device, "bDeviceProtocol")? as u8,
max_packet_size_0: get_integer_property(&device, "bMaxPacketSize0")? as u8,
speed: get_integer_property(&device, "Device Speed").and_then(map_speed),
manufacturer_string: get_string_property(&device, "USB Vendor Name"),
product_string: get_string_property(&device, "USB Product Name"),
Expand Down
1 change: 1 addition & 0 deletions src/platform/windows_winusb/enumeration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ pub fn probe_device(devinst: DevInst) -> Option<DeviceInfo> {
class: info.device_desc.bDeviceClass,
subclass: info.device_desc.bDeviceSubClass,
protocol: info.device_desc.bDeviceProtocol,
max_packet_size_0: info.device_desc.bMaxPacketSize0,
speed: info.speed,
manufacturer_string: None,
product_string,
Expand Down

0 comments on commit 137e8a3

Please sign in to comment.