4 * Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
14 * Revision 1.9 2008/02/24 00:42:53 james
15 * *** empty log message ***
17 * Revision 1.8 2008/02/23 13:05:58 staffcvs
18 * *** empty log message ***
20 * Revision 1.7 2008/02/15 23:52:12 james
21 * *** empty log message ***
23 * Revision 1.6 2008/02/15 19:51:30 james
24 * *** empty log message ***
26 * Revision 1.5 2008/02/15 19:09:00 james
27 * *** empty log message ***
29 * Revision 1.4 2008/02/15 16:48:56 james
30 * *** empty log message ***
32 * Revision 1.3 2008/02/15 03:32:07 james
33 * *** empty log message ***
35 * Revision 1.2 2008/02/14 16:21:17 james
36 * *** empty log message ***
38 * Revision 1.1 2008/02/14 12:51:14 james
39 * *** empty log message ***
41 * Revision 1.4 2008/02/14 10:39:14 james
42 * *** empty log message ***
44 * Revision 1.3 2008/02/13 09:12:21 james
45 * *** empty log message ***
47 * Revision 1.2 2008/02/12 22:36:46 james
48 * *** empty log message ***
50 * Revision 1.1 2008/02/09 15:47:28 james
51 * *** empty log message ***
53 * Revision 1.2 2008/02/07 11:11:14 staffcvs
54 * *** empty log message ***
56 * Revision 1.1 2008/02/07 01:02:52 james
57 * *** empty log message ***
59 * Revision 1.3 2008/02/06 17:53:28 james
60 * *** empty log message ***
62 * Revision 1.2 2008/02/04 02:05:06 james
63 * *** empty log message ***
65 * Revision 1.1 2008/02/04 01:32:39 james
66 * *** empty log message ***
85 serial_close (TTY * _t)
87 Serial *t = (Serial *) _t;
92 tcflush (t->fd, TCIOFLUSH);
99 serial_read (TTY * _t, void *buf, int len)
101 Serial *t = (Serial *) _t;
104 t->blocked = serial_lock_check (t->lock);
112 red = wrap_read (t->fd, buf, len);
130 serial_write (TTY * _t, void *buf, int len)
133 Serial *t = (Serial *) _t;
135 t->blocked = serial_lock_check (t->lock);
142 writ = wrap_write (t->fd, buf, len);
159 serial_open (char *path, int lock_mode)
164 struct winsize winsize = { 0 };
165 struct termios termios;
169 l = serial_lock_new (path, lock_mode);
174 fd = open (path, O_RDWR | O_NOCTTY | O_NONBLOCK);
176 set_nonblocking (fd);
179 if (tcgetattr (fd, &termios))
184 default_termios (&termios);
186 if (tcsetattr (fd, TCSANOW, &termios))
192 t = (Serial *) malloc (sizeof (Serial));
196 strncpy (t->name, path, sizeof (t->name));
197 t->name[sizeof (t->name) - 1] = 0;
199 t->recv = serial_read;
200 t->xmit = serial_write;
201 t->close = serial_close;
205 t->size.x = VT102_COLS;
206 t->size.y = VT102_ROWS;
207 t->blocked = serial_lock_check (t->lock);