Skip to content
Snippets Groups Projects
Commit 38178795 authored by Florian Pose's avatar Florian Pose
Browse files

Debug interfaces not compiled by default.

parent 2ddf504a
No related branches found
No related tags found
No related merge requests found
...@@ -3,5 +3,6 @@ ...@@ -3,5 +3,6 @@
set -x set -x
mkdir -p autoconf mkdir -p autoconf
aclocal -I autoconf aclocal -I autoconf
autoheader
automake --add-missing automake --add-missing
autoconf autoconf
...@@ -2,10 +2,13 @@ ...@@ -2,10 +2,13 @@
# $Id$ # $Id$
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
AC_PREREQ(2.59)
AC_INIT([ethercat],[1.1],[fp@igh-essen.com]) AC_INIT([ethercat],[1.1],[fp@igh-essen.com])
AC_CONFIG_AUX_DIR([autoconf]) AC_CONFIG_AUX_DIR([autoconf])
AC_PREFIX_DEFAULT([/opt/etherlab])
AM_INIT_AUTOMAKE([-Wall -Werror foreign dist-bzip2]) 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 # Linux sources
...@@ -48,12 +51,33 @@ if test -z "$DEPMOD"; then ...@@ -48,12 +51,33 @@ if test -z "$DEPMOD"; then
AC_MSG_WARN([depmod was not found!]); AC_MSG_WARN([depmod was not found!]);
fi 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([ AC_CONFIG_FILES([
Makefile Makefile
master/Makefile master/Makefile
devices/Makefile devices/Makefile
script/Makefile script/Makefile
include/Makefile include/Makefile
examples/mini/Makefile examples/mini/Makefile
......
...@@ -38,7 +38,11 @@ ...@@ -38,7 +38,11 @@
obj-m := ec_master.o obj-m := ec_master.o
ec_master-objs := module.o master.o device.o slave.o datagram.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 \ REV := $(shell if test -s $(src)/../svnrevision; then \
cat $(src)/../svnrevision; \ cat $(src)/../svnrevision; \
......
...@@ -52,7 +52,8 @@ EXTRA_DIST = \ ...@@ -52,7 +52,8 @@ EXTRA_DIST = \
xmldev.c xmldev.h xmldev.c xmldev.h
all: 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: clean-local:
$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" clean $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" clean
......
...@@ -71,14 +71,20 @@ int ec_device_init(ec_device_t *device, /**< EtherCAT device */ ...@@ -71,14 +71,20 @@ int ec_device_init(ec_device_t *device, /**< EtherCAT device */
device->open = 0; device->open = 0;
device->link_state = 0; // down device->link_state = 0; // down
#ifdef EC_DBG_IF
if (ec_debug_init(&device->dbg)) { if (ec_debug_init(&device->dbg)) {
EC_ERR("Failed to init debug device!\n"); EC_ERR("Failed to init debug device!\n");
goto out_return; goto out_return;
} }
#endif
if (!(device->tx_skb = dev_alloc_skb(ETH_FRAME_LEN))) { if (!(device->tx_skb = dev_alloc_skb(ETH_FRAME_LEN))) {
EC_ERR("Error allocating device socket buffer!\n"); EC_ERR("Error allocating device socket buffer!\n");
#ifdef EC_DBG_IF
goto out_debug; goto out_debug;
#else
goto out_return;
#endif
} }
device->tx_skb->dev = net_dev; device->tx_skb->dev = net_dev;
...@@ -92,8 +98,10 @@ int ec_device_init(ec_device_t *device, /**< EtherCAT device */ ...@@ -92,8 +98,10 @@ int ec_device_init(ec_device_t *device, /**< EtherCAT device */
return 0; return 0;
#ifdef EC_DBG_IF
out_debug: out_debug:
ec_debug_clear(&device->dbg); ec_debug_clear(&device->dbg);
#endif
out_return: out_return:
return -1; return -1;
} }
...@@ -108,7 +116,9 @@ void ec_device_clear(ec_device_t *device /**< EtherCAT device */) ...@@ -108,7 +116,9 @@ void ec_device_clear(ec_device_t *device /**< EtherCAT device */)
{ {
if (device->open) ec_device_close(device); if (device->open) ec_device_close(device);
if (device->tx_skb) dev_kfree_skb(device->tx_skb); if (device->tx_skb) dev_kfree_skb(device->tx_skb);
#ifdef EC_DBG_IF
ec_debug_clear(&device->dbg); ec_debug_clear(&device->dbg);
#endif
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -201,7 +211,9 @@ void ec_device_send(ec_device_t *device, /**< EtherCAT device */ ...@@ -201,7 +211,9 @@ void ec_device_send(ec_device_t *device, /**< EtherCAT device */
ec_print_data(device->tx_skb->data + ETH_HLEN, size); 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); ec_debug_send(&device->dbg, device->tx_skb->data, ETH_HLEN + size);
#endif
// start sending // start sending
device->dev->hard_start_xmit(device->tx_skb, device->dev); device->dev->hard_start_xmit(device->tx_skb, device->dev);
...@@ -243,7 +255,9 @@ void ecdev_receive(ec_device_t *device, /**< EtherCAT device */ ...@@ -243,7 +255,9 @@ void ecdev_receive(ec_device_t *device, /**< EtherCAT device */
data + ETH_HLEN, size - ETH_HLEN); data + ETH_HLEN, size - ETH_HLEN);
} }
#ifdef EC_DBG_IF
ec_debug_send(&device->dbg, data, size); ec_debug_send(&device->dbg, data, size);
#endif
ec_master_receive_datagrams(device->master, ec_master_receive_datagrams(device->master,
data + ETH_HLEN, data + ETH_HLEN,
......
...@@ -46,7 +46,10 @@ ...@@ -46,7 +46,10 @@
#include "../include/ecrt.h" #include "../include/ecrt.h"
#include "../devices/ecdev.h" #include "../devices/ecdev.h"
#include "globals.h" #include "globals.h"
#ifdef EC_DBG_IF
#include "debug.h" #include "debug.h"
#endif
/*****************************************************************************/ /*****************************************************************************/
...@@ -65,7 +68,9 @@ struct ec_device ...@@ -65,7 +68,9 @@ struct ec_device
ec_isr_t isr; /**< pointer to the device's interrupt service routine */ ec_isr_t isr; /**< pointer to the device's interrupt service routine */
struct module *module; /**< pointer to the device's owning module */ struct module *module; /**< pointer to the device's owning module */
uint8_t link_state; /**< device link state */ uint8_t link_state; /**< device link state */
#ifdef EC_DBG_IF
ec_debug_t dbg; /**< debug device */ ec_debug_t dbg; /**< debug device */
#endif
}; };
/*****************************************************************************/ /*****************************************************************************/
......
...@@ -43,6 +43,8 @@ ...@@ -43,6 +43,8 @@
#include <linux/types.h> #include <linux/types.h>
#include "../config.h"
/****************************************************************************** /******************************************************************************
* EtherCAT master * EtherCAT master
*****************************************************************************/ *****************************************************************************/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment