# HG changeset patch # User Florian Pose # Date 1161942402 0 # Node ID cd6b819c2351b3ad0eb11616c6f70e11ce5c6d4c # Parent 03523dfc4dff517c0d2d6dcacdada24962e6ec26 MSR example: Replaced msr_load and msr_unload with init script, removed msr_param.h diff -r 03523dfc4dff -r cd6b819c2351 examples/msr/Makefile.am --- a/examples/msr/Makefile.am Fri Oct 27 09:33:43 2006 +0000 +++ b/examples/msr/Makefile.am Fri Oct 27 09:46:42 2006 +0000 @@ -1,9 +1,5 @@ #------------------------------------------------------------------------------ # -# Makefile.am -# -# IgH EtherCAT master module -# # $Id$ # # Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH diff -r 03523dfc4dff -r cd6b819c2351 examples/msr/init.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/msr/init.sh Fri Oct 27 09:46:42 2006 +0000 @@ -0,0 +1,129 @@ +#!/bin/sh + +#------------------------------------------------------------------------------ +# +# MSR Init Script +# +# $Id$ +# +#------------------------------------------------------------------------------ + +### BEGIN INIT INFO +# Provides: msr +# Required-Start: $local_fs $syslog $network +# Should-Start: $time ntp ethercat +# Required-Stop: $local_fs $syslog $network +# Should-Stop: $time ntp ethercat +# Default-Start: 3 5 +# Default-Stop: 0 1 2 6 +# Short-Description: MSR module +# Description: +### END INIT INFO + +#------------------------------------------------------------------------------ + +# + +NAME="MSR EtherCAT sample" +BASE=/opt/etherlab +MSR_SERVER=$BASE/bin/msrserv.pl +MODULE=ec_msr_sample +RTAI_PATH=/usr/realtime +RTAI_MODULES="hal up" # sem math +DEVICE=msr +DEVMASK=664 +GROUP=users + +# + +#------------------------------------------------------------------------------ + +. /etc/rc.status +rc_reset + +#------------------------------------------------------------------------------ + +case "$1" in + start) + echo -n Starting $NAME" " + + # Insert RTAI modules + for mod in $RTAI_MODULES; do + if ! lsmod | grep -q "^rtai_$mod"; then + if ! insmod $RTAI_PATH/modules/rtai_$mod.ko; then + /bin/false + rc_status -v + rc_exit + fi + fi + done + + # Insert realtime module + if ! modprobe $MODULE; then + /bin/false + rc_status -v + rc_exit + fi + + #sleep 2 + + # Create MSR device + MAJOR=`cat /proc/devices | awk "\\$2==\"$DEVICE\" {print \\$1}"` + rm -f /dev/${DEVICE} + mknod /dev/${DEVICE} c $MAJOR 0 + chgrp $GROUP /dev/${DEVICE} + chmod $DEVMASK /dev/${DEVICE} + + #sleep 1 + + # Start MSR-Server + startproc $MSR_SERVER 1>/dev/null 2>/dev/null + rc_status -v + ;; + + stop) + echo -n Shutting down $NAME" " + + if ! killproc $MSR_SERVER; then + /bin/false + rc_status -v + rc_exit + fi + + if ! /sbin/rmmod $MODULE; then + /bin/false + rc_status -v + rc_exit + fi + + # Remove stale nodes + rm -f /dev/${DEVICE} /dev/${DEVICE}0 + + rc_status -v + ;; + + restart) + $0 stop || exit 1 + sleep 1 + $0 start + + rc_status + ;; + + status) + echo -n "Checking for MSR module: " + /sbin/lsmod | grep -q "^$MODULE" + rc_status -v + + echo -n "Checking for MSR server: " + checkproc $MSR_SERVER + rc_status -v + ;; + + *) + echo "Usage: $0 {start|stop|status|restart}" + exit 1 + ;; +esac + +rc_exit \ No newline at end of file diff -r 03523dfc4dff -r cd6b819c2351 examples/msr/msr_load --- a/examples/msr/msr_load Fri Oct 27 09:33:43 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -#!/bin/sh -module="ec_msr_sample" -device="msr" -mode="664" - -# Group: since distributions do it differently, look for wheel or use staff -if grep '^staff:' /etc/group > /dev/null; then - group="staff" -else - group="wheel" -fi - -# invoke insmod with all arguments we got -# and use a pathname, as newer modutils don't look in . by default -/sbin/insmod -f ./$module.ko $* || exit 1 - -major=`cat /proc/devices | awk "\\$2==\"$device\" {print \\$1}"` - -echo $major -# Remove stale nodes and replace them, then give gid and perms -# Usually the script is shorter, it's scull that has several devices in it. - -rm -f /dev/${device} -mknod /dev/${device} c $major 0 -# ln -sf ${device}0 /dev/${device} -chgrp users /dev/${device} -chmod $mode /dev/${device} - - - - - - - - - diff -r 03523dfc4dff -r cd6b819c2351 examples/msr/msr_param.h --- a/examples/msr/msr_param.h Fri Oct 27 09:33:43 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -/****************************************************************************** - * - * $Id$ - * - * Copyright (C) 2006 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 - * as published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * 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 right to use EtherCAT Technology is granted and comes free of - * charge under condition of compatibility of product made by - * Licensee. People intending to distribute/sell products based on the - * code, have to sign an agreement to guarantee that products using - * software based on IgH EtherCAT master stay compatible with the actual - * EtherCAT specification (which are released themselves as an open - * standard) as the (only) precondition to have the right to use EtherCAT - * Technology, IP and trade marks. - * - *****************************************************************************/ - -#ifndef _MSR_PARAM_H_ -#define _MSR_PARAM_H_ - -#define MSR_ABTASTFREQUENZ 1000 - -#endif - -/*****************************************************************************/ diff -r 03523dfc4dff -r cd6b819c2351 examples/msr/msr_sample.c --- a/examples/msr/msr_sample.c Fri Oct 27 09:33:43 2006 +0000 +++ b/examples/msr/msr_sample.c Fri Oct 27 09:46:42 2006 +0000 @@ -44,12 +44,13 @@ #include #include #include -#include "msr_param.h" // EtherCAT #include "../../include/ecrt.h" #include "../../include/ecdb.h" +#define MSR_ABTASTFREQUENZ 1000 + #define HZREDUCTION (MSR_ABTASTFREQUENZ / HZ) #define TIMERTICKS (1000000000 / MSR_ABTASTFREQUENZ) diff -r 03523dfc4dff -r cd6b819c2351 examples/msr/msr_unload --- a/examples/msr/msr_unload Fri Oct 27 09:33:43 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ -#!/bin/sh -module="ec_msr_sample" -device="msr" - -# invoke rmmod with all arguments we got -/sbin/rmmod $module $* || exit 1 - -# Remove stale nodes -rm -f /dev/${device} /dev/${device}0