Skip to content

Comments

Async transfer API added#73

Closed
dmitry-zakablukov wants to merge 2 commits intoa1ien:masterfrom
passware:async_transfer
Closed

Async transfer API added#73
dmitry-zakablukov wants to merge 2 commits intoa1ien:masterfrom
passware:async_transfer

Conversation

@dmitry-zakablukov
Copy link
Contributor

@dmitry-zakablukov dmitry-zakablukov commented Jun 28, 2021

Good day.

This pr suggests some API updates to support async transfers.

Async transfer usage:

let mut transfer = rusb::Transfer::<'a>::new(&device_handle, 0)?;
transfer.set_transfer_type(rusb::constants::LIBUSB_TRANSFER_TYPE_CONTROL)?;
transfer.set_timeout(1000)?;
transfer.set_endpoint(0)?;

transfer.set_callback(Some(Box::new(move |status, data| {
    // process data
})))?;

transfer.submit_transfer(
    [0u8;10], // data
    0, bm_request_type,
    0, b_request,
    0, w_value,
    0, w_index,
)?;

You can take this changes as a base for your own API or just merge it as is.

Ok(())
}

fn allocate_trhansfer_handle(iso_packets: i32) -> Result<*mut libusb_transfer> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thank you, fixed.

@a1ien
Copy link
Owner

a1ien commented Jul 1, 2021

I think it's good to split this PR.
Move log commit to separate PR.

@dmitry-zakablukov
Copy link
Contributor Author

@a1ien , done: #76

@samueldotj
Copy link

@a1ien are you planning to merge this patch?

@a1ien
Copy link
Owner

a1ien commented Jul 16, 2022

I want find some time to rework. And maybe as separate crate in workspace. Because I want more test.
I promise that I find time until mid-autumn to check and rewrite and made some async support in rusb.

P.S. I am now in relocation process so to much new things in new country :)

@a1ien
Copy link
Owner

a1ien commented Sep 4, 2022

Closed in favor of #143

@a1ien a1ien closed this Sep 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants