Skip to content

Conversation

Copy link

Copilot AI commented Nov 26, 2025

  • Investigate nusb 0.2.1 API changes
  • Update rockusb/src/nusb.rs to use new nusb 0.2.1 API:
    • Replace RequestBuffer with Buffer
    • Replace bulk_in/bulk_out methods with Endpoint<Bulk, In/Out> pattern
    • Add timeout parameter to control_out
    • Replace EndpointType::Bulk comparison with TransferType::Bulk
    • Use async variants for list_devices(), open(), and claim_interface()
    • Fix error construction for "device not found"
    • Use next_multiple_of for packet size alignment
  • Update example to use busnum() instead of bus_number()
  • Update example and README to use .await for async functions
  • Update version to 0.4.0 (breaking API change)
  • Build and test changes
  • Run code review
  • Run security scan (no alerts found)
  • Fix code formatting

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits November 26, 2025 16:49
Co-authored-by: sjoerdsimons <22603932+sjoerdsimons@users.noreply.github.com>
Co-authored-by: sjoerdsimons <22603932+sjoerdsimons@users.noreply.github.com>
Copilot AI changed the title [WIP] Update nusb requirement from 0.1.10 to 0.2.1 fix: migrate to nusb 0.2.1 API Nov 26, 2025
Copilot AI requested a review from sjoerdsimons November 26, 2025 16:55
Copy link
Collaborator

@sjoerdsimons sjoerdsimons left a 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

info: nusb::DeviceInfo,
) -> std::result::Result<Self, DeviceUnavalable> {
let device = info.open()?;
let device = info.open().wait()?;
Copy link
Collaborator

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

Copy link
Author

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.

input.address(),
output.address(),
)?));
let interface = device.claim_interface(iface_setting.interface_number()).wait()?;
Copy link
Collaborator

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

Copy link
Author

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.

/// 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))
Copy link
Collaborator

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

Copy link
Author

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.

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;
Copy link
Collaborator

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

Copy link
Author

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>
Copy link
Author

Copilot AI commented Nov 26, 2025

Some small changes required, also the version should be updated as this is an api change

All changes addressed in commit 5b9a24c:

  • Switched to async variants for devices(), from_usb_device_info(), and claim_interface()
  • Used next_multiple_of instead of manual calculation
  • Bumped version to 0.4.0

@sjoerdsimons
Copy link
Collaborator

@copilot Please fix the github action failures

Co-authored-by: sjoerdsimons <22603932+sjoerdsimons@users.noreply.github.com>
Copy link
Author

Copilot AI commented Nov 26, 2025

@copilot Please fix the github action failures

Fixed the CI failures in commit 79e6df8 by running cargo fmt to fix code formatting issues (import order and line length).

@sjoerdsimons sjoerdsimons marked this pull request as ready for review November 26, 2025 20:21
@sjoerdsimons sjoerdsimons merged commit 581e9a4 into dependabot/cargo/nusb-0.2.1 Nov 26, 2025
12 checks passed
@sjoerdsimons sjoerdsimons deleted the copilot/sub-pr-43 branch November 26, 2025 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants