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

Thiago A. Corrêa thiago.correa at gmail.com
Thu Aug 20 23:52:35 CEST 2009


Hi,

On Thu, Aug 20, 2009 at 5:48 PM, Ulrich Prinz<uprinz2 at netscape.net> wrote:
> Hi Harald!
>
> But that doesn't solve my problem. If I wait a certain time on fgetc() I
> miss characters that arrived after the one that is returned.
> If I use it in a loop, the timeout of fgetc() must be added to the
> NutSleep() ammount. But also then I miss characters, possibly containing
> the one I search for.

Looks like a bug then. I belive what Harald proposed should have worked.


> ...
> It seems to work. I set the timeout to 1ms and count down my timeout on
> any EOF condition. Going that way means, that any received character
> will not decrement the timeout as I cannot find out after what part of
> the timeout the character occured. So any character extends the timout.

Shouldn't you miss characters that arrive in that 1ms slot? I guess
I'm not understanding it properly.

> Its ok for now, but is there any other way without breaking into the
> driver structure? A routine like fsize( ) could help, to distinguish the
> filesize / rx-buffer size of a stream device.
>

I think there is a ioctl to get the buffer size. Some stream devices
like USARTs and Network doesn't have a filesize, at most you can check
for the bytes received so far.

Kind Regards,
   Thiago A. Correa



More information about the En-Nut-Discussion mailing list