* ser-unix.c (wait_for, hardwire_readchar) [HAVE_TERMIO, HAVE_TERMIOS]:
If the timeout is too big to fit in c_cc[VTIME], then do multiple reads to achieve the desired timeout. * serial.h (serial_t): Add field timeout_remaining.
This commit is contained in:
parent
f28c6e3813
commit
9db58d3ab4
3 changed files with 79 additions and 43 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
Sat Jan 29 07:44:59 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
|
||||||
|
|
||||||
|
* ser-unix.c (wait_for, hardwire_readchar) [HAVE_TERMIO, HAVE_TERMIOS]:
|
||||||
|
If the timeout is too big to fit in c_cc[VTIME], then do multiple reads
|
||||||
|
to achieve the desired timeout.
|
||||||
|
* serial.h (serial_t): Add field timeout_remaining.
|
||||||
|
|
||||||
Fri Jan 28 08:45:02 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
|
Fri Jan 28 08:45:02 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
|
||||||
|
|
||||||
* c-exp.y (yylex): Reenable nested type code.
|
* c-exp.y (yylex): Reenable nested type code.
|
||||||
|
@ -29,7 +36,6 @@ Fri Jan 28 11:55:52 1994 Rob Savoye (rob@darkstar.cygnus.com)
|
||||||
addition to the standard serial support.
|
addition to the standard serial support.
|
||||||
|
|
||||||
Fri Jan 28 08:45:02 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
|
Fri Jan 28 08:45:02 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
|
||||||
>>>>>>> 1.2186
|
|
||||||
|
|
||||||
* mdebugread.c (psymtab_to_symtab_1): Don't complain on stLabel with
|
* mdebugread.c (psymtab_to_symtab_1): Don't complain on stLabel with
|
||||||
index indexNil.
|
index indexNil.
|
||||||
|
|
111
gdb/ser-unix.c
111
gdb/ser-unix.c
|
@ -391,43 +391,48 @@ wait_for(scb, timeout)
|
||||||
serial_t scb;
|
serial_t scb;
|
||||||
int timeout;
|
int timeout;
|
||||||
{
|
{
|
||||||
|
scb->timeout_remaining = 0;
|
||||||
|
|
||||||
#ifdef HAVE_SGTTY
|
#ifdef HAVE_SGTTY
|
||||||
struct timeval tv;
|
{
|
||||||
fd_set readfds;
|
struct timeval tv;
|
||||||
|
fd_set readfds;
|
||||||
|
|
||||||
FD_ZERO (&readfds);
|
FD_ZERO (&readfds);
|
||||||
|
|
||||||
tv.tv_sec = timeout;
|
tv.tv_sec = timeout;
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
|
|
||||||
FD_SET(scb->fd, &readfds);
|
FD_SET(scb->fd, &readfds);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
int numfds;
|
int numfds;
|
||||||
|
|
||||||
if (timeout >= 0)
|
if (timeout >= 0)
|
||||||
numfds = select(scb->fd+1, &readfds, 0, 0, &tv);
|
numfds = select(scb->fd+1, &readfds, 0, 0, &tv);
|
||||||
else
|
|
||||||
numfds = select(scb->fd+1, &readfds, 0, 0, 0);
|
|
||||||
|
|
||||||
if (numfds <= 0)
|
|
||||||
if (numfds == 0)
|
|
||||||
return SERIAL_TIMEOUT;
|
|
||||||
else if (errno == EINTR)
|
|
||||||
continue;
|
|
||||||
else
|
else
|
||||||
return SERIAL_ERROR; /* Got an error from select or poll */
|
numfds = select(scb->fd+1, &readfds, 0, 0, 0);
|
||||||
|
|
||||||
return 0;
|
if (numfds <= 0)
|
||||||
}
|
if (numfds == 0)
|
||||||
|
return SERIAL_TIMEOUT;
|
||||||
|
else if (errno == EINTR)
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
return SERIAL_ERROR; /* Got an error from select or poll */
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif /* HAVE_SGTTY */
|
#endif /* HAVE_SGTTY */
|
||||||
|
|
||||||
#if defined HAVE_TERMIO || defined HAVE_TERMIOS
|
#if defined HAVE_TERMIO || defined HAVE_TERMIOS
|
||||||
if (timeout == scb->current_timeout)
|
if (timeout == scb->current_timeout)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
scb->current_timeout = timeout;
|
||||||
|
|
||||||
{
|
{
|
||||||
struct hardwire_ttystate state;
|
struct hardwire_ttystate state;
|
||||||
|
|
||||||
|
@ -447,8 +452,14 @@ wait_for(scb, timeout)
|
||||||
state.termios.c_cc[VTIME] = timeout * 10;
|
state.termios.c_cc[VTIME] = timeout * 10;
|
||||||
if (state.termios.c_cc[VTIME] != timeout * 10)
|
if (state.termios.c_cc[VTIME] != timeout * 10)
|
||||||
{
|
{
|
||||||
warning ("Timeout value %d too large, using %d", timeout,
|
|
||||||
state.termios.c_cc[VTIME] / 10);
|
/* If c_cc is an 8-bit signed character, we can't go
|
||||||
|
bigger than this. If it is always unsigned, we could use
|
||||||
|
25. */
|
||||||
|
|
||||||
|
scb->current_timeout = 12;
|
||||||
|
state.termios.c_cc[VTIME] = scb->current_timeout * 10;
|
||||||
|
scb->timeout_remaining = timeout - scb->current_timeout;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -466,14 +477,17 @@ wait_for(scb, timeout)
|
||||||
state.termio.c_cc[VTIME] = timeout * 10;
|
state.termio.c_cc[VTIME] = timeout * 10;
|
||||||
if (state.termio.c_cc[VTIME] != timeout * 10)
|
if (state.termio.c_cc[VTIME] != timeout * 10)
|
||||||
{
|
{
|
||||||
warning ("Timeout value %d too large, using %d", timeout,
|
/* If c_cc is an 8-bit signed character, we can't go
|
||||||
state.termio.c_cc[VTIME] / 10);
|
bigger than this. If it is always unsigned, we could use
|
||||||
|
25. */
|
||||||
|
|
||||||
|
scb->current_timeout = 12;
|
||||||
|
state.termios.c_cc[VTIME] = scb->current_timeout * 10;
|
||||||
|
scb->timeout_remaining = timeout - scb->current_timeout;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
scb->current_timeout = timeout;
|
|
||||||
|
|
||||||
if (set_tty_state (scb, &state))
|
if (set_tty_state (scb, &state))
|
||||||
fprintf_unfiltered(gdb_stderr, "set_tty_state failed: %s\n", safe_strerror(errno));
|
fprintf_unfiltered(gdb_stderr, "set_tty_state failed: %s\n", safe_strerror(errno));
|
||||||
|
|
||||||
|
@ -497,24 +511,37 @@ hardwire_readchar(scb, timeout)
|
||||||
if (scb->bufcnt-- > 0)
|
if (scb->bufcnt-- > 0)
|
||||||
return *scb->bufp++;
|
return *scb->bufp++;
|
||||||
|
|
||||||
status = wait_for(scb, timeout);
|
while (1)
|
||||||
|
{
|
||||||
|
status = wait_for (scb, timeout);
|
||||||
|
|
||||||
if (status < 0)
|
if (status < 0)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
scb->bufcnt = read(scb->fd, scb->buf, BUFSIZ);
|
scb->bufcnt = read (scb->fd, scb->buf, BUFSIZ);
|
||||||
|
|
||||||
if (scb->bufcnt <= 0)
|
if (scb->bufcnt <= 0)
|
||||||
if (scb->bufcnt == 0)
|
{
|
||||||
return SERIAL_TIMEOUT; /* 0 chars means timeout [may need to
|
if (scb->bufcnt == 0)
|
||||||
distinguish between EOF & timeouts
|
{
|
||||||
someday] */
|
/* Zero characters means timeout (it could also be EOF, but
|
||||||
else
|
we don't (yet at least) distinguish). */
|
||||||
return SERIAL_ERROR; /* Got an error from read */
|
if (scb->timeout_remaining > 0)
|
||||||
|
{
|
||||||
|
timeout = scb->timeout_remaining;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return SERIAL_TIMEOUT;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return SERIAL_ERROR; /* Got an error from read */
|
||||||
|
}
|
||||||
|
|
||||||
scb->bufcnt--;
|
scb->bufcnt--;
|
||||||
scb->bufp = scb->buf;
|
scb->bufp = scb->buf;
|
||||||
return *scb->bufp++;
|
return *scb->bufp++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef B19200
|
#ifndef B19200
|
||||||
|
|
|
@ -33,6 +33,9 @@ struct _serial_t
|
||||||
unsigned char *bufp; /* Current byte */
|
unsigned char *bufp; /* Current byte */
|
||||||
unsigned char buf[BUFSIZ]; /* Da buffer itself */
|
unsigned char buf[BUFSIZ]; /* Da buffer itself */
|
||||||
int current_timeout; /* (termio{s} only), last value of VTIME */
|
int current_timeout; /* (termio{s} only), last value of VTIME */
|
||||||
|
/* ser-unix.c termio{,s} only, we still need to wait for this many more
|
||||||
|
seconds. */
|
||||||
|
int timeout_remaining;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _serial_t *serial_t;
|
typedef struct _serial_t *serial_t;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue