chiark / gitweb /
*** empty log message ***
[sympathy.git] / src / serial.c
index 2e67d3dd75e5f465876a37784baf64070dea991f..1044bb25d14c6415b4a686e2d87e38ad9914c5b0 100644 (file)
@@ -6,10 +6,20 @@
  *
  */
 
-static char rcsid[] = "$Id$";
+static char rcsid[] =
+  "$Id$";
 
 /*
  * $Log$
+ * Revision 1.9  2008/02/24 00:42:53  james
+ * *** empty log message ***
+ *
+ * Revision 1.8  2008/02/23 13:05:58  staffcvs
+ * *** empty log message ***
+ *
+ * Revision 1.7  2008/02/15 23:52:12  james
+ * *** empty log message ***
+ *
  * Revision 1.6  2008/02/15 19:51:30  james
  * *** empty log message ***
  *
@@ -79,6 +89,7 @@ serial_close (TTY * _t)
   if (!t)
     return;
 
+  tcflush (t->fd, TCIOFLUSH);
   close (t->fd);
   free (t);
 }
@@ -116,7 +127,7 @@ serial_read (TTY * _t, void *buf, int len)
 
 
 static int
-ptty_write (TTY * _t, void *buf, int len)
+serial_write (TTY * _t, void *buf, int len)
 {
   int writ, done = 0;
   Serial *t = (Serial *) _t;
@@ -159,12 +170,25 @@ serial_open (char *path, int lock_mode)
   if (!l)
     return NULL;
 
-  default_termios (&termios);
 
-  fd = open (path, O_RDWR);
+  fd = open (path, O_RDWR | O_NOCTTY | O_NONBLOCK);
 
   set_nonblocking (fd);
 
+
+  if (tcgetattr (fd, &termios))
+    {
+      close (fd);
+      return NULL;
+    }
+  default_termios (&termios);
+
+  if (tcsetattr (fd, TCSANOW, &termios))
+    {
+      close (fd);
+      return NULL;
+    }
+
   t = (Serial *) malloc (sizeof (Serial));
 
   t->lock = l;
@@ -173,7 +197,7 @@ serial_open (char *path, int lock_mode)
   t->name[sizeof (t->name) - 1] = 0;
 
   t->recv = serial_read;
-  //t->xmit = serial_write;
+  t->xmit = serial_write;
   t->close = serial_close;
   t->fd = fd;
   t->rfd = t->fd;
@@ -181,6 +205,7 @@ serial_open (char *path, int lock_mode)
   t->size.x = VT102_COLS;
   t->size.y = VT102_ROWS;
   t->blocked = serial_lock_check (t->lock);
+  t->hanging_up = 0;
 
   return (TTY *) t;
 }