summaryrefslogtreecommitdiffstats
path: root/etc/rc.d/serial
blob: 7f042e84e66615ece1b268be33080a90ca1102dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# Change some defauls for serial devices.
# Standard defaults are:
#	dtrwait 300
#	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.
	for i in $*
	do
		comcontrol /dev/ttyd$i dtrwait 300
		stty </dev/ttyid$i -clocal  crtscts  hupcl 9600 reprint ^R
		stty </dev/ttyld$i -clocal -crtscts -hupcl 0
		stty </dev/cuai0$i -clocal  crtscts  hupcl 9600 reprint ^R
		stty </dev/cual0$i -clocal -crtscts -hupcl 0
	done
}

maybe() {
	# Special settings.
	for i in $*
	do
		# Don't use ^R; it breaks bash's ^R when typed ahead.
		stty </dev/ttyid$i reprint undef
		stty </dev/cuai0$i reprint undef
		# Lock clocal off on dialin device for security.
		stty </dev/ttyld$i clocal
		# Lock the speeds to use old binaries that don't support them.
		# Any legal speed works to lock the initial speed.
		stty </dev/ttyld$i 300
		stty </dev/cual0$i 300
	done
}

modem() {
	# Modem that supports CTS and perhaps RTS handshaking.
	for i in $*
	do
		comcontrol /dev/ttyd$i dtrwait 100	# may depend on modem
		# Lock crtscts on.
		# Speed reasonable for V42bis.
		stty </dev/ttyid$i crtscts 57600
		stty </dev/ttyld$i crtscts
		stty </dev/cuai0$i crtscts 57600
		stty </dev/cual0$i crtscts
	done
}

mouse() {
	# Mouse on either callin or callout port.
	for i in $*
	do
		# Lock clocal on, hupcl off.
		# Standard speed for Microsoft mouse.
		stty </dev/ttyid$i clocal -hupcl 1200
		stty </dev/ttyld$i clocal  hupcl
		stty </dev/cuai0$i clocal -hupcl 1200
		stty </dev/cual0$i clocal  hupcl
	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.
	modem $*
	for i in $*
	do
		comcontrol /dev/ttyd$i dtrwait 0
		stty </dev/ttyid$i 115200
		stty </dev/cuai0$i 115200
	done
}

# Don't use anything from this file unless you have some buggy programs
# that require it.
#
# Edit the functions and the examples to suit your system.
#
# 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
# mouse		    2
# modem		  1
# terminal	0
OpenPOWER on IntegriCloud