Hi

I notice this list has been very quite recently,  so I hope someone is still out there?

I am trying to write an interface in C so I can communicate with a PIC chip via USB using libhid, but I do not understand how to use the path information I am seeing to send and receive massages.

This is the output I get when I run the example code that I downloaded from the libhid site.

 NOTICE: hid_find_usb_device(): found a matching USB device 004/003[0].
  TRACE: hid_force_open(): claiming USB device 004/003[0].
 NOTICE: hid_force_open(): successfully claimed USB device 004/003[0].
  TRACE: hid_init_parser(): initialising the HID parser for USB Device 004/003[0]...
  TRACE: hid_init_parser(): allocating space for HIDData structure...
  TRACE: hid_init_parser(): successfully allocated memory for HIDData strcture.
  TRACE: hid_init_parser(): allocating space for HIDParser structure...
  TRACE: hid_init_parser(): successfully allocated memory for HIDParser strcture.
 NOTICE: hid_init_parser(): successfully initialised the HID parser for USB Device 004/003[0].
  TRACE: hid_prepare_hid_descriptor(): initialising the HID descriptor for USB device 004/003[0]...
  TRACE: hid_prepare_hid_descriptor(): retrieving HID descriptor for USB device 004/003[0]...
 NOTICE: hid_prepare_hid_descriptor(): successfully initialised HID descriptor for USB device 004/003[0] (29 bytes).
  TRACE: hid_prepare_report_descriptor(): initialising the report descriptor for USB device 004/003[0]...
  TRACE: hid_prepare_report_descriptor(): retrieving report descriptor for USB device 004/003[0]...
 NOTICE: hid_prepare_report_descriptor(): successfully initialised report descriptor for USB device 004/003[0].
  TRACE: hid_prepare_parser(): setting up the HID parser for USB device 004/003[0]...
  TRACE: hid_reset_parser(): resetting the HID parser for USB device 004/003[0]...
  TRACE: hid_prepare_parser(): dumping the raw report descriptor
  TRACE: hid_prepare_parser(): 0x000: 0x06 0x00 0xff 0x09 0x01 0xa1 0x01 0x19
  TRACE: hid_prepare_parser(): 0x008: 0x01 0x29 0x40 0x15 0x00 0x26 0xff 0x00
  TRACE: hid_prepare_parser(): 0x010: 0x75 0x08 0x95 0x40 0x81 0x00 0x19 0x01
  TRACE: hid_prepare_parser(): 0x018: 0x29 0x40 0x91 0x00 0xc0
  TRACE: hid_prepare_parser(): parsing the HID tree of USB device 004/003[0]...
 NOTICE: hid_prepare_parser(): successfully set up the HID parser for USB device 004/003[0].
 NOTICE: hid_force_open(): successfully opened USB device 004/003[0].
device identification of HIDInterface 004/003[0]:
  dev_handle:    0x00a68ea0
  device:        0x00a7c470
  location:      004/003
  manufacturer:  Microchip Technology Inc.
  product:       Simple HID Device Demo
  TRACE: hid_reset_parser(): resetting the HID parser for USB device 004/003[0]...
  TRACE: hid_dump_tree(): iterating the parse tree for USB device 004/003[0]...
parse tree of HIDInterface 004/003[0]:
  path: 0xff000001.0x00000000; type: 0x80
  {listed a total of 64 times}

  path: 0xff000001.0x00000000; type: 0x90
  {listed a total of 64 times}

  TRACE: hid_reset_parser(): resetting the HID parser for USB device 004/003[0]...
  TRACE: hid_close(): closing USB device 004/003[0]...
  TRACE: hid_close(): closing handle of USB device 004/003[0]...
 NOTICE: hid_close(): successfully closed USB device 004/003[0].
  TRACE: hid_reset_parser(): resetting the HID parser for USB device 004/003[0]...
  TRACE: hid_close(): freeing memory allocated for HID parser...
  TRACE: hid_close(): resetting HIDInterface...
 NOTICE: hid_cleanup(): successfully deinitialised HID library.

I have tried the following code in an attempt to read some data:

unsigned char const RECV_PACKET_LEN = 64;
char packet[RECV_PACKET_LEN];
unsigned char const PATHLEN = 2;
int const PATH_IN[2] = { 0xff000001, 0 };
int i;

ret = hid_get_input_report(hid, PATH_IN, PATHLEN, packet, RECV_PACKET_LEN);
  if (ret != HID_RET_SUCCESS)
    {
      fprintf(stderr, "hid_get_input_report failed with return code %d\n", ret);
    }
else
  {
    printf("data...\n");

    for (i=0; i<RECV_PACKET_LEN; i++)
      printf("0x%02X ", (unsigned char) packet[i]);

    printf("\n");
  }

But it complains of a broken pipe.....

  TRACE: hid_reset_parser(): resetting the HID parser for USB device 004/003[0]...
  TRACE: hid_get_input_report(): looking up report ID...
  TRACE: hid_prepare_parse_path(): preparing search path of depth 2 for parse tree of USB device 004/003[0]...
  TRACE: hid_prepare_parse_path(): search path prepared for parse tree of USB device 004/003[0].
 NOTICE: hid_find_object(): found requested item.
  TRACE: hid_get_input_report(): retrieving report ID 0x00 (length: 64) from USB device 004/003[0]...
WARNING: hid_get_input_report(): failed to retrieve report from USB device 004/003[0]:error sending control message: Broken pipe.
hid_get_input_report failed with return code 20
  TRACE: hid_close(): closing USB device 004/003[0]...
  TRACE: hid_close(): closing handle of USB device 004/003[0]...
 NOTICE: hid_close(): successfully closed USB device 004/003[0].
  TRACE: hid_reset_parser(): resetting the HID parser for USB device 004/003[0]...
  TRACE: hid_close(): freeing memory allocated for HID parser...
  TRACE: hid_close(): resetting HIDInterface...
 NOTICE: hid_cleanup(): successfully deinitialised HID library.



This is the output I get from lsusb

$ sudo lsusb -d 0x04d8:0x003f -vvv

Bus 004 Device 003: ID 04d8:003f Microchip Technology, Inc.
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0         8
  idVendor           0x04d8 Microchip Technology, Inc.
  idProduct          0x003f
  bcdDevice            0.02
  iManufacturer           1 Microchip Technology Inc.
  iProduct                2 Simple HID Device Demo
  iSerial                 0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           41
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0xc0
      Self Powered
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 No Subclass
      bInterfaceProtocol      0 None
      iInterface              0
      ** UNRECOGNIZED:  09 21 11 01 00 01 22 1d 00
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
Device Status:     0x0001
  Self Powered


Can someone give me some pointers as I am a little stuck.

Thanks


Tim
_______________________________________________
libhid-discuss mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/libhid-discuss
http://libhid.alioth.debian.org/

Reply via email to