This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: RedBoot - Bug in _rb_gets()?
- To: Gary Thomas <gthomas at redhat dot com>
- Subject: Re: [ECOS] RedBoot - Bug in _rb_gets()?
- From: Chris Zankel <zankel at tensilica dot com>
- Date: Mon, 15 Oct 2001 10:16:22 -0700
- CC: eCos Discussion <ecos-discuss at sources dot redhat dot com>
- References: <3BC7A41C.8020802@tensilica.com> <1003031949.15507.3.camel@station91>
Gary,
Sounds reasonable. But wouldn't that imply that the inner
loop is set to at maximum to 50 ms? Right now
mon_set_read_char_timeout() sets the timeout to whatever
you passed to it.
So, what happens right now is, if you do a mon_read_char_with_timeout()
with, for example, 1s timeout, that the inner-loop
mon_read_char_with_timout() waits 1s and the outer loop
loops 1000/50 = 20 times. The whole function waits 20s instead
of the specified one second.
Wouldn't it make more sense to rewrite that part to:
mon_set_read_char_timeout(timeout > 50? 50:timeout);
while (timeout > 0) {
...
}
Thanks,
Chris
Gary Thomas wrote:
>>Although the timeout value for the mon_read_char_with_timeout()
>>function has already been set to a <timeout> value the while
>>loop also loops over this <timeout> variable:
>>
>>...
>> mon_set_read_char_timeout(timeout);
>>
>> while (timeout > 0) {
>> res = mon_read_char_with_timeout(&c);
>> if (res) { ... }
>> timeout -= 50;
>> }
>>...
>>
>
> There are two separate "timeout"s at work here. The innermost one is
> what is used by the read_char function to decide if a character has
> arrived within some period of time. The outermost is used by RedBoot
> to allow it to do some things while waiting for characters to arrive
> and will be much larger (orders of magnitude) than the innermost
> timeout. The idea is for RedBoot to see if a character has arrived
> or wait at most the "innermost" time. If no character has arrived, then
> RedBoot can take on some "background" processing, e.g. checking for
> any arriving network connections, blanking LCD screens, etc.
>