From 38178795abb0c9ddc6a04c26ba999059e309d617 Mon Sep 17 00:00:00 2001 From: Florian Pose <fp@igh-essen.com> Date: Fri, 13 Oct 2006 09:38:23 +0000 Subject: [PATCH] Debug interfaces not compiled by default. --- bootstrap | 1 + configure.ac | 32 ++++++++++++++++++++++++++++---- master/Kbuild | 6 +++++- master/Makefile.am | 3 ++- master/device.c | 14 ++++++++++++++ master/device.h | 5 +++++ master/globals.h | 2 ++ 7 files changed, 57 insertions(+), 6 deletions(-) diff --git a/bootstrap b/bootstrap index 56423768..9234fbf9 100755 --- a/bootstrap +++ b/bootstrap @@ -3,5 +3,6 @@ set -x mkdir -p autoconf aclocal -I autoconf +autoheader automake --add-missing autoconf diff --git a/configure.ac b/configure.ac index 6126815a..d4dd3d66 100644 --- a/configure.ac +++ b/configure.ac @@ -2,10 +2,13 @@ # $Id$ #------------------------------------------------------------------------------ +AC_PREREQ(2.59) AC_INIT([ethercat],[1.1],[fp@igh-essen.com]) AC_CONFIG_AUX_DIR([autoconf]) -AC_PREFIX_DEFAULT([/opt/etherlab]) AM_INIT_AUTOMAKE([-Wall -Werror foreign dist-bzip2]) +AC_PREFIX_DEFAULT([/opt/etherlab]) +AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_SRCDIR([config.h.in]) #------------------------------------------------------------------------------ # Linux sources @@ -48,12 +51,33 @@ if test -z "$DEPMOD"; then AC_MSG_WARN([depmod was not found!]); 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 + Makefile + master/Makefile + devices/Makefile script/Makefile include/Makefile examples/mini/Makefile diff --git a/master/Kbuild b/master/Kbuild index c489bcfa..3e4b3b3e 100644 --- a/master/Kbuild +++ b/master/Kbuild @@ -38,7 +38,11 @@ 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 xmldev.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; \ diff --git a/master/Makefile.am b/master/Makefile.am index bad227ae..f1c8f06a 100644 --- a/master/Makefile.am +++ b/master/Makefile.am @@ -52,7 +52,8 @@ EXTRA_DIST = \ xmldev.c xmldev.h all: - $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" modules + $(MAKE) -C "$(LINUX_SOURCE_DIR)" \ + M="@abs_srcdir@" EC_DBG_IF="$(EC_DBG_IF)" modules clean-local: $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" clean diff --git a/master/device.c b/master/device.c index c38cfc12..5f681b5f 100644 --- a/master/device.c +++ b/master/device.c @@ -71,14 +71,20 @@ int ec_device_init(ec_device_t *device, /**< EtherCAT device */ 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 @@ int ec_device_init(ec_device_t *device, /**< EtherCAT device */ return 0; +#ifdef EC_DBG_IF out_debug: ec_debug_clear(&device->dbg); +#endif out_return: return -1; } @@ -108,7 +116,9 @@ void ec_device_clear(ec_device_t *device /**< EtherCAT device */) { 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 @@ void ec_device_send(ec_device_t *device, /**< EtherCAT device */ 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 @@ void ecdev_receive(ec_device_t *device, /**< EtherCAT device */ 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, diff --git a/master/device.h b/master/device.h index 3ab41d85..90291bd1 100644 --- a/master/device.h +++ b/master/device.h @@ -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 @@ struct ec_device 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 }; /*****************************************************************************/ diff --git a/master/globals.h b/master/globals.h index 488577a4..7d678991 100644 --- a/master/globals.h +++ b/master/globals.h @@ -43,6 +43,8 @@ #include <linux/types.h> +#include "../config.h" + /****************************************************************************** * EtherCAT master *****************************************************************************/ -- GitLab