/*
* $Log$
+ * Revision 1.10 2008/02/15 23:52:12 james
+ * *** empty log message ***
+ *
+ * Revision 1.9 2008/02/15 03:32:07 james
+ * *** empty log message ***
+ *
+ * Revision 1.8 2008/02/14 10:36:18 james
+ * *** empty log message ***
+ *
* Revision 1.7 2008/02/14 10:34:30 james
* *** empty log message ***
*
void
tty_pre_select (TTY * t, fd_set * rfds, fd_set * wfds)
{
+ int line;
+ struct timeval now, dif;
+
+ if (t->hanging_up)
+ {
+
+ gettimeofday (&now, NULL);
+ timersub (&now, &t->hangup_clock, &dif);
+ if (dif.tv_sec)
+ {
+ fprintf (stderr, "+DTR\n");
+
+ line = TIOCM_DTR;
+ ioctl (t->rfd, TIOCMBIS, &line);
+ t->hanging_up = 0;
+ }
+ }
+
+
FD_SET (t->rfd, rfds);
}
tty_get_status (TTY * t, TTY_Status * s)
{
- s->lines=0;
+ s->lines = 0;
ioctl (t->rfd, TIOCMGET, &s->lines);
+ if (t->hanging_up)
+ fprintf (stderr, "s->lines & TIOCM_DTR=%x\n", s->lines & TIOCM_DTR);
if (tcgetattr (t->rfd, &s->termios))
return -1;
-
- s->baud=speed_t_to_baud(cfgetispeed(&s->termios));
+
+ s->baud = speed_t_to_baud (cfgetispeed (&s->termios));
+ s->blocked = t->blocked;
return 0;
}
+void
+tty_set_baud (TTY * t, int rate)
+{
+ struct termios tios = { 0 };
+
+ speed_t s = baud_to_speed_t (rate);
+
+ if (s == (speed_t) - 1)
+ return;
+
+ if (tcgetattr (t->rfd, &tios))
+ return;
+
+ cfsetispeed (&tios, s);
+ cfsetospeed (&tios, s);
+
+ tcsetattr (t->rfd, TCSANOW, &tios);
+}
+
+void
+tty_send_break (TTY * t)
+{
+ tcsendbreak (t->wfd, 0);
+}
+
+void
+tty_set_flow (TTY * t, int flow)
+{
+ struct termios tios = { 0 };
+
+ if (tcgetattr (t->rfd, &tios))
+ return;
+
+ if (flow)
+ tios.c_cflag |= CRTSCTS;
+ else
+ tios.c_cflag &= ~CRTSCTS;
+
+ tcsetattr (t->rfd, TCSANOW, &tios);
+
+}
+
+void
+tty_hangup (TTY * t)
+{
+ int line;
+
+ line = TIOCM_DTR;
+ ioctl (t->rfd, TIOCMBIC, &line);
+
+ t->hanging_up = 1;
+ gettimeofday (&t->hangup_clock, NULL);
+ fprintf (stderr, "-DTR\n");
+
+}
+
+
#if 0
int
tty_post_select (Context * c, fd_set * rfds, fd_set * wfds)