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.
> 
> I've also tried setting the timeout parameter in usb_bulk_msg to 0 (wait
> forever). But then you can't exit (^c) or even kill the program reading
> from the port.

There are two possible approaches.  The easy way is just to use a very,
very long timeout.  Alternatively, when a timeout does occur don't
return to the user; instead loop back and submit another usb_bulk_msg.

Alan Stern


-------------------------------------------------------------------------
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@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-users

Reply via email to