Hi,

linux-usb-devel is the better place for these types of questions, but
I'll give it a go...

On Thu, Dec 20, 2001 at 10:18:08PM -0800, Angderson, Charyll wrote:
> i expect that the bulk data read on the wire would be the same data in
> "buf".  i see different data on the wire than that returned by "buf" 50% of
> the time.  
> 
> isoc reads seem to be consistent.  and both isoc/bulk writes are correct.  i
> only have one "buf".  i've tried making "buf" a static pointer:  static WORD
> * buf;

What's a "WORD" size?  Any reason you aren't using "unsigned char"?

> and when ever user wants to do transfers i have to read the "size"
> they pass in and do a "kmalloc" for "buf".  after each transaction "buf" is
> freed.  but definitely not until transaction is done.  
> 
> i even have a print statement right after transaction completes (see below)
> and it proves that "buf" is bad.
> 
> anyone have any ideas?  snippet of my code is below.
> 
> thanks,
> -charyll angderson
> 
> int usbx_submit_trans(struct usbxDevice *usbxPtr, struct usb_device *dev, 
>                       struct _Transaction *trans, WORD *buf)
> {
>       int i,j,k;
>       usbx_show_trans(trans);
> 
>       switch(trans->type) {
>       case USBX_R_BULK:
>               FILL_BULK_URB(usbxPtr->usbx_urb, dev, usb_rcvbulkpipe(dev,
> trans->endpoint),
>                       buf, trans->size, usbx_urb_complete, usbxPtr);
>               break;
>       default:
>               dbg("invaid trans type!");
>               break;
>       }
>       
>       usbx_submit_urb(usbxPtr->usbx_urb);
>       interruptible_sleep_on_timeout(&(usbxPtr->wait), trans->timeout);

Does your callback wake up your "wait"?

>       if (usbxPtr->usbx_urb->status!=0) {
>               err("TIMEOUT awoken %i (%s)
> status=0x%x",current->pid,current->comm,usbxPtr->usbx_urb->status); //ca
> debug
>               usbx_unlink_urb(usbxPtr->usbx_urb);  // remove urb safely

I recommend unlinking in your callback, much easier.

>       }
> 
>       switch (trans->type) {
>       case USBX_R_BULK:
>               dbg("usbx_submit_trans:  print buffer read ..
> address=0x%lx", (DWORD)&buf);
>               for (i=0; i<(trans->size/2); i++) {
>                       dbg(" %x ",(WORD)buf[i]);

You should use the urb->actual_length field here.  That tells you how
many bytes you received (which can be different from what you
requested).  Also, what's with the "size/2" stuff?  We are transferring
bytes here :)

If you want to do a bulk read that blocks until completed (or timed
out) there already is a usb core function that does it called
usb_bulk_msg() keeping you from having to roll your own.

Hope this helps,

greg k-h

_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-users

Reply via email to