diff options
Diffstat (limited to 'sbin/comcontrol')
| -rw-r--r-- | sbin/comcontrol/Makefile | 6 | ||||
| -rw-r--r-- | sbin/comcontrol/comcontrol.8 | 53 | ||||
| -rw-r--r-- | sbin/comcontrol/comcontrol.c | 92 |
3 files changed, 151 insertions, 0 deletions
diff --git a/sbin/comcontrol/Makefile b/sbin/comcontrol/Makefile new file mode 100644 index 000000000000..abc8d0a7f81f --- /dev/null +++ b/sbin/comcontrol/Makefile @@ -0,0 +1,6 @@ +# @(#)Makefile 5.4 (Berkeley) 6/5/91 + +PROG= comcontrol +MAN8= comcontrol.8 + +.include <bsd.prog.mk> diff --git a/sbin/comcontrol/comcontrol.8 b/sbin/comcontrol/comcontrol.8 new file mode 100644 index 000000000000..53d7d332afdc --- /dev/null +++ b/sbin/comcontrol/comcontrol.8 @@ -0,0 +1,53 @@ +.Dd May 15, 1994 +.Dt COMCONTROL 8 +.Os FreeBSD +.Sh NAME +.Nm comcontrol +.Nd control an sio device. +.Sh SYNOPSIS +.Nm comcontrol +.Ar sio_special_device +.Op options +.Sh DESCRIPTION +.Nm Comcontrol +is used to examine and modify some of the special characterstics +of the specified sio device. +If no arguments other than the device are specified, +it prints the settings of all controllable characteristics. +This usage requires only read access on the device. +Only the superuser can change the settings. +.Pp +The following options are available: +.Bl -tag -width Fl +.It Cm dtrwait Ar number +Set the time to wait after dropping DTR +to the given number. +The units are hundredths of a second. +The default is 300 hundredths, i.e., 3 seconds. +.El +.Pp +The standard way to use +.Nm comcontrol +is to put invocations of it in the +.Ar /etc/rc.local +startup script. +.Sh SEE ALSO +.Xr sio 4 , +.Xr stty 1 . +.Sh FILES +.Bl -tag -width Pa +.It Pa /dev/ttyd? +dialin devices. +.It Pa /dev/cua0? +dialout devices. +.Sh AUTHOR +Christopher G. Demetriou +.Sh BUGS +.Nm comcontrol +should be named +.Nm siocontrol . +. +.Sh HISTORY +Originally part of cgd's com package patches, version 0.2.1, to 386BSD 0.1. +Once controlled bidirectional capabilities. Little is left to control now +that these capabilities are standard. diff --git a/sbin/comcontrol/comcontrol.c b/sbin/comcontrol/comcontrol.c new file mode 100644 index 000000000000..40cf8d25c8a8 --- /dev/null +++ b/sbin/comcontrol/comcontrol.c @@ -0,0 +1,92 @@ +/*- + * Copyright (c) 1992 Christopher G. Demetriou + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* comcontrol.c */ + +#include <sys/types.h> +#include <sys/ioctl.h> +#include <stdio.h> +#include <stdlib.h> +#include <ctype.h> +#include <fcntl.h> + + +void usage(char *progname) +{ + fprintf(stderr, "usage: %s <filename> [dtrwait <n>]\n", progname); + exit(1); +} + +int main(int argc, char *argv[]) +{ + int fd; + int res; + int dtrwait; + + if ((argc < 2) || (argc > 5)) usage(argv[0]); + + fd = open(argv[1], O_RDONLY|O_NONBLOCK, 0); + if (fd < 0) { + fprintf(stderr, "%s: couldn't open file %s\n", argv[0], argv[1]); + perror("open"); + exit(1); + } + + if (argc == 2) { + if (ioctl(fd, TIOCMGDTRWAIT, &dtrwait) < 0) { + perror("TIOCMGDTRWAIT"); + exit(1); + } + printf("dtrwait %d\n", dtrwait); + } else { + char *prg = argv[0]; + + res = dtrwait = -1; + while (argv[2] != NULL) { + if (!strcmp(argv[2],"dtrwait")) { + if (dtrwait >= 0) + usage(prg); + if (argv[3] == NULL || !isdigit(argv[3][0])) + usage(prg); + dtrwait = atoi(argv[3]); + argv += 2; + } else { + usage(prg); + } + } + if (dtrwait >= 0) { + if (ioctl(fd, TIOCMSDTRWAIT, &dtrwait) < 0) { + perror("TIOCMSDTRWAIT"); + exit(1); + } + } + } + + close(fd); + exit(0); +} |
