You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I am trying to read device information from the device descriptor (iManufacturer, iProduct, iSerial). In libusb, there is libusb_get_device_descriptor and libusb_get_string_descriptor_ascii but in QtUsb there seems no nice way to do this.
Describe the solution you'd like
QtUsb already uses libusb_get_device_descriptor in QUsb and QUsbDevice but it does not save the descriptor anywhere. I would propose that QUsbDevice is extended with:
A single struct property, say QUsbDeviceDescriptor descriptor(), that is modeled after the structure of struct libusb_device_descriptor (it could possibly be Qt-ified, so as to use QString instead of const char* and the Q_GADGET macro, etc.)
Multiple properties that would have been fields of QUsbDeviceDescriptor, so that user code can access directly device->manufacturer() or device->product() etc.
In the first case, it would be easy to envision that the getter internally calls libusb_get_device_descriptor and just re-arranges returned data into a neater form. In the second case, there would have to be some sort of lazy loading logic implemented (i.e. the first call to device->manufacturer() populates some internal fields, which would also feed other getters). Alternatively, we could just pass the device descriptor first retrieved in QUsb into QUsbDevice's constructor but that may be too much work for a little effect.
Describe alternatives you've considered
I have considered using libusb directly but I think it is never a good idea to bypass an abstraction layer.
Additional context Here is an example showing how a device descriptor can be retrieved and its contents can be printed.
One more perhaps related issue, while QUsbEndpoint offers the makeControlPacket() function that prepares a buffer for control transfer, it is not clear how large this buffer should be. To this end, libusb defines the LIBUSB_CONTROL_SETUP_SIZE macro, which is unfortunately not accessible because QtUsb does not expose libusb headers to user code. Currently I am working around this by defining the constant in my code, however it would be great if QtUsb could somehow repackage this macro in its interface. Perhaps as a static qsizetype QUsbEndpoint::controlSetupSize(), or even better something that can be used at compile-time, so as to enable the use of templates such as std::array<char, LIBUSB_CONTROL_SETUP_SIZE>.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
I am trying to read device information from the device descriptor (iManufacturer, iProduct, iSerial). In libusb, there is
libusb_get_device_descriptor
andlibusb_get_string_descriptor_ascii
but in QtUsb there seems no nice way to do this.Describe the solution you'd like
QtUsb already uses
libusb_get_device_descriptor
inQUsb
andQUsbDevice
but it does not save the descriptor anywhere. I would propose thatQUsbDevice
is extended with:QUsbDeviceDescriptor descriptor()
, that is modeled after the structure ofstruct libusb_device_descriptor
(it could possibly be Qt-ified, so as to useQString
instead ofconst char*
and theQ_GADGET
macro, etc.)QUsbDeviceDescriptor
, so that user code can access directlydevice->manufacturer()
ordevice->product()
etc.In the first case, it would be easy to envision that the getter internally calls
libusb_get_device_descriptor
and just re-arranges returned data into a neater form. In the second case, there would have to be some sort of lazy loading logic implemented (i.e. the first call todevice->manufacturer()
populates some internal fields, which would also feed other getters). Alternatively, we could just pass the device descriptor first retrieved inQUsb
intoQUsbDevice
's constructor but that may be too much work for a little effect.Describe alternatives you've considered
I have considered using libusb directly but I think it is never a good idea to bypass an abstraction layer.
Additional context
Here is an example showing how a device descriptor can be retrieved and its contents can be printed.
One more perhaps related issue, while
QUsbEndpoint
offers themakeControlPacket()
function that prepares a buffer for control transfer, it is not clear how large this buffer should be. To this end, libusb defines theLIBUSB_CONTROL_SETUP_SIZE
macro, which is unfortunately not accessible because QtUsb does not expose libusb headers to user code. Currently I am working around this by defining the constant in my code, however it would be great if QtUsb could somehow repackage this macro in its interface. Perhaps as astatic qsizetype QUsbEndpoint::controlSetupSize()
, or even better something that can be used at compile-time, so as to enable the use of templates such asstd::array<char, LIBUSB_CONTROL_SETUP_SIZE>
.The text was updated successfully, but these errors were encountered: