bimetek / QUSB

Qt wrapper classes for LibUSB 1.0
GNU Lesser General Public License v3.0
21 stars 16 forks source link

Implemented additional wrapper methods #2

Closed stevedorries closed 9 years ago

stevedorries commented 9 years ago

Additional wrapper methods and an idea on how to handle LIBUSB_ERROR codes.

uranusjr commented 9 years ago

I have been looking into device descriptors, and there’re some things I’d like to clarify.

First of all, how would you (and possibly others) use those descriptor integers? Are they only used for getting a string description of the device (via handle->stringDescriptor()), or can be used elsewhere? If they are only for getting a string descriptor, I’m thinking maybe we should abstract away some of the details, and make those functions return Descriptor instances, instead of raw integers.

Also, is the 256 length in Handle::stringDescriptor() a bullet-proof implementation? Is it possible to have string descriptors longer than that? If so, what would libusb_get_string_descriptor_ascii react? Does it fail if the buffer is too short, or would the output be truncated?

Sorry if some of my questions are a bit dumb. I’m more software than hardware, and is not very knowledgable with libusb. I know how to use it, but only has limited experience with it.

Thanks in advance.

uranusjr commented 9 years ago

Forgot to mention—The patch itself is fine. Merging. :)

stevedorries commented 9 years ago

There are string versions of multiple other fields about devices besides product, vendor, and manufacturer descriptions, but I can't think of them off the top of my head.

The 256 buffer size was just a temporary size on the array, we'll have to ask more experienced USB wizards about whether that's a safe assumption or if there should be some type of magic to determine proper buffer size.

I think convenience methods that get the string descriptors for things may be useful, would reduce typing for some.