4 * Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
9 static char rcsid[] = "$Id$";
13 * Revision 1.11 2008/02/26 23:23:17 james
14 * *** empty log message ***
16 * Revision 1.10 2008/02/24 00:47:14 james
17 * *** empty log message ***
19 * Revision 1.9 2008/02/24 00:42:53 james
20 * *** empty log message ***
22 * Revision 1.8 2008/02/23 13:05:58 staffcvs
23 * *** empty log message ***
25 * Revision 1.7 2008/02/15 23:52:12 james
26 * *** empty log message ***
28 * Revision 1.6 2008/02/15 19:51:30 james
29 * *** empty log message ***
31 * Revision 1.5 2008/02/15 19:09:00 james
32 * *** empty log message ***
34 * Revision 1.4 2008/02/15 16:48:56 james
35 * *** empty log message ***
37 * Revision 1.3 2008/02/15 03:32:07 james
38 * *** empty log message ***
40 * Revision 1.2 2008/02/14 16:21:17 james
41 * *** empty log message ***
43 * Revision 1.1 2008/02/14 12:51:14 james
44 * *** empty log message ***
46 * Revision 1.4 2008/02/14 10:39:14 james
47 * *** empty log message ***
49 * Revision 1.3 2008/02/13 09:12:21 james
50 * *** empty log message ***
52 * Revision 1.2 2008/02/12 22:36:46 james
53 * *** empty log message ***
55 * Revision 1.1 2008/02/09 15:47:28 james
56 * *** empty log message ***
58 * Revision 1.2 2008/02/07 11:11:14 staffcvs
59 * *** empty log message ***
61 * Revision 1.1 2008/02/07 01:02:52 james
62 * *** empty log message ***
64 * Revision 1.3 2008/02/06 17:53:28 james
65 * *** empty log message ***
67 * Revision 1.2 2008/02/04 02:05:06 james
68 * *** empty log message ***
70 * Revision 1.1 2008/02/04 01:32:39 james
71 * *** empty log message ***
90 serial_close (TTY * _t)
92 Serial *t = (Serial *) _t;
97 tcflush (t->fd, TCIOFLUSH);
104 serial_read (TTY * _t, void *buf, int len)
106 Serial *t = (Serial *) _t;
109 t->blocked = serial_lock_check (t->lock);
117 red = wrap_read (t->fd, buf, len);
135 serial_write (TTY * _t, void *buf, int len)
138 Serial *t = (Serial *) _t;
140 t->blocked = serial_lock_check (t->lock);
147 writ = wrap_write (t->fd, buf, len);
164 serial_open (char *path, int lock_mode)
169 struct winsize winsize = { 0 };
170 struct termios termios;
174 l = serial_lock_new (path, lock_mode);
179 fd = open (path, O_RDWR | O_NOCTTY | O_NONBLOCK);
181 set_nonblocking (fd);
184 if (tcgetattr (fd, &termios))
189 default_termios (&termios);
191 if (tcsetattr (fd, TCSANOW, &termios))
197 t = (Serial *) malloc (sizeof (Serial));
201 strncpy (t->name, path, sizeof (t->name));
202 t->name[sizeof (t->name) - 1] = 0;
204 t->recv = serial_read;
205 t->xmit = serial_write;
206 t->close = serial_close;
210 t->size.x = VT102_COLS_80;
211 t->size.y = VT102_ROWS;
212 t->blocked = serial_lock_check (t->lock);