<br><br><div class="gmail_quote">On Tue, Sep 1, 2009 at 3:53 AM, Charles Lepple <span dir="ltr">&lt;clepple@ghz.cc&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im"><br>
On Aug 31, 2009, at 1:22 AM, sajjad gerami wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
i have problem with finding path to read and write with libhid<br>
my device parsing :<br>
<br>
path: 0xff000001.0xff000001; type: 0x90<br>
 path: 0xff000001.0x00000000; type: 0x90<br>
 path: 0xff000001.0x00000000; type: 0x90<br>
 path: 0xff000001.0x00000000; type: 0x90<br>
 path: 0xff000001.0x00000000; type: 0x90<br>
 path: 0xff000001.0x00000000; type: 0x90<br>
 path: 0xff000001.0x00000000; type: 0x90<br>
 path: 0xff000001.0xff000001; type: 0xb0<br>
 path: 0xff000001.0x00000000; type: 0xb0<br>
 path: 0xff000001.0x00000000; type: 0xb0<br>
 path: 0xff000001.0x00000000; type: 0xb0<br>
 path: 0xff000001.0x00000000; type: 0xb0<br>
 path: 0xff000001.0x00000000; type: 0xb0<br>
 path: 0xff000001.0x00000000; type: 0xb0<br>
<br>
no 0x80 exist!!!!!<br>
</blockquote>
<br></div>
What does &#39;lsusb&#39; say?<br>
<br>
Also, please provide some basic information about your setup:<br>
<br>
* OS<br>
* Distribution (if Linux)<br>
* version of libhid<br>
<br>
</blockquote></div><br><br>hi<br>absolutly<br><br>lsusb result :<br><br>root@sajjad-laptop:/media/laptop-bullshit# lsusb -d 0x1114:0x1028 -vvv<br><br>Bus 003 Device 002: ID 1114:1028  <br>Device Descriptor:<br>  bLength                18<br>
  bDescriptorType         1<br>  bcdUSB               1.10<br>  bDeviceClass            0 (Defined at Interface level)<br>  bDeviceSubClass         0 <br>  bDeviceProtocol         0 <br>  bMaxPacketSize0         8<br>  idVendor           0x1114 <br>
  idProduct          0x1028 <br>  bcdDevice            1.00<br>  iManufacturer           1 IBECo<br>  iProduct                2 Safe Hardware Lock<br>  iSerial                 3 IBECo525085<br>  bNumConfigurations      1<br>
  Configuration Descriptor:<br>    bLength                 9<br>    bDescriptorType         2<br>    wTotalLength           34<br>    bNumInterfaces          1<br>    bConfigurationValue     1<br>    iConfiguration          0 <br>
    bmAttributes         0x80<br>      (Bus Powered)<br>    MaxPower               20mA<br>    Interface Descriptor:<br>      bLength                 9<br>      bDescriptorType         4<br>      bInterfaceNumber        0<br>
      bAlternateSetting       0<br>      bNumEndpoints           1<br>      bInterfaceClass         3 Human Interface Device<br>      bInterfaceSubClass      0 No Subclass<br>      bInterfaceProtocol      0 None<br>      iInterface              0 <br>
        HID Device Descriptor:<br>          bLength                 9<br>          bDescriptorType        33<br>          bcdHID               1.01<br>          bCountryCode            0 Not supported<br>          bNumDescriptors         1<br>
          bDescriptorType        34 Report<br>          wDescriptorLength      40<br>          Report Descriptor: (length is 40)<br>            Item(Global): Usage Page, data= [ 0x00 0xff ] 65280<br>                            (null)<br>
            Item(Global): Logical Minimum, data= [ 0x00 ] 0<br>            Item(Local ): Usage, data= [ 0x01 ] 1<br>                            (null)<br>            Item(Main  ): Collection, data= [ 0x01 ] 1<br>                            Application<br>
            Item(Global): Report ID, data= [ 0x01 ] 1<br>            Item(Local ): Usage, data= [ 0x01 ] 1<br>                            (null)<br>            Item(Global): Logical Minimum, data= [ 0x00 ] 0<br>            Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255<br>
            Item(Global): Report Size, data= [ 0x08 ] 8<br>            Item(Global): Report Count, data= [ 0x07 ] 7<br>            Item(Main  ): Output, data= [ 0x02 ] 2<br>                            Data Variable Absolute No_Wrap Linear<br>
                            Preferred_State No_Null_Position Non_Volatile Bitfield<br>            Item(Global): Report ID, data= [ 0x02 ] 2<br>            Item(Local ): Usage, data= [ 0x01 ] 1<br>                            (null)<br>
            Item(Global): Logical Minimum, data= [ 0x00 ] 0<br>            Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255<br>            Item(Global): Report Size, data= [ 0x08 ] 8<br>            Item(Global): Report Count, data= [ 0x07 ] 7<br>
            Item(Main  ): Feature, data= [ 0x02 ] 2<br>                            Data Variable Absolute No_Wrap Linear<br>                            Preferred_State No_Null_Position Non_Volatile Bitfield<br>            Item(Main  ): End Collection, data=none<br>
      Endpoint Descriptor:<br>        bLength                 7<br>        bDescriptorType         5<br>        bEndpointAddress     0x81  EP 1 IN<br>        bmAttributes            3<br>          Transfer Type            Interrupt<br>
          Synch Type               None<br>          Usage Type               Data<br>        wMaxPacketSize     0x0008  1x 8 bytes<br>        bInterval             100<br>Device Status:     0x0000<br>  (Bus Powered)<br><br>
/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\<br><br>I use ubuntu 9.04 kernel 2.6.28-13-generic<br>ubuntu Synaptic package manager say my libhid version is 0.2.15+20060325.2ubuntu1<br>but i think i&#39;ve compiled 2.16 version <br>
(do they deffers lot?)<br><br>is it possible that both input and output path of that device be equal?<br>
path: 0xff000001.0xff000001; type: 0x90<br>path: 0xff000001.0xff000001; type: 0xb0<br><br>i thinks this should be 0x80 for output <br><br>i&#39;m really confused about this pathes <br><br>i&#39;m interested about finding the path from lsusb -v result <br>
            Item(Global): Usage Page, data= [ 0x00 0xff ] 65280<br>            ...<br>            Item(Local ): Usage, data= [ 0x01 ] 1<br>0xff00+0001<br><br><br>/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\<br>
<br><br>here is my whole testing code :<br><br>/* <br> * File:   main.c<br> * Author: sajjad<br> *<br> * Created on August 30, 2009, 2:07 PM<br> */<br><br>#include &lt;stdio.h&gt;<br>#include &lt;stdlib.h&gt;<br>#include &lt;hid.h&gt;<br>
<br>#define _debug__ 0<br><br>int main(int argc, char** argv)<br><br>{<br>    printf(&quot;\n------******* program started *******--------\n&quot;);<br><br>    /*<br>    typedef struct HIDInterface_t {<br>        struct usb_dev_handle *dev_handle;<br>
        struct usb_device *device;<br>        int interface;<br>        char id[32];<br>        HIDData* hid_data;<br>        HIDParser* hid_parser;<br>    } HIDInterface;<br>    */<br><br>    HIDInterface* safe1_hid ;<br>
    hid_return safe1_return;<br>    //char const* const serial=&quot;IBECo525055&quot;;//IBECo524229<br>    HIDInterfaceMatcher safeMatcher={0x1114 , 0x1028 , NULL ,NULL  , 0};<br>    //HIDInterfaceMatcher safeMatcher={0x16c0 , 0x05df , NULL ,NULL  , 0};<br>
<br>    //enabling debuging<br>#if _debug__<br>    hid_set_debug(HID_DEBUG_ALL);<br>    hid_set_debug_stream(stderr);<br>    hid_set_usb_debug(0);/* passed directly to libusb */<br>#endif<br><br>    //initiazization don&#39;t work!!!!<br>
    safe1_return = hid_init();<br>#if _debug__<br>    if (safe1_return!=HID_RET_SUCCESS)<br>        printf(&quot;ERROR : Initialize libhid: scan for USB busses and devices using libusb.\n&quot;);<br>    else<br>        printf(&quot;SUCCESS : Initialize libhid: scan for USB busses and devices using libusb.\n&quot;);<br>
#endif<br>    safe1_hid=hid_new_HIDInterface();<br>#if _debug__<br>    if(safe1_hid==0)<br>        printf(&quot;ERROR : your out of memory hid_new_HIDInterface() faild!!\n&quot;);<br>    else<br>        printf(&quot;SUCCESS : hid_new_HIDInterface() \n&quot;);<br>
#endif <br>    //opennig devices<br><br>    //safe1_return=hid_open(safe1_hid,0,&amp;safeMatcher);<br>    safe1_return=hid_force_open(safe1_hid,0,&amp;safeMatcher,3);<br>    if(safe1_return!=HID_RET_SUCCESS)<br>        printf(&quot;ERROR : hid_open failed!!!\n&quot;);<br>
    else<br>        printf(&quot;SUCCESS : hid_open SUCCESSFULY!!!\n&quot;);<br>    //opennig devices DONE<br>    <br>    printf(&quot;************\nVIP=%hx     PID=%hx \n************\n&quot;,safeMatcher.vendor_id,safeMatcher.product_id);<br>
<br>/*<br>    //opennig tiny<br>      HIDInterfaceMatcher tiny = { 0x16c0 , 0x05df ,NULL,NULL , 0};<br>      HIDInterface* hid4tiny;<br>      hid_return tinyReturn;<br><br>      tinyReturn = hid_force_open(hid4tiny, 0, &amp;tiny, 3);<br>
      <br>      if (tinyReturn != HID_RET_SUCCESS) {<br>          printf(&quot;ERROR : Openning tiny failed!!!!\n&quot;);<br>//        return 1;<br>      }<br><br>      printf(&quot;\n************\nVIP=%hx \nPID=%hx \n************\n&quot;,tiny.vendor_id,tiny.product_id);<br>
*/<br><br>    //device identification of HIDInterface<br>    safe1_return = hid_write_identification(stdout, safe1_hid);<br>#if _debug__<br>    if (safe1_return != HID_RET_SUCCESS)<br>        printf(&quot;ERROR : hid_write_identification failed with return code %d\n&quot;, safe1_return);<br>
    else<br>        printf(&quot;SUCCESS : hid_write_identification \n&quot;);<br>#endif<br>    //dumping hid tree<br>#if _debug__<br>    safe1_return=hid_dump_tree(stdout,safe1_hid);<br><br>    if (safe1_return!=HID_RET_SUCCESS)<br>
        printf(&quot;ERROR : Dump_tree failed!!!!\n&quot;);<br>    else<br>        printf(&quot;SUCCESS : hid_dump_tree \n&quot;);<br>#endif    <br><br>    //*******************************************************************<br>
    //*******************************************************************<br>    //*******************************************************************<br><br>   //------------------ Writing to device --------------------------------<br>
   unsigned int const PATHLEN = 2;<br>   int PATH_OUT[PATHLEN];<br>   PATH_OUT[0]=0xff000001;<br>   PATH_OUT[1]=0xff000001;<br><br><br>   unsigned int const SEND_PACKET_LENGHT=8;<br>   char PACKET[SEND_PACKET_LENGHT];<br>
   PACKET[0]=0x0;PACKET[1]=0x10;PACKET[2]=0x2;PACKET[3]=0x3;<br>   PACKET[4]=0x1;PACKET[5]=0x12;PACKET[6]=0x3;PACKET[7]=0x7;<br>   int timeout = 1000; // milliseconds<br><br>   safe1_return = hid_set_output_report(safe1_hid,PATH_OUT,PATHLEN,PACKET,SEND_PACKET_LENGHT);<br>
   //safe1_return = hid_set_feature_report(safe1_hid , PATH_OUT , PATHLEN , PACKET ,SEND_PACKET_LENGHT);<br>   //safe1_return = hid_interrupt_write(safe1_hid , 0x02 , PACKET , 8 , timeout);<br><br>   if(safe1_return!=HID_RET_SUCCESS)<br>
       printf(&quot;ERROR : Writing failed !!!\n&quot;);<br>   else<br>   {<br>       printf(&quot;SUCCESS : Writing successfuly DONE\n&quot;);<br>       int i;<br>       printf(&quot;writed packet : \n***********************\n&quot;);<br>
       for (i=0 ; i&lt;SEND_PACKET_LENGHT ; i++)<br>           printf(&quot;%hx  &quot;,PACKET[i]);<br>       printf(&quot;\n&quot;);<br>   }<br><br>   //--------------- reading from device --------------------<br><br>    int PATH_IN[PATHLEN];<br>
    PATH_IN[0] = 0xff000001 ;<br>    PATH_IN[1] = 0xff000001 ;<br>    //printf(&quot;---------%lx------\n&quot;,sizeof(PATH_IN));  !!!!!!!!!!!!!!<br><br>    char recived_packet[8];<br>    unsigned int RECIVE_PACKET_LENGHT=8;<br>
<br>    safe1_return = hid_get_feature_report(safe1_hid,PATH_IN , PATHLEN , recived_packet , RECIVE_PACKET_LENGHT);<br>    //safe1_return = hid_get_input_report(safe1_hid,PATH_IN ,PATHLEN,recived_packet,RECIVE_PACKET_LENGHT);<br>
    //!!!//safe1_return = hid_interrupt_read(safe1_hid , 0x02 , recived_packet , RECIVE_PACKET_LENGHT , timeout);<br>    if (safe1_return!=HID_RET_SUCCESS)<br>        printf(&quot;ERROR : hid_interrupt_read failed !!!!\n&quot;);<br>
    else<br>    {<br>        int i=0;<br>        printf(&quot;SUCCESS : hid_interrupt_read \n***********************\n&quot;);<br>        for (i=0 ; i &lt; RECIVE_PACKET_LENGHT ; i++)<br>           printf(&quot;%hx  &quot;,recived_packet[i]);<br>
       printf(&quot;\n&quot;);<br>    }<br>   <br><br>   //*******************************************************************<br>   //*******************************************************************<br>   //*******************************************************************<br>
    //---------- end of program -------------<br><br>    //closing hid interface<br>    safe1_return=hid_close(safe1_hid);<br>#if _debug__<br>    if(safe1_return!=HID_RET_SUCCESS)<br>        printf(&quot;ERROR : hid_close failed!!!\n&quot;);<br>
    else<br>        printf(&quot;SUCCESS : hid_close \n&quot;);<br>#endif<br>    //delete interface<br>    hid_delete_HIDInterface(&amp;safe1_hid);<br><br>    //cleaning up - release allocated memory<br>    safe1_return=hid_cleanup();<br>
#if _debug__<br>    if (safe1_return!=HID_RET_SUCCESS)<br>        printf(&quot;ERROR : hid_cleanup() failed !!!\n&quot;);<br>    else<br>        printf(&quot;SUCCESS : hid_cleanup \n&quot;);<br>#endif<br>    return (EXIT_SUCCESS);<br>
}<br><br><br>/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\<br><br>maybe i&#39;ve founded the right path but my writing and reading part has problem !!???!!!<br><br>anything is possible<br><br>thanks for your help<br>
god bless you.<br><br>//sajjadG<br>