Skip to content

Conversation

@blandger
Copy link

@blandger blandger commented Aug 31, 2020

  • Examples are rewritten to using 'MaybeUninit'
  • added LIBUSB_SPEED_SUPER_PLUS const
  • added libusb_control_setup struct
  • added missing functions : libusb_set_log_cb(..), libusb_cpu_to_le16(..), libusb_control_transfer_get_data(), libusb_fill_control_setup(), libusb_fill_control_transfer(), libusb_fill_bulk_transfer(), libusb_fill_bulk_stream_transfer(), libusb_fill_interrupt_transfer(), libusb_fill_iso_transfer(), libusb_set_iso_packet_lengths()

@dcuddeback looks as absent since beginning 2020? That's a pity...

@dcuddeback
Copy link
Owner

@blandger Thanks for sending this in and sorry for taking so long to reply. I'd love to add the remaining definitions to libusb-sys. The main reason they didn't previously exist is that I didn't have the time to write the necessary examples. Examples are compiled and linked with cargo test, which is enough to catch typos in function names or functions that are missing in older versions of the library. I'd like new additions to be consistent with that approach.

In addition to that, this PR needs to focus on one thing. It's doing a lot more besides adding some missing definitions. All extraneous changes need to be separated.

let ptr = setup as *const usize;
if !ptr.is_null() {
// let size_of_result = libusb_cpu_to_le16((*setup).wLength);
(*transfer).length = (LIBUSB_CONTROL_SETUP_SIZE + std::mem::size_of::<u16>()).try_into().unwrap();

Choose a reason for hiding this comment

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

This assumes that the length of the payload is exactly 16 bits.
For payloads of other sizes, the transfer will fail.

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.

3 participants