author | Florian Pose <fp@igh-essen.com> |
Wed, 21 Feb 2007 11:40:40 +0000 | |
changeset 583 | 172d42146930 |
parent 573 | cdee4ea90ce9 |
child 588 | ba69f7f34fbf |
permissions | -rwxr-xr-x |
563
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
#!/bin/sh |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
|
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
#------------------------------------------------------------------------------ |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
# |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
5 |
# Init script for EtherCAT |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
# |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
# $Id$ |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
8 |
# |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
9 |
# Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
10 |
# |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
11 |
# This file is part of the IgH EtherCAT Master. |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
12 |
# |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
13 |
# The IgH EtherCAT Master is free software; you can redistribute it |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
14 |
# and/or modify it under the terms of the GNU General Public License |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
15 |
# as published by the Free Software Foundation; either version 2 of the |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
16 |
# License, or (at your option) any later version. |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
17 |
# |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
18 |
# The IgH EtherCAT Master is distributed in the hope that it will be |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
19 |
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
20 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
21 |
# GNU General Public License for more details. |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
22 |
# |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
23 |
# You should have received a copy of the GNU General Public License |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
24 |
# along with the IgH EtherCAT Master; if not, write to the Free Software |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
25 |
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
26 |
# |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
27 |
# The right to use EtherCAT Technology is granted and comes free of |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
# charge under condition of compatibility of product made by |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
# Licensee. People intending to distribute/sell products based on the |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
30 |
# code, have to sign an agreement to guarantee that products using |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
31 |
# software based on IgH EtherCAT master stay compatible with the actual |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
# EtherCAT specification (which are released themselves as an open |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
# standard) as the (only) precondition to have the right to use EtherCAT |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
# Technology, IP and trade marks. |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
# |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
#------------------------------------------------------------------------------ |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
|
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
### BEGIN INIT INFO |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
# Provides: ethercat |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
# Required-Start: $local_fs $syslog $network |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
# Should-Start: $time ntp |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
# Required-Stop: $local_fs $syslog $network |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
# Should-Stop: $time ntp |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
# Default-Start: 3 5 |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
45 |
# Default-Stop: 0 1 2 6 |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
46 |
# Short-Description: IgH EtherCAT master modules |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
47 |
# Description: |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
48 |
### END INIT INFO |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
49 |
|
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
50 |
#------------------------------------------------------------------------------ |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
51 |
|
573
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
52 |
XMLDEVICE='ecxml' |
563
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
53 |
|
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
54 |
#------------------------------------------------------------------------------ |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
55 |
|
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
56 |
ETHERCAT_CONFIG=/etc/sysconfig/ethercat |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
57 |
|
573
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
58 |
if [ ! -r ${ETHERCAT_CONFIG} ]; then |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
59 |
echo "${ETHERCAT_CONFIG} not existing"; |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
60 |
if [ "${1}" = "stop" ]; then |
563
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
61 |
exit 0 |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
62 |
else |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
63 |
exit 6 |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
64 |
fi |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
65 |
fi |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
66 |
|
573
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
67 |
. ${ETHERCAT_CONFIG} |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
68 |
|
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
69 |
#------------------------------------------------------------------------------ |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
70 |
|
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
71 |
function make_device_id() |
563
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
72 |
{ |
573
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
73 |
if [ -z "${1}" ]; then |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
74 |
DEVICE_ID=";" |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
75 |
elif echo ${1} | grep -qE '^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$'; then |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
76 |
DEVICE_ID="M${1};" |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
77 |
elif echo ${1} | grep -qE '^[^:]+:[0-9]+$'; then |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
78 |
DEVICE_ID="D${1};" |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
79 |
else |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
80 |
echo Invalid device ID syntax in ${ETHERCAT_CONFIG} |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
81 |
/bin/false |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
82 |
rc_status -v |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
83 |
rc_exit |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
84 |
fi |
563
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
85 |
} |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
86 |
|
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
87 |
#------------------------------------------------------------------------------ |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
88 |
|
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
89 |
. /etc/rc.status |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
90 |
rc_reset |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
91 |
|
573
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
92 |
case "${1}" in |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
93 |
|
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
94 |
start) |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
95 |
echo -n "Starting EtherCAT master " |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
96 |
|
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
97 |
# construct DEVICES and BACKUPS from configuration variables |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
98 |
DEVICES="" |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
99 |
BACKUPS="" |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
100 |
MASTER_INDEX=0 |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
101 |
while true; do |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
102 |
DEVICE=$(eval echo "\${MASTER${MASTER_INDEX}_DEVICE}") |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
103 |
BACKUP=$(eval echo "\${MASTER${MASTER_INDEX}_BACKUP}") |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
104 |
if [ -z "${DEVICE}" ]; then break; fi |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
105 |
|
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
106 |
make_device_id ${DEVICE} |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
107 |
DEVICES=${DEVICES}${DEVICE_ID} |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
108 |
make_device_id ${BACKUP} |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
109 |
BACKUPS=${BACKUPS}${DEVICE_ID} |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
110 |
|
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
111 |
MASTER_INDEX=$(expr ${MASTER_INDEX} + 1) |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
112 |
done |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
113 |
|
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
114 |
# unload conflicting modules at first |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
115 |
for MODULE in 8139too; do |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
116 |
if lsmod | grep "^${MODULE} " > /dev/null; then |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
117 |
if ! rmmod ${MODULE}; then |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
118 |
/bin/false |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
119 |
rc_status -v |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
120 |
rc_exit |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
121 |
fi |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
122 |
fi |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
123 |
done |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
124 |
|
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
125 |
# load master module |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
126 |
if ! modprobe ec_master main=${DEVICES} backup=${BACKUPS}; then |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
127 |
modprobe 8139too |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
128 |
/bin/false |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
129 |
rc_status -v |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
130 |
rc_exit |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
131 |
fi |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
132 |
|
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
133 |
# remove stale device node |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
134 |
rm -f /dev/${XMLDEVICE}0 |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
135 |
|
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
136 |
# get dynamic major number |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
137 |
MAJOR=$(awk "\$2==\"EtherCAT\" {print \$1}" /proc/devices) |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
138 |
|
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
139 |
# create character device |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
140 |
mknod /dev/${XMLDEVICE}0 c ${MAJOR} 0 |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
141 |
|
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
142 |
# load device module |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
143 |
if ! modprobe ec_8139too; then |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
144 |
rmmod ec_master |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
145 |
modprobe 8139too |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
146 |
/bin/false |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
147 |
rc_status -v |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
148 |
rc_exit |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
149 |
fi |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
150 |
|
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
151 |
rc_status -v |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
152 |
;; |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
153 |
|
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
154 |
stop) |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
155 |
echo -n "Shutting down EtherCAT master " |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
156 |
|
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
157 |
# unload modules |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
158 |
for mod in ec_8139too ec_master; do |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
159 |
if lsmod | grep "^$mod " > /dev/null; then |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
160 |
if ! rmmod $mod; then |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
161 |
/bin/false |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
162 |
rc_status -v |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
163 |
rc_exit |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
164 |
fi; |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
165 |
fi; |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
166 |
done |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
167 |
|
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
168 |
# remove device node |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
169 |
rm -f /dev/${XMLDEVICE}0 |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
170 |
|
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
171 |
sleep 1 |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
172 |
|
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
173 |
# reload previous modules |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
174 |
if ! modprobe 8139too; then |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
175 |
echo "Warning: Failed to restore 8139too module." |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
176 |
fi |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
177 |
|
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
178 |
rc_status -v |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
179 |
;; |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
180 |
|
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
181 |
restart) |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
182 |
$0 stop || exit 1 |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
183 |
sleep 1 |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
184 |
$0 start |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
185 |
rc_status |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
186 |
;; |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
187 |
|
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
188 |
status) |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
189 |
echo -n "Checking for EtherCAT " |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
190 |
|
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
191 |
lsmod | grep "^ec_master " > /dev/null |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
192 |
master_running=$? |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
193 |
lsmod | grep "^ec_8139too " > /dev/null |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
194 |
device_running=$? |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
195 |
|
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
196 |
# master module and device module loaded? |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
197 |
test $master_running -eq 0 -a $device_running -eq 0 |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
198 |
|
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
199 |
rc_status -v |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
200 |
;; |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
201 |
|
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
202 |
*) |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
203 |
echo "USAGE: $0 {start|stop|restart|status}" |
cdee4ea90ce9
Introduced device IDs; removed comment lines from 8139too; removed
Florian Pose <fp@igh-essen.com>
parents:
563
diff
changeset
|
204 |
;; |
563
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
205 |
|
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
206 |
esac |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
207 |
|
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
208 |
rc_exit |
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
209 |
|
d113b63c55c4
Changed structure of scripts subdirectory.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
210 |
#------------------------------------------------------------------------------ |