script/init.d/ethercat
changeset 921 c8c2caf0d667
parent 812 80c3d9c8292f
child 922 fede1d8f5b71
equal deleted inserted replaced
920:d50af9d482ed 921:c8c2caf0d667
    47 # Description:
    47 # Description:
    48 ### END INIT INFO
    48 ### END INIT INFO
    49 
    49 
    50 #------------------------------------------------------------------------------
    50 #------------------------------------------------------------------------------
    51 
    51 
    52 XMLDEVICE='ecxml'
       
    53 MODPROBE=/sbin/modprobe
    52 MODPROBE=/sbin/modprobe
    54 RMMOD=/sbin/rmmod
    53 RMMOD=/sbin/rmmod
    55 MODINFO=/sbin/modinfo
    54 MODINFO=/sbin/modinfo
    56 
    55 
    57 #------------------------------------------------------------------------------
    56 #------------------------------------------------------------------------------
   178     if ! ${MODPROBE} ${MODPROBE_FLAGS} ec_master \
   177     if ! ${MODPROBE} ${MODPROBE_FLAGS} ec_master \
   179             main_devices=${DEVICES} backup_devices=${BACKUPS}; then
   178             main_devices=${DEVICES} backup_devices=${BACKUPS}; then
   180         exit_fail
   179         exit_fail
   181     fi
   180     fi
   182 
   181 
   183     # remove stale device node
       
   184     rm -f /dev/${XMLDEVICE}0
       
   185 
       
   186     # get dynamic major number
       
   187     MAJOR=$(awk "\$2==\"EtherCAT\" {print \$1}" /proc/devices)
       
   188 
       
   189     # create character device
       
   190     mknod /dev/${XMLDEVICE}0 c ${MAJOR} 0
       
   191 
       
   192     # check for modules to replace
   182     # check for modules to replace
   193     for MODULE in ${DEVICE_MODULES}; do
   183     for MODULE in ${DEVICE_MODULES}; do
   194         ECMODULE=ec_${MODULE}
   184         ECMODULE=ec_${MODULE}
   195         if ! ${MODINFO} ${ECMODULE} > /dev/null; then
   185         if ! ${MODINFO} ${ECMODULE} > /dev/null; then
   196             continue # ec_* module not found
   186             continue # ec_* module not found
   221         if ! ${RMMOD} ${ECMODULE}; then
   211         if ! ${RMMOD} ${ECMODULE}; then
   222             exit_fail
   212             exit_fail
   223         fi;
   213         fi;
   224     done
   214     done
   225 
   215 
   226     # remove device node
       
   227     rm -f /dev/${XMLDEVICE}0
       
   228 
       
   229     sleep 1
   216     sleep 1
   230 
   217 
   231     # reload previous modules
   218     # reload previous modules
   232     for MODULE in ${DEVICE_MODULES}; do
   219     for MODULE in ${DEVICE_MODULES}; do
   233         if ! ${MODPROBE} ${MODPROBE_FLAGS} ${MODULE}; then
   220         if ! ${MODPROBE} ${MODPROBE_FLAGS} ${MODULE}; then