This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
RedBoot gets() implimentation question
- To: ecos-discuss at sources dot redhat dot com
- Subject: [ECOS] RedBoot gets() implimentation question
- From: Grant Edwards <grante at visi dot com>
- Date: Thu, 18 Jan 2001 16:17:05 -0600
If you don't mind, I've got a couple questions about the
implimentation of gets() in RedBoot:
========================================================================
gets(char *buf, int buflen, int timeout)
{
[...]
while (true) {
#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
if (script && *script) {
c = *script++;
} else
#endif
if ((timeout > 0) && (ptr == buf)) {
mon_set_read_char_timeout(50);
while (timeout > 0) {
res = mon_read_char_with_timeout(&c);
if (res) {
// Got a character
break;
}
timeout -= 50;
}
if (res == false) {
return _GETS_TIMEOUT; // Input timed out
}
} else {
mon_read_char(&c);
}
*ptr = '\0';
switch (c) {
[...]
========================================================================
The test ((timeout > 0) && (ptr == buf)) means that the timeout
only applies for the first character, and once we've received
that first character we use blocking reads until we see an
end-of-line?
That means that network polling stops and TCP sockets (and
associated timers) go dead between between the time the first
character is received and the newline is received? [I don't
think that's a problem, but it's something to keep in mind.]
I'm also curious about the inner loop:
mon_set_read_char_timeout(50);
while (timeout > 0) {
res = mon_read_char_with_timeout(&c);
if (res) {
// Got a character
break;
}
timeout -= 50;
}
Would the following be equivalent?
mon_set_read_char_timeout(timeout);
res = mon_read_char_with_timeout(&c);
--
Grant Edwards
grante@visi.com