-
Notifications
You must be signed in to change notification settings - Fork 13
fix: migrate to nusb 0.2.1 API #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: sjoerdsimons <22603932+sjoerdsimons@users.noreply.github.com>
Co-authored-by: sjoerdsimons <22603932+sjoerdsimons@users.noreply.github.com>
sjoerdsimons
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small changes required, also the version should be updated as this is an api change
rockusb/src/nusb.rs
Outdated
| info: nusb::DeviceInfo, | ||
| ) -> std::result::Result<Self, DeviceUnavalable> { | ||
| let device = info.open()?; | ||
| let device = info.open().wait()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot use the async variant here rather then blocking
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed from_usb_device_info() to async and using .await in commit 5b9a24c.
rockusb/src/nusb.rs
Outdated
| input.address(), | ||
| output.address(), | ||
| )?)); | ||
| let interface = device.claim_interface(iface_setting.interface_number()).wait()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Use async function here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed from_usb_device() to async and using .await for claim_interface() in commit 5b9a24c.
rockusb/src/nusb.rs
Outdated
| /// List rockchip devices | ||
| pub fn devices() -> std::result::Result<impl Iterator<Item = DeviceInfo>, nusb::Error> { | ||
| Ok(nusb::list_devices()?.filter(|d| d.vendor_id() == 0x2207)) | ||
| Ok(nusb::list_devices().wait()?.filter(|d| d.vendor_id() == 0x2207)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Use the async variant ere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed devices() to async and using .await in commit 5b9a24c.
rockusb/src/nusb.rs
Outdated
| data.copy_from_slice(&read); | ||
| // For IN transfers, requested_len must be a multiple of max_packet_size | ||
| let max_packet_size = self.ep_in.max_packet_size(); | ||
| let requested_len = ((data.len() + max_packet_size - 1) / max_packet_size) * max_packet_size; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use next_multiple_of instead of open-coding it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to use next_multiple_of in commit 5b9a24c.
Co-authored-by: sjoerdsimons <22603932+sjoerdsimons@users.noreply.github.com>
All changes addressed in commit 5b9a24c:
|
|
@copilot Please fix the github action failures |
Co-authored-by: sjoerdsimons <22603932+sjoerdsimons@users.noreply.github.com>
rockusb/src/nusb.rsto use new nusb 0.2.1 API:RequestBufferwithBufferbulk_in/bulk_outmethods withEndpoint<Bulk, In/Out>patterncontrol_outEndpointType::Bulkcomparison withTransferType::Bulklist_devices(),open(), andclaim_interface()next_multiple_offor packet size alignmentbusnum()instead ofbus_number().awaitfor async functions✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.