usb-device: Default bDeviceClass, bDeviceSubClass, bDeviceProtocol to 0.

These values are apparently interpreted as "interface defined", which is
a good fit for what happens here (more than one interface might show up in
the device).

It works as expected for the examples in Linux and Windows 10. There will
probably be some scenarios where a different value needs to be explicitly
passed in for the device.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
Angus Gratton 2024-04-03 16:08:26 +11:00
rodzic e40dd53300
commit 575251fb01
1 zmienionych plików z 6 dodań i 6 usunięć

Wyświetl plik

@ -95,9 +95,9 @@ class _Device:
id_vendor=None, id_vendor=None,
id_product=None, id_product=None,
bcd_device=None, bcd_device=None,
device_class=None, device_class=0,
device_subclass=None, device_subclass=0,
device_protocol=None, device_protocol=0,
config_str=None, config_str=None,
max_power_ma=None, max_power_ma=None,
): ):
@ -137,9 +137,9 @@ class _Device:
f[0], # bLength f[0], # bLength
f[1], # bDescriptorType f[1], # bDescriptorType
f[2], # bcdUSB f[2], # bcdUSB
maybe_set(device_class, 3), # bDeviceClass device_class, # bDeviceClass
maybe_set(device_subclass, 4), # bDeviceSubClass device_subclass, # bDeviceSubClass
maybe_set(device_protocol, 5), # bDeviceProtocol device_protocol, # bDeviceProtocol
f[6], # bMaxPacketSize0, TODO: allow overriding this value? f[6], # bMaxPacketSize0, TODO: allow overriding this value?
maybe_set(id_vendor, 7), # idVendor maybe_set(id_vendor, 7), # idVendor
maybe_set(id_product, 8), # idProduct maybe_set(id_product, 8), # idProduct