On Wed, 27 Sep 2006, Lisa Ray wrote:

> Hi Alan
> 
> 
> >In case you didn't already realize this, endpoint 0x81 is _input_ and
> >endpoint 0x02 is _output_.  Look again at your lsusb output.  If you mixed
> >them up, it could explain a lot.
> 
> Yes you right and I reported vice-versa but I am using correctly 0x02 for 
> writing to device and 0x081 for reading.

Really?

> Here is lsusb -vvv output

...

> Below is code change in linux kernel ver 2.6.17.11 : -
> File : hid-core.c
> 
> ------CODE START-----------
> <start>
> static int hid_probe(struct usb_interface *intf, const struct usb_device_id 
> *id)
> {
>       struct hid_device *hid;
>       char path[64];
>       int i;
>       char *c;
> 
>       dbg("HID probe called for ifnum %d",
>                       intf->altsetting->desc.bInterfaceNumber);
> 
>       if (!(hid = usb_hid_configure(intf)))
>               return -ENODEV;
> 
>            ....
>            ....   // code deleted for understanding in email
> 
>       usb_make_path(interface_to_usbdev(intf), path, 63);
> 
>       printk(": USB HID v%x.%02x %s [%s] on %s\n",
>               hid->version >> 8, hid->version & 0xff, c, hid->name, path);
> 
>        lisa_talk(hid, mydev) ; // mydev is static global pointer which is 
> assigned in hid_configure()
>       return 0;
> }
> 
> static void lisa_talk(struct hid_device *hid,  struct usb_device *dev)
> {
>     struct urb *urbin, *urbout ;
>     int pipe, rc ;
>     char inbuff[10] = {0x01,0x04,'C','v',0x05,0x00}; 

Why is inbuf initialized?  It will just get overwritten by the data
received from the device.

>     char outbuff[20] ;    

Why isn't outbuf initialized?  When you transmit it to the device, you'll 
be sending garbage.

> 
>     //lets write
>     urbin = usb_alloc_urb(0, GFP_KERNEL) ;
>     pipe = usb_rcvintpipe(dev, 0x81);
>     usb_fill_int_urb(urbin, dev, pipe, inbuff, 6,hid_irq_in, hid, 50);

You should not use transfer buffers allocated on the stack.  On x86 it's 
okay, but some architectures can't do DMA to stack addresses.  You should 
use kmalloc() for your buffers.

Bear in mind as well that these stack-based buffers will disappear when 
this function returns, but the USB transfers will still be going on.  
That's not a good situation to be in...

>     urbin->transfer_dma = hid->inbuf_dma;
>     urbin->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
>     spin_lock_init(&urbin->lock);
>     if (usb_submit_urb(urbin,GFP_ATOMIC))  
>         printk(KERN_ERR ":: write failed.. usb_submit_urb failed");

You should print out the error code returned by usb_submit_urb().  
Otherwise you won't have any way to know what went wrong.

Also, this is urbin going to endpoint 0x81, correct?  So it's a read, not
a write.

>     else
>         printk(KERN_ERR ":: write SUCESS usb_submit_urb");
>     
>    urbout = usb_alloc_urb(0, GFP_KERNEL) ;
>    pipe = usb_sndintpipe(dev, 0x02);
>    usb_fill_int_urb(urbout, dev, pipe, outbuff, 0, hid_irq_out, hid, 50);
>    urbout->transfer_dma = hid->outbuf_dma;
>    urbout->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
>    spin_lock_init(&urbout->lock);
> 
>    if (usb_submit_urb(urbout,GFP_ATOMIC))  
>         printk(KERN_ERR ":: READ failed.. usb_submit_urb failed");

Again, print the error code and realize that this is a write, not a read.

>     else
>         printk(KERN_ERR ":: READ SUCESS usb_submit_urb 0x%04x  0x%04x 
> 0x%04x", outbuff[0],outbuff[1],outbuff[2]);

Are you trying to print out the data bytes received from the device?  They 
won't be available until the URB completes.

> 
>     return ;
> 
> }
> </end>
> ------CODE END-----------
> 
> In output it gives write and read faiulures with bogus endpoint error 
> messages !

What exactly are the messages?  Cut & paste from your system log to your 
email reply.

Alan Stern


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to