Added first systemd support.
--- a/.hgignore Wed Jan 04 15:57:10 2012 +0100
+++ b/.hgignore Wed Jan 04 18:00:36 2012 +0100
@@ -129,6 +129,8 @@
modules.order
script/Makefile
script/Makefile.in
+script/ethercat.service
+script/ethercatctl
script/init.d/Makefile
script/init.d/Makefile.in
script/init.d/ethercat
--- a/NEWS Wed Jan 04 15:57:10 2012 +0100
+++ b/NEWS Wed Jan 04 18:00:36 2012 +0100
@@ -77,6 +77,7 @@
* A sync manager is always enabled, if it contains registered process data.
* Added a configuration switch --enable-wildcards to use 0xffffffff as a
* wildcard for vendor ID and product code.
+* Added support for systemd.
Changes in 1.4.0:
--- a/configure.ac Wed Jan 04 15:57:10 2012 +0100
+++ b/configure.ac Wed Jan 04 18:00:36 2012 +0100
@@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
#
-# $Id: configure.ac,v 1baafcd263cc 2011/07/06 14:37:40 fp $
+# $Id$
#
# Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH
#
@@ -798,26 +798,28 @@
examples/mini/Makefile
examples/rtai/Kbuild
examples/rtai/Makefile
+ examples/rtai_rtdm/Makefile
examples/tty/Kbuild
examples/tty/Makefile
examples/user/Makefile
examples/xenomai/Makefile
examples/xenomai_posix/Makefile
- examples/rtai_rtdm/Makefile
include/Makefile
lib/Makefile
m4/Makefile
master/Kbuild
master/Makefile
+ rtdm/Kbuild
+ rtdm/Makefile
script/Makefile
+ script/ethercat.service
+ script/ethercatctl
script/init.d/Makefile
script/init.d/ethercat
script/sysconfig/Makefile
tool/Makefile
tty/Kbuild
tty/Makefile
- rtdm/Makefile
- rtdm/Kbuild
])
AC_OUTPUT
--- a/script/Makefile.am Wed Jan 04 15:57:10 2012 +0100
+++ b/script/Makefile.am Wed Jan 04 18:00:36 2012 +0100
@@ -24,15 +24,29 @@
# 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.
+#
+# 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.
#
#------------------------------------------------------------------------------
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
#------------------------------------------------------------------------------
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/script/ethercat.conf Wed Jan 04 18:00:36 2012 +0100
@@ -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"
+
+#------------------------------------------------------------------------------
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/script/ethercat.service.in Wed Jan 04 18:00:36 2012 +0100
@@ -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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/script/ethercatctl.in Wed Jan 04 18:00:36 2012 +0100
@@ -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
+
+#------------------------------------------------------------------------------