hi all,
i have 2 questions:

1) i make simple while loop,at the host side, in which i m receiving the data 
using the read function of usb-skeleton module,it is as follows:
***************************************************************************
do
        {
                insize =read (fd,(char*)inbuff, sizeof (inbuff) );
                printf("insize is %d\n",insize);
                printf(" %s\n",inbuff);
        }while (strcmp(inbuff,"end"));
****************************************************************************
my aim is : when the gadget has something to send to the host this while loop 
will print what the hosts receives from the gadget.

but this does not happen when i use the skel_read function,it is in 
usb-skeleton.c,as when the gadget does not have anything to send to the host,i 
found that the read function is non-blocking and it prints the following 
forever:
insize is -1
black line //i think this is because inbuff is empty

anyway i found that there is a function in skel_read function, named by 
usb_bulk_msg and the last argument of it, is the timeout and if i set this 
timeout to zero it will stop printing insize is -1 and thus it becomes a 
blocking function.

so now if the gadget is not sending anything to the host, the while loop stops 
printing 
insize is -1
bu when the gadget really sends a word like "hello host" for example, the host 
really receives it but still printing the phrase of insize is 64 i.e the output 
is as follows:

insize is 64
hello host
insize is 64
insize is 64 and it prints this phrase forever
so why it just receives 64B while i was really sending 2KB buffer?

actually what i want exactly is when the gadget sends "hello host" the while 
looop output is :

insize is 2048 // 2KB=2048
hello host

and doesnt print anything else?

2) can i make the following steps in reading instead of usb_bulk_msg:
1.urb = usb_alloc_urb(0, GFP_KERNEL);
2.buf = usb_buffer_alloc(dev->udev, writesize, GFP_KERNEL, &urb->transfer_dma);
3.copy_to_user(buf, user_buffer, readsize
4.usb_fill_bulk_urb( urb, dev->udev,
                      usb_rcvctrlpipe(dev->udev, dev->bulk_in_endpointAddr),
                     buf, readsize, skel_read_bulk_callback, dev);
5.urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
6.usb_submit_urb

the location of copy_to_user is correct?or it should be put after 
usb_submit_urb?

this is the same algorithm for skel_write.so can i make the same algorithm with 
 
skel_read?or not?





-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
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