1 /* Generic serial interface routines
2 Copyright 1992, 1993 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
23 /* Open up a device or a network socket, depending upon the syntax of NAME. */
25 static struct serial_ops *serial_ops_list = NULL;
27 static struct serial_ops *
28 serial_interface_lookup (name)
31 struct serial_ops *ops;
33 for (ops = serial_ops_list; ops; ops = ops->next)
34 if (strcmp (name, ops->name) == 0)
41 serial_add_interface(optable)
42 struct serial_ops *optable;
44 optable->next = serial_ops_list;
45 serial_ops_list = optable;
53 struct serial_ops *ops;
55 ops = serial_interface_lookup ("hardwire");
60 scb = (serial_t)xmalloc (sizeof (struct _serial_t));
67 if (SERIAL_OPEN (scb, name))
77 /* Connect the user directly to the remote system. This command acts just like
78 the 'cu' or 'tip' command. Use <CR>~. or <CR>~^D to break out. */
82 struct ttystate ttystate;
84 printf("\r\n[Exiting connect mode]\r\n");
85 serial_restore(0, &ttystate);
89 connect_command (args, fromtty)
97 static struct ttystate ttystate;
102 error("target not open.");
105 fprintf("This command takes no args. They have been ignored.\n");
107 printf("[Entering connect mode. Use ~. or ~^D to escape]\n");
109 serial_raw(0, &ttystate);
111 make_cleanup(cleanup_tty, &ttystate);
120 FD_SET(desc, &readfds);
121 numfds = select(sizeof(readfds)*8, &readfds, 0, 0, 0);
126 perror_with_name("select");
128 if (FD_ISSET(0, &readfds))
129 { /* tty input, send to stdebug */
132 c = serial_readchar(-1);
134 perror_with_name("connect");
137 serial_write(&cx, 1);
151 if (c == '.' || c == '\004')
158 if (FD_ISSET(desc, &readfds))
162 c = serial_readchar(-1);
175 _initialize_serial ()
177 add_com ("connect", class_obscure, connect_command,
178 "Connect the terminal directly up to the command monitor.\n\
179 Use <CR>~. or <CR>~^D to break out.");