[ECOS] RedBoot - Bug in _rb_gets()?
Chris Zankel
zankel@tensilica.com
Mon Oct 15 10:17:00 GMT 2001
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.
>
More information about the Ecos-discuss
mailing list