[En-Nut-Discussion] Problem: read uart port
Alexander Baranov
baranov at intech21.com
Thu Mar 19 20:54:41 CET 2009
>
> 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?
> Is there a way to tell the microcontroller to read exactly 58 bytes before
> returning.
> In other words, if got < 58, keep on reading until got = 58.
>
> I have tried with both version: 3.9.7 and 4.6.3. I have ethernut board
> version 1.3f
>
> Regards,
> Samkol
I use something like this:
while( (rx_bytes=_read(_fileno(uart1), uart_buff+len,
UART_BUF_LEN-len))>0)
{
len += rx_bytes;
if(len >= replength) break;
NutDelay( 20 );
}
Regards
Alexander
More information about the En-Nut-Discussion
mailing list