[En-Nut-Discussion] Quickly flushing input stream

Michel Hendriks unreal at home.nl
Thu Apr 8 09:57:02 CEST 2004


a _read(uart, 0, 0) or fread(0, 0, 0, uart) will flush the input buffer

Krzysztof Jankowski said:
> Hi,
> how can I quickly clear (flush) an input stream e.x. UART's buffer ? For output
> streams there is fflush() function, so what about input ones ?
>
> I'm looking for something like code below, but this seems to suspend a thread when
>  the stream had been already emptied. Another disadvantage of that solution is a
> not necessary loop.
>
> FILE *uart;
> int c;
>
>     do {
>        c = fgetc(uart);
>     } while(c != EOF);
>
>
> Other possible solution could be to move stream's position to the beginning using
> fseek(), but as I read documentation this function isn't implemented yet. Is there
> any ioctl() I could use on uart's buffer to do that job ?
>
> ps. I'm using the previous release of NutOS (3.3.1 I hope).
>
> Thanks,
> Krzysztof
> _______________________________________________
> En-Nut-Discussion mailing list
> En-Nut-Discussion at egnite.de
> http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion






More information about the En-Nut-Discussion mailing list