[En-Nut-Discussion] How to write character filter with timeout?
Harald Kipp
harald.kipp at egnite.de
Thu Aug 20 09:31:04 CEST 2009
Hi Ulrich,
Ulrich Prinz wrote:
> _ioctl(_fileno(dev), UART_SETREADTIMEOUT, &t);
...
> Is there a non-blocking function for fgetc() or do I have to do stream
> parsing or is there any easier way?
When you set a read timeout on a specific device, then the related
fgetc() on that device will be non-blocking. When -1 is returned, you
can use feof() or ferror() to distinguish between timeout (end of file)
or error.
http://beej.us/guide/bgc/output/html/multipage/feof.html
Harald
More information about the En-Nut-Discussion
mailing list