Added first systemd support.
This commit is contained in:
parent
6214bafd82
commit
04b652a7fb
|
|
@ -125,6 +125,8 @@ m4/lt~obsolete.m4
|
||||||
modules.order
|
modules.order
|
||||||
script/Makefile
|
script/Makefile
|
||||||
script/Makefile.in
|
script/Makefile.in
|
||||||
|
script/ethercat.service
|
||||||
|
script/ethercatctl
|
||||||
script/init.d/Makefile
|
script/init.d/Makefile
|
||||||
script/init.d/Makefile.in
|
script/init.d/Makefile.in
|
||||||
script/init.d/ethercat
|
script/init.d/ethercat
|
||||||
|
|
|
||||||
1
NEWS
1
NEWS
|
|
@ -74,6 +74,7 @@ Changes since 1.4.0:
|
||||||
* A sync manager is always enabled, if it contains registered process data.
|
* A sync manager is always enabled, if it contains registered process data.
|
||||||
* Added a configuration switch --enable-wildcards to use 0xffffffff as a
|
* Added a configuration switch --enable-wildcards to use 0xffffffff as a
|
||||||
* wildcard for vendor ID and product code.
|
* wildcard for vendor ID and product code.
|
||||||
|
* Added support for systemd.
|
||||||
|
|
||||||
Changes in 1.4.0:
|
Changes in 1.4.0:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -657,6 +657,8 @@ AC_CONFIG_FILES([
|
||||||
master/Kbuild
|
master/Kbuild
|
||||||
master/Makefile
|
master/Makefile
|
||||||
script/Makefile
|
script/Makefile
|
||||||
|
script/ethercat.service
|
||||||
|
script/ethercatctl
|
||||||
script/init.d/Makefile
|
script/init.d/Makefile
|
||||||
script/init.d/ethercat
|
script/init.d/ethercat
|
||||||
script/sysconfig/Makefile
|
script/sysconfig/Makefile
|
||||||
|
|
|
||||||
|
|
@ -24,15 +24,29 @@
|
||||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
#
|
#
|
||||||
# ---
|
# ---
|
||||||
#
|
#
|
||||||
# The license mentioned above concerns the source code only. Using the EtherCAT
|
# The license mentioned above concerns the source code only. Using the
|
||||||
# technology and brand is only permitted in compliance with the industrial
|
# EtherCAT technology and brand is only permitted in compliance with the
|
||||||
# property and similar rights of Beckhoff Automation GmbH.
|
# industrial property and similar rights of Beckhoff Automation GmbH.
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
SUBDIRS = init.d sysconfig
|
SUBDIRS = init.d sysconfig
|
||||||
|
|
||||||
EXTRA_DIST = ifup-eoe.sh
|
sbin_SCRIPTS = ethercatctl
|
||||||
|
|
||||||
|
systemddir = $(libdir)/systemd/system
|
||||||
|
systemd_DATA = ethercat.service
|
||||||
|
|
||||||
|
sysconf_DATA = ethercat.conf
|
||||||
|
|
||||||
|
EXTRA_DIST = \
|
||||||
|
ethercatctl.in \
|
||||||
|
ethercat.service.in \
|
||||||
|
ifup-eoe.sh
|
||||||
|
|
||||||
|
BUILT_SOURCES = \
|
||||||
|
ethercatctl \
|
||||||
|
ethercat.service
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# EtherCAT master configuration file for use with ethercatctl.
|
||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
#
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#
|
||||||
|
# Master devices.
|
||||||
|
#
|
||||||
|
# The MASTER<X>_DEVICE variable specifies the Ethernet device for a master
|
||||||
|
# with index 'X'.
|
||||||
|
#
|
||||||
|
# Specify the MAC address (hexadecimal with colons) of the Ethernet device to
|
||||||
|
# use. Example: "00:00:08:44:ab:66"
|
||||||
|
#
|
||||||
|
# The broadcast address "ff:ff:ff:ff:ff:ff" has a special meaning: It tells
|
||||||
|
# the master to accept the first device offered by any Ethernet driver.
|
||||||
|
#
|
||||||
|
# The MASTER<X>_DEVICE variables also determine, how many masters will be
|
||||||
|
# created: A non-empty variable MASTER0_DEVICE will create one master, adding a
|
||||||
|
# non-empty variable MASTER1_DEVICE will create a second master, and so on.
|
||||||
|
#
|
||||||
|
MASTER0_DEVICE=""
|
||||||
|
#MASTER1_DEVICE=""
|
||||||
|
|
||||||
|
#
|
||||||
|
# Ethernet driver modules to use for EtherCAT operation.
|
||||||
|
#
|
||||||
|
# Specify a non-empty list of Ethernet drivers, that shall be used for EtherCAT
|
||||||
|
# operation.
|
||||||
|
#
|
||||||
|
# Except for the generic Ethernet driver module, the init script will try to
|
||||||
|
# unload the usual Ethernet driver modules in the list and replace them with
|
||||||
|
# the EtherCAT-capable ones. If a certain (EtherCAT-capable) driver is not
|
||||||
|
# found, a warning will appear.
|
||||||
|
#
|
||||||
|
# Possible values: 8139too, e100, e1000, e1000e, r8169, generic. Separate
|
||||||
|
# multiple drivers with spaces.
|
||||||
|
#
|
||||||
|
# Note: The e100, e1000, e1000e, r8169 and generic drivers are not built by
|
||||||
|
# default. Enable them with the --enable-<driver> configure switches.
|
||||||
|
#
|
||||||
|
DEVICE_MODULES=""
|
||||||
|
|
||||||
|
#
|
||||||
|
# Flags for loading kernel modules.
|
||||||
|
#
|
||||||
|
# This can usually be left empty. Adjust this variable, if you have problems
|
||||||
|
# with module loading.
|
||||||
|
#
|
||||||
|
#MODPROBE_FLAGS="-b"
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
#
|
||||||
|
# EtherCAT Master Kernel Modules
|
||||||
|
#
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=EtherCAT Master Kernel Modules
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
RemainAfterExit=yes
|
||||||
|
ExecStart=@prefix@/sbin/ethercatctl start
|
||||||
|
ExecStop=@prefix@/sbin/ethercatctl stop
|
||||||
|
|
@ -0,0 +1,211 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Start script for EtherCAT to use with systemd
|
||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
#
|
||||||
|
# Copyright (C) 2006-2012 Florian Pose, Ingenieurgemeinschaft IgH
|
||||||
|
#
|
||||||
|
# This file is part of the IgH EtherCAT Master.
|
||||||
|
#
|
||||||
|
# The IgH EtherCAT Master is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License version 2, as
|
||||||
|
# published by the Free Software Foundation.
|
||||||
|
#
|
||||||
|
# The IgH EtherCAT Master is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
# Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License along
|
||||||
|
# with the IgH EtherCAT Master; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
#
|
||||||
|
# ---
|
||||||
|
#
|
||||||
|
# The license mentioned above concerns the source code only. Using the
|
||||||
|
# EtherCAT technology and brand is only permitted in compliance with the
|
||||||
|
# industrial property and similar rights of Beckhoff Automation GmbH.
|
||||||
|
#
|
||||||
|
# vim: expandtab sw=4 tw=78
|
||||||
|
#
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
MODPROBE=/sbin/modprobe
|
||||||
|
RMMOD=/sbin/rmmod
|
||||||
|
MODINFO=/sbin/modinfo
|
||||||
|
|
||||||
|
ETHERCAT=@prefix@/bin/ethercat
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
ETHERCAT_CONFIG=/etc/ethercat.conf
|
||||||
|
|
||||||
|
if [ ! -r ${ETHERCAT_CONFIG} ]; then
|
||||||
|
echo ${ETHERCAT_CONFIG} not existing;
|
||||||
|
exit 6
|
||||||
|
fi
|
||||||
|
|
||||||
|
. ${ETHERCAT_CONFIG}
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
parse_mac_address() {
|
||||||
|
if [ -z "${1}" ]; then
|
||||||
|
MAC=""
|
||||||
|
elif echo ${1} | grep -qE '^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$'; then
|
||||||
|
MAC=${1}
|
||||||
|
else
|
||||||
|
echo Invalid MAC address \"${1}\" in ${ETHERCAT_CONFIG}
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
case "${1}" in
|
||||||
|
|
||||||
|
start)
|
||||||
|
# construct DEVICES and BACKUPS from configuration variables
|
||||||
|
DEVICES=""
|
||||||
|
BACKUPS=""
|
||||||
|
MASTER_INDEX=0
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
DEVICE=$(eval echo "\${MASTER${MASTER_INDEX}_DEVICE}")
|
||||||
|
BACKUP=$(eval echo "\${MASTER${MASTER_INDEX}_BACKUP}")
|
||||||
|
if [ -z "${DEVICE}" ]; then break; fi
|
||||||
|
|
||||||
|
if [ ${MASTER_INDEX} -gt 0 ]; then
|
||||||
|
DEVICES=${DEVICES},
|
||||||
|
BACKUPS=${BACKUPS},
|
||||||
|
fi
|
||||||
|
|
||||||
|
parse_mac_address ${DEVICE}
|
||||||
|
DEVICES=${DEVICES}${MAC}
|
||||||
|
|
||||||
|
parse_mac_address ${BACKUP}
|
||||||
|
BACKUPS=${BACKUPS}${MAC}
|
||||||
|
|
||||||
|
MASTER_INDEX=$(expr ${MASTER_INDEX} + 1)
|
||||||
|
done
|
||||||
|
|
||||||
|
# load master module
|
||||||
|
if ! ${MODPROBE} ${MODPROBE_FLAGS} ec_master \
|
||||||
|
main_devices=${DEVICES} backup_devices=${BACKUPS}; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
LOADED_MODULES=ec_master
|
||||||
|
|
||||||
|
# check for modules to replace
|
||||||
|
for MODULE in ${DEVICE_MODULES}; do
|
||||||
|
ECMODULE=ec_${MODULE}
|
||||||
|
if ! ${MODINFO} ${ECMODULE} > /dev/null; then
|
||||||
|
continue # ec_* module not found
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ${MODULE} != "generic" ]; then
|
||||||
|
# try to unload standard module
|
||||||
|
if lsmod | grep "^${MODULE} " > /dev/null; then
|
||||||
|
if ! ${RMMOD} ${MODULE}; then
|
||||||
|
${RMMOD} ${LOADED_MODULES}
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! ${MODPROBE} ${MODPROBE_FLAGS} ${ECMODULE}; then
|
||||||
|
if [ ${MODULE} != "generic" ]; then
|
||||||
|
${MODPROBE} ${MODPROBE_FLAGS} ${MODULE} # try to restore
|
||||||
|
fi
|
||||||
|
${RMMOD} ${LOADED_MODULES}
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
LOADED_MODULES=${ECMODULE} ${LOADED_MODULES}
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
stop)
|
||||||
|
# unload EtherCAT device modules
|
||||||
|
for MODULE in ${DEVICE_MODULES} master; do
|
||||||
|
ECMODULE=ec_${MODULE}
|
||||||
|
if ! lsmod | grep -q "^${ECMODULE} "; then
|
||||||
|
continue # ec_* module not loaded
|
||||||
|
fi
|
||||||
|
if ! ${RMMOD} ${ECMODULE}; then
|
||||||
|
exit 1
|
||||||
|
fi;
|
||||||
|
done
|
||||||
|
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
# load standard modules again
|
||||||
|
for MODULE in ${DEVICE_MODULES}; do
|
||||||
|
if [ ${MODULE} == "generic" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
${MODPROBE} ${MODPROBE_FLAGS} ${MODULE}
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
restart)
|
||||||
|
$0 stop || exit 1
|
||||||
|
sleep 1
|
||||||
|
$0 start
|
||||||
|
;;
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
status)
|
||||||
|
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
|
||||||
|
|
||||||
|
RESULT=0
|
||||||
|
|
||||||
|
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
|
||||||
|
echo " running"
|
||||||
|
else
|
||||||
|
echo " dead"
|
||||||
|
RESULT=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
exit ${RESULT}
|
||||||
|
;;
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "USAGE: $0 {start|stop|restart|status}"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
Loading…
Reference in New Issue