Dear Sirs,
I have a USB-kit board with PIC16C745. I am trying to get the data from the
5-channels of its A/D converter.
The vendors also provide a program in Visual Basic which uses a HIDComm
program and Active X components underneath.
I don't quite know what is in the firmware and I can only make guesses from
the VB program itself.
The Visual Basic program seems to write 1-byte channel number at data
location with Report ID 2.
Then after delay of 71 ms, it reads from the same location, which returns
the 1-byte data from the respective A/D channel number specified before.
I have tried your program test_libhid.c and I can successfully connect to
the device. But I have not been able to write to the specific location of
Report ID 2.
I have tried different Input Paths as specified in your example for the
Phidgets Quad ServoController, but I have not quite gotten it right.
I have tried different things but I seem to end up with  report ID 0x00 and
report ID 0x01, and never with the desired  report ID 0x02.
This is the part I have added to your program for write and read.
-----------
int const PATH_IN[2] = { 0xff000000,0xff000000};
int const PATH_OUT[2] = {0xff000000,0xff000000};
char const PACKET[1] = {0x02,0x04};
printf("From here ================================================ \n");

ret = hid_set_output_report(hid, PATH_IN, PATHLEN, PACKET, SEND_PACKET_LEN);

if (ret != HID_RET_SUCCESS)
{
fprintf(stderr, "hid_set_output_report failed with return code %d\n", ret);
}

unsigned char const RECV_PACKET_LEN = 2;
//char packet[RECV_PACKET_LEN];
char packet[2];
usleep(71000);
ret = hid_get_input_report(hid, PATH_OUT, PATHLEN, packet, RECV_PACKET_LEN);

if (ret != HID_RET_SUCCESS)
{
fprintf(stderr, "hid_get_input_report failed with return code %d\n", ret);
}
printf("To here ================================================ \n");


--------------------
Snippet from the output ....
 TRACE: hid_prepare_report_descriptor(): initialising the report descriptor
for USB device 001/008[0]...
 TRACE: hid_prepare_report_descriptor(): retrieving report descriptor for
USB device 001/008[0]...
NOTICE: hid_prepare_report_descriptor(): successfully initialised report
descriptor for USB device 001/008[0].
 TRACE: hid_prepare_parser(): setting up the HID parser for USB device
001/008[0]...
 TRACE: hid_reset_parser(): resetting the HID parser for USB device
001/008[0]...
 TRACE: hid_prepare_parser(): dumping the raw report descriptor
 TRACE: hid_prepare_parser(): 0x000: 0x06 0x00 0xff 0x09 0x00 0xa1 0x01 0x06

 TRACE: hid_prepare_parser(): 0x008: 0x00 0xff 0x85 0x01 0x09 0x00 0x15 0x00

 TRACE: hid_prepare_parser(): 0x010: 0x26 0xff 0x00 0x75 0x08 0x95 0x01 0x81

 TRACE: hid_prepare_parser(): 0x018: 0x02 0x09 0x00 0x75 0x08 0x95 0x01 0x91

 TRACE: hid_prepare_parser(): 0x020: 0x02 0x85 0x02 0x09 0x00 0x75 0x08 0x95

 TRACE: hid_prepare_parser(): 0x028: 0x01 0x81 0x02 0x09 0x00 0x75 0x08 0x95

 TRACE: hid_prepare_parser(): 0x030: 0x01 0x91 0x02 0x85 0x03 0x09 0x00 0x15

 TRACE: hid_prepare_parser(): 0x038: 0x00 0x26 0xff 0x00 0x75 0x08 0x95 0x01

 TRACE: hid_prepare_parser(): 0x040: 0x81 0x02 0x09 0x00 0x75 0x08 0x95 0x01

 TRACE: hid_prepare_parser(): 0x048: 0x91 0x02 0xc0
 TRACE: hid_prepare_parser(): parsing the HID tree of USB device
001/008[0]...
NOTICE: hid_prepare_parser(): successfully set up the HID parser for USB
device 001/008[0].
NOTICE: hid_force_open(): successfully opened USB device 001/008[0].
device identification of HIDInterface 001/008[0]:
 dev_handle:    0x0804e0c0
 device:        0x0804d048
 location:      001/008
 manufacturer:  Innovative Experiment
 product:       U-Board USB1.0/1.1 Interface
 serial number: V1.00
 TRACE: hid_reset_parser(): resetting the HID parser for USB device
001/008[0]...
 TRACE: hid_dump_tree(): iterating the parse tree for USB device
001/008[0]...
parse tree of HIDInterface 001/008[0]:
 path: 0xff000000.0xff000000; type: 0x80
 path: 0xff000000.0xff000000; type: 0x90
 path: 0xff000000.0xff000000; type: 0x80
 path: 0xff000000.0xff000000; type: 0x90
 path: 0xff000000.0xff000000; type: 0x80
 path: 0xff000000.0xff000000; type: 0x90
 TRACE: hid_reset_parser(): resetting the HID parser for USB device
001/008[0]...
>From here ================================================
 TRACE: hid_set_output_report(): looking up report ID...
 TRACE: hid_prepare_parse_path(): preparing search path of depth 2 for parse
tree of USB device 001/008[0]...
 TRACE: hid_prepare_parse_path(): search path prepared for parse tree of USB
device 001/008[0].
NOTICE: hid_find_object(): found requested item.
 TRACE: hid_set_output_report(): sending report ID 0x01 (length: 2) to USB
device 001/008[0]...
NOTICE: hid_set_output_report(): successfully sent report to USB device
001/008[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 001/008[0]...
 TRACE: hid_prepare_parse_path(): search path prepared for parse tree of USB
device 001/008[0].
NOTICE: hid_find_object(): found requested item.
 TRACE: hid_get_input_report(): retrieving report ID 0x01 (length: 2) from
USB device 001/008[0]...
WARNING: hid_get_input_report(): failed to retrieve report from USB device
001/008[0]:error sending control message: Broken pipe.
hid_get_input_report failed with return code 20
To here ================================================
 TRACE: hid_close(): closing USB device 001/008[0]...
 TRACE: hid_close(): closing handle of USB device 001/008[0]...
NOTICE: hid_close(): successfully closed USB device 001/008[0].
 ---------------------------------------


Below is the output of lsusb -v
----------------
minSOSpy:/home/aadit/USB# lsusb -d 04d8:0fff -v

Bus 001 Device 008: ID 04d8:0fff Microchip Technology, Inc.
Device Descriptor:
 bLength                18
 bDescriptorType         1
 bcdUSB               1.00
 bDeviceClass            0 (Defined at Interface level)
 bDeviceSubClass         0
 bDeviceProtocol         0
 bMaxPacketSize0         8
 idVendor           0x04d8 Microchip Technology, Inc.
 idProduct          0x0fff
 bcdDevice            1.00
 iManufacturer           1 Innovative Experiment
 iProduct                2 U-Board USB1.0/1.1 Interface
 iSerial                 3 V1.00
 bNumConfigurations      1
 Configuration Descriptor:
   bLength                 9
   bDescriptorType         2
   wTotalLength           55
   bNumInterfaces          1
   bConfigurationValue     1
   iConfiguration          4 Config 1
   bmAttributes         0xa0
     (Bus Powered)
     Remote Wakeup
   MaxPower              400mA
   Interface Descriptor:
     bLength                 9
     bDescriptorType         4
     bInterfaceNumber        0
     bAlternateSetting       0
     bNumEndpoints           4
     bInterfaceClass         3 Human Interface Devices
     bInterfaceSubClass      0 No Subclass
     bInterfaceProtocol      0 None
     iInterface              5 Interface 0
       HID Device Descriptor:
         bLength                 9
         bDescriptorType        33
         bcdHID               1.00
         bCountryCode            0 Not supported
         bNumDescriptors         1
         bDescriptorType        34 Report
         wDescriptorLength      75
         Report Descriptor: (length is 75)
           Item(Global): Usage Page, data= [ 0x00 0xff ] 65280
                           (null)
           Item(Local ): Usage, data= [ 0x00 ] 0
                           (null)
           Item(Main  ): Collection, data= [ 0x01 ] 1
                           Application
           Item(Global): Usage Page, data= [ 0x00 0xff ] 65280
                           (null)
           Item(Global): Report ID, data= [ 0x01 ] 1
           Item(Local ): Usage, data= [ 0x00 ] 0
                           (null)
           Item(Global): Logical Minimum, data= [ 0x00 ] 0
           Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
           Item(Global): Report Size, data= [ 0x08 ] 8
           Item(Global): Report Count, data= [ 0x01 ] 1
           Item(Main  ): Input, data= [ 0x02 ] 2
                           Data Variable Absolute No_Wrap Linear
                           Preferred_State No_Null_Position Non_Volatile
Bitfield
           Item(Local ): Usage, data= [ 0x00 ] 0
                           (null)
           Item(Global): Report Size, data= [ 0x08 ] 8
           Item(Global): Report Count, data= [ 0x01 ] 1
           Item(Main  ): Output, data= [ 0x02 ] 2
                           Data Variable Absolute No_Wrap Linear
                           Preferred_State No_Null_Position Non_Volatile
Bitfield
           Item(Global): Report ID, data= [ 0x02 ] 2
           Item(Local ): Usage, data= [ 0x00 ] 0
                           (null)
           Item(Global): Report Size, data= [ 0x08 ] 8
           Item(Global): Report Count, data= [ 0x01 ] 1
           Item(Main  ): Input, data= [ 0x02 ] 2
                           Data Variable Absolute No_Wrap Linear
                           Preferred_State No_Null_Position Non_Volatile
Bitfield
           Item(Local ): Usage, data= [ 0x00 ] 0
                           (null)
           Item(Global): Report Size, data= [ 0x08 ] 8
           Item(Global): Report Count, data= [ 0x01 ] 1
           Item(Main  ): Output, data= [ 0x02 ] 2
                           Data Variable Absolute No_Wrap Linear
                           Preferred_State No_Null_Position Non_Volatile
Bitfield
           Item(Global): Report ID, data= [ 0x03 ] 3
           Item(Local ): Usage, data= [ 0x00 ] 0
                           (null)
           Item(Global): Logical Minimum, data= [ 0x00 ] 0
           Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
           Item(Global): Report Size, data= [ 0x08 ] 8
           Item(Global): Report Count, data= [ 0x01 ] 1
           Item(Main  ): Input, data= [ 0x02 ] 2
                           Data Variable Absolute No_Wrap Linear
                           Preferred_State No_Null_Position Non_Volatile
Bitfield
           Item(Local ): Usage, data= [ 0x00 ] 0
                           (null)
           Item(Global): Report Size, data= [ 0x08 ] 8
           Item(Global): Report Count, data= [ 0x01 ] 1
           Item(Main  ): Output, data= [ 0x02 ] 2
                           Data Variable Absolute No_Wrap Linear
                           Preferred_State No_Null_Position Non_Volatile
Bitfield
           Item(Main  ): End Collection, data=none
     Endpoint Descriptor:
       bLength                 7
       bDescriptorType         5
       bEndpointAddress     0x81  EP 1 IN
       bmAttributes            3
         Transfer Type            Interrupt
         Synch Type               None
         Usage Type               Data
       wMaxPacketSize     0x0002  1x 2 bytes
       bInterval              10
     Endpoint Descriptor:
       bLength                 7
       bDescriptorType         5
       bEndpointAddress     0x01  EP 1 OUT
       bmAttributes            3
         Transfer Type            Interrupt
         Synch Type               None
         Usage Type               Data
       wMaxPacketSize     0x0002  1x 2 bytes
       bInterval              10
     Endpoint Descriptor:
       bLength                 7
       bDescriptorType         5
       bEndpointAddress     0x82  EP 2 IN
       bmAttributes            3
         Transfer Type            Interrupt
         Synch Type               None
         Usage Type               Data
       wMaxPacketSize     0x0002  1x 2 bytes
       bInterval              10
     Endpoint Descriptor:
       bLength                 7
       bDescriptorType         5
       bEndpointAddress     0x02  EP 2 OUT
       bmAttributes            3
         Transfer Type            Interrupt
         Synch Type               None
         Usage Type               Data
       wMaxPacketSize     0x0002  1x 2 bytes
       bInterval              10
Device Status:     0x0000
 (Bus Powered)

---------------------
Can anyone tell me how to first write 1-byte into the data corresponding to
ReportID 0x02 and the read from the same location after a delay.
I apologize for sending a long message with so many details. I am sincerely
hoping that someone can point me the right direction.
Thanks and regards,
_______________________________________________
libhid-discuss mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/libhid-discuss

Reply via email to