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$ ...@@ -8,8 +8,6 @@ $Id$
Version 1.4.0: 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. * Attach Pdo names from SII or Coe dictionary to Pdos read via CoE.
* Update documentation. * Update documentation.
* Check for possible race condition in jiffy-based frame timeout calculation. * Check for possible race condition in jiffy-based frame timeout calculation.
...@@ -17,10 +15,10 @@ Version 1.4.0: ...@@ -17,10 +15,10 @@ Version 1.4.0:
Future issues: Future issues:
* Distributed clocks. * 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 * Move master threads, slave handlers and state machines into a user
space daemon. space daemon.
* Implement user space realtime interface via cdev. * Allow master requesting when in ORPHANED phase
* Mailbox protocol handlers. * Mailbox protocol handlers.
* Mailbox state machine using toggle bits. * Mailbox state machine using toggle bits.
* Mailbox gateway. * Mailbox gateway.
......
...@@ -503,6 +503,7 @@ AC_CONFIG_FILES([ ...@@ -503,6 +503,7 @@ AC_CONFIG_FILES([
master/Makefile master/Makefile
script/Makefile script/Makefile
script/init.d/Makefile script/init.d/Makefile
script/init.d/ethercat
script/sysconfig/Makefile script/sysconfig/Makefile
tool/Makefile tool/Makefile
]) ])
......
...@@ -35,6 +35,8 @@ initdir = $(sysconfdir)/init.d ...@@ -35,6 +35,8 @@ initdir = $(sysconfdir)/init.d
init_SCRIPTS = ethercat init_SCRIPTS = ethercat
EXTRA_DIST = ethercat EXTRA_DIST = ethercat.in
BUILT_SOURCES = ethercat
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
...@@ -43,8 +43,8 @@ ...@@ -43,8 +43,8 @@
# Should-Stop: $time ntp # Should-Stop: $time ntp
# Default-Start: 3 5 # Default-Start: 3 5
# Default-Stop: 0 1 2 6 # Default-Stop: 0 1 2 6
# Short-Description: EtherCAT Master # Short-Description: EtherCAT master
# Description: # Description: EtherCAT master @VERSION@
### END INIT INFO ### END INIT INFO
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
MODPROBE=/sbin/modprobe MODPROBE=/sbin/modprobe
RMMOD=/sbin/rmmod RMMOD=/sbin/rmmod
MODINFO=/sbin/modinfo MODINFO=/sbin/modinfo
ETHERCAT=@prefix@/bin/ethercat
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
...@@ -84,43 +85,39 @@ function exit_success() ...@@ -84,43 +85,39 @@ function exit_success()
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
function exit_running() function exit_fail()
{ {
if [ -r /etc/rc.status ]; then if [ -r /etc/rc.status ]; then
rc_reset rc_failed
rc_status -v rc_status -v
rc_exit rc_exit
else else
echo " running" echo " failed"
exit 0 exit 1
fi fi
} }
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
function exit_fail() function print_running()
{ {
if [ -r /etc/rc.status ]; then if [ -r /etc/rc.status ]; then
rc_failed rc_reset
rc_status -v rc_status -v
rc_exit
else else
echo " failed" echo " running"
exit 1
fi fi
} }
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
function exit_dead() function print_dead()
{ {
if [ -r /etc/rc.status ]; then if [ -r /etc/rc.status ]; then
rc_failed rc_failed
rc_status -v rc_status -v
rc_exit
else else
echo " dead" echo " dead"
exit 1
fi fi
} }
...@@ -148,7 +145,7 @@ fi ...@@ -148,7 +145,7 @@ fi
case "${1}" in case "${1}" in
start) start)
echo -n "Starting EtherCAT master " echo -n "Starting EtherCAT master @VERSION@"
# construct DEVICES and BACKUPS from configuration variables # construct DEVICES and BACKUPS from configuration variables
DEVICES="" DEVICES=""
...@@ -200,7 +197,7 @@ start) ...@@ -200,7 +197,7 @@ start)
;; ;;
stop) stop)
echo -n "Shutting down EtherCAT master " echo -n "Shutting down EtherCAT master @VERSION@"
# unload EtherCAT device modules # unload EtherCAT device modules
for MODULE in ${DEVICE_MODULES} master; do for MODULE in ${DEVICE_MODULES} master; do
...@@ -232,20 +229,35 @@ restart) ...@@ -232,20 +229,35 @@ restart)
;; ;;
status) 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 " RESULT=0
MASTERS_RUNNING=$?
! grep -q "(WAITING)" /sys/ethercat/master*/info for i in `seq 0 $(expr ${MASTER_COUNT} - 1)`; do
MASTERS_IDLE=$? 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? exit ${RESULT}
if [ ${MASTERS_RUNNING} -eq 0 -a ${MASTERS_IDLE} -eq 0 ]; then
exit_running
else
exit_dead
fi
;; ;;
*) *)
......
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