diff options
Diffstat (limited to 'sbin/comcontrol')
| -rw-r--r-- | sbin/comcontrol/Makefile | 2 | ||||
| -rw-r--r-- | sbin/comcontrol/comcontrol.8 | 74 | ||||
| -rw-r--r-- | sbin/comcontrol/comcontrol.c | 65 |
3 files changed, 124 insertions, 17 deletions
diff --git a/sbin/comcontrol/Makefile b/sbin/comcontrol/Makefile index 46179428a7e7..abc8d0a7f81f 100644 --- a/sbin/comcontrol/Makefile +++ b/sbin/comcontrol/Makefile @@ -1,6 +1,6 @@ # @(#)Makefile 5.4 (Berkeley) 6/5/91 PROG= comcontrol -NOMAN= noman +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..bcb44e1088ee --- /dev/null +++ b/sbin/comcontrol/comcontrol.8 @@ -0,0 +1,74 @@ +.Dd December 10, 1993 +.Dt COMCONTROL 8 +.Os FreeBSD +.Sh NAME +.Nm comcontrol +.Nd "control the bidirectional status of a sio port and waiting time after DTR drop" +.Sh SYNOPSIS +.Nm comcontrol +.Ar sio_special_device +.Op Cm bidir | Fl bidir +.Op Cm dtrwait Ar ticks +.Sh DESCRIPTION +.Nm Comcontrol +is used to examine and modify the bidirectional status +of a specified +sio communications port +and its waiting time after DTR drop. +By default (if +.Ar sio_special_device +only specified), +.Nm comcontrol +will print the current port state +(if kernel was built with +.Cm options COM_BIDIR ) +as either +.Cm bidir +to indicate that bidirectional operation is enabled or +.Fl bidir +to indicate that it is disabled, string +.Cm dtrwait +and current waiting time in ticks +after DTR drop. +To modify the status of the port or waiting time, simply +specify the desired new state +and/or new waiting time +on the command line. All users with +read access to the +.Ar sio_special_device +can use +.Nm comcontrol +to get the port's status and current waiting time. +Only root can set a port's status and waiting time. +By default, each port is initially unidirectional, waiting time is +2 seconds. +.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 +.Sh FILES +.Bl -tag -width Pa +.It Pa /dev/sio?? +.Sh DIAGNOSTICS +.Cm TIOCMSBIDIR: Inappropriate ioctl for device. +.Pp +This indicates attempt to change port status on +a non-sio special device file, +or the kernel has not been built with +.Cm options COM_BIDIR . +For more information concerning reconfiguration +of your kernel see +.Ar /usr/src/sys/i386/doc/config_options.doc. +.Sh AUTHOR +Christopher G. Demetriou +.Sh BUGS +It is strongly recommended that you do *not* +change the bidirectional status of a port while there are programs +using the port. Read that as: if you do, and it breaks, don't yell +at me; that's a really weird thing to do. +.Sh HISTORY +Originally part of cgd's com package patches, version 0.2.1, to 386BSD 0.1. diff --git a/sbin/comcontrol/comcontrol.c b/sbin/comcontrol/comcontrol.c index 101d64ff4759..e88e3d8f71e0 100644 --- a/sbin/comcontrol/comcontrol.c +++ b/sbin/comcontrol/comcontrol.c @@ -31,12 +31,14 @@ #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> [[-]bidir]\n", progname); + fprintf(stderr, "usage: %s <filename> [[-]bidir] [dtrwait <n>]\n", progname); exit(1); } @@ -44,8 +46,9 @@ int main(int argc, char *argv[]) { int fd; int res; + int dtrwait; - if ((argc < 2) || (argc > 3)) usage(argv[0]); + if ((argc < 2) || (argc > 5)) usage(argv[0]); fd = open(argv[1], O_RDONLY|O_NONBLOCK, 0); if (fd < 0) { @@ -55,25 +58,55 @@ int main(int argc, char *argv[]) } if (argc == 2) { - if (ioctl(fd, TIOCMGBIDIR, &res) < 0) { - perror("ioctl"); + if (ioctl(fd, TIOCMGBIDIR, &res) >= 0) { + if (!res) printf("-"); + printf("bidir "); + } + if (ioctl(fd, TIOCMGDTRWAIT, &dtrwait) < 0) { + perror("TIOCMGDTRWAIT"); exit(1); } - if (!res) printf("-"); - printf("bidir\n"); + printf("dtrwait %d\n", dtrwait); } else { - if (!strcmp(argv[2],"bidir")) { - res = 1; - } else if (!strcmp(argv[2],"-bidir")) { - res = 0; - } else { - usage(argv[0]); + char *prg = argv[0]; + + res = dtrwait = -1; + while (argv[2] != NULL) { + if (!strcmp(argv[2],"bidir")) { + if (res >= 0) + usage(prg); + res = 1; + argv++; + } else if (!strcmp(argv[2],"-bidir")) { + if (res >= 0) + usage(prg); + res = 0; + argv++; + } else 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 (res >= 0) { + if (ioctl(fd, TIOCMSBIDIR, &res) < 0) { + perror("TIOCMSBIDIR"); + exit(1); + } + } + if (dtrwait >= 0) { + if (ioctl(fd, TIOCMSDTRWAIT, &dtrwait) < 0) { + perror("TIOCMSDTRWAIT"); + exit(1); + } } - if (ioctl(fd, TIOCMSBIDIR, &res) < 0) { - perror("ioctl"); - exit(1); - } } close(fd); + exit(0); } |
