diff --git a/adafruit_usb_host_descriptors.py b/adafruit_usb_host_descriptors.py index d114189..338b859 100644 --- a/adafruit_usb_host_descriptors.py +++ b/adafruit_usb_host_descriptors.py @@ -10,6 +10,7 @@ * Author(s): Scott Shawcroft """ +import array import struct import usb @@ -83,23 +84,23 @@ def get_descriptor(device, desc_type, index, buf, language_id=0): def get_device_descriptor(device): """Fetch the device descriptor and return it.""" - buf = bytearray(1) + buf = array.array("B", bytearray(1)) get_descriptor(device, DESC_DEVICE, 0, buf) - full_buf = bytearray(buf[0]) + full_buf = array.array("B", bytearray(buf[0])) get_descriptor(device, DESC_DEVICE, 0, full_buf) - return full_buf + return bytearray(full_buf) def get_configuration_descriptor(device, index): """Fetch the configuration descriptor, its associated descriptors and return it.""" # Allow capitalization that matches the USB spec. # pylint: disable=invalid-name - buf = bytearray(4) + buf = array.array("B", bytearray(4)) get_descriptor(device, DESC_CONFIGURATION, index, buf) wTotalLength = struct.unpack("