MSR example: Replaced msr_load and msr_unload with init script, removed msr_param.h

This commit is contained in:
Florian Pose 2006-10-27 09:46:42 +00:00
parent 68998a19a6
commit e00d3c9449
6 changed files with 131 additions and 91 deletions

View File

@ -1,9 +1,5 @@
#------------------------------------------------------------------------------
#
# Makefile.am
#
# IgH EtherCAT master module
#
# $Id$
#
# Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH

129
examples/msr/init.sh Executable file
View File

@ -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
#------------------------------------------------------------------------------
# <Customizing>
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
# </Customizing>
#------------------------------------------------------------------------------
. /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

View File

@ -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}

View File

@ -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
/*****************************************************************************/

View File

@ -44,12 +44,13 @@
#include <msr_main.h>
#include <msr_reg.h>
#include <msr_time.h>
#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)

View File

@ -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