MERGE trunk -r573:587 -> branches/stable-1.1 (race, bootstrap, mailbox bugfix, debug interface switch)
--- a/Makefile.am Thu Sep 28 08:31:33 2006 +0000
+++ b/Makefile.am Fri Oct 13 10:07:10 2006 +0000
@@ -35,39 +35,11 @@
#
#------------------------------------------------------------------------------
-SUBDIRS = master/ devices/
+SUBDIRS = master devices script include
-initdir = $(sysconfdir)/init.d
-sysdir = $(sysconfdir)/sysconfig
+DIST_SUBDIRS = master devices script include examples
-include_HEADERS = include/ecdb.h include/ecrt.h
-noinst_SCRIPTS = script/lsec.pl script/ethercat.sh script/sysconfig
-
-MINI_FILES = \
- examples/mini/Kbuild \
- examples/mini/Makefile.am \
- examples/mini/Makefile.in \
- examples/mini/mini.c
-
-RTAI_FILES = \
- examples/rtai/Kbuild \
- examples/rtai/Makefile.am \
- examples/rtai/Makefile.in \
- examples/rtai/rtai_sample.c
-
-MSR_FILES = \
- examples/msr/Kbuild \
- examples/msr/libm.o_shipped \
- examples/msr/Makefile.am \
- examples/msr/Makefile.in \
- examples/msr/msr_load \
- examples/msr/msr_param.h \
- examples/msr/msr_sample.c \
- examples/msr/msrserv.pl \
- examples/msr/msr_unload
-
-EXTRA_DIST = $(noinst_SCRIPTS) documentation/ethercat_doc.pdf \
- $(MINI_FILES) $(RTAI_FILES) $(MSR_FILES)
+EXTRA_DIST = documentation/ethercat_doc.pdf
mydist:
@SVNREV=`svnversion $(srcdir)` && \
@@ -79,19 +51,7 @@
fi
install-data-local:
- $(mkinstalldirs) $(bindir)
- $(mkinstalldirs) $(initdir)
- $(mkinstalldirs) $(sysdir)
- $(INSTALL_SCRIPT) $(srcdir)/script/lsec.pl $(bindir)/lsec
- $(INSTALL_SCRIPT) $(srcdir)/script/ethercat.sh $(initdir)/ethercat
- $(INSTALL_DATA) $(srcdir)/script/sysconfig $(sysdir)/ethercat
- $(DEPMOD) $(LINUX_KERNEL_VERSION)
-
-uninstall-local:
- rm -rf $(LINUX_MODULES_DIR)/ethercat
- rm $(bindir)/lsec
- rm $(initdir)/ethercat
- rm $(sysdir)/ethercat
+ $(DEPMOD) -b "$(DESTDIR)" $(LINUX_KERNEL_VERSION)
doc:
doxygen Doxyfile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bootstrap Fri Oct 13 10:07:10 2006 +0000
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+set -x
+mkdir -p autoconf
+aclocal -I autoconf
+autoheader
+automake --add-missing
+autoconf
--- a/configure.ac Thu Sep 28 08:31:33 2006 +0000
+++ b/configure.ac Fri Oct 13 10:07:10 2006 +0000
@@ -2,13 +2,13 @@
# $Id$
#------------------------------------------------------------------------------
+AC_PREREQ(2.59)
AC_INIT([ethercat],[1.1],[fp@igh-essen.com])
+AC_CONFIG_AUX_DIR([autoconf])
AM_INIT_AUTOMAKE([-Wall -Werror foreign dist-bzip2])
AC_PREFIX_DEFAULT([/opt/etherlab])
-AC_CONFIG_FILES([Makefile master/Makefile devices/Makefile \
- examples/mini/Makefile \
- examples/rtai/Makefile \
- examples/msr/Makefile])
+AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_SRCDIR([config.h.in])
#------------------------------------------------------------------------------
# Linux sources
@@ -52,7 +52,39 @@
fi
#------------------------------------------------------------------------------
+# Debug interface
+#------------------------------------------------------------------------------
+AC_ARG_ENABLE([debug-if],
+ AS_HELP_STRING([--enable-dbg-if],
+ [Create a debug interface for each master @<:@NO@:>@]),
+ [case "${enableval}" in
+ yes) dbg=1
+ AC_DEFINE([EC_DBG_IF], [1], [Debug interfaces enabled])
+ ;;
+ no) dbg=0
+ ;;
+ *) AC_MSG_ERROR([Invalid value for --enable-dbg-if])
+ ;;
+ esac],
+ [dbg=0]
+)
+AM_CONDITIONAL(EC_DBG_IF, test "x$dbg" = x1)
+AC_SUBST([EC_DBG_IF],${dbg})
+
+#------------------------------------------------------------------------------
+
+AC_CONFIG_FILES([
+ Makefile
+ master/Makefile
+ devices/Makefile
+ script/Makefile
+ include/Makefile
+ examples/Makefile
+ examples/mini/Makefile
+ examples/rtai/Makefile
+ examples/msr/Makefile
+])
AC_OUTPUT
#------------------------------------------------------------------------------
--- a/devices/8139too.c Thu Sep 28 08:31:33 2006 +0000
+++ b/devices/8139too.c Fri Oct 13 10:07:10 2006 +0000
@@ -156,17 +156,17 @@
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
#include "ecdev.h"
+#include "../master/globals.h"
#define LIT(X) #X
#define STR(X) LIT(X)
-#define COMPILE_INFO "Revision " STR(EC_REV) \
- ", compiled by " STR(EC_USER) \
- " at " __DATE__ " " __TIME__
+#define RTL8139_DRIVER_NAME DRV_NAME \
+ " EtherCAT-capable Fast Ethernet driver " \
+ DRV_VERSION ", master " EC_MASTER_VERSION
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
-#define RTL8139_DRIVER_NAME DRV_NAME " Fast Ethernet driver " DRV_VERSION
#define PFX DRV_NAME ": "
/* Default Message level */
@@ -674,7 +674,7 @@
MODULE_AUTHOR("Florian Pose <fp@igh-essen.com>");
MODULE_DESCRIPTION("RealTek RTL-8139 EtherCAT driver");
MODULE_LICENSE("GPL");
-MODULE_VERSION(COMPILE_INFO);
+MODULE_VERSION(EC_MASTER_VERSION);
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
@@ -2900,7 +2900,7 @@
{
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
- printk(KERN_INFO RTL8139_DRIVER_NAME " " COMPILE_INFO "\n");
+ printk(KERN_INFO RTL8139_DRIVER_NAME "\n");
printk(KERN_INFO "ec_device_index is %i\n", ec_device_index);
if (pci_module_init(&rtl8139_pci_driver) < 0) {
--- a/devices/Kbuild Thu Sep 28 08:31:33 2006 +0000
+++ b/devices/Kbuild Fri Oct 13 10:07:10 2006 +0000
@@ -42,9 +42,9 @@
REV := $(shell if test -s $(src)/../svnrevision; then \
cat $(src)/../svnrevision; \
else \
- svnversion $(src) 2>/dev/null || echo "unknown"; \
+ svnversion $(src)/.. 2>/dev/null || echo "unknown"; \
fi)
-EXTRA_CFLAGS = -DEC_REV=$(REV) -DEC_USER=$(USER)
+EXTRA_CFLAGS = -DSVNREV=$(REV)
#------------------------------------------------------------------------------
--- a/devices/Makefile.am Thu Sep 28 08:31:33 2006 +0000
+++ b/devices/Makefile.am Fri Oct 13 10:07:10 2006 +0000
@@ -41,16 +41,15 @@
8139too.c \
original_8139too.c
-ABSSRCDIR = `cd $(srcdir) && pwd -P`
-
all:
- $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(ABSSRCDIR)" modules
+ $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" modules
clean-local:
- $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(ABSSRCDIR)" clean
+ $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" clean
install-data-local:
- $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(ABSSRCDIR)" \
+ $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" \
+ INSTALL_MOD_PATH="$(DESTDIR)" \
INSTALL_MOD_DIR="ethercat" modules_install
#------------------------------------------------------------------------------
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/Makefile.am Fri Oct 13 10:07:10 2006 +0000
@@ -0,0 +1,40 @@
+#------------------------------------------------------------------------------
+#
+# Makefile.am
+#
+# IgH EtherCAT master
+#
+# $Id: Makefile.am 581 2006-10-09 14:47:48Z fp $
+#
+# 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.
+#
+#------------------------------------------------------------------------------
+
+DIST_SUBDIRS = mini rtai msr
+
+#------------------------------------------------------------------------------
--- a/examples/mini/Makefile.am Thu Sep 28 08:31:33 2006 +0000
+++ b/examples/mini/Makefile.am Fri Oct 13 10:07:10 2006 +0000
@@ -35,16 +35,17 @@
#
#------------------------------------------------------------------------------
-ABSSRCDIR = `cd $(srcdir) && pwd -P`
+EXTRA_DIST = Kbuild mini.c
all:
- $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(ABSSRCDIR)" modules
+ $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" modules
clean-local:
- $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(ABSSRCDIR)" clean
+ $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" clean
install-data-local:
- $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(ABSSRCDIR)" \
+ $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" \
+ INSTALL_MOD_PATH="$(DESTDIR)" \
INSTALL_MOD_DIR="ethercat" modules_install
#------------------------------------------------------------------------------
--- a/examples/msr/Makefile.am Thu Sep 28 08:31:33 2006 +0000
+++ b/examples/msr/Makefile.am Fri Oct 13 10:07:10 2006 +0000
@@ -37,21 +37,22 @@
EXTRA_DIST = \
Kbuild \
- msr_sample.c msr_param.h \
libm.o_shipped \
- msr_load msr_unload \
+ msr_load \
+ msr_unload \
+ msr_param.h \
+ msr_sample.c \
msrserv.pl
-ABSSRCDIR = `cd $(srcdir) && pwd -P`
-
all:
- $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(ABSSRCDIR)" modules
+ $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" modules
clean-local:
- $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(ABSSRCDIR)" clean
+ $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" clean
install-data-local:
- $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(ABSSRCDIR)" \
+ $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" \
+ INSTALL_MOD_PATH="$(DESTDIR)" \
INSTALL_MOD_DIR="ethercat" modules_install
#------------------------------------------------------------------------------
--- a/examples/rtai/Makefile.am Thu Sep 28 08:31:33 2006 +0000
+++ b/examples/rtai/Makefile.am Fri Oct 13 10:07:10 2006 +0000
@@ -37,16 +37,15 @@
EXTRA_DIST = Kbuild rtai_sample.c
-ABSSRCDIR = `cd $(srcdir) && pwd -P`
-
all:
- $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(ABSSRCDIR)" modules
+ $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" modules
clean-local:
- $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(ABSSRCDIR)" clean
+ $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" clean
install-data-local:
- $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(ABSSRCDIR)" \
+ $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" \
+ INSTALL_MOD_PATH="$(DESTDIR)" \
INSTALL_MOD_DIR="ethercat" modules_install
#------------------------------------------------------------------------------
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/include/Makefile.am Fri Oct 13 10:07:10 2006 +0000
@@ -0,0 +1,40 @@
+#------------------------------------------------------------------------------
+#
+# Makefile.am
+#
+# IgH EtherCAT master
+#
+# $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.
+#
+#------------------------------------------------------------------------------
+
+include_HEADERS = ecdb.h ecrt.h
+
+#------------------------------------------------------------------------------
--- a/include/ecdb.h Thu Sep 28 08:31:33 2006 +0000
+++ b/include/ecdb.h Fri Oct 13 10:07:10 2006 +0000
@@ -54,14 +54,19 @@
#define Beckhoff_EL2032_Outputs 0x00000002, 0x07F03052, 0x3001, 1
#define Beckhoff_EL3102_Status1 0x00000002, 0x0C1E3052, 0x3101, 1
-#define Beckhoff_EL3102_Input1 0x00000002, 0x0C1E3052, 0x3101, 2
+#define Beckhoff_EL3102_Input1 0x00000002, 0x0C1E3052, 0x3101, 2
#define Beckhoff_EL3102_Status2 0x00000002, 0x0C1E3052, 0x3102, 1
-#define Beckhoff_EL3102_Input2 0x00000002, 0x0C1E3052, 0x3102, 2
+#define Beckhoff_EL3102_Input2 0x00000002, 0x0C1E3052, 0x3102, 2
+
+#define Beckhoff_EL3152_Status1 0x00000002, 0x0C503052, 0x3101, 1
+#define Beckhoff_EL3152_Input1 0x00000002, 0x0C503052, 0x3101, 2
+#define Beckhoff_EL3152_Status2 0x00000002, 0x0C503052, 0x3102, 1
+#define Beckhoff_EL3152_Input2 0x00000002, 0x0C503052, 0x3102, 2
#define Beckhoff_EL3162_Status1 0x00000002, 0x0C5A3052, 0x3101, 1
-#define Beckhoff_EL3162_Input1 0x00000002, 0x0C5A3052, 0x3101, 2
+#define Beckhoff_EL3162_Input1 0x00000002, 0x0C5A3052, 0x3101, 2
#define Beckhoff_EL3162_Status2 0x00000002, 0x0C5A3052, 0x3102, 1
-#define Beckhoff_EL3162_Input2 0x00000002, 0x0C5A3052, 0x3102, 2
+#define Beckhoff_EL3162_Input2 0x00000002, 0x0C5A3052, 0x3102, 2
#define Beckhoff_EL4102_Output1 0x00000002, 0x10063052, 0x6411, 1
#define Beckhoff_EL4102_Output2 0x00000002, 0x10063052, 0x6411, 2
@@ -72,7 +77,14 @@
#define Beckhoff_EL5001_Status 0x00000002, 0x13893052, 0x3101, 1
#define Beckhoff_EL5001_Value 0x00000002, 0x13893052, 0x3101, 2
-#define Beckhoff_EL5101_Value 0x00000002, 0x13ED3052, 0x6000, 2
+#define Beckhoff_EL5101_Status 0x00000002, 0x13ED3052, 0x6000, 1
+#define Beckhoff_EL5101_Value 0x00000002, 0x13ED3052, 0x6000, 2
+#define Beckhoff_EL5101_Latch 0x00000002, 0x13ED3052, 0x6000, 3
+#define Beckhoff_EL5101_Frequency 0x00000002, 0x13ED3052, 0x6000, 4
+#define Beckhoff_EL5101_Period 0x00000002, 0x13ED3052, 0x6000, 5
+#define Beckhoff_EL5101_Window 0x00000002, 0x13ED3052, 0x6000, 6
+#define Beckhoff_EL5101_Ctrl 0x00000002, 0x13ED3052, 0x7000, 1
+#define Beckhoff_EL5101_OutputValue 0x00000002, 0x13ED3052, 0x7000, 2
/** \endcond */
--- a/master/Kbuild Thu Sep 28 08:31:33 2006 +0000
+++ b/master/Kbuild Fri Oct 13 10:07:10 2006 +0000
@@ -38,15 +38,19 @@
obj-m := ec_master.o
ec_master-objs := module.o master.o device.o slave.o datagram.o \
- domain.o mailbox.o ethernet.o debug.o fsm.o
+ domain.o mailbox.o ethernet.o fsm.o
# xmldev.o
+ifeq ($(EC_DBG_IF),1)
+ ec_master-objs += debug.o
+endif
+
REV := $(shell if test -s $(src)/../svnrevision; then \
cat $(src)/../svnrevision; \
else \
svnversion $(src) 2>/dev/null || echo "unknown"; \
fi)
-EXTRA_CFLAGS := -DSVNREV=$(REV) -DUSER=$(USER)
+EXTRA_CFLAGS := -DSVNREV=$(REV)
#------------------------------------------------------------------------------
--- a/master/Makefile.am Thu Sep 28 08:31:33 2006 +0000
+++ b/master/Makefile.am Fri Oct 13 10:07:10 2006 +0000
@@ -51,16 +51,16 @@
slave.c slave.h
# xmldev.c xmldev.h
-ABSSRCDIR = `cd $(srcdir) && pwd -P`
-
all:
- $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(ABSSRCDIR)" modules
+ $(MAKE) -C "$(LINUX_SOURCE_DIR)" \
+ M="@abs_srcdir@" EC_DBG_IF="$(EC_DBG_IF)" modules
clean-local:
- $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(ABSSRCDIR)" clean
+ $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" clean
install-data-local:
- $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(ABSSRCDIR)" \
+ $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" \
+ INSTALL_MOD_PATH="$(DESTDIR)" \
INSTALL_MOD_DIR="ethercat" modules_install
#------------------------------------------------------------------------------
--- a/master/device.c Thu Sep 28 08:31:33 2006 +0000
+++ b/master/device.c Fri Oct 13 10:07:10 2006 +0000
@@ -71,14 +71,20 @@
device->open = 0;
device->link_state = 0; // down
+#ifdef EC_DBG_IF
if (ec_debug_init(&device->dbg)) {
EC_ERR("Failed to init debug device!\n");
goto out_return;
}
+#endif
if (!(device->tx_skb = dev_alloc_skb(ETH_FRAME_LEN))) {
EC_ERR("Error allocating device socket buffer!\n");
+#ifdef EC_DBG_IF
goto out_debug;
+#else
+ goto out_return;
+#endif
}
device->tx_skb->dev = net_dev;
@@ -92,8 +98,10 @@
return 0;
+#ifdef EC_DBG_IF
out_debug:
ec_debug_clear(&device->dbg);
+#endif
out_return:
return -1;
}
@@ -108,7 +116,9 @@
{
if (device->open) ec_device_close(device);
if (device->tx_skb) dev_kfree_skb(device->tx_skb);
+#ifdef EC_DBG_IF
ec_debug_clear(&device->dbg);
+#endif
}
/*****************************************************************************/
@@ -201,7 +211,9 @@
ec_print_data(device->tx_skb->data + ETH_HLEN, size);
}
+#ifdef EC_DBG_IF
ec_debug_send(&device->dbg, device->tx_skb->data, ETH_HLEN + size);
+#endif
// start sending
device->dev->hard_start_xmit(device->tx_skb, device->dev);
@@ -243,7 +255,9 @@
data + ETH_HLEN, size - ETH_HLEN);
}
+#ifdef EC_DBG_IF
ec_debug_send(&device->dbg, data, size);
+#endif
ec_master_receive_datagrams(device->master,
data + ETH_HLEN,
--- a/master/device.h Thu Sep 28 08:31:33 2006 +0000
+++ b/master/device.h Fri Oct 13 10:07:10 2006 +0000
@@ -46,7 +46,10 @@
#include "../include/ecrt.h"
#include "../devices/ecdev.h"
#include "globals.h"
+
+#ifdef EC_DBG_IF
#include "debug.h"
+#endif
/*****************************************************************************/
@@ -65,7 +68,9 @@
ec_isr_t isr; /**< pointer to the device's interrupt service routine */
struct module *module; /**< pointer to the device's owning module */
uint8_t link_state; /**< device link state */
+#ifdef EC_DBG_IF
ec_debug_t dbg; /**< debug device */
+#endif
};
/*****************************************************************************/
--- a/master/ethernet.c Thu Sep 28 08:31:33 2006 +0000
+++ b/master/ethernet.c Fri Oct 13 10:07:10 2006 +0000
@@ -362,7 +362,7 @@
void ec_eoe_state_rx_fetch(ec_eoe_t *eoe /**< EoE handler */)
{
size_t rec_size, data_size;
- uint8_t *data, frame_type, last_fragment, time_appended;
+ uint8_t *data, frame_type, last_fragment, time_appended, mbox_prot;
uint8_t frame_number, fragment_offset, fragment_number;
off_t offset;
#if EOE_DEBUG_LEVEL > 1
@@ -376,7 +376,13 @@
}
if (!(data = ec_slave_mbox_fetch(eoe->slave, &eoe->datagram,
- 0x02, &rec_size))) {
+ &mbox_prot, &rec_size))) {
+ eoe->stats.rx_errors++;
+ eoe->state = ec_eoe_state_tx_start;
+ return;
+ }
+
+ if (mbox_prot != 0x02) { // EoE
eoe->stats.rx_errors++;
eoe->state = ec_eoe_state_tx_start;
return;
--- a/master/fsm.c Thu Sep 28 08:31:33 2006 +0000
+++ b/master/fsm.c Fri Oct 13 10:07:10 2006 +0000
@@ -2064,7 +2064,7 @@
EC_WRITE_U16(data + 3, sdodata->index);
EC_WRITE_U8 (data + 5, sdodata->subindex);
EC_WRITE_U32(data + 6, sdodata->size);
- memcpy(data + 6, sdodata->data, sdodata->size);
+ memcpy(data + 10, sdodata->data, sdodata->size);
ec_master_queue_datagram(fsm->master, datagram);
fsm->coe_state = ec_fsm_coe_down_request;
@@ -2142,7 +2142,7 @@
{
ec_datagram_t *datagram = &fsm->datagram;
ec_slave_t *slave = fsm->slave;
- uint8_t *data;
+ uint8_t *data, mbox_prot;
size_t rec_size;
ec_sdo_data_t *sdodata = fsm->sdodata;
@@ -2153,11 +2153,18 @@
return;
}
- if (!(data = ec_slave_mbox_fetch(slave, datagram, 0x03, &rec_size))) {
+ if (!(data = ec_slave_mbox_fetch(slave, datagram,
+ &mbox_prot, &rec_size))) {
fsm->coe_state = ec_fsm_error;
return;
}
+ if (mbox_prot != 0x03) { // CoE
+ EC_WARN("Received mailbox protocol 0x%02X as response.\n", mbox_prot);
+ fsm->coe_state = ec_fsm_error;
+ return;
+ }
+
if (rec_size < 6) {
fsm->coe_state = ec_fsm_error;
EC_ERR("Received data is too small (%i bytes):\n", rec_size);
--- a/master/globals.h Thu Sep 28 08:31:33 2006 +0000
+++ b/master/globals.h Fri Oct 13 10:07:10 2006 +0000
@@ -43,6 +43,8 @@
#include <linux/types.h>
+#include "../config.h"
+
/******************************************************************************
* EtherCAT master
*****************************************************************************/
@@ -58,12 +60,10 @@
/** Compile version info. */
-#define EC_COMPILE_INFO EC_STR(EC_MASTER_VERSION_MAIN) \
- "." EC_STR(EC_MASTER_VERSION_SUB) \
- " (" EC_MASTER_VERSION_EXTRA ")" \
- " - rev. " EC_STR(SVNREV) \
- ", compiled by " EC_STR(USER) \
- " at " __DATE__ " " __TIME__
+#define EC_MASTER_VERSION EC_STR(EC_MASTER_VERSION_MAIN) \
+ "." EC_STR(EC_MASTER_VERSION_SUB) \
+ " " EC_MASTER_VERSION_EXTRA \
+ " r" EC_STR(SVNREV)
/** maximum number of FMMUs per slave */
#define EC_MAX_FMMUS 16
--- a/master/mailbox.c Thu Sep 28 08:31:33 2006 +0000
+++ b/master/mailbox.c Fri Oct 13 10:07:10 2006 +0000
@@ -135,32 +135,63 @@
/*****************************************************************************/
/**
+ Mailbox error codes.
+*/
+
+const ec_code_msg_t mbox_error_messages[] = {
+ {0x00000001, "MBXERR_SYNTAX"},
+ {0x00000002, "MBXERR_UNSUPPORTEDPROTOCOL"},
+ {0x00000003, "MBXERR_INVAILDCHANNEL"},
+ {0x00000004, "MBXERR_SERVICENOTSUPPORTED"},
+ {0x00000005, "MBXERR_INVALIDHEADER"},
+ {0x00000006, "MBXERR_SIZETOOSHORT"},
+ {0x00000007, "MBXERR_NOMOREMEMORY"},
+ {0x00000008, "MBXERR_INVALIDSIZE"},
+ {}
+};
+
+/*****************************************************************************/
+
+/**
Processes received mailbox data.
\return pointer to the received data
*/
uint8_t *ec_slave_mbox_fetch(const ec_slave_t *slave, /**< slave */
ec_datagram_t *datagram, /**< datagram */
- uint8_t type, /**< expected mailbox protocol */
+ uint8_t *type, /**< expected mailbox protocol */
size_t *size /**< size of the received data */
)
{
size_t data_size;
- if ((EC_READ_U8(datagram->data + 5) & 0x0F) != type) {
- EC_ERR("Unexpected mailbox protocol 0x%02X (exp.: 0x%02X) at"
- " slave %i!\n", EC_READ_U8(datagram->data + 5), type,
- slave->ring_position);
+ if ((data_size = EC_READ_U16(datagram->data)) >
+ slave->sii_tx_mailbox_size - 6) {
+ EC_ERR("Corrupt mailbox response detected!\n");
return NULL;
}
- if ((data_size = EC_READ_U16(datagram->data)) >
- slave->sii_tx_mailbox_size - 6) {
- EC_ERR("Currupt mailbox response detected!\n");
+ *type = EC_READ_U8(datagram->data + 5) & 0x0F;
+ *size = data_size;
+
+ if (*type == 0x00) {
+ const ec_code_msg_t *mbox_msg;
+ uint16_t code = EC_READ_U16(datagram->data + 8);
+
+ EC_ERR("Mailbox error response received.\n");
+ for (mbox_msg = mbox_error_messages; mbox_msg->code; mbox_msg++) {
+ if (mbox_msg->code != code) continue;
+ EC_ERR("Error reply code: 0x%04X: \"%s\".\n",
+ mbox_msg->code, mbox_msg->message);
+ break;
+ }
+
+ if (!mbox_msg->code)
+ EC_ERR("Unknown error reply code 0x%04X.\n", code);
+
return NULL;
}
- *size = data_size;
return datagram->data + 6;
}
--- a/master/mailbox.h Thu Sep 28 08:31:33 2006 +0000
+++ b/master/mailbox.h Fri Oct 13 10:07:10 2006 +0000
@@ -51,7 +51,7 @@
int ec_slave_mbox_check(const ec_datagram_t *);
int ec_slave_mbox_prepare_fetch(const ec_slave_t *, ec_datagram_t *);
uint8_t *ec_slave_mbox_fetch(const ec_slave_t *, ec_datagram_t *,
- uint8_t, size_t *);
+ uint8_t *, size_t *);
/*****************************************************************************/
--- a/master/master.c Thu Sep 28 08:31:33 2006 +0000
+++ b/master/master.c Fri Oct 13 10:07:10 2006 +0000
@@ -108,6 +108,7 @@
master->index = index;
master->device = NULL;
+ init_MUTEX(&master->device_sem);
atomic_set(&master->available, 1);
INIT_LIST_HEAD(&master->slaves);
INIT_LIST_HEAD(&master->datagram_queue);
@@ -705,7 +706,7 @@
ec_eoe_t *eoe;
uint32_t cur, sum, min, max, pos, i;
- off += sprintf(buffer + off, "\nVersion: " EC_COMPILE_INFO);
+ off += sprintf(buffer + off, "\nVersion: " EC_MASTER_VERSION);
off += sprintf(buffer + off, "\nMode: ");
switch (master->mode) {
case EC_MASTER_MODE_ORPHANED:
--- a/master/master.h Thu Sep 28 08:31:33 2006 +0000
+++ b/master/master.h Fri Oct 13 10:07:10 2006 +0000
@@ -45,6 +45,7 @@
#include <linux/sysfs.h>
#include <linux/timer.h>
#include <asm/atomic.h>
+#include <asm/semaphore.h>
#include "device.h"
#include "domain.h"
@@ -98,6 +99,7 @@
struct kobject kobj; /**< kobject */
ec_device_t *device; /**< EtherCAT device */
+ struct semaphore device_sem; /**< device semaphore */
ec_fsm_t fsm; /**< master state machine */
ec_master_mode_t mode; /**< master mode */
--- a/master/module.c Thu Sep 28 08:31:33 2006 +0000
+++ b/master/module.c Fri Oct 13 10:07:10 2006 +0000
@@ -67,7 +67,7 @@
MODULE_AUTHOR("Florian Pose <fp@igh-essen.com>");
MODULE_DESCRIPTION("EtherCAT master driver module");
MODULE_LICENSE("GPL");
-MODULE_VERSION(EC_COMPILE_INFO);
+MODULE_VERSION(EC_MASTER_VERSION);
MODULE_PARM_DESC(ec_master_count, "number of EtherCAT masters to initialize");
MODULE_PARM_DESC(ec_eoeif_count, "number of EoE interfaces per master");
@@ -86,7 +86,7 @@
unsigned int i;
ec_master_t *master, *next;
- EC_INFO("Master driver, %s\n", EC_COMPILE_INFO);
+ EC_INFO("Master driver %s\n", EC_MASTER_VERSION);
if (ec_master_count < 1) {
EC_ERR("Error - Invalid ec_master_count: %i\n", ec_master_count);
@@ -282,15 +282,20 @@
if (!(master = ec_find_master(master_index))) return NULL;
+ if (down_interruptible(&master->device_sem)) {
+ EC_ERR("Interrupted while waiting for device!\n");
+ goto out_return;
+ }
+
if (master->device) {
EC_ERR("Master %i already has a device!\n", master_index);
- goto out_return;
+ goto out_up;
}
if (!(master->device =
(ec_device_t *) kmalloc(sizeof(ec_device_t), GFP_KERNEL))) {
EC_ERR("Failed to allocate device!\n");
- goto out_return;
+ goto out_up;
}
if (ec_device_init(master->device, master, net_dev, isr, module)) {
@@ -298,11 +303,14 @@
goto out_free;
}
+ up(&master->device_sem);
return master->device;
out_free:
kfree(master->device);
master->device = NULL;
+ out_up:
+ up(&master->device_sem);
out_return:
return NULL;
}
@@ -326,7 +334,10 @@
if (!(master = ec_find_master(master_index))) return;
+ down(&master->device_sem);
+
if (!master->device || master->device != device) {
+ up(&master->device_sem);
EC_WARN("Unable to unregister device!\n");
return;
}
@@ -334,6 +345,8 @@
ec_device_clear(master->device);
kfree(master->device);
master->device = NULL;
+
+ up(&master->device_sem);
}
/*****************************************************************************/
@@ -356,7 +369,6 @@
return -1;
}
- ec_master_measure_bus_time(master);
ec_master_idle_start(master);
return 0;
}
@@ -407,16 +419,25 @@
goto out_return;
}
+ if (down_interruptible(&master->device_sem)) {
+ EC_ERR("Interrupted while waiting for device!\n");
+ goto out_release;
+ }
+
if (!master->device) {
+ up(&master->device_sem);
EC_ERR("Master %i has no assigned device!\n", master_index);
goto out_release;
}
- if (!try_module_get(master->device->module)) { // possible race?
- EC_ERR("Failed to reserve device module!\n");
+ if (!try_module_get(master->device->module)) {
+ up(&master->device_sem);
+ EC_ERR("Device module is unloading!\n");
goto out_release;
}
+ up(&master->device_sem);
+
if (!master->device->link_state) {
EC_ERR("Link is DOWN.\n");
goto out_module_put;
--- a/master/slave.c Thu Sep 28 08:31:33 2006 +0000
+++ b/master/slave.c Fri Oct 13 10:07:10 2006 +0000
@@ -867,6 +867,18 @@
/*****************************************************************************/
/**
+ \return non-zero if slave is a bus coupler
+*/
+
+int ec_slave_has_subbus(const ec_slave_t *slave /**< EtherCAT slave */)
+{
+ return slave->sii_vendor_id == 0x00000002
+ && slave->sii_product_code == 0x13ED3052;
+}
+
+/*****************************************************************************/
+
+/**
\return 0 in case of success, else < 0
*/
--- a/master/slave.h Thu Sep 28 08:31:33 2006 +0000
+++ b/master/slave.h Fri Oct 13 10:07:10 2006 +0000
@@ -334,6 +334,7 @@
const ec_sii_sync_t *);
int ec_slave_is_coupler(const ec_slave_t *);
+int ec_slave_has_subbus(const ec_slave_t *);
/*****************************************************************************/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/script/Makefile.am Fri Oct 13 10:07:10 2006 +0000
@@ -0,0 +1,53 @@
+#------------------------------------------------------------------------------
+#
+# Makefile.am
+#
+# IgH EtherCAT master
+#
+# $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.
+#
+#------------------------------------------------------------------------------
+
+initdir = $(sysconfdir)/init.d
+sysdir = $(sysconfdir)/sysconfig
+
+bin_SCRIPTS = lsec
+init_SCRIPTS = ethercat
+sys_DATA = sysconfig
+
+EXTRA_DIST = lsec.pl ethercat.sh sysconfig
+
+lsec: lsec.pl
+ cp $(srcdir)/lsec.pl lsec
+
+ethercat: ethercat.sh
+ cp $(srcdir)/ethercat.sh ethercat
+
+#------------------------------------------------------------------------------