ethercat.sh
changeset 174 99907332ff1e
parent 169 b3ecbec2c487
child 197 b9a6e2c22745
equal deleted inserted replaced
173:10e182a8bc4e 174:99907332ff1e
    12 
    12 
    13 #------------------------------------------------------------------------------
    13 #------------------------------------------------------------------------------
    14 
    14 
    15 print_usage()
    15 print_usage()
    16 {
    16 {
    17     echo "Usage $0 { start | stop }"
    17     echo "Usage: $0 { start | stop | restart }"
    18 }
    18 }
    19 
    19 
    20 unload_module()
    20 unload_module()
    21 {
    21 {
    22     if lsmod | grep ^$1 > /dev/null; then
    22     if lsmod | grep ^$1 > /dev/null; then
    43     echo "ERROR: Configuration file \"$CONFIGFILE\" not found!"
    43     echo "ERROR: Configuration file \"$CONFIGFILE\" not found!"
    44     exit 1
    44     exit 1
    45 fi
    45 fi
    46 
    46 
    47 case $ACTION in
    47 case $ACTION in
    48     start)
    48     start | restart)
    49 	echo "Starting EtherCAT master..."
    49 	echo "Starting EtherCAT master..."
       
    50 
    50 	# remove modules
    51 	# remove modules
    51 	unload_module 8139too
    52 	unload_module 8139too
    52 	unload_module 8139cp
    53 	unload_module 8139cp
    53 	unload_module ec_8139too
    54 	unload_module ec_8139too
    54 	unload_module ec_master
    55 	unload_module ec_master
       
    56 
    55 	echo "  loading master modules..."
    57 	echo "  loading master modules..."
    56 	if ! modprobe ec_8139too ec_device_index=$DEVICEINDEX; then
    58 	if ! modprobe ec_8139too ec_device_index=$DEVICEINDEX; then
    57 	    echo "ERROR: Failed to load module!"
    59 	    echo "ERROR: Failed to load module!"
    58 	    exit 1
    60 	    exit 1
    59 	fi
    61 	fi
    60 	;;
    62 	;;
       
    63 
    61     stop)
    64     stop)
    62 	echo "Stopping EtherCAT master..."
    65 	echo "Stopping EtherCAT master..."
    63 	unload_module ec_8139too
    66 	unload_module ec_8139too
    64 	unload_module ec_master
    67 	unload_module ec_master
    65 	if ! modprobe 8139too; then
    68 	if ! modprobe 8139too; then
    66 	    echo "Warning: Failed to restore 8139too module."
    69 	    echo "Warning: Failed to restore 8139too module."
    67 	fi
    70 	fi
    68 	;;
    71 	;;
       
    72 
    69     *)
    73     *)
    70 	print_usage
    74 	print_usage
    71 	exit 1
    75 	exit 1
    72 esac
    76 esac
    73 
    77