serial revision 50472
114239Sbde#!/bin/sh
250472Speter# $FreeBSD: head/etc/rc.d/serial 50472 1999-08-27 23:37:10Z peter $
314239Sbde
413798Smpp# Change some defaults for serial devices.
51675Sache# Standard defaults are:
67708Srgrimes#	dtrwait 300 drainwait 0
71675Sache#	initial cflag from <sys/ttydefaults.h> = cread cs8 hupcl
81675Sache#	initial iflag, lflag and oflag all 0
91675Sache#	speed 9600
101675Sache#	special chars from <sys/ttydefaults.h>
111675Sache#	nothing locked
121675Sache# except for serial consoles the initial iflag, lflag and oflag are from
131675Sache# <sys/ttydefaults.h> and clocal is locked on.
141675Sache
151675Sachedefault() {
161675Sache	# Reset everything changed by the other functions to initial defaults.
1714239Sbde
1814239Sbde	ci=$1; shift	# call in device identifier
1914239Sbde	co=$1; shift	# call out device identifier
2014239Sbde
211675Sache	for i in $*
221675Sache	do
2350357Ssheldonh		comcontrol /dev/tty${ci}${i} dtrwait 300 drainwait 0
2450454Ssheldonh		stty < /dev/ttyi${ci}${i} -clocal crtscts hupcl 9600 reprint ^R
2550357Ssheldonh		stty < /dev/ttyl${ci}${i} -clocal -crtscts -hupcl 0
2650454Ssheldonh		stty < /dev/cuai${co}${i} -clocal crtscts hupcl 9600 reprint ^R
2750357Ssheldonh		stty < /dev/cual${co}${i} -clocal -crtscts -hupcl 0
281675Sache	done
291675Sache}
301675Sache
311675Sachemaybe() {
321675Sache	# Special settings.
3314239Sbde
3414239Sbde	ci=$1; shift
3514239Sbde	co=$1; shift
3614239Sbde
371675Sache	for i in $*
381675Sache	do
391675Sache		# Don't use ^R; it breaks bash's ^R when typed ahead.
4050357Ssheldonh		stty < /dev/ttyi${ci}${i} reprint undef
4150357Ssheldonh		stty < /dev/cuai${co}${i} reprint undef
421675Sache		# Lock clocal off on dialin device for security.
4350357Ssheldonh		stty < /dev/ttyl${ci}${i} clocal
441675Sache		# Lock the speeds to use old binaries that don't support them.
451675Sache		# Any legal speed works to lock the initial speed.
4650357Ssheldonh		stty < /dev/ttyl${ci}${i} 300
4750357Ssheldonh		stty < /dev/cual${co}${i} 300
481675Sache	done
491675Sache}
501675Sache
511675Sachemodem() {
521675Sache	# Modem that supports CTS and perhaps RTS handshaking.
5314239Sbde
5414239Sbde	ci=$1; shift
5514239Sbde	co=$1; shift
5614239Sbde
571675Sache	for i in $*
581675Sache	do
597708Srgrimes		# may depend on modem
6050357Ssheldonh		comcontrol /dev/tty${ci}${i} dtrwait 100 drainwait 180
611675Sache		# Lock crtscts on.
621675Sache		# Speed reasonable for V42bis.
6350357Ssheldonh		stty < /dev/ttyi${ci}${i} crtscts 57600
6450357Ssheldonh		stty < /dev/ttyl${ci}${i} crtscts
6550357Ssheldonh		stty < /dev/cuai${co}${i} crtscts 57600
6650357Ssheldonh		stty < /dev/cual${co}${i} crtscts
671675Sache	done
681675Sache}
691675Sache
701675Sachemouse() {
711675Sache	# Mouse on either callin or callout port.
7214239Sbde
7314239Sbde	ci=$1; shift
7414239Sbde	co=$1; shift
7514239Sbde
761675Sache	for i in $*
771675Sache	do
781675Sache		# Lock clocal on, hupcl off.
791675Sache		# Standard speed for Microsoft mouse.
8050357Ssheldonh		stty < /dev/ttyi${ci}${i} clocal -hupcl 1200
8150357Ssheldonh		stty < /dev/ttyl${ci}${i} clocal  hupcl
8250357Ssheldonh		stty < /dev/cuai${co}${i} clocal -hupcl 1200
8350357Ssheldonh		stty < /dev/cual${co}${i} clocal  hupcl
841675Sache	done
851675Sache}
861675Sache
871675Sacheterminal() {
881675Sache	# Terminal that supports CTS and perhaps RTS handshaking
891675Sache	# with the cable or terminal arranged so that DCD is on
901675Sache	# at least while the terminal is on.
911675Sache	# Also works for bidirectional communications to another pc
921675Sache	# provided at most one side runs getty.
931675Sache	# Same as modem() except we want a faster speed and no dtrwait.
9414239Sbde
9514239Sbde	ci=$1; shift
9614239Sbde	co=$1; shift
9714239Sbde
9850357Ssheldonh	modem ${ci} ${co} $*
991675Sache	for i in $*
1001675Sache	do
10150357Ssheldonh		comcontrol /dev/tty${ci}${i} dtrwait 0
10250357Ssheldonh		stty < /dev/ttyi${ci}${i} 115200
10350357Ssheldonh		stty < /dev/cuai${co}${i} 115200
1041675Sache	done
1051675Sache}
1061675Sache
1071675Sache# Don't use anything from this file unless you have some buggy programs
1081675Sache# that require it.
10914239Sbde
1101675Sache# Edit the functions and the examples to suit your system.
11114239Sbde# $1 is the call in device identifier, $2 is the call out device identifier
11214239Sbde# and the remainder of the line lists the device numbers.
11314239Sbde
11414239Sbde# Initialize assorted 8250-16550 (sio) ports.
11514239Sbde# maybe    d a  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
11614239Sbde# mouse    d a      2
11714239Sbde# modem    d a    1
11814239Sbde# terminal d a  0
11914239Sbde
12014239Sbde# Initialize all ports on a Cyclades-8yo.
12134561Sdanny# modem    c c  00 01 02 03 04 05 06 07
12214239Sbde
12314239Sbde# Initialize all ports on a Cyclades-16ye.
12434561Sdanny# modem    c c  00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 
12514239Sbde
12614239Sbde# Initialize all ports on a Digiboard 8.
12723607Sbde# modem    D D  00 01 02 03 04 05 06 07
128