[En-Nut-Discussion] How to write character filter with timeout?

Ulrich Prinz uprinz2 at netscape.net
Fri Aug 21 21:11:11 CEST 2009


Hi!

Cool idea! Just lower the timeout by the ammount of time left at each 
incoming char. Really cool idea! I'll check that in a few minutes.

First I have to integrate my scripts for OpenOCD into NutOS. Then we'll 
see :)

Ole Reinhardt wrote:
> Hi Ulrich,
> 
>> _ioctl(_fileno(dev), UART_SETREADTIMEOUT, &t);
> 
> what's about the following code (more or less pseudo code)
> 
> u_long timeout = 500; // 500ms
> u_long start_time;
> u_long time_diff;
> char   ch;
> 
> read_time = NutGetMillis();
> 
> while ((time_diff = NutGetMillis() - start_time) < timeout) {
>     register u_long to = timeout - time_diff;
>     _ioctl(_fileno(dev), UART_SETREADTIMEOUT, &to);
>     ch = fgetc(dev);
>     if (ch == the_char_to_search) break;
> }
> 
> Bye,
> 
> Ole Reinhardt
> 



More information about the En-Nut-Discussion mailing list