serial revision 13798
1# Change some defaults for serial devices.
2# Standard defaults are:
3#	dtrwait 300 drainwait 0
4#	initial cflag from <sys/ttydefaults.h> = cread cs8 hupcl
5#	initial iflag, lflag and oflag all 0
6#	speed 9600
7#	special chars from <sys/ttydefaults.h>
8#	nothing locked
9# except for serial consoles the initial iflag, lflag and oflag are from
10# <sys/ttydefaults.h> and clocal is locked on.
11
12default() {
13	# Reset everything changed by the other functions to initial defaults.
14	for i in $*
15	do
16		comcontrol /dev/ttyd$i dtrwait 300 drainwait 0
17		stty </dev/ttyid$i -clocal  crtscts  hupcl 9600 reprint ^R
18		stty </dev/ttyld$i -clocal -crtscts -hupcl 0
19		stty </dev/cuaia$i -clocal  crtscts  hupcl 9600 reprint ^R
20		stty </dev/cuala$i -clocal -crtscts -hupcl 0
21	done
22}
23
24maybe() {
25	# Special settings.
26	for i in $*
27	do
28		# Don't use ^R; it breaks bash's ^R when typed ahead.
29		stty </dev/ttyid$i reprint undef
30		stty </dev/cuaia$i reprint undef
31		# Lock clocal off on dialin device for security.
32		stty </dev/ttyld$i clocal
33		# Lock the speeds to use old binaries that don't support them.
34		# Any legal speed works to lock the initial speed.
35		stty </dev/ttyld$i 300
36		stty </dev/cuala$i 300
37	done
38}
39
40modem() {
41	# Modem that supports CTS and perhaps RTS handshaking.
42	for i in $*
43	do
44		# may depend on modem
45		comcontrol /dev/ttyd$i dtrwait 100 drainwait 180
46		# Lock crtscts on.
47		# Speed reasonable for V42bis.
48		stty </dev/ttyid$i crtscts 57600
49		stty </dev/ttyld$i crtscts
50		stty </dev/cuaia$i crtscts 57600
51		stty </dev/cuala$i crtscts
52	done
53}
54
55mouse() {
56	# Mouse on either callin or callout port.
57	for i in $*
58	do
59		# Lock clocal on, hupcl off.
60		# Standard speed for Microsoft mouse.
61		stty </dev/ttyid$i clocal -hupcl 1200
62		stty </dev/ttyld$i clocal  hupcl
63		stty </dev/cuaia$i clocal -hupcl 1200
64		stty </dev/cuala$i clocal  hupcl
65	done
66}
67
68terminal() {
69	# Terminal that supports CTS and perhaps RTS handshaking
70	# with the cable or terminal arranged so that DCD is on
71	# at least while the terminal is on.
72	# Also works for bidirectional communications to another pc
73	# provided at most one side runs getty.
74	# Same as modem() except we want a faster speed and no dtrwait.
75	modem $*
76	for i in $*
77	do
78		comcontrol /dev/ttyd$i dtrwait 0
79		stty </dev/ttyid$i 115200
80		stty </dev/cuaia$i 115200
81	done
82}
83
84# Don't use anything from this file unless you have some buggy programs
85# that require it.
86#
87# Edit the functions and the examples to suit your system.
88#
89# maybe		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
90# mouse		    2
91# modem		  1
92# terminal	0
93