Re: Blocking read() from a USB->Serial adapter.
- From: Grant Edwards <grante@xxxxxxxx>
- Date: Sat, 25 Nov 2006 23:36:30 -0000
On 2006-11-25, Floyd L. Davidson <floyd@xxxxxxxxxx> wrote:
Or until the driver decides to return for whatever reason it
chooses. On success, you're guaranteed a minimum of one byte.
Maybe. (Maybe not too!)
There's the case where the file is at EOF. Is there another
case where read() will return success with 0 bytes?
Any time there is no data available. With a file that will
indeed set the EOF flag, but with a serial port (or a pipe, or a
console) there is no such concept.
Sure there is. The tty line discipline will generate an "EOF"
condition and return 0 bytes when it sees the EOF character
(typically ctrl-d) as the first byte after read() is called.
If the timer is enabled, and times out, read() will return 0.
You're right. I thought it returned with an ETIMEDOUT error,
but I was probably thinking of a different OS.
Another possibility is if the number of bytes request was 0,
read() will return 0.
Yup -- I forgot about that.
--
Grant Edwards
grante@xxxxxxxx
.
- Follow-Ups:
- Re: Blocking read() from a USB->Serial adapter.
- From: Floyd L. Davidson
- Re: Blocking read() from a USB->Serial adapter.
- References:
- Blocking read() from a USB->Serial adapter.
- From: Charles Sullivan
- Re: Blocking read() from a USB->Serial adapter.
- From: Floyd L. Davidson
- Re: Blocking read() from a USB->Serial adapter.
- From: Charles Sullivan
- Re: Blocking read() from a USB->Serial adapter.
- From: Grant Edwards
- Re: Blocking read() from a USB->Serial adapter.
- From: Floyd L. Davidson
- Re: Blocking read() from a USB->Serial adapter.
- From: Grant Edwards
- Re: Blocking read() from a USB->Serial adapter.
- From: Floyd L. Davidson
- Blocking read() from a USB->Serial adapter.
- Prev by Date: Re: How to locate implementation of a specific function in glibc source code?
- Next by Date: Re: Blocking read() from a USB->Serial adapter.
- Previous by thread: Re: Blocking read() from a USB->Serial adapter.
- Next by thread: Re: Blocking read() from a USB->Serial adapter.
- Index(es):
Relevant Pages
|