mirror of
https://github.com/UzixLS/picocom.git
synced 2025-07-19 07:21:18 +03:00
Added drain to term ops
This commit is contained in:
24
term.c
24
term.c
@ -141,6 +141,20 @@ local_flush(struct term_s *t, int selector)
|
||||
return tcflush(t->fd, selector);
|
||||
}
|
||||
|
||||
static int
|
||||
local_drain(struct term_s *t)
|
||||
{
|
||||
int r;
|
||||
|
||||
#ifdef __BIONIC__
|
||||
/* See: http://dan.drown.org/android/src/gdb/no-tcdrain */
|
||||
r = ioctl(t->fd, TCSBRK, 1);
|
||||
#else
|
||||
r = tcdrain(t->fd);
|
||||
#endif
|
||||
return r;
|
||||
}
|
||||
|
||||
int
|
||||
local_read(struct term_s *t, void *buf, unsigned bufsz)
|
||||
{
|
||||
@ -162,6 +176,7 @@ static const struct term_ops local_term_ops = {
|
||||
.modem_bic = local_modem_bic,
|
||||
.send_break = local_send_break,
|
||||
.flush = local_flush,
|
||||
.drain = local_drain,
|
||||
.read = local_read,
|
||||
.write = local_write,
|
||||
};
|
||||
@ -1699,12 +1714,7 @@ term_drain(int fd)
|
||||
}
|
||||
|
||||
do {
|
||||
#ifdef __BIONIC__
|
||||
/* See: http://dan.drown.org/android/src/gdb/no-tcdrain */
|
||||
r = ioctl(t->fd, TCSBRK, 1);
|
||||
#else
|
||||
r = tcdrain(t->fd);
|
||||
#endif
|
||||
r = t->ops->drain(t);
|
||||
} while ( r < 0 && errno == EINTR);
|
||||
if ( r < 0 ) {
|
||||
term_errno = TERM_EDRAIN;
|
||||
@ -1762,7 +1772,7 @@ term_fake_flush(int fd)
|
||||
}
|
||||
/* Wait for output to drain. Without flow-control this should
|
||||
complete in finite time. */
|
||||
r = tcdrain(t->fd);
|
||||
r = t->ops->drain(t);
|
||||
if ( r < 0 ) {
|
||||
term_errno = TERM_EDRAIN;
|
||||
rval = -1;
|
||||
|
@ -49,6 +49,7 @@ struct term_ops {
|
||||
int (*modem_bic)(struct term_s *t, const int *modem);
|
||||
int (*send_break)(struct term_s *t);
|
||||
int (*flush)(struct term_s *t, int selector);
|
||||
int (*drain)(struct term_s *t);
|
||||
int (*read)(struct term_s *t, void *buf, unsigned bufsz);
|
||||
int (*write)(struct term_s *t, const void *buf, unsigned bufsz);
|
||||
};
|
||||
|
7
tn2217.c
7
tn2217.c
@ -969,6 +969,12 @@ tn2217_flush(struct term_s *t, int selector)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
tn2217_drain(struct term_s *t)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Reads raw binary from the socket and immediately handles any
|
||||
* in-stream TELNET commands. */
|
||||
static int
|
||||
@ -1079,6 +1085,7 @@ const struct term_ops tn2217_ops = {
|
||||
.modem_bic = tn2217_modem_bic,
|
||||
.send_break = tn2217_send_break,
|
||||
.flush = tn2217_flush,
|
||||
.drain = tn2217_drain,
|
||||
.read = tn2217_read,
|
||||
.write = tn2217_write,
|
||||
};
|
||||
|
Reference in New Issue
Block a user