First working RTDM Version,

to be reviewed,
further testing and optimation needed

Thanks to Moehwald GmbH B.Benner for Basic Code
This commit is contained in:
Andreas Stewering-Bone
2011-03-16 22:12:23 +01:00
parent 68709df653
commit 76ff88c43c
19 changed files with 7441 additions and 3 deletions
+4
View File
@@ -35,4 +35,8 @@ ifeq (@ENABLE_TTY@,1)
obj-m += tty/
endif
ifeq (@ENABLE_RTDM@,1)
obj-m += rtdm/
endif
#------------------------------------------------------------------------------
+5
View File
@@ -47,6 +47,10 @@ if ENABLE_TTY
SUBDIRS += tty
endif
if ENABLE_RTDM
SUBDIRS += rtdm
endif
# userspace example depends on lib/
SUBDIRS += examples
@@ -59,6 +63,7 @@ DIST_SUBDIRS = \
master \
script \
tool \
rtdm \
tty
noinst_HEADERS = \
+65 -1
View File
@@ -365,7 +365,7 @@ AC_SUBST(KERNEL_R8169,[$kernel_r8169])
AC_ARG_WITH([rtai-dir],
AC_HELP_STRING(
[--with-rtai-dir=<DIR>],
[RTAI path (only for RTAI examples)]
[RTAI path (only for RTDM Interface or RTAI examples)]
),
[
rtaidir=[$withval]
@@ -388,6 +388,67 @@ fi
AC_SUBST(RTAI_DIR,[$rtaidir])
#------------------------------------------------------------------------------
# Xenomai path (optional)
#------------------------------------------------------------------------------
AC_ARG_WITH([xenomai-dir],
AC_HELP_STRING(
[--with-xenomai-dir=<DIR>],
[Xenomai path (only for RTDM Interface or Xenomai examples)]
),
[
xenomaidir=[$withval]
],
[
xenomaidir=""
]
)
AC_MSG_CHECKING([for Xenomai path])
if test -z "${xenomaidir}"; then
AC_MSG_RESULT([not specified.])
else
if test \! -r ${xenomaidir}/include/xeno_config.h; then
AC_MSG_ERROR([no Xenomai installation found in ${xenomaidir}!])
fi
AC_MSG_RESULT([$xenomaidir])
fi
AC_SUBST(XENOMAI_DIR,[$xenomaidir])
#------------------------------------------------------------------------------
# RTDM Interface (optional)
#------------------------------------------------------------------------------
AC_ARG_ENABLE([rtdm],
AC_HELP_STRING(
[--enable-rtdm],
[Enable RTDM Interface, depends on RTAI or Xenomai]
),
[
case "${enableval}" in
yes) rtdm=1
;;
no) rtdm=0
;;
*) AC_MSG_ERROR([Invalid value for --enable-rtdm])
;;
esac
],
[rtdm=0]
)
if test "x${rtdm}" = "x1"; then
AC_DEFINE([EC_RTDM], [1], [RTDM interfaces enabled])
fi
AM_CONDITIONAL(ENABLE_RTDM, test "x$rtdm" = "x1")
AC_SUBST(ENABLE_RTDM,[$rtdm])
#------------------------------------------------------------------------------
# Debug interface
#------------------------------------------------------------------------------
@@ -626,6 +687,7 @@ AC_CONFIG_FILES([
examples/tty/Kbuild
examples/tty/Makefile
examples/user/Makefile
examples/xenomai/Makefile
include/Makefile
lib/Makefile
m4/Makefile
@@ -638,6 +700,8 @@ AC_CONFIG_FILES([
tool/Makefile
tty/Kbuild
tty/Makefile
rtdm/Makefile
rtdm/Kbuild
])
AC_OUTPUT
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+2
View File
@@ -65,6 +65,8 @@ noinst_HEADERS = \
8139too-2.6.33-orig.c \
8139too-2.6.34-ethercat.c \
8139too-2.6.34-orig.c \
8139too-2.6.35-ethercat.c \
8139too-2.6.35-orig.c \
e100-2.6.20-ethercat.c \
e100-2.6.20-orig.c \
e100-2.6.24-ethercat.c \
+1
View File
@@ -35,4 +35,5 @@ ifeq (@ENABLE_TTY@,1)
obj-m += tty/
endif
#------------------------------------------------------------------------------
+6
View File
@@ -40,12 +40,18 @@ SUBDIRS += \
tty
endif
if ENABLE_RTDM
SUBDIRS += \
xenomai
endif
DIST_SUBDIRS = \
dc_rtai \
dc_user \
mini \
rtai \
tty \
xenomai \
user
EXTRA_DIST = \
+39
View File
@@ -0,0 +1,39 @@
#------------------------------------------------------------------------------
#
# $Id$
#
# Copyright (C) 2006-2008 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 version 2, as
# published by the Free Software Foundation.
#
# 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 license mentioned above concerns the source code only. Using the
# EtherCAT technology and brand is only permitted in compliance with the
# industrial property and similar rights of Beckhoff Automation GmbH.
#
#------------------------------------------------------------------------------
AM_CFLAGS = -Wall
noinst_PROGRAMS = ec_xenomai_example
ec_xenomai_example_SOURCES = main.c
ec_xenomai_example_CFLAGS = -I/opt/etherlab/xenomai/include -D_GNU_SOURCE -D_REENTRANT -Wall -pipe -D__XENO__ -I$(top_srcdir)/include
ec_xenomai_example_LDFLAGS = -lrtdm -L$(top_builddir)/lib/.libs -lethercat -lnative -L/opt/etherlab/xenomai/lib -lxenomai -lpthread
#------------------------------------------------------------------------------
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -33,6 +33,7 @@
include_HEADERS = \
ecrt.h \
ectty.h
ectty.h \
ec_rtdm.h
#------------------------------------------------------------------------------
+72
View File
@@ -0,0 +1,72 @@
/******************************************************************************
*
* $Id$
*
* ec_rtdm.h Copyright (C) 2009-2010 Moehwald GmbH B.Benner
* 2011 IgH Andreas Stewering-Bone
*
* This file is used for Prisma RT to interface to EtherCAT devices
*
* This file is part of ethercatrtdm interface to IgH EtherCAT master
*
* The Moehwald ethercatrtdm interface is free software; you can
* redistribute it and/or modify it under the terms of the GNU Lesser General
* Public License as published by the Free Software Foundation; version 2.1
* of the License.
*
* The IgH EtherCAT master userspace library 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the IgH EtherCAT master userspace library. If not, see
* <http://www.gnu.org/licenses/>.
*
* The license mentioned above concerns the source code only. Using the
* EtherCAT technology and brand is only permitted in compliance with the
* industrial property and similar rights of Beckhoff Automation GmbH.
*
*****************************************************************************/
#ifndef __ECRT_RTDM_H
#define __ECRT_RTDM_H
//
// Basefilename of RTDM device
//
#define EC_RTDM_DEV_FILE_NAME "ec_rtdm"
//
// IOCTRL Values for RTDM_EXTENSION
//
// Realtime IOCTRL function
#define EC_RTDM_MSTRATTACH 1 // attach to a running master
#define EC_RTDM_MSTRGETMUTNAME 2 // return the mutexname
#define EC_RTDM_MSTRRECEIVE 3 // call the master receive
#define EC_RTDM_MSTRSEND 4 // call the master send
#define EC_RTDM_DOMAINSTATE 5 // get domain state
#define EC_RTDM_MASTERSTATE 6 // get master state
#define EC_RTDM_MASTER_APP_TIME 7
#define EC_RTDM_SYNC_REF_CLOCK 8
#define EC_RTDM_SYNC_SLAVE_CLOCK 9
typedef struct _CstructMstrAttach
{
unsigned int domainindex;
unsigned int masterindex;
} CstructMstrAttach;
#define ecrt_rtdm_master_attach(X,Y) rt_dev_ioctl(X, EC_RTDM_MSTRATTACH, Y)
#define ecrt_rtdm_master_recieve(X) rt_dev_ioctl(X, EC_RTDM_MSTRRECEIVE)
#define ecrt_rtdm_master_send(X) rt_dev_ioctl(X, EC_RTDM_MSTRSEND)
#define ecrt_rtdm_domain_state(X,Y) rt_dev_ioctl(X, EC_RTDM_DOMAINSTATE, Y)
#define ecrt_rtdm_master_state(X,Y) rt_dev_ioctl(X, EC_RTDM_MASTERSTATE, Y)
#define ecrt_rtdm_master_application_time(X,Y) rt_dev_ioctl(X, EC_RTDM_MASTER_APP_TIME, Y)
#define ecrt_rtdm_master_sync_reference_clock(X) rt_dev_ioctl(X, EC_RTDM_SYNC_REF_CLOCK)
#define ecrt_rtdm_master_sync_slave_clocks(X) rt_dev_ioctl(X, EC_RTDM_SYNC_SLAVE_CLOCK);
#endif
+48
View File
@@ -455,6 +455,23 @@ void ecrt_release_master(
ec_master_t *master /**< EtherCAT master */
);
#ifdef __KERNEL__
/** Attach to a running master
*
* This function returns the master handle for the RTDM-Interface
*
* \return Pointer to the opened master, otherwise \a NULL.
*/
ec_master_t *ecrt_attach_master(
unsigned int master_index /**< Index of the master to request. */
);
#endif // #ifdef __KERNEL__
/******************************************************************************
* Master methods
*****************************************************************************/
@@ -500,8 +517,38 @@ void ecrt_master_callbacks(
*/
);
/** Returns domain structure pointer
*
* This functions return the domain structure pointer for usage inside the
* RTDM-Interface.
*
* \return Pointer to the domain on success, else NULL.
*/
ec_domain_t *ecrt_master_find_domain(
ec_master_t *master,
unsigned int index);
#endif /* __KERNEL__ */
#ifndef __KERNEL__
/** Return the domain index of a given domain strucure
*
* Return the domain index of a given domain strucure. Usage inside of the
* RTDM Interface
*
* \return Index of the domain strucure
*
*/
unsigned int ecrt_domain_index(
ec_domain_t *domain
);
#endif // #ifndef __KERNEL__
/** Creates a new process data domain.
*
* For process data exchange, at least one process data domain is needed.
@@ -515,6 +562,7 @@ ec_domain_t *ecrt_master_create_domain(
ec_master_t *master /**< EtherCAT master. */
);
/** Obtains a slave configuration.
*
* Creates a slave configuration object for the given \a alias and \a position
+7
View File
@@ -52,6 +52,13 @@ void ec_domain_clear(ec_domain_t *domain)
// nothing to do
}
/*****************************************************************************/
unsigned int ecrt_domain_index(ec_domain_t *domain)
{
return domain->index;
}
/*****************************************************************************/
int ecrt_domain_reg_pdo_entry_list(ec_domain_t *domain,
+15 -1
View File
@@ -1636,6 +1636,20 @@ ec_domain_t *ec_master_find_domain(
EC_FIND_DOMAIN;
}
/** Wrapper Function for external usage
*
* \return Domain pointer, or \a NULL if not found.
*/
ec_domain_t *ecrt_master_find_domain(
ec_master_t *master, /**< EtherCAT master. */
unsigned int index /**< Domain index. */
)
{
return ec_master_find_domain(
master,
index);
}
/** Get a domain via its position in the list.
*
* Const version.
@@ -2535,7 +2549,7 @@ EXPORT_SYMBOL(ecrt_master_sync_monitor_process);
EXPORT_SYMBOL(ecrt_master_write_idn);
EXPORT_SYMBOL(ecrt_master_read_idn);
EXPORT_SYMBOL(ecrt_master_reset);
EXPORT_SYMBOL(ecrt_master_find_domain);
/** \endcond */
/*****************************************************************************/
+32
View File
@@ -611,6 +611,37 @@ unsigned int ecrt_version_magic(void)
return ECRT_VERSION_MAGIC;
}
/** Return pointer to running master
/*****************************************************************************/
ec_master_t *ecrt_attach_master(unsigned int master_index)
{
ec_master_t *master = NULL;
EC_INFO("Requesting master %u...\n", master_index);
if (master_index >= master_count) {
EC_ERR("Invalid master index %u.\n", master_index);
return master;
}
master = &masters[master_index];
if (master->reserved)
{
// ok master is attached
EC_INFO("attaching Master %u!\n", master_index);
}
else
{
EC_ERR("No Master %u in use!\n", master_index);
master = NULL;
}
return master;
}
/*****************************************************************************/
/** Global request state type translation table.
@@ -637,6 +668,7 @@ EXPORT_SYMBOL(ecdev_offer);
EXPORT_SYMBOL(ecrt_request_master);
EXPORT_SYMBOL(ecrt_release_master);
EXPORT_SYMBOL(ecrt_version_magic);
EXPORT_SYMBOL(ecrt_attach_master);
/** \endcond */
+56
View File
@@ -0,0 +1,56 @@
#------------------------------------------------------------------------------
#
# $Id$
#
# Copyright (C) 2006-2008 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 version 2, as
# published by the Free Software Foundation.
#
# 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 license mentioned above concerns the source code only. Using the EtherCAT
# technology and brand is only permitted in compliance with the industrial
# property and similar rights of Beckhoff Automation GmbH.
#
# ---
#
# vi: syntax=make
#
#------------------------------------------------------------------------------
obj-m := ec_rtdm.o
ec_rtdm-objs := \
module.o
### Xenomai directory, xeno-config and library directory ###########
XENO_DIR := @XENOMAI_DIR@
XENO_CONFIG := $(XENO_DIR)/bin/xeno-config
XENO_LIB_DIR := $(shell $(XENO_CONFIG) --library-dir)
REV := $(shell if test -s $(src)/../revision; then \
cat $(src)/../revision; \
else \
hg id -i $(src)/.. 2>/dev/null || echo "unknown"; \
fi)
CFLAGS_module.o := -DREV=$(REV) -I$(XENO_DIR)/include
KBUILD_EXTRA_SYMBOLS := \
@abs_top_builddir@/$(LINUX_SYMVERS) \
@abs_top_builddir@/master/$(LINUX_SYMVERS)
#------------------------------------------------------------------------------
+51
View File
@@ -0,0 +1,51 @@
#------------------------------------------------------------------------------
#
# $Id$
#
# Copyright (C) 2006-2008 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 version 2, as
# published by the Free Software Foundation.
#
# 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 license mentioned above concerns the source code only. Using the
# EtherCAT technology and brand is only permitted in compliance with the
# industrial property and similar rights of Beckhoff Automation GmbH.
#
#------------------------------------------------------------------------------
# using HEADERS to enable tags target
noinst_HEADERS = \
module.c
EXTRA_DIST = \
Kbuild.in
BUILT_SOURCES = \
Kbuild
modules:
$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" modules
modules_install:
$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" \
INSTALL_MOD_DIR="$(INSTALL_MOD_DIR)" modules_install
clean-local:
$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" clean
#------------------------------------------------------------------------------
+719
View File
File diff suppressed because it is too large Load Diff