1996-02-24 19:51:25 +00:00
|
|
|
#!/bin/sh
|
2000-10-08 19:20:36 +00:00
|
|
|
#
|
|
|
|
# Copyright (c) 1996 Andrey A. Chernov
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 AUTHOR 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.
|
|
|
|
#
|
1999-08-27 23:37:10 +00:00
|
|
|
# $FreeBSD$
|
2000-10-08 19:20:36 +00:00
|
|
|
#
|
1996-02-24 19:51:25 +00:00
|
|
|
|
2002-07-18 05:00:17 +00:00
|
|
|
# PROVIDE: serial
|
|
|
|
# REQUIRE: root
|
2004-10-07 13:55:26 +00:00
|
|
|
# KEYWORD: nojail
|
2002-07-18 05:00:17 +00:00
|
|
|
|
1996-01-31 15:03:18 +00:00
|
|
|
# Change some defaults for serial devices.
|
1994-06-04 00:44:00 +00:00
|
|
|
# Standard defaults are:
|
2003-05-04 22:46:33 +00:00
|
|
|
# dtrwait 300 drainwait `sysctl -n kern.drainwait`
|
1994-06-04 00:44:00 +00:00
|
|
|
# initial cflag from <sys/ttydefaults.h> = cread cs8 hupcl
|
|
|
|
# initial iflag, lflag and oflag all 0
|
|
|
|
# speed 9600
|
|
|
|
# special chars from <sys/ttydefaults.h>
|
|
|
|
# nothing locked
|
|
|
|
# except for serial consoles the initial iflag, lflag and oflag are from
|
|
|
|
# <sys/ttydefaults.h> and clocal is locked on.
|
|
|
|
|
|
|
|
default() {
|
|
|
|
# Reset everything changed by the other functions to initial defaults.
|
1996-02-24 19:51:25 +00:00
|
|
|
|
2004-11-14 19:51:34 +00:00
|
|
|
dc=$1; shift # device name character
|
2003-05-04 22:46:33 +00:00
|
|
|
drainwait=`sysctl -n kern.drainwait`
|
1996-02-24 19:51:25 +00:00
|
|
|
|
1994-06-04 00:44:00 +00:00
|
|
|
for i in $*
|
|
|
|
do
|
2004-11-14 19:51:34 +00:00
|
|
|
comcontrol /dev/tty${dc}${i} dtrwait 300 drainwait $drainwait
|
|
|
|
stty < /dev/tty${dc}${i}.init -clocal crtscts hupcl 9600 reprint ^R
|
|
|
|
stty < /dev/tty${dc}${i}.lock -clocal -crtscts -hupcl 0
|
|
|
|
stty < /dev/cua${dc}${i}.init -clocal crtscts hupcl 9600 reprint ^R
|
|
|
|
stty < /dev/cua${dc}${i}.lock -clocal -crtscts -hupcl 0
|
1994-06-04 00:44:00 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
maybe() {
|
|
|
|
# Special settings.
|
1996-02-24 19:51:25 +00:00
|
|
|
|
2004-11-14 19:51:34 +00:00
|
|
|
dc=$1; shift
|
1996-02-24 19:51:25 +00:00
|
|
|
|
1994-06-04 00:44:00 +00:00
|
|
|
for i in $*
|
|
|
|
do
|
|
|
|
# Don't use ^R; it breaks bash's ^R when typed ahead.
|
2004-11-14 19:51:34 +00:00
|
|
|
stty < /dev/tty${dc}${i}.init reprint undef
|
|
|
|
stty < /dev/cua${dc}${i}.init reprint undef
|
1994-06-04 00:44:00 +00:00
|
|
|
# Lock clocal off on dialin device for security.
|
2004-11-14 19:51:34 +00:00
|
|
|
stty < /dev/tty${dc}${i}.lock clocal
|
1994-06-04 00:44:00 +00:00
|
|
|
# Lock the speeds to use old binaries that don't support them.
|
|
|
|
# Any legal speed works to lock the initial speed.
|
2004-11-14 19:51:34 +00:00
|
|
|
stty < /dev/tty${dc}${i}.lock 300
|
|
|
|
stty < /dev/cua${dc}${i}.lock 300
|
1994-06-04 00:44:00 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
modem() {
|
|
|
|
# Modem that supports CTS and perhaps RTS handshaking.
|
1996-02-24 19:51:25 +00:00
|
|
|
|
2004-11-14 19:51:34 +00:00
|
|
|
dc=$1; shift
|
1996-02-24 19:51:25 +00:00
|
|
|
|
1994-06-04 00:44:00 +00:00
|
|
|
for i in $*
|
|
|
|
do
|
1995-04-09 09:54:51 +00:00
|
|
|
# may depend on modem
|
2004-11-14 19:51:34 +00:00
|
|
|
comcontrol /dev/tty${dc}${i} dtrwait 100 drainwait 180
|
1994-06-04 00:44:00 +00:00
|
|
|
# Lock crtscts on.
|
|
|
|
# Speed reasonable for V42bis.
|
2004-11-14 19:51:34 +00:00
|
|
|
stty < /dev/tty${dc}${i}.init crtscts 115200
|
|
|
|
stty < /dev/tty${dc}${i}.lock crtscts
|
|
|
|
stty < /dev/cua${dc}${i}.init crtscts 115200
|
|
|
|
stty < /dev/cua${dc}${i}.lock crtscts
|
1994-06-04 00:44:00 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
mouse() {
|
|
|
|
# Mouse on either callin or callout port.
|
1996-02-24 19:51:25 +00:00
|
|
|
|
2004-11-14 19:51:34 +00:00
|
|
|
dc=$1; shift
|
1996-02-24 19:51:25 +00:00
|
|
|
|
1994-06-04 00:44:00 +00:00
|
|
|
for i in $*
|
|
|
|
do
|
|
|
|
# Lock clocal on, hupcl off.
|
|
|
|
# Standard speed for Microsoft mouse.
|
2004-11-14 19:51:34 +00:00
|
|
|
stty < /dev/tty${dc}${i}.init clocal -hupcl 1200
|
|
|
|
stty < /dev/tty${dc}${i}.lock clocal hupcl
|
|
|
|
stty < /dev/cua${dc}${i}.init clocal -hupcl 1200
|
|
|
|
stty < /dev/cua${dc}${i}.lock clocal hupcl
|
1994-06-04 00:44:00 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
terminal() {
|
|
|
|
# Terminal that supports CTS and perhaps RTS handshaking
|
|
|
|
# with the cable or terminal arranged so that DCD is on
|
|
|
|
# at least while the terminal is on.
|
|
|
|
# Also works for bidirectional communications to another pc
|
|
|
|
# provided at most one side runs getty.
|
|
|
|
# Same as modem() except we want a faster speed and no dtrwait.
|
1996-02-24 19:51:25 +00:00
|
|
|
|
2004-11-14 19:51:34 +00:00
|
|
|
dc=$1; shift
|
1996-02-24 19:51:25 +00:00
|
|
|
|
2004-11-14 19:51:34 +00:00
|
|
|
modem ${dc} $*
|
1994-06-04 00:44:00 +00:00
|
|
|
for i in $*
|
|
|
|
do
|
2004-11-14 19:51:34 +00:00
|
|
|
comcontrol /dev/tty${dc}${i} dtrwait 0
|
|
|
|
stty < /dev/tty${dc}${i}.init 115200
|
|
|
|
stty < /dev/cua${dc}${i}.init 115200
|
1994-06-04 00:44:00 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# Don't use anything from this file unless you have some buggy programs
|
|
|
|
# that require it.
|
1996-02-24 19:51:25 +00:00
|
|
|
|
1994-06-04 00:44:00 +00:00
|
|
|
# Edit the functions and the examples to suit your system.
|
1996-02-24 19:51:25 +00:00
|
|
|
# $1 is the call in device identifier, $2 is the call out device identifier
|
|
|
|
# and the remainder of the line lists the device numbers.
|
|
|
|
|
|
|
|
# Initialize assorted 8250-16550 (sio) ports.
|
2004-11-14 19:51:34 +00:00
|
|
|
# maybe d 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v
|
|
|
|
# mouse d 2
|
|
|
|
# modem d 1
|
|
|
|
# terminal d 0
|
1996-02-24 19:51:25 +00:00
|
|
|
|
|
|
|
# Initialize all ports on a Cyclades-8yo.
|
2004-11-14 19:51:34 +00:00
|
|
|
# modem c 00 01 02 03 04 05 06 07
|
1996-02-24 19:51:25 +00:00
|
|
|
|
|
|
|
# Initialize all ports on a Cyclades-16ye.
|
2004-11-14 19:51:34 +00:00
|
|
|
# modem c 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
|
1996-02-24 19:51:25 +00:00
|
|
|
|
|
|
|
# Initialize all ports on a Digiboard 8.
|
2004-11-14 19:51:34 +00:00
|
|
|
# modem D 00 01 02 03 04 05 06 07
|