# HG changeset patch # User Florian Pose # Date 1172065082 0 # Node ID ba69f7f34fbf47b866d0374d069ee0dbd364aab2 # Parent 59913f648e04d2c6277709eecf94d231250bc4d1 Introduced DEVICE_MODULES variable in sysconfig file; enabled init script to handle serveral device modules. diff -r 59913f648e04 -r ba69f7f34fbf script/init.d/ethercat --- a/script/init.d/ethercat Wed Feb 21 13:36:08 2007 +0000 +++ b/script/init.d/ethercat Wed Feb 21 13:38:02 2007 +0000 @@ -56,7 +56,7 @@ ETHERCAT_CONFIG=/etc/sysconfig/ethercat if [ ! -r ${ETHERCAT_CONFIG} ]; then - echo "${ETHERCAT_CONFIG} not existing"; + echo ${ETHERCAT_CONFIG} not existing; if [ "${1}" = "stop" ]; then exit 0 else @@ -111,17 +111,6 @@ MASTER_INDEX=$(expr ${MASTER_INDEX} + 1) done - # unload conflicting modules at first - for MODULE in 8139too; do - if lsmod | grep "^${MODULE} " > /dev/null; then - if ! rmmod ${MODULE}; then - /bin/false - rc_status -v - rc_exit - fi - fi - done - # load master module if ! modprobe ec_master main=${DEVICES} backup=${BACKUPS}; then modprobe 8139too @@ -139,29 +128,43 @@ # create character device mknod /dev/${XMLDEVICE}0 c ${MAJOR} 0 - # load device module - if ! modprobe ec_8139too; then - rmmod ec_master - modprobe 8139too - /bin/false - rc_status -v - rc_exit - fi - - rc_status -v - ;; - -stop) - echo -n "Shutting down EtherCAT master " - - # unload modules - for mod in ec_8139too ec_master; do - if lsmod | grep "^$mod " > /dev/null; then - if ! rmmod $mod; then + # check for modules to replace + for MODULE in ${DEVICE_MODULES}; do + ECMODULE=ec_${MODULE} + if ! modinfo ${ECMODULE} > /dev/null; then + continue + fi + if lsmod | grep "^${MODULE} " > /dev/null; then + if ! rmmod ${MODULE}; then /bin/false rc_status -v rc_exit - fi; + fi + fi + if ! modprobe ${ECMODULE}; then + modprobe ${MODULE} # try to restore module + /bin/false + rc_status -v + rc_exit + fi + done + + rc_status -v + ;; + +stop) + echo -n "Shutting down EtherCAT master " + + # unload EtherCAT device modules + for MODULE in ${DEVICE_MODULES} master; do + ECMODULE=ec_${MODULE} + if ! lsmod | grep -q "^${ECMODULE} "; then + continue + fi + if ! rmmod ${ECMODULE}; then + /bin/false + rc_status -v + rc_exit fi; done @@ -171,9 +174,11 @@ sleep 1 # reload previous modules - if ! modprobe 8139too; then - echo "Warning: Failed to restore 8139too module." - fi + for MODULE in ${DEVICE_MODULES}; do + if ! modprobe ${MODULE}; then + echo Warning: Failed to restore ${MODULE}. + fi + done rc_status -v ;; @@ -188,13 +193,14 @@ status) echo -n "Checking for EtherCAT " - lsmod | grep "^ec_master " > /dev/null - master_running=$? - lsmod | grep "^ec_8139too " > /dev/null - device_running=$? - - # master module and device module loaded? - test $master_running -eq 0 -a $device_running -eq 0 + lsmod | grep -q "^ec_master " + MASTERS_RUNNING=$? + + ! grep -q "(WAITING)" /sys/ethercat/master*/info + MASTERS_IDLE=$? + + # master module loaded and masters not waiting for devices? + test ${MASTERS_RUNNING} -eq 0 -a ${MASTERS_IDLE} -eq 0 rc_status -v ;; diff -r 59913f648e04 -r ba69f7f34fbf script/sysconfig/ethercat --- a/script/sysconfig/ethercat Wed Feb 21 13:36:08 2007 +0000 +++ b/script/sysconfig/ethercat Wed Feb 21 13:38:02 2007 +0000 @@ -14,7 +14,7 @@ # redundancy purposes. # # There are three formats for specifying ethernet devices: -# 1) MAC address (example: "00:00:08:44:55:66"). Specify the MAC address of +# 1) MAC address (example: "00:00:08:44:ab:66"). Specify the MAC address of # the ethernet card to use. # 2) PCI bus address (example: "01:1c.0"). Specify the PCU bis address of the # ethernet card to use. @@ -29,4 +29,16 @@ MASTER0_DEVICE= MASTER0_BACKUP= +# +# Ethernet driver modules to replace with EtherCAT-capable ones. +# +# The init script will try to unload the ethernet driver modules in the list +# and replace them with the EtherCAT-capable ones, respectively. If a certain +# (EtherCAT-capable) driver is not found, a warning will appear. +# +# Remove all unused driver modules to prevent unnecesessary module +# replacement. +# +DEVICE_MODULES="8139too e100 forcedeth" + #------------------------------------------------------------------------------