Google
  Web www.spinics.net

Re: handling timeouts on usb_bulk_msg

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


On Mon, Nov 05, 2007 at 04:10:35PM -0500, Alan Stern wrote:
> On Mon, 5 Nov 2007, Andrew Greensted wrote:
> 
> > Hi All,
> > 
> > I've written a custom device driver based on the usb-skeleton.c file in
> > the kernel source.
> > 
> > I want the driver to act in a similar way to when you read from a serial
> > port. ie, when you do this:
> > 
> > cat /dev/ttyS0
> > 
> > it will wait for data to appear on the port and output to the terminal.
> > It doesn't timeout, or close the connection when no data is available.
> > In my case the data source is an IN endpoint from a custom usb board.
> > 
> > The problem is how do I stop cat (or any other program) closing the
> > connection when the read function timesout (the condition when no data
> > is yet available).
> > 
> > I've tried checking to see if the return value from usb_bulk_msg is
> > ETIMEDOUT and returning 0 (no bytes read) from my read function rather
> > than the error, but cat still exits.

If you return "0" on the timeout, standard unix interfaces define this
as end-of-file. So cat is correct in interpreting this as EOF and
exiting.

In your driver, you should NOT return if you get the ETIMEDOUT return, 
and simply call usb_bulk_msg again. This is entirely acceptable. 

You will find that doing something about signals is worth the trouble.

	Roger. 

-- 
** R.E.Wolff@xxxxxxxxxxxx ** http://www.BitWizard.nl/ ** +31-15-2600998 **
**    Delftechpark 26 2628 XH  Delft, The Netherlands. KVK: 27239233    **
*-- BitWizard writes Linux device drivers for any device you may have! --*
Q: It doesn't work. A: Look buddy, doesn't work is an ambiguous statement. 
Does it sit on the couch all day? Is it unemployed? Please be specific! 
Define 'it' and what it isn't doing. --------- Adapted from lxrbot FAQ

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Linux-usb-users@xxxxxxxxxxxxxxxxxxxxx
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-users

[Linux USB]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Video Projectors]     [PDAs]     [Free Online Dating]     [Hacking TiVo]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Devices]     [Big List of Linux Books]     [16.7MP]