[En-Nut-Discussion] Problem: read uart port

Matthias Ringwald mringwal at inf.ethz.ch
Thu Mar 19 20:35:55 CET 2009


Hi Samkol

read returns the current data from the buffer. This can be less than  
your request. The same happens on any other POSIX system (linux, bsd,  
os x, ...)

The only way around this is a loop that sums up the amount of bytes  
read until you have your block.
I once hacked the drivers to return exactly the amount of requested  
bytes, but a quick check tells
me that I've never got around to add this (non-standard behavior) to  
nut/os.

cheers
  Matthias

On Mar 19, 2009, at 7:57 PM, samkol chea wrote:

>
> Hi all,
>
> I have a problem when I try to read from the UART port. I follow the  
> uart.c sample application.
> Below are code snap
>
> int got;
> static char inbuf[58];
> got = _read(_fileno(uart), inbuf, 58);
>
> The
> problem is that I want to read 58 bytes from the UART port, but the
> read function always returns 'got' less than 58. Do you know why?



More information about the En-Nut-Discussion mailing list