script/init.d/ethercat
changeset 639 aa23c48dca2d
parent 588 ba69f7f34fbf
child 698 6693ea7c9047
--- a/script/init.d/ethercat	Thu Mar 08 13:06:20 2007 +0000
+++ b/script/init.d/ethercat	Thu Mar 08 18:15:25 2007 +0000
@@ -68,16 +68,14 @@
 
 #------------------------------------------------------------------------------
 
-function make_device_id()
+function parse_mac_address()
 {
     if [ -z "${1}" ]; then
-        DEVICE_ID=";"
+        MAC=""
     elif echo ${1} | grep -qE '^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$'; then
-        DEVICE_ID="M${1};"
-    elif echo ${1} | grep -qE '^[^:]+:[0-9]+$'; then
-        DEVICE_ID="D${1};"
+        MAC=${1}
     else
-        echo Invalid device ID syntax in ${ETHERCAT_CONFIG}
+        echo Invalid MAC address \"${1}\" in ${ETHERCAT_CONFIG}
         /bin/false
         rc_status -v
         rc_exit
@@ -103,10 +101,16 @@
         BACKUP=$(eval echo "\${MASTER${MASTER_INDEX}_BACKUP}")
         if [ -z "${DEVICE}" ]; then break; fi
 
-        make_device_id ${DEVICE}
-        DEVICES=${DEVICES}${DEVICE_ID}
-        make_device_id ${BACKUP}
-        BACKUPS=${BACKUPS}${DEVICE_ID}
+        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