abcminiuser / lufa

LUFA - the Lightweight USB Framework for AVRs.
http://www.lufa-lib.org
1.03k stars 321 forks source link

Generic HID Example lang id failure #159

Closed 84Park closed 4 years ago

84Park commented 4 years ago

LUFA-170418: the Generic HID Example lang id fails.

The device, GenericHID.hex, has been compiled and burned to a ProMicro atmega32u4 clone board. lsusb -v displays the GenericHID USB device contents with no apparent issues. The Mac device USB port is /dev/cu.usbmodem14400.

The host app, test_generic_hid_libusb.py, runs on a MacBook Pro, OS X 10.15, with python v3.7.6, pyUSB v1.0.2, libusb v1.0.23, and pyserial v3.4.1.

% python3 test_generic_hid_libusb.py apparently finds the vendor id and product id then gives the following error:

"Traceback (most recent call last): File "test_generic_hid_libusb.py", line 98, in main() File "test_generic_hid_libusb.py", line 75, in main usb.util.get_string(hid_device, 256, hid_device.iProduct), File "/usr/local/lib/python3.7/site-packages/usb/util.py", line 318, in get_string raise ValueError("The device does not support the specified langid") ValueError: The device does not support the specified langid"

The device Descriptors.c includes this: "const USB_Descriptor_String_t PROGMEM LanguageString = USB_STRING_DESCRIPTOR_ARRAY(LANGUAGE_ID_ENG);"

which I assume is to provide the desired langid for English language.

I have not found a solution to this error. Any help with this would be appreciated.

84Park commented 4 years ago

Digging deeper into this problem seems to be that MacOS can not use libusb. According to two comments I found on the web:

1) “Does python LibUsb work on HID Devices on Mac OS X ? It is no. It looks like libusb cannot be used on Mac to access HID devices, and you should use HIDAPI library or similar instead.”

2) "It seems to me this has nothing to do with pyusb. If it is an HID device, you can not use libusb/pyusb under Mac OS X since Mac OS X will bind the device to the kernel driver."

I have not found any useful host example code using HIDAPI. I did get the HIDAPI Test App to function on my Mac, and it will communicate with a Pro Micro running a Generic Hid example.

Any example of how to build a Mac host app with HIDAPI would be appreciated, for instance, send a report from host to toggle 4 LEDs on Pro Micro device.

Thanks.