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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
|
#!/bin/bash
exec 2>&1
export TERM=linux
. /etc/rc.conf
. /etc/rc.d/functions
. /usr/MythVantage/bin/install_functions.sh
LOG=/tmp/remotes.log
if [ -f $LOG ]
then
rm -f $LOG
fi
echo "`date` --- run started" >> $LOG
echo "====== lirc modules already loaded ==========" >> $LOG
lsmod |grep lirc >> $LOG
echo "====== lirc modules end =========" >> $LOG
echo >> $LOG
#What is done in this file may not be enough to start your specific remote.
#If that is true of your remote place your remote startup commands in:
# /etc/runit/lirc.sh
#Anything in that file will be used and the rest of this file is ignored.
if [ -x /etc/runit/lirc.sh ]
then
#program must not terminate.
stat_runit "Starting remotes from /etc/runit/lirc.sh"
echo "Starting remotes from /etc/runit/lirc.sh" >>$LOG
/etc/runit/lirc.sh
else
. /etc/systemconfig
stat_runit "Starting remotes"
[ -e /etc/sv/remotes/.runtime ] || mkdir -p /etc/sv/remotes/.runtime
[ -e /var/run/lirc ] || mkdir -p /var/run/lirc
num_lirc=`ls -la /dev/lirc[0-9] 2>/dev/null |wc -l `
num_lirc=$((num_lirc-1))
serial_port=""
if [ x$ReceiverType = xserial ]
then
serial_port=$ReceiverSerialport
elif [ x$HostBlasterType = xserial ]
then
serial_port=$HostSerialPort_blasterlirc
fi
if [ -n "$serial_port" ]
then
echo "Serial device setup: $serial_port" >>$LOG
#/dev/ttyS0 (COM1), port 0x3f8, irq 4
#/dev/ttyS1 (COM2), port 0x2f8, irq 3
#/dev/ttyS2 (COM3), port 0x3e8, irq 4
#/dev/ttyS3 (COM4), port 0x2e8, irq 3
printhl " Using serial device, loading module lirc_serial"
case $serial_port in
ttyS0)
FLAGS="io=0x3f8 irq=4 debug=1 "
;;
ttyS1)
FLAGS="io=0x2f8 irq=3 debug=1"
;;
ttyS2)
FLAGS="io=0x3e8 irq=4 debug=1"
;;
ttyS3)
FLAGS="io=0x2e8 irq=3 debug=1"
;;
esac
#set_serial debugging
/usr/bin/setserial -va /dev/$serial_port 2>&1 >> $LOG
echo '' 2>&1 >> $LOG
#run set_serial command
/usr/bin/setserial -v /dev/$serial_port uart none 2>&1 >> $LOG
echo '' 2>&1 >> $LOG
#set_serial debugging
/usr/bin/setserial -va /dev/$serial_port 2>&1 >> $LOG
sleep 1
#remove lirc_serial
echo "*Removing lirc_serial" 2>&1 >> $LOG
/usr/bin/rmmod -v lirc_serial 2>> $LOG
/usr/bin/rmmod -v lirc_dev 2>> $LOG
echo "*Loading lirc_serial" 2>&1 >> $LOG
echo "/sbin/modprobe lirc_serial $FLAGS" 2>&1 >> $LOG
/sbin/modprobe -v lirc_serial $FLAGS 2>&1 >> $LOG
echo "====== lirc modules after load ==========" >> $LOG
lsmod |grep lirc >> $LOG
echo "====== lirc modules end =========" >> $LOG
sleep 1
echo "====== dmesg output ============" >>$LOG
dmesg | tail -20 >> $LOG
echo "======= dmesg end ===========" >>$LOG
fi
if [ x$HostBlasterType = xCommandIR -o x$ReceiverType = xCommandIR ]
then
CMD="/usr/sbin/lircd -r -n --driver=commandir"
printhl " Using commandir"
echo $CMD >>$LOG
$CMD >>$LOG 2>>$LOG
elif [ x$HostBlasterType = xiguanaIR-usb -o x$ReceiverType = xiguanaIR-usb ]
then
sv start igdaemon
CMD="/usr/sbin/lircd -r -n --driver=iguanaIR"
printhl " Using iguanaIR usb"
echo $CMD >>$LOG
$CMD >>$LOG 2>>$LOG
elif [ x$ReceiverType = "xSiliconDust_HDHR" ]
then
# if using the SiliconDust_HDHR as an I/R Receiver
CMD="/usr/sbin/lircd -H udp -d 5000 -n"
printhl " Using SiliconDust on port 5000"
echo $CMD >>$LOG
$CMD >>$LOG 2>>$LOG
else
if [ -f /etc/remote.run ]
then
#program must not terminate.
stat_runit "Starting remotes from /etc/remote.run"
LCMD="/etc/remote.run"
echo "Starting remotes from $LCMD" >>$LOG
exec $LCMD >>$LOG 2>>$LOG
else
#/etc/remote.run not found, carry one with normal init
LASTCMD=""
USE_BLASTER="False"
DEFINED_RECEIVER="False"
case x$ReceiverType in
xmce)
IRNODE=/dev/remotes/mce_lirc
DEFINED_RECEIVER="True"
LASTCMD="--connect=localhost:8761"
;;
xserial)
IRNODE=/dev/remotes/serial_lirc
DEFINED_RECEIVER="True"
LASTCMD="--connect=localhost:8761"
;;
xNone)
IRNODE='None'
DEFINED_RECEIVER="False"
;;
xstreamzap)
IRNODE=/dev/remotes/streamzap_lirc
DEFINED_RECEIVER="True"
LASTCMD="--connect=localhost:8761"
;;
xhd_pvr)
IRNODE=/dev/remotes/hdpvr_lirc
DEFINED_RECEIVER="True"
LASTCMD="--connect=localhost:8761"
;;
Default|*)
DEFINED_RECEIVER="False"
for i in `seq 1 $num_lirc`
do
CMD="/usr/sbin/lircd -r -d /dev/lirc$i --output=/var/run/lirc/lircd$i --pidfile=/var/run/lircd$i.pid --listen=876$i"
printhl " Device $i"
echo $CMD >>$LOG
$CMD >>$LOG 2>>$LOG
LASTCMD="--connect=localhost:876$i $LASTCMD "
done
;;
esac
#find valid blaster device and make it the LCMD
# Receiver, Serial, MCE, NONE
case x$HostBlasterType in
xmce)
BLASTERNODE=/dev/remotes/mce_lirc
USE_BLASTER="True"
;;
xserial)
BLASTERNODE=/dev/remotes/serial_lirc
USE_BLASTER="True"
;;
xNone)
BLASTERNODE='None'
USE_BLASTER="False"
;;
xReceiver)
BLASTERNODE=$IRNODE
USE_BLASTER="True"
DEFINED_RECEIVER="False"
;;
xhd_pvr)
BLASTERNODE=/dev/remotes/hdpvr_lirc
USE_BLASTER="True"
esac
if [ x$USE_BLASTER = xTrue -a x$DEFINED_RECEIVER = xTrue ]
then
#start receiver
#start blaster chain
CMD="/usr/sbin/lircd -r -d $IRNODE --output=/var/run/lirc/lircd1 --pidfile=/var/run/lircd1.pid --listen=8761"
LCMD="/usr/sbin/lircd -r -n -d $BLASTERNODE --output /var/run/lirc/lircd $LASTCMD"
echo $CMD >>$LOG
$CMD >>$LOG 2>>$LOG
elif [ x$USE_BLASTER = xTrue ]
then
#start only the blaster
LCMD="/usr/sbin/lircd -r -n -d $BLASTERNODE --output /var/run/lirc/lircd $LASTCMD"
elif [ x$DEFINED_RECEIVER = xTrue ]
then
#start reciever
LCMD="/usr/sbin/lircd -r -n -d $IRNODE --output /var/run/lirc/lircd"
else
#default case of /dev/lirc0
LCMD="/usr/sbin/lircd -r -n -d /dev/lirc0 --output /var/run/lirc/lircd $LASTCMD"
fi
echo $LASTCMD >>$LOG
echo "Disable in kernel remote driver" >>$LOG
in_kernel_support "disable"
echo "Starting remotes from $LCMD" >>$LOG
exec $LCMD >>$LOG 2>>$LOG
fi
fi
fi
|