[En-Nut-Discussion] UART Buffer Flush Problem

Pat Shueh ptlinux at optushome.com.au
Sun Jan 5 13:17:34 CET 2003


I have got a similar problem as described in JasonG's earlier post.

Basically, I couldnt seem to flush the output buffer of my UART device if
the buffer is not full. My process will just hang unless i type something to
UART to trigger output. My ethernut application basically send and receieve
data from a device connected to the UART. I couldnt seem to get the last bit
of data if the buffer is not full. the part of my code is included below,
can someone give me a hand here?!

I have used UartAvrFlush(uart).. but not sure if i have used it correctly.

u_char inbuf[256];

int i;
while(connected)
{
		i=NutDeviceGetLine(uart, inbuf, sizeof(inbuf));

		NutPrintFormat(sostream, "buffer size=%d\r\n", i);

		//NutPrintFormat(sostream, "%s\r\n", inbuf);
		NutPrintFlush(sostream);

		if (i != sizeof(inbuf))
		{
			UartAvrFlush(uart);
		}
		NutThreadYield();
}

my output looks like this.

buffer size = 256
buffer size = 256
buffer size = 256
buffer size = 256
buffer size = 256
buffer size = 256
<--------------------hang there...
after i send a \r to uart..
buffer size = 236 got printed..


Thanks






More information about the En-Nut-Discussion mailing list