Skip to content
Snippets Groups Projects
Commit 123df2e5 authored by Florian Pose's avatar Florian Pose
Browse files

Repaired init script status command.

parent 343c96cd
No related branches found
No related tags found
No related merge requests found
......@@ -8,8 +8,6 @@ $Id$
Version 1.4.0:
* Abort code messages in userspace.
* Repair rcethercat status.
* Attach Pdo names from SII or Coe dictionary to Pdos read via CoE.
* Update documentation.
* Check for possible race condition in jiffy-based frame timeout calculation.
......@@ -17,10 +15,10 @@ Version 1.4.0:
Future issues:
* Distributed clocks.
* Allow master requesting when in ORPHANED phase
* Implement user space realtime interface via cdev.
* Move master threads, slave handlers and state machines into a user
space daemon.
* Implement user space realtime interface via cdev.
* Allow master requesting when in ORPHANED phase
* Mailbox protocol handlers.
* Mailbox state machine using toggle bits.
* Mailbox gateway.
......
......@@ -503,6 +503,7 @@ AC_CONFIG_FILES([
master/Makefile
script/Makefile
script/init.d/Makefile
script/init.d/ethercat
script/sysconfig/Makefile
tool/Makefile
])
......
......@@ -35,6 +35,8 @@ initdir = $(sysconfdir)/init.d
init_SCRIPTS = ethercat
EXTRA_DIST = ethercat
EXTRA_DIST = ethercat.in
BUILT_SOURCES = ethercat
#------------------------------------------------------------------------------
......@@ -43,8 +43,8 @@
# Should-Stop: $time ntp
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: EtherCAT Master
# Description:
# Short-Description: EtherCAT master
# Description: EtherCAT master @VERSION@
### END INIT INFO
#------------------------------------------------------------------------------
......@@ -52,6 +52,7 @@
MODPROBE=/sbin/modprobe
RMMOD=/sbin/rmmod
MODINFO=/sbin/modinfo
ETHERCAT=@prefix@/bin/ethercat
#------------------------------------------------------------------------------
......@@ -84,43 +85,39 @@ function exit_success()
#------------------------------------------------------------------------------
function exit_running()
function exit_fail()
{
if [ -r /etc/rc.status ]; then
rc_reset
rc_failed
rc_status -v
rc_exit
else
echo " running"
exit 0
echo " failed"
exit 1
fi
}
#------------------------------------------------------------------------------
function exit_fail()
function print_running()
{
if [ -r /etc/rc.status ]; then
rc_failed
rc_reset
rc_status -v
rc_exit
else
echo " failed"
exit 1
echo " running"
fi
}
#------------------------------------------------------------------------------
function exit_dead()
function print_dead()
{
if [ -r /etc/rc.status ]; then
rc_failed
rc_status -v
rc_exit
else
echo " dead"
exit 1
fi
}
......@@ -148,7 +145,7 @@ fi
case "${1}" in
start)
echo -n "Starting EtherCAT master "
echo -n "Starting EtherCAT master @VERSION@"
# construct DEVICES and BACKUPS from configuration variables
DEVICES=""
......@@ -200,7 +197,7 @@ start)
;;
stop)
echo -n "Shutting down EtherCAT master "
echo -n "Shutting down EtherCAT master @VERSION@"
# unload EtherCAT device modules
for MODULE in ${DEVICE_MODULES} master; do
......@@ -232,20 +229,35 @@ restart)
;;
status)
echo -n "Checking for EtherCAT "
echo "Checking for EtherCAT master @VERSION@"
# count masters in configuration file
MASTER_COUNT=0
while true; do
DEVICE=$(eval echo "\${MASTER${MASTER_COUNT}_DEVICE}")
if [ -z "${DEVICE}" ]; then break; fi
MASTER_COUNT=$(expr ${MASTER_COUNT} + 1)
done
lsmod | grep -q "^ec_master "
MASTERS_RUNNING=$?
RESULT=0
! grep -q "(WAITING)" /sys/ethercat/master*/info
MASTERS_IDLE=$?
for i in `seq 0 $(expr ${MASTER_COUNT} - 1)`; do
echo -n "Master${i}"
# Check if the master is in idle or operation phase
${ETHERCAT} master --master ${i} 2>/dev/null | \
grep -qE 'Phase:[[:space:]]*Idle|Phase:[[:space:]]*Operation'
EXITCODE=$?
if [ ${EXITCODE} -eq 0 ]; then
print_running
else
print_dead
RESULT=1
fi
done
# master module loaded and masters not waiting for devices?
if [ ${MASTERS_RUNNING} -eq 0 -a ${MASTERS_IDLE} -eq 0 ]; then
exit_running
else
exit_dead
fi
exit ${RESULT}
;;
*)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment