diff --git a/usb/src/dev_handler.rs b/usb/src/dev_handler.rs index 21fc050..f3057ba 100644 --- a/usb/src/dev_handler.rs +++ b/usb/src/dev_handler.rs @@ -140,7 +140,7 @@ impl DeviceInner { let closed = Arc::new(AtomicBool::new(false)); let (mut framer, out_framer) = Self::init_framers(&handle, &read_ep); - let mut read_transfer = Transfer::new_bulk(&handle, read_ep.address, 1024); + let mut read_transfer = Transfer::new_bulk(&handle, read_ep.address, read_ep.max_packet_size); read_transfer.set_timeout(READ_DURATION); read_transfer.set_callback(move |buf| { let Some(buf) = buf else { diff --git a/usb/src/endpoint.rs b/usb/src/endpoint.rs index 4217bff..22cd902 100644 --- a/usb/src/endpoint.rs +++ b/usb/src/endpoint.rs @@ -9,7 +9,8 @@ pub struct Endpoint { pub iface: u8, pub setting: u8, pub address: u8, - pub transfer_type: TransferType + pub transfer_type: TransferType, + pub max_packet_size: usize, } pub fn find_endpoint( @@ -38,6 +39,7 @@ pub fn find_endpoint( setting: interface_desc.setting_number(), address: endpoint_desc.address(), transfer_type: endpoint_desc.transfer_type(), + max_packet_size: endpoint_desc.max_packet_size() as usize, }); } }