HIDAPI on linux doesn't seem to recognize descriptors

395 views Asked by At

Got a device reported in dmesg as:

[ 7679.312788] hid-generic 0003:16D0:0E70.0012: hiddev0,hidraw0: USB HID v1.01 Device [.de.nonchip TinyStick HIDSTM1640] on usb-0000:00:13.0-3/input0

the actual HID descriptor (as I put it into the device's firmware, not sniffed+decoded) is as follows:

PROGMEM const char usbHidReportDescriptor[USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH] = {    /* USB report descriptor */
    0x06, 0x00, 0xff,              // USAGE_PAGE (Generic Desktop)
    0x09, 0x01,                    // USAGE (Vendor Usage 1)
    0xa1, 0x01,                    // COLLECTION (Application)
    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
    0x26, 0xff, 0x00,              //   LOGICAL_MAXIMUM (255)
    0x75, 0x08,                    //   REPORT_SIZE (8)
    0x95, 0x08,                    //   REPORT_COUNT (8)
    0x09, 0x00,                    //   USAGE (Undefined)  
    0x82, 0x02, 0x01,              //   INPUT (Data,Var,Abs,Buf)
    0x95, 32, //   REPORT_COUNT (32)
    0x09, 0x00,                    //   USAGE (Undefined)        
    0xb2, 0x02, 0x01,              //   FEATURE (Data,Var,Abs,Buf)
    0xc0                           // END_COLLECTION
};

the string descriptors are defined as:

#define USB_CFG_VENDOR_NAME     '.','d','e','.','n','o','n','c','h','i','p'
#define USB_CFG_VENDOR_NAME_LEN 11
#define USB_CFG_DEVICE_NAME     'T','i','n','y','S','t','i','c','k',' ','H','I','D','S','T','M','1','6','4','0'
#define USB_CFG_DEVICE_NAME_LEN 20

i'm using the following code in hidapi to (try to) find it:

#define HIDSERIAL_VENDOR_ID 0x16d0
#define HIDSERIAL_PRODUCT_ID 0x0E70
#define HIDSERIAL_MANUFACTURER_STRING L".de.nonchip"
#define HIDSERIAL_PRODUCT_STRING L"TinyStick HIDSTM1640"

hid_device* hidserial_find_device(void){
  hid_device *handle = NULL;

  hid_init();
  // Enumerate and print the HID devices on the system
  struct hid_device_info *devs, *cur_dev;

  devs = hid_enumerate(HIDSERIAL_VENDOR_ID, HIDSERIAL_PRODUCT_ID);
  cur_dev = devs; 
  while (cur_dev) {
    wprintf(L"%ls %ls\n", cur_dev->manufacturer_string, cur_dev->product_string); // <------ DEBUG
    if( cur_dev->manufacturer_string!=NULL && cur_dev->product_string!=NULL &&
        0==wcscmp(HIDSERIAL_MANUFACTURER_STRING,cur_dev->manufacturer_string) &&
        0==wcscmp(HIDSERIAL_PRODUCT_STRING,cur_dev->product_string)){
      handle = hid_open_path(cur_dev->path);
      break;
    }
    cur_dev = cur_dev->next;
  }
  hid_free_enumeration(devs);

  return handle;
}

my problem is, the device, while reported correctly by the kernel, is not found. the debug output shows a single line of (null) (null), which indicates the device was enumerated by its VID:PID pair, but the strings are empty all of a sudden. I don't get any errors (one might expect something like "permission denied" but nothing is reported and even running it as root doesn't seem to help)...

0

There are 0 answers