81 lines
1.9 KiB
Bash
Executable file
81 lines
1.9 KiB
Bash
Executable file
#!/bin/sh
|
|
### BEGIN INIT INFO
|
|
# Provides: comedi
|
|
# Required-Start:
|
|
# Should-Start: haldaemon
|
|
# Required-Stop:
|
|
# Default-Start: 3 5
|
|
# Default-Stop: 0 1 2 6
|
|
# Description: Start Name Service Cache Daemon
|
|
### END INIT INFO
|
|
|
|
#exit
|
|
|
|
set -u
|
|
set -e
|
|
#set -x
|
|
|
|
MODPR=/sbin/modprobe
|
|
COM_CON=/usr/local/sbin/comedi_config
|
|
COM_CAL="/usr/local/bin/comedi_calibrate --calibrate"
|
|
#OPTIONS="--read-buffer 32 --write-buffer 32"
|
|
# modules to load - one module (with parameters) per line
|
|
COMEDI_MODULES="comedi_parport 0x378"
|
|
# erstmal deaktivieren
|
|
# cb_pcidda
|
|
# ni_pcimio
|
|
# comedi_test"
|
|
# parport wird extra geladen, da es einen Parameter braucht
|
|
|
|
ACTION=start
|
|
[ $# -gt 0 ] && ACTION="$1"
|
|
|
|
case "$ACTION" in
|
|
stop )
|
|
if lsmod | grep -q comedi
|
|
then echo "Comedi is active ..."
|
|
else echo "Comedi is not active ..."
|
|
exit 3
|
|
fi
|
|
echo -e "$COMEDI_MODULES" | while read mod opt; do $MODPR -r $mod; done
|
|
$MODPR -r comedi
|
|
echo "Comedi-Module wurden entfernt"
|
|
;;
|
|
restart|start )
|
|
lsmod | grep -q comedi && "$0" stop
|
|
$MODPR -r lp parport_pc ppdev parport || true
|
|
sleep 1
|
|
echo "Install comedi modules ..."
|
|
devnum=0;
|
|
echo -e "$COMEDI_MODULES" | while read mod opt
|
|
do echo -n "Configuring /dev/comedi$devnum as $mod ..."
|
|
# create device nod if necessary
|
|
[ -e "/dev/comedi$devnum" ] || mknod "/dev/comedi$devnum" c 98 "$devnum"
|
|
$MODPR $mod || true
|
|
sleep 1
|
|
if $COM_CON /dev/comedi$devnum $mod $opt
|
|
then chgrp users /dev/comedi$devnum
|
|
chmod 660 /dev/comedi$devnum
|
|
echo -e "\t OK"
|
|
else echo -e "\t Failure!"
|
|
fi
|
|
devnum=$((devnum+1))
|
|
done
|
|
maxC=$devnum
|
|
devnum=0
|
|
while [ $devnum -lt $maxC ]
|
|
do $COM_CAL -f /dev/comedi$devnum || true
|
|
# errors may occour, if the device can not be calibrated (e.g. parport) ...
|
|
devnum=$((devnum+1))
|
|
done
|
|
;;
|
|
status )
|
|
lsmod | grep -q comedi && exit 0
|
|
exit 1
|
|
;;
|
|
* )
|
|
echo "Syntax: $0 { start | stop | restart | status }"
|
|
echo
|
|
exit 1
|
|
;;
|
|
esac
|