# HG changeset patch # User Florian Pose # Date 1181149358 0 # Node ID a9794f927d781f8030deaa995b79d2000aaa63da # Parent 18c48cb7de06ea1df907145c97c6574ef94280c9 Added dummy module for simulation purposes. diff -r 18c48cb7de06 -r a9794f927d78 Kbuild --- a/Kbuild Thu May 03 14:29:21 2007 +0000 +++ b/Kbuild Wed Jun 06 17:02:38 2007 +0000 @@ -31,6 +31,6 @@ # #------------------------------------------------------------------------------ -obj-m := master/ devices/ +obj-m := master/ devices/ dummy/ #------------------------------------------------------------------------------ diff -r 18c48cb7de06 -r a9794f927d78 Makefile.am --- a/Makefile.am Thu May 03 14:29:21 2007 +0000 +++ b/Makefile.am Wed Jun 06 17:02:38 2007 +0000 @@ -31,9 +31,9 @@ # #------------------------------------------------------------------------------ -SUBDIRS = master devices script include +SUBDIRS = master devices script include dummy -DIST_SUBDIRS = master devices script include examples +DIST_SUBDIRS = master devices script include examples dummy EXTRA_DIST = \ Doxyfile \ @@ -47,6 +47,7 @@ modules_install: $(MAKE) -C master modules_install $(MAKE) -C devices modules_install + $(MAKE) -C dummy modules_install clean-local: $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" clean diff -r 18c48cb7de06 -r a9794f927d78 NEWS --- a/NEWS Thu May 03 14:29:21 2007 +0000 +++ b/NEWS Wed Jun 06 17:02:38 2007 +0000 @@ -43,6 +43,7 @@ state machine. * Master state machine scheduled with timeout if idle, otherwise is executed as fast as possible (with schedule()). +* Added dummy module for simulation purpuses. * Removed EtherCAT line comments from 8139too drivers. ------------------------------------------------------------------------------- diff -r 18c48cb7de06 -r a9794f927d78 configure.ac --- a/configure.ac Thu May 03 14:29:21 2007 +0000 +++ b/configure.ac Wed Jun 06 17:02:38 2007 +0000 @@ -347,6 +347,7 @@ examples/mini/Makefile examples/rtai/Makefile examples/msr/Makefile + dummy/Makefile ]) AC_OUTPUT diff -r 18c48cb7de06 -r a9794f927d78 dummy/Kbuild --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dummy/Kbuild Wed Jun 06 17:02:38 2007 +0000 @@ -0,0 +1,48 @@ +#------------------------------------------------------------------------------ +# +# $Id: Kbuild 844 2007-03-08 18:15:25Z 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. +# +#------------------------------------------------------------------------------ + +include $(src)/../config.kbuild + +obj-m := ec_dummy.o + +ec_dummy-objs := module.o master.o slave.o domain.o + +REV := $(shell if test -s $(src)/../svnrevision; then \ + cat $(src)/../svnrevision; \ + else \ + svnversion $(src) 2>/dev/null || echo "unknown"; \ + fi) + +CFLAGS_dummy.o := -DSVNREV=$(REV) + +#------------------------------------------------------------------------------ diff -r 18c48cb7de06 -r a9794f927d78 dummy/Makefile.am --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dummy/Makefile.am Wed Jun 06 17:02:38 2007 +0000 @@ -0,0 +1,51 @@ +#------------------------------------------------------------------------------ +# +# $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. +# +#------------------------------------------------------------------------------ + +EXTRA_DIST = \ + Kbuild \ + module.c \ + master.c \ + slave.c \ + domain.c + +modules: + $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_top_srcdir@" modules + +modules_install: + mkdir -p $(DESTDIR)$(LINUX_MOD_PATH) + cp $(srcdir)/ec_dummy.ko $(DESTDIR)$(LINUX_MOD_PATH) + +clean-local: + $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" clean + +#------------------------------------------------------------------------------ diff -r 18c48cb7de06 -r a9794f927d78 dummy/domain.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dummy/domain.c Wed Jun 06 17:02:38 2007 +0000 @@ -0,0 +1,157 @@ +/****************************************************************************** + * + * $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. + * + *****************************************************************************/ + +/** + \file + EtherCAT DUMMY domain methods. +*/ + +/*****************************************************************************/ + +#include "../master/globals.h" +#include "../master/domain.h" +#include "../master/master.h" + +/*****************************************************************************/ + +uint8_t dummy_data[PAGE_SIZE]; + +/*****************************************************************************/ + +/** \cond */ + +int ecrt_domain_register_pdo( + ec_domain_t *domain, /**< EtherCAT domain */ + ec_slave_t *slave, /**< EtherCAT slave */ + uint16_t pdo_entry_index, /**< PDO entry index */ + uint8_t pdo_entry_subindex, /**< PDO entry subindex */ + void **data_ptr /**< address of the process data pointer */ + ) +{ + *data_ptr = dummy_data; + return 0; +} + +/*****************************************************************************/ + +/** + * Registers a bunch of data fields. + * \attention The list has to be terminated with a NULL structure ({})! + * \return 0 in case of success, else < 0 + * \ingroup RealtimeInterface + */ + +int ecrt_domain_register_pdo_list( + ec_domain_t *domain, /**< EtherCAT domain */ + const ec_pdo_reg_t *pdo_regs /**< array of PDO registrations */ + ) +{ + const ec_pdo_reg_t *reg; + + for (reg = pdo_regs; reg->slave_address; reg++) { + *(reg->data_ptr) = dummy_data; + } + + return 0; +} + +/*****************************************************************************/ + +/** + * Registers a PDO range in a domain. + * \return 0 on success, else non-zero + * \ingroup RealtimeInterface + */ + +int ecrt_domain_register_pdo_range( + ec_domain_t *domain, /**< EtherCAT domain */ + ec_slave_t *slave, /**< EtherCAT slave */ + ec_direction_t dir, /**< data direction */ + uint16_t offset, /**< offset in slave's PDO range */ + uint16_t length, /**< length of this range */ + void **data_ptr /**< address of the process data pointer */ + ) +{ + *data_ptr = dummy_data; + return 0; +} + +/*****************************************************************************/ + +/** + Processes received process data and requeues the domain datagram(s). + \ingroup RealtimeInterface +*/ + +void ecrt_domain_process(ec_domain_t *domain /**< EtherCAT domain */) +{ +} + +/*****************************************************************************/ + +/** + Places all process data datagrams in the masters datagram queue. + \ingroup RealtimeInterface +*/ + +void ecrt_domain_queue(ec_domain_t *domain /**< EtherCAT domain */) +{ +} + +/*****************************************************************************/ + +/** + Returns the state of a domain. + \return 0 if all datagrams were received, else -1. + \ingroup RealtimeInterface +*/ + +int ecrt_domain_state(const ec_domain_t *domain /**< EtherCAT domain */) +{ + return 0; +} + +/*****************************************************************************/ + +/** \cond */ + +EXPORT_SYMBOL(ecrt_domain_register_pdo); +EXPORT_SYMBOL(ecrt_domain_register_pdo_list); +EXPORT_SYMBOL(ecrt_domain_register_pdo_range); +EXPORT_SYMBOL(ecrt_domain_process); +EXPORT_SYMBOL(ecrt_domain_queue); +EXPORT_SYMBOL(ecrt_domain_state); + +/** \endcond */ + +/*****************************************************************************/ diff -r 18c48cb7de06 -r a9794f927d78 dummy/master.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dummy/master.c Wed Jun 06 17:02:38 2007 +0000 @@ -0,0 +1,119 @@ +/****************************************************************************** + * + * $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. + * + *****************************************************************************/ + +/** + \file + EtherCAT DUMMY master methods. +*/ + +/*****************************************************************************/ + +#include "../include/ecrt.h" +#include "../master/master.h" + +/****************************************************************************** + * Realtime interface + *****************************************************************************/ + +/** \cond */ + +ec_domain_t *ecrt_master_create_domain(ec_master_t *master) +{ + return (ec_domain_t *) 1; +} + +/*****************************************************************************/ + +int ecrt_master_activate(ec_master_t *master) +{ + return 0; +} + +/*****************************************************************************/ + +void ecrt_master_send(ec_master_t *master) +{ +} + +/*****************************************************************************/ + +void ecrt_master_receive(ec_master_t *master) +{ +} + +/*****************************************************************************/ + +ec_slave_t *ecrt_master_get_slave( + const ec_master_t *master, + const char *address, + uint32_t v, + uint32_t p + ) +{ + return (ec_slave_t *) 1; +} + +/*****************************************************************************/ + +void ecrt_master_callbacks(ec_master_t *m, + int (*q)(void *), + void (*l)(void *), + void *u + ) +{ +} + +/*****************************************************************************/ + +void ecrt_master_get_status(const ec_master_t *master, /**< EtherCAT master */ + ec_master_status_t *status /**< target status object */ + ) +{ + status->bus_status = EC_BUS_OK; + status->bus_tainted = 0; + status->slaves_responding = 999; +} + +/*****************************************************************************/ + +EXPORT_SYMBOL(ecrt_master_create_domain); +EXPORT_SYMBOL(ecrt_master_activate); +EXPORT_SYMBOL(ecrt_master_send); +EXPORT_SYMBOL(ecrt_master_receive); +EXPORT_SYMBOL(ecrt_master_callbacks); +EXPORT_SYMBOL(ecrt_master_get_slave); +EXPORT_SYMBOL(ecrt_master_get_status); + +/** \endcond */ + +/*****************************************************************************/ diff -r 18c48cb7de06 -r a9794f927d78 dummy/module.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dummy/module.c Wed Jun 06 17:02:38 2007 +0000 @@ -0,0 +1,136 @@ +/****************************************************************************** + * + * $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. + * + *****************************************************************************/ + +/** + \file + Dummy EtherCAT master driver module. +*/ + +/*****************************************************************************/ + +#include +//#include +//#include + +#include "../master/globals.h" +#include "../include/ecrt.h" + +/*****************************************************************************/ + +int __init ec_init_module(void); +void __exit ec_cleanup_module(void); + +char *ec_master_version_str = EC_MASTER_VERSION; + +/*****************************************************************************/ + +/** \cond */ + +MODULE_AUTHOR("Florian Pose "); +MODULE_DESCRIPTION("DUMMY EtherCAT master driver module"); +MODULE_LICENSE("GPL"); +MODULE_VERSION(EC_MASTER_VERSION); + +/** \endcond */ + +/*****************************************************************************/ + +/** + * Module initialization. + * Initializes \a ec_master_count masters. + * \return 0 on success, else < 0 + */ + +int __init ec_init_module(void) +{ + EC_INFO("Master DUMMY driver %s\n", EC_MASTER_VERSION); + return 0; +} + +/*****************************************************************************/ + +/** + Module cleanup. + Clears all master instances. +*/ + +void __exit ec_cleanup_module(void) +{ + EC_INFO("Master DUMMY module cleaned up.\n"); +} + +/****************************************************************************** + * Realtime interface + *****************************************************************************/ + +unsigned int ecrt_version_magic(void) +{ + return ECRT_VERSION_MAGIC; +} + +/*****************************************************************************/ + +ec_master_t *ecrt_request_master(unsigned int master_index + /**< master index */ + ) +{ + EC_INFO("Requesting DUMMY master %u...\n", master_index); + return (void *) master_index + 1; +} + +/*****************************************************************************/ + +/** + Releases a reserved EtherCAT master. + \ingroup RealtimeInterface +*/ + +void ecrt_release_master(ec_master_t *master /**< EtherCAT master */) +{ + EC_INFO("Released DUMMY master %u.\n", (unsigned int) master - 1); +} + +/*****************************************************************************/ + +/** \cond */ + +module_init(ec_init_module); +module_exit(ec_cleanup_module); + +EXPORT_SYMBOL(ecrt_request_master); +EXPORT_SYMBOL(ecrt_release_master); +EXPORT_SYMBOL(ecrt_version_magic); + +/** \endcond */ + +/*****************************************************************************/ diff -r 18c48cb7de06 -r a9794f927d78 dummy/slave.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dummy/slave.c Wed Jun 06 17:02:38 2007 +0000 @@ -0,0 +1,134 @@ +/****************************************************************************** + * + * $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. + * + *****************************************************************************/ + +/** + \file + EtherCAT DUMMY slave methods. +*/ + +/*****************************************************************************/ + +#include "../include/ecrt.h" +#include "../master/master.h" +#include "../master/slave.h" + +/*****************************************************************************/ + +/** \cond */ + +int ecrt_slave_conf_sdo8(ec_slave_t *slave, /**< EtherCAT slave */ + uint16_t sdo_index, /**< SDO index */ + uint8_t sdo_subindex, /**< SDO subindex */ + uint8_t value /**< new SDO value */ + ) +{ + return 0; +} + +/*****************************************************************************/ + +/** + \return 0 in case of success, else < 0 + \ingroup RealtimeInterface +*/ + +int ecrt_slave_conf_sdo16(ec_slave_t *slave, /**< EtherCAT slave */ + uint16_t sdo_index, /**< SDO index */ + uint8_t sdo_subindex, /**< SDO subindex */ + uint16_t value /**< new SDO value */ + ) +{ + return 0; +} + +/*****************************************************************************/ + +/** + \return 0 in case of success, else < 0 + \ingroup RealtimeInterface +*/ + +int ecrt_slave_conf_sdo32(ec_slave_t *slave, /**< EtherCAT slave */ + uint16_t sdo_index, /**< SDO index */ + uint8_t sdo_subindex, /**< SDO subindex */ + uint32_t value /**< new SDO value */ + ) +{ + return 0; +} + +/*****************************************************************************/ + +void ecrt_slave_pdo_mapping_clear( + ec_slave_t *slave, /**< EtherCAT slave */ + ec_direction_t dir /**< output/input */ + ) +{ +} + +/*****************************************************************************/ + +int ecrt_slave_pdo_mapping_add( + ec_slave_t *slave, /**< EtherCAT slave */ + ec_direction_t dir, /**< input/output */ + uint16_t pdo_index /**< Index of PDO mapping list */) +{ + return 0; +} + +/*****************************************************************************/ + +int ecrt_slave_pdo_mapping(ec_slave_t *slave, /**< EtherCAT slave */ + ec_direction_t dir, /**< input/output */ + unsigned int num_args, /**< Number of following arguments */ + ... /**< PDO indices to map */ + ) +{ + return 0; +} + + +/*****************************************************************************/ + +/** \cond */ + +EXPORT_SYMBOL(ecrt_slave_conf_sdo8); +EXPORT_SYMBOL(ecrt_slave_conf_sdo16); +EXPORT_SYMBOL(ecrt_slave_conf_sdo32); +EXPORT_SYMBOL(ecrt_slave_pdo_mapping_clear); +EXPORT_SYMBOL(ecrt_slave_pdo_mapping_add); +EXPORT_SYMBOL(ecrt_slave_pdo_mapping); + +/** \endcond */ + +/*****************************************************************************/