This commit is contained in:
Martin Troxler
2009-12-27 16:58:19 +01:00
48 changed files with 8646 additions and 191 deletions
+6
View File
@@ -25,8 +25,14 @@
# 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 := examples/ master/ devices/
ifeq (@ENABLE_TTY@,1)
obj-m += tty/
endif
#------------------------------------------------------------------------------
+9 -1
View File
@@ -43,6 +43,10 @@ if ENABLE_USERLIB
SUBDIRS += lib
endif
if ENABLE_TTY
SUBDIRS += tty
endif
# userspace example depends on lib/
SUBDIRS += examples
@@ -54,7 +58,8 @@ DIST_SUBDIRS = \
m4 \
master \
script \
tool
tool \
tty
noinst_HEADERS = \
globals.h
@@ -75,6 +80,9 @@ modules:
modules_install:
$(MAKE) -C master modules_install
$(MAKE) -C devices modules_install
if ENABLE_TTY
$(MAKE) -C tty modules_install
endif
clean-local:
$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" clean
+1
View File
@@ -21,6 +21,7 @@ Changes since 1.4.0:
Introduced new method ec_datagram_zero() for that.
* Added phy_read and phy_write commands to ethercat tool.
* Added e100 driver for Intel PRO/100 NICs.
- Added e100 driver for 2.6.27.
- Added e100 driver for 2.6.28, thanks to Kim. H. Madsen.
- Added e100 driver for 2.6.29, thanks to Andre Puschmann.
* Added 8139too driver for kernels 2.6.25 (F. Pose), 2.6.26 (M. Luescher),
+7 -10
View File
@@ -21,28 +21,19 @@ Version 1.5.0:
- Check if register 0x0980 is working, to avoid clearing it when
configuring.
* Remove byte-swapping functions from user space.
* EoE:
- Only execute one EoE handler per cycle.
- Mailbox protocol handlers.
- Mailbox state machine using toggle bits.
* Implement 'ethercat foe_read --output-file ...'.
* Use ec_datagram_zero() where possible.
* Fix arguments of reg_read.
* Sign/Abs type for reg_ commands?
* Number layout for reg_read.
* Show Record / Array / List type of SDOs.
* Limit bandwidth of state machine datagram.
* Read alias from register 0x0012 instead of SII.
* Finish library implementation.
* Rescan command.
* Override sync manager size?
* Remove ecrt_domain_state()?
* Check force_config flag before error.
* Remove allow_scanning flag.
* Check for ioctl() interface version.
* Improve application-triggered SDO transfers by moving the state machine into
the SDO handlers.
* Move device driver files in subdirectories.
* Document ec_fsm_foe members.
* Test KBUILD_EXTRA_SYMBOLS.
* Remove default buffer size in SDO upload.
@@ -54,10 +45,16 @@ Version 1.5.0:
* Change SDO index at runtime for SDO request.
* Implement ecrt_slave_config_request_state().
* Output skipped datagrams again.
* Output warning on unmatched slave configuration.
* ec_direction_t default
* Send_ext context warn
* XML hex
* r8169
Future issues:
* Segmented SDO downloads.
* Mailbox protocol handlers.
* Mailbox state machine using toggle bits.
* External memory for SDO transfers.
* C++ implementation of the library.
* Bus simulator interface.
+50
View File
@@ -101,6 +101,29 @@ AC_SUBST(LINUX_KERNEL_VERSION,[$linuxversion])
AC_SUBST(LINUX_MOD_PATH,[/lib/modules/$kernelrelease/ethercat])
AC_MSG_RESULT([$LINUX_SOURCE_DIR (Kernel $LINUX_KERNEL_RELEASE)])
#------------------------------------------------------------------------------
# Generic Ethernet driver
#------------------------------------------------------------------------------
AC_ARG_ENABLE([generic],
AS_HELP_STRING([--enable-generic],
[Enable generic Ethernet driver]),
[
case "${enableval}" in
yes) enablegeneric=1
;;
no) enablegeneric=0
;;
*) AC_MSG_ERROR([Invalid value for --enable-generic])
;;
esac
],
[enablegeneric=0]
)
AM_CONDITIONAL(ENABLE_GENERIC, test "x$enablegeneric" = "x1")
AC_SUBST(ENABLE_GENERIC,[$enablegeneric])
#------------------------------------------------------------------------------
# 8139too driver
#------------------------------------------------------------------------------
@@ -495,6 +518,29 @@ AC_ARG_ENABLE([userlib],
AM_CONDITIONAL(ENABLE_USERLIB, test "x$userlib" = "x1")
#------------------------------------------------------------------------------
# TTY driver
#------------------------------------------------------------------------------
AC_ARG_ENABLE([tty],
AS_HELP_STRING([--enable-tty],
[Generation of the ec_tty module (default: no)]),
[
case "${enableval}" in
yes) tty=1
;;
no) tty=0
;;
*) AC_MSG_ERROR([Invalid value for --enable-tty])
;;
esac
],
[tty=0]
)
AM_CONDITIONAL(ENABLE_TTY, test "x$tty" = "x1")
AC_SUBST(ENABLE_TTY,[$tty])
#------------------------------------------------------------------------------
AC_CONFIG_FILES([
@@ -514,6 +560,8 @@ AC_CONFIG_FILES([
examples/mini/Makefile
examples/rtai/Kbuild
examples/rtai/Makefile
examples/tty/Makefile
examples/tty/Kbuild
examples/user/Makefile
include/Makefile
lib/Makefile
@@ -525,6 +573,8 @@ AC_CONFIG_FILES([
script/init.d/ethercat
script/sysconfig/Makefile
tool/Makefile
tty/Makefile
tty/Kbuild
])
AC_OUTPUT
+1 -1
View File
@@ -1,6 +1,6 @@
/******************************************************************************
*
* $Id: 8139too-2.6.31-ethercat.c 1779 2009-06-16 08:29:30Z fp $
* $Id$
*
* Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH
*
+7
View File
@@ -37,6 +37,13 @@ REV := $(shell if test -s $(src)/../revision; then \
hg id -i $(src)/.. 2>/dev/null || echo "unknown"; \
fi)
ifeq (@ENABLE_GENERIC@,1)
EC_GENERIC_OBJ := generic.o
obj-m += ec_generic.o
ec_generic-objs := $(EC_GENERIC_OBJ)
CFLAGS_$(EC_GENERIC_OBJ) = -DREV=$(REV)
endif
ifeq (@ENABLE_8139TOO@,1)
EC_8139TOO_OBJ := 8139too-@KERNEL_8139TOO@-ethercat.o
obj-m += ec_8139too.o
+6
View File
@@ -63,11 +63,14 @@ noinst_HEADERS = \
e100-2.6.24-orig.c \
e100-2.6.26-ethercat.c \
e100-2.6.26-orig.c \
e100-2.6.27-ethercat.c \
e100-2.6.27-orig.c \
e100-2.6.28-ethercat.c \
e100-2.6.28-orig.c \
e100-2.6.29-ethercat.c \
e100-2.6.29-orig.c \
ecdev.h \
generic.c \
r8169-2.6.24-ethercat.c \
r8169-2.6.24-orig.c \
r8169-2.6.28-ethercat.c \
@@ -86,6 +89,9 @@ modules:
modules_install:
mkdir -p $(DESTDIR)$(LINUX_MOD_PATH)
if ENABLE_GENERIC
cp $(srcdir)/ec_generic.ko $(DESTDIR)$(LINUX_MOD_PATH)
endif
if ENABLE_8139TOO
cp $(srcdir)/ec_8139too.ko $(DESTDIR)$(LINUX_MOD_PATH)
endif
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+456
View File
@@ -0,0 +1,456 @@
/******************************************************************************
*
* $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.
*
*****************************************************************************/
/** \file
* EtherCAT generic Ethernet device module.
*/
/*****************************************************************************/
#include <linux/module.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/version.h>
#include <linux/if_arp.h> /* ARPHRD_ETHER */
#include <linux/etherdevice.h>
#include "../globals.h"
#include "ecdev.h"
#define PFX "ec_generic: "
#define ETH_P_ETHERCAT 0x88A4
#define EC_GEN_RX_BUF_SIZE 1600
/*****************************************************************************/
int __init ec_gen_init_module(void);
void __exit ec_gen_cleanup_module(void);
/*****************************************************************************/
/** \cond */
MODULE_AUTHOR("Florian Pose <fp@igh-essen.com>");
MODULE_DESCRIPTION("EtherCAT master generic Ethernet device module");
MODULE_LICENSE("GPL");
MODULE_VERSION(EC_MASTER_VERSION);
/** \endcond */
struct list_head generic_devices;
typedef struct {
struct list_head list;
struct net_device *netdev;
struct socket *socket;
ec_device_t *ecdev;
uint8_t *rx_buf;
} ec_gen_device_t;
typedef struct {
struct list_head list;
char name[IFNAMSIZ];
int ifindex;
uint8_t dev_addr[ETH_ALEN];
} ec_gen_interface_desc_t;
int ec_gen_device_open(ec_gen_device_t *);
int ec_gen_device_stop(ec_gen_device_t *);
int ec_gen_device_start_xmit(ec_gen_device_t *, struct sk_buff *);
void ec_gen_device_poll(ec_gen_device_t *);
/*****************************************************************************/
static int ec_gen_netdev_open(struct net_device *dev)
{
ec_gen_device_t *gendev = *((ec_gen_device_t **) netdev_priv(dev));
return ec_gen_device_open(gendev);
}
/*****************************************************************************/
static int ec_gen_netdev_stop(struct net_device *dev)
{
ec_gen_device_t *gendev = *((ec_gen_device_t **) netdev_priv(dev));
return ec_gen_device_stop(gendev);
}
/*****************************************************************************/
static int ec_gen_netdev_start_xmit(
struct sk_buff *skb,
struct net_device *dev
)
{
ec_gen_device_t *gendev = *((ec_gen_device_t **) netdev_priv(dev));
return ec_gen_device_start_xmit(gendev, skb);
}
/*****************************************************************************/
void ec_gen_poll(struct net_device *dev)
{
ec_gen_device_t *gendev = *((ec_gen_device_t **) netdev_priv(dev));
ec_gen_device_poll(gendev);
}
/*****************************************************************************/
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
static const struct net_device_ops ec_gen_netdev_ops = {
.ndo_open = ec_gen_netdev_open,
.ndo_stop = ec_gen_netdev_stop,
.ndo_start_xmit = ec_gen_netdev_start_xmit,
};
#endif
/*****************************************************************************/
/** Init generic device.
*/
int ec_gen_device_init(
ec_gen_device_t *dev
)
{
ec_gen_device_t **priv;
char null = 0x00;
dev->ecdev = NULL;
dev->socket = NULL;
dev->rx_buf = NULL;
dev->netdev = alloc_netdev(sizeof(ec_gen_device_t *), &null, ether_setup);
if (!dev->netdev) {
return -ENOMEM;
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
dev->netdev->netdev_ops = &ec_gen_netdev_ops;
#else
dev->netdev->open = ec_gen_netdev_open;
dev->netdev->stop = ec_gen_netdev_stop;
dev->netdev->hard_start_xmit = ec_gen_netdev_start_xmit;
#endif
priv = netdev_priv(dev->netdev);
*priv = dev;
return 0;
}
/*****************************************************************************/
/** Clear generic device.
*/
void ec_gen_device_clear(
ec_gen_device_t *dev
)
{
if (dev->ecdev) {
ecdev_close(dev->ecdev);
ecdev_withdraw(dev->ecdev);
}
if (dev->socket) {
sock_release(dev->socket);
}
free_netdev(dev->netdev);
if (dev->rx_buf) {
kfree(dev->rx_buf);
}
}
/*****************************************************************************/
/** Creates a network socket.
*/
int ec_gen_device_create_socket(
ec_gen_device_t *dev,
ec_gen_interface_desc_t *desc
)
{
int ret;
struct sockaddr_ll sa;
dev->rx_buf = kmalloc(EC_GEN_RX_BUF_SIZE, GFP_KERNEL);
if (!dev->rx_buf) {
return -ENOMEM;
}
ret = sock_create_kern(PF_PACKET, SOCK_RAW, htons(ETH_P_ETHERCAT), &dev->socket);
if (ret) {
printk(KERN_ERR PFX "Failed to create socket.\n");
return ret;
}
printk(KERN_ERR PFX "Binding socket to interface %i (%s).\n",
desc->ifindex, desc->name);
memset(&sa, 0x00, sizeof(sa));
sa.sll_family = AF_PACKET;
sa.sll_protocol = htons(ETH_P_ETHERCAT);
sa.sll_ifindex = desc->ifindex;
ret = kernel_bind(dev->socket, (struct sockaddr *) &sa, sizeof(sa));
if (ret) {
printk(KERN_ERR PFX "Failed to bind() socket to interface.\n");
sock_release(dev->socket);
dev->socket = NULL;
return ret;
}
return 0;
}
/*****************************************************************************/
/** Offer generic device to master.
*/
int ec_gen_device_offer(
ec_gen_device_t *dev,
ec_gen_interface_desc_t *desc
)
{
int ret = 0;
memcpy(dev->netdev->dev_addr, desc->dev_addr, ETH_ALEN);
dev->ecdev = ecdev_offer(dev->netdev, ec_gen_poll, THIS_MODULE);
if (dev->ecdev) {
if (ec_gen_device_create_socket(dev, desc)) {
ecdev_withdraw(dev->ecdev);
dev->ecdev = NULL;
} else if (ecdev_open(dev->ecdev)) {
ecdev_withdraw(dev->ecdev);
dev->ecdev = NULL;
} else {
ecdev_set_link(dev->ecdev, 1); // FIXME
ret = 1;
}
}
return ret;
}
/*****************************************************************************/
/** Open the device.
*/
int ec_gen_device_open(
ec_gen_device_t *dev
)
{
return 0;
}
/*****************************************************************************/
/** Stop the device.
*/
int ec_gen_device_stop(
ec_gen_device_t *dev
)
{
return 0;
}
/*****************************************************************************/
int ec_gen_device_start_xmit(
ec_gen_device_t *dev,
struct sk_buff *skb
)
{
struct msghdr msg;
struct kvec iov;
size_t len = skb->len;
int ret;
iov.iov_base = skb->data;
iov.iov_len = len;
memset(&msg, 0, sizeof(msg));
ret = kernel_sendmsg(dev->socket, &msg, &iov, 1, len);
return ret == len ? NETDEV_TX_OK : NETDEV_TX_BUSY;
}
/*****************************************************************************/
/** Polls the device.
*/
void ec_gen_device_poll(
ec_gen_device_t *dev
)
{
struct msghdr msg;
struct kvec iov;
int ret, budget = 10; // FIXME
do {
iov.iov_base = dev->rx_buf;
iov.iov_len = EC_GEN_RX_BUF_SIZE;
memset(&msg, 0, sizeof(msg));
ret = kernel_recvmsg(dev->socket, &msg, &iov, 1, iov.iov_len,
MSG_DONTWAIT);
if (ret > 0) {
ecdev_receive(dev->ecdev, dev->rx_buf, ret);
} else if (ret < 0) {
break;
}
budget--;
} while (budget);
}
/*****************************************************************************/
/** Offer device.
*/
int offer_device(
ec_gen_interface_desc_t *desc
)
{
ec_gen_device_t *gendev;
int ret = 0;
gendev = kmalloc(sizeof(ec_gen_device_t), GFP_KERNEL);
if (!gendev) {
return -ENOMEM;
}
ret = ec_gen_device_init(gendev);
if (ret) {
kfree(gendev);
return ret;
}
if (ec_gen_device_offer(gendev, desc)) {
list_add_tail(&gendev->list, &generic_devices);
} else {
ec_gen_device_clear(gendev);
kfree(gendev);
}
return ret;
}
/*****************************************************************************/
/** Clear devices.
*/
void clear_devices(void)
{
ec_gen_device_t *gendev, *next;
list_for_each_entry_safe(gendev, next, &generic_devices, list) {
list_del(&gendev->list);
ec_gen_device_clear(gendev);
kfree(gendev);
}
}
/*****************************************************************************/
/** Module initialization.
*
* Initializes \a master_count masters.
* \return 0 on success, else < 0
*/
int __init ec_gen_init_module(void)
{
int ret = 0;
struct list_head descs;
struct net_device *netdev;
ec_gen_interface_desc_t *desc, *next;
printk(KERN_INFO PFX "EtherCAT master generic Ethernet device module %s\n",
EC_MASTER_VERSION);
INIT_LIST_HEAD(&generic_devices);
INIT_LIST_HEAD(&descs);
read_lock(&dev_base_lock);
for_each_netdev(&init_net, netdev) {
if (netdev->type != ARPHRD_ETHER)
continue;
desc = kmalloc(sizeof(ec_gen_interface_desc_t), GFP_KERNEL);
if (!desc) {
ret = -ENOMEM;
read_unlock(&dev_base_lock);
goto out_err;
}
strncpy(desc->name, netdev->name, IFNAMSIZ);
desc->ifindex = netdev->ifindex;
memcpy(desc->dev_addr, netdev->dev_addr, ETH_ALEN);
list_add_tail(&desc->list, &descs);
}
read_unlock(&dev_base_lock);
list_for_each_entry_safe(desc, next, &descs, list) {
ret = offer_device(desc);
if (ret) {
goto out_err;
}
kfree(desc);
}
return ret;
out_err:
list_for_each_entry_safe(desc, next, &descs, list) {
list_del(&desc->list);
kfree(desc);
}
clear_devices();
return ret;
}
/*****************************************************************************/
/** Module cleanup.
*
* Clears all master instances.
*/
void __exit ec_gen_cleanup_module(void)
{
clear_devices();
printk(KERN_INFO PFX "Unloading.\n");
}
/*****************************************************************************/
/** \cond */
module_init(ec_gen_init_module);
module_exit(ec_gen_cleanup_module);
/** \endcond */
/*****************************************************************************/
+6
View File
@@ -25,8 +25,14 @@
# 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 := mini/
ifeq (@ENABLE_TTY@,1)
obj-m += tty/
endif
#------------------------------------------------------------------------------
+1
View File
@@ -38,6 +38,7 @@ DIST_SUBDIRS = \
dc_user \
mini \
rtai \
tty \
user
EXTRA_DIST = \
+42
View File
@@ -0,0 +1,42 @@
#------------------------------------------------------------------------------
#
# $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_tty_example.o
ec_tty_example-objs := tty.o
KBUILD_EXTRA_SYMBOLS := \
@abs_top_builddir@/Module.symvers \
@abs_top_builddir@/master/Module.symvers
#------------------------------------------------------------------------------
+51
View File
@@ -0,0 +1,51 @@
#------------------------------------------------------------------------------
#
# Makefile.am
#
# IgH EtherCAT master module
#
# $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.
#
#------------------------------------------------------------------------------
EXTRA_DIST = \
Kbuild.in \
tty.c
BUILT_SOURCES = \
Kbuild
modules:
$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" modules
modules_install:
mkdir -p $(DESTDIR)$(LINUX_MOD_PATH)
cp $(srcdir)/ec_tty_example.ko $(DESTDIR)$(LINUX_MOD_PATH)
clean-local:
$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" clean
#------------------------------------------------------------------------------
+552
View File
File diff suppressed because it is too large Load Diff
+3 -1
View File
@@ -31,6 +31,8 @@
#
#------------------------------------------------------------------------------
include_HEADERS = ecrt.h
include_HEADERS = \
ecrt.h \
ectty.h
#------------------------------------------------------------------------------
+97
View File
@@ -0,0 +1,97 @@
/******************************************************************************
*
* $Id$
*
* Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH
*
* This file is part of the IgH EtherCAT master userspace library.
*
* The IgH EtherCAT master userspace library 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.
*
*****************************************************************************/
/** \file
*
* EtherCAT virtual TTY interface.
*
* \defgroup TTYInterface EtherCAT Virtual TTY Interface
*
* @{
*/
/*****************************************************************************/
#ifndef __ECTTY_H__
#define __ECTTY_H__
/******************************************************************************
* Data types
*****************************************************************************/
struct ec_tty;
typedef struct ec_tty ec_tty_t; /**< \see ec_tty */
/******************************************************************************
* Global functions
*****************************************************************************/
/** Create a virtual TTY interface.
*
* \return Pointer to the interface object, otherwise an ERR_PTR value.
*/
ec_tty_t *ectty_create(void);
/******************************************************************************
* TTY interface methods
*****************************************************************************/
/** Releases a virtual TTY interface.
*/
void ectty_free(
ec_tty_t *tty /**< TTY interface. */
);
/** Reads data to send from the TTY interface.
*
* If there are data to send, they are copied into the \a buffer. At maximum,
* \a size bytes are copied. The actual number of bytes copied is returned.
*
* \return Number of bytes copied.
*/
unsigned int ectty_tx_data(
ec_tty_t *tty, /**< TTY interface. */
uint8_t *buffer, /**< Buffer for data to transmit. */
size_t size /**< Available space in \a buffer. */
);
/** Pushes received data to the TTY interface.
*/
void ectty_rx_data(
ec_tty_t *tty, /**< TTY interface. */
const uint8_t *buffer, /**< Buffer with received data. */
size_t size /**< Number of bytes in \a buffer. */
);
/*****************************************************************************/
/** @} */
#endif
+3 -3
View File
@@ -587,7 +587,7 @@ int ec_cdev_ioctl_domain_data(
if (domain->data_size != data.data_size) {
up(&master->master_sem);
EC_ERR("Data size mismatch %u/%u!\n",
EC_ERR("Data size mismatch %u/%zu!\n",
data.data_size, domain->data_size);
return -EFAULT;
}
@@ -982,7 +982,7 @@ int ec_cdev_ioctl_slave_sii_read(
|| data.offset + data.nwords > slave->sii_nwords) {
up(&master->master_sem);
EC_ERR("Invalid SII read offset/size %u/%u for slave "
"SII size %u!\n", data.offset,
"SII size %zu!\n", data.offset,
data.nwords, slave->sii_nwords);
return -EINVAL;
}
@@ -3088,7 +3088,7 @@ int ec_cdev_ioctl_slave_foe_read(
data.error_code = request.req.error_code;
if (master->debug_level) {
EC_DBG("Read %d bytes via FoE (result = 0x%x).\n",
EC_DBG("Read %zd bytes via FoE (result = 0x%x).\n",
request.req.data_size, request.req.result);
}
+16 -3
View File
@@ -116,6 +116,8 @@ void ec_datagram_init(ec_datagram_t *datagram /**< EtherCAT datagram. */)
*/
void ec_datagram_clear(ec_datagram_t *datagram /**< EtherCAT datagram. */)
{
ec_datagram_unqueue(datagram);
if (datagram->data_origin == EC_ORIG_INTERNAL && datagram->data) {
kfree(datagram->data);
datagram->data = NULL;
@@ -124,6 +126,17 @@ void ec_datagram_clear(ec_datagram_t *datagram /**< EtherCAT datagram. */)
/*****************************************************************************/
/** Unqueue datagram.
*/
void ec_datagram_unqueue(ec_datagram_t *datagram /**< EtherCAT datagram. */)
{
if (!list_empty(&datagram->queue)) {
list_del_init(&datagram->queue);
}
}
/*****************************************************************************/
/** Allocates internal payload memory.
*
* If the allocated memory is already larger than requested, nothing ist done.
@@ -149,7 +162,7 @@ int ec_datagram_prealloc(
}
if (!(datagram->data = kmalloc(size, GFP_KERNEL))) {
EC_ERR("Failed to allocate %u bytes of datagram memory!\n", size);
EC_ERR("Failed to allocate %zu bytes of datagram memory!\n", size);
return -ENOMEM;
}
@@ -516,8 +529,8 @@ void ec_datagram_output_stats(
datagram->stats_output_jiffies = jiffies;
if (unlikely(datagram->skip_count)) {
EC_WARN("Datagram %x (%s) was SKIPPED %u time%s.\n",
(unsigned int) datagram, datagram->name,
EC_WARN("Datagram %p (%s) was SKIPPED %u time%s.\n",
datagram, datagram->name,
datagram->skip_count,
datagram->skip_count == 1 ? "" : "s");
datagram->skip_count = 0;
+1
View File
@@ -115,6 +115,7 @@ typedef struct {
void ec_datagram_init(ec_datagram_t *);
void ec_datagram_clear(ec_datagram_t *);
void ec_datagram_unqueue(ec_datagram_t *);
int ec_datagram_prealloc(ec_datagram_t *, size_t);
void ec_datagram_zero(ec_datagram_t *);
+7 -5
View File
@@ -309,16 +309,18 @@ void ec_device_send(
skb->len = ETH_HLEN + size;
if (unlikely(device->master->debug_level > 1)) {
EC_DBG("sending frame:\n");
ec_print_data(skb->data + ETH_HLEN, size);
EC_DBG("Sending frame:\n");
ec_print_data(skb->data, ETH_HLEN + size);
}
// start sending
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
if (device->dev->netdev_ops->ndo_start_xmit(skb, device->dev) == NETDEV_TX_OK) {
if (device->dev->netdev_ops->ndo_start_xmit(skb, device->dev) ==
NETDEV_TX_OK)
#else
if (device->dev->hard_start_xmit(skb, device->dev) == NETDEV_TX_OK) {
if (device->dev->hard_start_xmit(skb, device->dev) == NETDEV_TX_OK)
#endif
{
device->tx_count++;
#ifdef EC_DEBUG_IF
ec_debug_send(&device->dbg, skb->data, ETH_HLEN + size);
@@ -516,7 +518,7 @@ void ecdev_receive(
if (unlikely(device->master->debug_level > 1)) {
EC_DBG("Received frame:\n");
ec_print_data(ec_data, ec_size);
ec_print_data(data, size);
}
#ifdef EC_DEBUG_IF
+8 -10
View File
@@ -80,8 +80,6 @@ void ec_domain_clear(ec_domain_t *domain /**< EtherCAT domain */)
// dequeue and free datagrams
list_for_each_entry_safe(datagram, next, &domain->datagrams, list) {
if (!list_empty(&datagram->queue)) // datagram queued?
list_del(&datagram->queue);
ec_datagram_clear(datagram);
kfree(datagram);
}
@@ -118,7 +116,7 @@ void ec_domain_add_fmmu_config(
list_add_tail(&fmmu->list, &domain->fmmu_configs);
if (domain->master->debug_level)
EC_DBG("Domain %u: Added %u bytes, total %u.\n", domain->index,
EC_DBG("Domain %u: Added %u bytes, total %zu.\n", domain->index,
fmmu->data_size, domain->data_size);
}
@@ -213,7 +211,7 @@ int ec_domain_finish(
if (domain->data_size && domain->data_origin == EC_ORIG_INTERNAL) {
if (!(domain->data =
(uint8_t *) kmalloc(domain->data_size, GFP_KERNEL))) {
EC_ERR("Failed to allocate %u bytes internal memory for"
EC_ERR("Failed to allocate %zu bytes internal memory for"
" domain %u!\n", domain->data_size, domain->index);
return -ENOMEM;
}
@@ -267,12 +265,12 @@ int ec_domain_finish(
datagram_count++;
}
EC_INFO("Domain%u: Logical address 0x%08x, %u byte, "
EC_INFO("Domain%u: Logical address 0x%08x, %zu byte, "
"expected working counter %u.\n", domain->index,
domain->logical_base_address, domain->data_size,
domain->expected_working_counter);
list_for_each_entry(datagram, &domain->datagrams, list) {
EC_INFO(" Datagram %s: Logical offset 0x%08x, %u byte, type %s.\n",
EC_INFO(" Datagram %s: Logical offset 0x%08x, %zu byte, type %s.\n",
datagram->name, EC_READ_U32(datagram->address),
datagram->data_size, ec_datagram_type_string(datagram));
}
@@ -328,8 +326,8 @@ int ecrt_domain_reg_pdo_entry_list(ec_domain_t *domain,
int ret;
if (domain->master->debug_level)
EC_DBG("ecrt_domain_reg_pdo_entry_list(domain = 0x%x, regs = 0x%x)\n",
(u32) domain, (u32) regs);
EC_DBG("ecrt_domain_reg_pdo_entry_list(domain = 0x%p, regs = 0x%p)\n",
domain, regs);
for (reg = regs; reg->index; reg++) {
sc = ecrt_master_slave_config_err(domain->master, reg->alias,
@@ -360,8 +358,8 @@ size_t ecrt_domain_size(const ec_domain_t *domain)
void ecrt_domain_external_memory(ec_domain_t *domain, uint8_t *mem)
{
if (domain->master->debug_level)
EC_DBG("ecrt_domain_external_memory(domain = 0x%x, mem = 0x%x)\n",
(u32) domain, (u32) mem);
EC_DBG("ecrt_domain_external_memory(domain = 0x%p, mem = 0x%p)\n",
domain, mem);
down(&domain->master->master_sem);
+10 -7
View File
@@ -80,9 +80,10 @@ int ec_eoedev_stop(struct net_device *);
int ec_eoedev_tx(struct sk_buff *, struct net_device *);
struct net_device_stats *ec_eoedev_stats(struct net_device *);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31)
static const struct net_device_ops ec_eoe_netdev_ops =
{
/*****************************************************************************/
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
static const struct net_device_ops ec_eoedev_ops = {
.ndo_open = ec_eoedev_open,
.ndo_stop = ec_eoedev_stop,
.ndo_start_xmit = ec_eoedev_tx,
@@ -150,8 +151,8 @@ int ec_eoe_init(
}
// initialize net_device
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31)
eoe->dev->netdev_ops = &ec_eoe_netdev_ops;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
eoe->dev->netdev_ops = &ec_eoedev_ops;
#else
eoe->dev->open = ec_eoedev_open;
eoe->dev->stop = ec_eoedev_stop;
@@ -201,7 +202,6 @@ int ec_eoe_init(
void ec_eoe_clear(ec_eoe_t *eoe /**< EoE handler */)
{
unregister_netdev(eoe->dev); // possibly calls close callback
free_netdev(eoe->dev);
// empty transmit queue
ec_eoe_flush(eoe);
@@ -211,7 +211,10 @@ void ec_eoe_clear(ec_eoe_t *eoe /**< EoE handler */)
kfree(eoe->tx_frame);
}
if (eoe->rx_skb) dev_kfree_skb(eoe->rx_skb);
if (eoe->rx_skb)
dev_kfree_skb(eoe->rx_skb);
free_netdev(eoe->dev);
ec_datagram_clear(&eoe->datagram);
}
+1 -1
View File
@@ -114,7 +114,7 @@ int ec_foe_request_alloc(
ec_foe_request_clear_data(req);
if (!(req->buffer = (uint8_t *) kmalloc(size, GFP_KERNEL))) {
EC_ERR("Failed to allocate %u bytes of FoE memory.\n", size);
EC_ERR("Failed to allocate %zu bytes of FoE memory.\n", size);
return -1;
}
+308 -35
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -61,6 +61,8 @@ struct ec_fsm_coe {
ec_sdo_request_t *request; /**< SDO request */
uint32_t complete_size; /**< Used when segmenting. */
uint8_t toggle; /**< toggle bit for segment commands */
uint32_t offset; /**< Data offset during segmented download. */
uint32_t remaining; /**< Remaining bytes during segmented download. */
};
/*****************************************************************************/
+1 -1
View File
@@ -849,7 +849,7 @@ void ec_fsm_foe_state_data_read(
printk ("ERROR: data doesn't fit in receive buffer\n");
printk (" rx_buffer_size = %d\n", fsm->rx_buffer_size);
printk (" rx_buffer_offset= %d\n", fsm->rx_buffer_offset);
printk (" rec_size = %d\n", rec_size);
printk (" rec_size = %zd\n", rec_size);
printk (" rx_mailbox_size = %d\n",
slave->configured_rx_mailbox_size);
printk (" rx_last_packet = %d\n", fsm->rx_last_packet);
+5 -5
View File
@@ -367,13 +367,13 @@ int ec_fsm_master_action_process_register(
// found pending request; process it!
if (master->debug_level)
EC_DBG("Processing register request for slave %u, "
"offset 0x%04x, length %u...\n",
"offset 0x%04x, length %zu...\n",
request->slave->ring_position,
request->offset, request->length);
if (request->length > fsm->datagram->mem_size) {
EC_ERR("Request length (%u) exceeds maximum "
"datagram size (%u)!\n", request->length,
EC_ERR("Request length (%zu) exceeds maximum "
"datagram size (%zu)!\n", request->length,
fsm->datagram->mem_size);
request->state = EC_INT_REQUEST_FAILURE;
wake_up(&master->reg_queue);
@@ -869,7 +869,7 @@ void ec_fsm_master_state_write_sii(
// finished writing SII
if (master->debug_level)
EC_DBG("Finished writing %u words of SII data to slave %u.\n",
EC_DBG("Finished writing %zu words of SII data to slave %u.\n",
request->nwords, slave->ring_position);
if (request->offset <= 4 && request->offset + request->nwords > 4) {
@@ -986,7 +986,7 @@ void ec_fsm_master_state_reg_request(
kfree(request->data);
request->data = kmalloc(request->length, GFP_KERNEL);
if (!request->data) {
EC_ERR("Failed to allocate %u bytes of memory for"
EC_ERR("Failed to allocate %zu bytes of memory for"
" register data.\n", request->length);
request->state = EC_INT_REQUEST_FAILURE;
wake_up(&master->reg_queue);
+2 -2
View File
@@ -236,7 +236,7 @@ void ec_fsm_pdo_read_state_pdo_count(
}
if (fsm->request.data_size != sizeof(uint8_t)) {
EC_ERR("Invalid data size %u returned when uploading SDO 0x%04X:%02X "
EC_ERR("Invalid data size %zu returned when uploading SDO 0x%04X:%02X "
"from slave %u.\n", fsm->request.data_size,
fsm->request.index, fsm->request.subindex,
fsm->slave->ring_position);
@@ -298,7 +298,7 @@ void ec_fsm_pdo_read_state_pdo(
}
if (fsm->request.data_size != sizeof(uint16_t)) {
EC_ERR("Invalid data size %u returned when uploading SDO 0x%04X:%02X "
EC_ERR("Invalid data size %zu returned when uploading SDO 0x%04X:%02X "
"from slave %u.\n", fsm->request.data_size,
fsm->request.index, fsm->request.subindex,
fsm->slave->ring_position);
+2 -2
View File
@@ -193,7 +193,7 @@ void ec_fsm_pdo_entry_read_state_count(
}
if (fsm->request.data_size != sizeof(uint8_t)) {
EC_ERR("Invalid data size %u at uploading SDO 0x%04X:%02X.\n",
EC_ERR("Invalid data size %zu at uploading SDO 0x%04X:%02X.\n",
fsm->request.data_size, fsm->request.index,
fsm->request.subindex);
fsm->state = ec_fsm_pdo_entry_state_error;
@@ -248,7 +248,7 @@ void ec_fsm_pdo_entry_read_state_entry(
}
if (fsm->request.data_size != sizeof(uint32_t)) {
EC_ERR("Invalid data size %u at uploading SDO 0x%04X:%02X.\n",
EC_ERR("Invalid data size %zu at uploading SDO 0x%04X:%02X.\n",
fsm->request.data_size, fsm->request.index,
fsm->request.subindex);
fsm->state = ec_fsm_pdo_entry_state_error;
+1 -1
View File
@@ -546,7 +546,7 @@ alloc_sii:
if (!(slave->sii_words =
(uint16_t *) kmalloc(slave->sii_nwords * 2, GFP_KERNEL))) {
EC_ERR("Failed to allocate %u words of SII data for slave %u.\n",
EC_ERR("Failed to allocate %zu words of SII data for slave %u.\n",
slave->sii_nwords, slave->ring_position);
slave->sii_nwords = 0;
slave->error_flag = 1;
-24
View File
@@ -254,30 +254,6 @@ enum {
#define EC_DBG(fmt, args...) \
printk(KERN_DEBUG "EtherCAT DEBUG: " fmt, ##args)
/** Convenience macro for defining read-only SysFS attributes.
*
* This results in creating a static variable called attr_\a NAME. The SysFS
* file will be world-readable.
*
* \param NAME name of the attribute to create.
*/
#define EC_SYSFS_READ_ATTR(NAME) \
static struct attribute attr_##NAME = { \
.name = EC_STR(NAME), .owner = THIS_MODULE, .mode = S_IRUGO \
}
/** Convenience macro for defining read-write SysFS attributes.
*
* This results in creating a static variable called attr_\a NAME. The SysFS
* file will be word-readable plus owner-writable.
*
* \param NAME name of the attribute to create.
*/
#define EC_SYSFS_READ_WRITE_ATTR(NAME) \
static struct attribute attr_##NAME = { \
.name = EC_STR(NAME), .owner = THIS_MODULE, .mode = S_IRUGO | S_IWUSR \
}
/*****************************************************************************/
extern char *ec_master_version_str;
+1 -2
View File
@@ -66,12 +66,11 @@ uint8_t *ec_slave_mbox_prepare_send(const ec_slave_t *slave, /**< slave */
total_size = EC_MBOX_HEADER_SIZE + size;
if (unlikely(total_size > slave->configured_rx_mailbox_size)) {
EC_ERR("Data size (%u) does not fit in mailbox (%u)!\n",
EC_ERR("Data size (%zu) does not fit in mailbox (%u)!\n",
total_size, slave->configured_rx_mailbox_size);
return ERR_PTR(-EOVERFLOW);
}
ec_datagram_zero(datagram);
ret = ec_datagram_fpwr(datagram, slave->station_address,
slave->configured_rx_mailbox_offset,
slave->configured_rx_mailbox_size);
+4
View File
@@ -41,6 +41,10 @@
/*****************************************************************************/
#define EC_MBOX_HEADER_SIZE 6
/*****************************************************************************/
uint8_t *ec_slave_mbox_prepare_send(const ec_slave_t *, ec_datagram_t *,
uint8_t, size_t);
int ec_slave_mbox_prepare_check(const ec_slave_t *, ec_datagram_t *);
+17 -17
View File
@@ -821,7 +821,7 @@ void ec_master_queue_datagram(
if (queued_datagram == datagram) {
datagram->skip_count++;
if (master->debug_level)
EC_DBG("skipping datagram %x.\n", (unsigned int) datagram);
EC_DBG("skipping datagram %p.\n", datagram);
datagram->state = EC_DATAGRAM_QUEUED;
return;
}
@@ -934,7 +934,7 @@ void ec_master_send_datagrams(ec_master_t *master /**< EtherCAT master */)
EC_WRITE_U8(cur_data++, 0x00);
if (unlikely(master->debug_level > 1))
EC_DBG("frame size: %u\n", cur_data - frame_data);
EC_DBG("frame size: %zu\n", cur_data - frame_data);
// send frame
ec_device_send(&master->main_device, cur_data - frame_data);
@@ -988,7 +988,7 @@ void ec_master_receive_datagrams(ec_master_t *master, /**< EtherCAT master */
if (unlikely(size < EC_FRAME_HEADER_SIZE)) {
if (master->debug_level) {
EC_DBG("Corrupted frame received (size %u < %u byte):\n",
EC_DBG("Corrupted frame received (size %zu < %u byte):\n",
size, EC_FRAME_HEADER_SIZE);
ec_print_data(frame_data, size);
}
@@ -1005,8 +1005,8 @@ void ec_master_receive_datagrams(ec_master_t *master, /**< EtherCAT master */
if (unlikely(frame_size > size)) {
if (master->debug_level) {
EC_DBG("Corrupted frame received (invalid frame size %u for "
"received size %u):\n", frame_size, size);
EC_DBG("Corrupted frame received (invalid frame size %zu for "
"received size %zu):\n", frame_size, size);
ec_print_data(frame_data, size);
}
master->stats.corrupted++;
@@ -1026,7 +1026,7 @@ void ec_master_receive_datagrams(ec_master_t *master, /**< EtherCAT master */
if (unlikely(cur_data - frame_data
+ data_size + EC_DATAGRAM_FOOTER_SIZE > size)) {
if (master->debug_level) {
EC_DBG("Corrupted frame received (invalid data size %u):\n",
EC_DBG("Corrupted frame received (invalid data size %zu):\n",
data_size);
ec_print_data(frame_data, size);
}
@@ -1803,7 +1803,7 @@ ec_domain_t *ecrt_master_create_domain_err(
unsigned int index;
if (master->debug_level)
EC_DBG("ecrt_master_create_domain(master = 0x%x)\n", (u32) master);
EC_DBG("ecrt_master_create_domain(master = 0x%p)\n", master);
if (!(domain = (ec_domain_t *) kmalloc(sizeof(ec_domain_t), GFP_KERNEL))) {
EC_ERR("Error allocating domain memory!\n");
@@ -1849,7 +1849,7 @@ int ecrt_master_activate(ec_master_t *master)
int ret;
if (master->debug_level)
EC_DBG("ecrt_master_activate(master = 0x%x)\n", (u32) master);
EC_DBG("ecrt_master_activate(master = 0x%p)\n", master);
if (master->active) {
EC_WARN("%s: Master already active!\n", __func__);
@@ -1864,7 +1864,7 @@ int ecrt_master_activate(ec_master_t *master)
ret = ec_domain_finish(domain, domain_offset);
if (ret < 0) {
up(&master->master_sem);
EC_ERR("Failed to finish domain 0x%08X!\n", (u32) domain);
EC_ERR("Failed to finish domain 0x%p!\n", domain);
return ret;
}
domain_offset += domain->data_size;
@@ -1884,7 +1884,7 @@ int ecrt_master_activate(ec_master_t *master)
ec_master_thread_stop(master);
if (master->debug_level)
EC_DBG("FSM datagram is %x.\n", (unsigned int) &master->fsm_datagram);
EC_DBG("FSM datagram is %p.\n", &master->fsm_datagram);
master->injection_seq_fsm = 0;
master->injection_seq_rt = 0;
@@ -2042,8 +2042,8 @@ void ecrt_master_receive(ec_master_t *master)
time_us = (unsigned int) ((master->main_device.jiffies_poll -
datagram->jiffies_sent) * 1000000 / HZ);
#endif
EC_DBG("TIMED OUT datagram %08x, index %02X waited %u us.\n",
(unsigned int) datagram, datagram->index, time_us);
EC_DBG("TIMED OUT datagram %p, index %02X waited %u us.\n",
datagram, datagram->index, time_us);
}
}
}
@@ -2079,9 +2079,9 @@ ec_slave_config_t *ecrt_master_slave_config_err(ec_master_t *master,
if (master->debug_level)
EC_DBG("ecrt_master_slave_config(master = 0x%x, alias = %u, "
EC_DBG("ecrt_master_slave_config(master = 0x%p, alias = %u, "
"position = %u, vendor_id = 0x%08x, product_code = 0x%08x)\n",
(u32) master, alias, position, vendor_id, product_code);
master, alias, position, vendor_id, product_code);
list_for_each_entry(sc, &master->configs, list) {
if (sc->alias == alias && sc->position == position) {
@@ -2142,9 +2142,9 @@ void ecrt_master_callbacks(ec_master_t *master,
void (*send_cb)(void *), void (*receive_cb)(void *), void *cb_data)
{
if (master->debug_level)
EC_DBG("ecrt_master_callbacks(master = 0x%x, send_cb = 0x%x, "
" receive_cb = 0x%x, cb_data = 0x%x)\n", (u32) master,
(u32) send_cb, (u32) receive_cb, (u32) cb_data);
EC_DBG("ecrt_master_callbacks(master = 0x%p, send_cb = 0x%p, "
" receive_cb = 0x%p, cb_data = 0x%p)\n", master,
send_cb, receive_cb, cb_data);
master->app_send_cb = send_cb;
master->app_receive_cb = receive_cb;
+2 -1
View File
@@ -471,7 +471,8 @@ ec_device_t *ecdev_offer(
ec_device_attach(&master->main_device, net_dev, poll, module);
up(&master->device_sem);
sprintf(net_dev->name, "ec%u", master->index);
snprintf(net_dev->name, IFNAMSIZ, "ec%u", master->index);
return &master->main_device; // offer accepted
}
else {
+1 -1
View File
@@ -145,7 +145,7 @@ int ec_sdo_request_alloc(
ec_sdo_request_clear_data(req);
if (!(req->data = (uint8_t *) kmalloc(size, GFP_KERNEL))) {
EC_ERR("Failed to allocate %u bytes of SDO memory.\n", size);
EC_ERR("Failed to allocate %zu bytes of SDO memory.\n", size);
return -ENOMEM;
}
+3 -3
View File
@@ -345,7 +345,7 @@ int ec_slave_fetch_sii_general(
uint8_t flags;
if (data_size != 32) {
EC_ERR("Wrong size of general category (%u/32) in slave %u.\n",
EC_ERR("Wrong size of general category (%zu/32) in slave %u.\n",
data_size, slave->ring_position);
return -EINVAL;
}
@@ -400,7 +400,7 @@ int ec_slave_fetch_sii_syncs(
// one sync manager struct is 4 words long
if (data_size % 8) {
EC_ERR("Invalid SII sync manager category size %u in slave %u.\n",
EC_ERR("Invalid SII sync manager category size %zu in slave %u.\n",
data_size, slave->ring_position);
return -EINVAL;
}
@@ -415,7 +415,7 @@ int ec_slave_fetch_sii_syncs(
}
memsize = sizeof(ec_sync_t) * total_count;
if (!(syncs = kmalloc(memsize, GFP_KERNEL))) {
EC_ERR("Failed to allocate %u bytes for sync managers.\n",
EC_ERR("Failed to allocate %zu bytes for sync managers.\n",
memsize);
return -ENOMEM;
}
+32 -33
View File
@@ -418,9 +418,9 @@ int ecrt_slave_config_sync_manager(ec_slave_config_t *sc, uint8_t sync_index,
ec_sync_config_t *sync_config;
if (sc->master->debug_level)
EC_DBG("ecrt_slave_config_sync_manager(sc = 0x%x, sync_index = %u, "
EC_DBG("ecrt_slave_config_sync_manager(sc = 0x%p, sync_index = %u, "
"dir = %i, watchdog_mode = %i)\n",
(u32) sc, sync_index, dir, watchdog_mode);
sc, sync_index, dir, watchdog_mode);
if (sync_index >= EC_MAX_SYNC_MANAGERS) {
EC_ERR("Invalid sync manager index %u!\n", sync_index);
@@ -444,8 +444,8 @@ void ecrt_slave_config_watchdog(ec_slave_config_t *sc,
uint16_t divider, uint16_t intervals)
{
if (sc->master->debug_level)
EC_DBG("%s(sc = 0x%x, divider = %u, intervals = %u)\n",
__func__, (u32) sc, divider, intervals);
EC_DBG("%s(sc = 0x%p, divider = %u, intervals = %u)\n",
__func__, sc, divider, intervals);
sc->watchdog_divider = divider;
sc->watchdog_intervals = intervals;
@@ -459,8 +459,8 @@ int ecrt_slave_config_pdo_assign_add(ec_slave_config_t *sc,
ec_pdo_t *pdo;
if (sc->master->debug_level)
EC_DBG("ecrt_slave_config_pdo_assign_add(sc = 0x%x, sync_index = %u, "
"pdo_index = 0x%04X)\n", (u32) sc, sync_index, pdo_index);
EC_DBG("ecrt_slave_config_pdo_assign_add(sc = 0x%p, sync_index = %u, "
"pdo_index = 0x%04X)\n", sc, sync_index, pdo_index);
if (sync_index >= EC_MAX_SYNC_MANAGERS) {
EC_ERR("Invalid sync manager index %u!\n", sync_index);
@@ -488,8 +488,8 @@ void ecrt_slave_config_pdo_assign_clear(ec_slave_config_t *sc,
uint8_t sync_index)
{
if (sc->master->debug_level)
EC_DBG("ecrt_slave_config_pdo_assign_clear(sc = 0x%x, "
"sync_index = %u)\n", (u32) sc, sync_index);
EC_DBG("ecrt_slave_config_pdo_assign_clear(sc = 0x%p, "
"sync_index = %u)\n", sc, sync_index);
if (sync_index >= EC_MAX_SYNC_MANAGERS) {
EC_ERR("Invalid sync manager index %u!\n", sync_index);
@@ -513,10 +513,10 @@ int ecrt_slave_config_pdo_mapping_add(ec_slave_config_t *sc,
int retval = 0;
if (sc->master->debug_level)
EC_DBG("ecrt_slave_config_pdo_mapping_add(sc = 0x%x, "
EC_DBG("ecrt_slave_config_pdo_mapping_add(sc = 0x%p, "
"pdo_index = 0x%04X, entry_index = 0x%04X, "
"entry_subindex = 0x%02X, entry_bit_length = %u)\n",
(u32) sc, pdo_index, entry_index, entry_subindex,
sc, pdo_index, entry_index, entry_subindex,
entry_bit_length);
for (sync_index = 0; sync_index < EC_MAX_SYNC_MANAGERS; sync_index++)
@@ -549,8 +549,8 @@ void ecrt_slave_config_pdo_mapping_clear(ec_slave_config_t *sc,
ec_pdo_t *pdo = NULL;
if (sc->master->debug_level)
EC_DBG("ecrt_slave_config_pdo_mapping_clear(sc = 0x%x, "
"pdo_index = 0x%04X)\n", (u32) sc, pdo_index);
EC_DBG("ecrt_slave_config_pdo_mapping_clear(sc = 0x%p, "
"pdo_index = 0x%04X)\n", sc, pdo_index);
for (sync_index = 0; sync_index < EC_MAX_SYNC_MANAGERS; sync_index++)
if ((pdo = ec_pdo_list_find_pdo(
@@ -579,8 +579,8 @@ int ecrt_slave_config_pdos(ec_slave_config_t *sc,
const ec_pdo_entry_info_t *entry_info;
if (sc->master->debug_level)
EC_DBG("ecrt_slave_config_pdos(sc = 0x%x, n_syncs = %u, "
"syncs = 0x%x)\n", (u32) sc, n_syncs, (u32) syncs);
EC_DBG("ecrt_slave_config_pdos(sc = 0x%p, n_syncs = %u, "
"syncs = 0x%p)\n", sc, n_syncs, syncs);
if (!syncs)
return 0;
@@ -651,9 +651,9 @@ int ecrt_slave_config_reg_pdo_entry(
int sync_offset;
if (sc->master->debug_level)
EC_DBG("ecrt_slave_config_reg_pdo_entry(sc = 0x%x, index = 0x%04X, "
"subindex = 0x%02X, domain = 0x%x, bit_position = 0x%x)\n",
(u32) sc, index, subindex, (u32) domain, (u32) bit_position);
EC_DBG("ecrt_slave_config_reg_pdo_entry(sc = 0x%p, index = 0x%04X, "
"subindex = 0x%02X, domain = 0x%p, bit_position = 0x%p)\n",
sc, index, subindex, domain, bit_position);
for (sync_index = 0; sync_index < EC_MAX_SYNC_MANAGERS; sync_index++) {
sync_config = &sc->sync_configs[sync_index];
@@ -713,9 +713,9 @@ int ecrt_slave_config_sdo(ec_slave_config_t *sc, uint16_t index,
int ret;
if (sc->master->debug_level)
EC_DBG("ecrt_slave_config_sdo(sc = 0x%x, index = 0x%04X, "
"subindex = 0x%02X, data = 0x%x, size = %u)\n", (u32) sc,
index, subindex, (u32) data, size);
EC_DBG("ecrt_slave_config_sdo(sc = 0x%p, index = 0x%04X, "
"subindex = 0x%02X, data = 0x%p, size = %zu)\n", sc,
index, subindex, data, size);
if (slave && !(slave->sii.mailbox_protocols & EC_MBOX_COE)) {
EC_ERR("Slave %u does not support CoE!\n", slave->ring_position);
@@ -752,8 +752,8 @@ int ecrt_slave_config_sdo8(ec_slave_config_t *sc, uint16_t index,
uint8_t data[1];
if (sc->master->debug_level)
EC_DBG("ecrt_slave_config_sdo8(sc = 0x%x, index = 0x%04X, "
"subindex = 0x%02X, value = %u)\n", (u32) sc,
EC_DBG("ecrt_slave_config_sdo8(sc = 0x%p, index = 0x%04X, "
"subindex = 0x%02X, value = %u)\n", sc,
index, subindex, (u32) value);
EC_WRITE_U8(data, value);
@@ -768,8 +768,8 @@ int ecrt_slave_config_sdo16(ec_slave_config_t *sc, uint16_t index,
uint8_t data[2];
if (sc->master->debug_level)
EC_DBG("ecrt_slave_config_sdo16(sc = 0x%x, index = 0x%04X, "
"subindex = 0x%02X, value = %u)\n", (u32) sc,
EC_DBG("ecrt_slave_config_sdo16(sc = 0x%p, index = 0x%04X, "
"subindex = 0x%02X, value = %u)\n", sc,
index, subindex, value);
EC_WRITE_U16(data, value);
@@ -784,8 +784,8 @@ int ecrt_slave_config_sdo32(ec_slave_config_t *sc, uint16_t index,
uint8_t data[4];
if (sc->master->debug_level)
EC_DBG("ecrt_slave_config_sdo32(sc = 0x%x, index = 0x%04X, "
"subindex = 0x%02X, value = %u)\n", (u32) sc,
EC_DBG("ecrt_slave_config_sdo32(sc = 0x%p, index = 0x%04X, "
"subindex = 0x%02X, value = %u)\n", sc,
index, subindex, value);
EC_WRITE_U32(data, value);
@@ -802,9 +802,8 @@ int ecrt_slave_config_complete_sdo(ec_slave_config_t *sc, uint16_t index,
int ret;
if (sc->master->debug_level)
EC_DBG("ecrt_slave_config_complete_sdo(sc = 0x%x, index = 0x%04X, "
"data = 0x%x, size = %u)\n", (u32) sc,
index, (u32) data, size);
EC_DBG("ecrt_slave_config_complete_sdo(sc = 0x%p, index = 0x%04X, "
"data = 0x%p, size = %zu)\n", sc, index, data, size);
if (slave && !(slave->sii.mailbox_protocols & EC_MBOX_COE)) {
EC_ERR("Slave %u does not support CoE!\n", slave->ring_position);
@@ -846,8 +845,8 @@ ec_sdo_request_t *ecrt_slave_config_create_sdo_request_err(
int ret;
if (sc->master->debug_level)
EC_DBG("ecrt_slave_config_create_sdo_request(sc = 0x%x, "
"index = 0x%04X, subindex = 0x%02X, size = %u)\n", (u32) sc,
EC_DBG("ecrt_slave_config_create_sdo_request(sc = 0x%p, "
"index = 0x%04X, subindex = 0x%02X, size = %zu)\n", sc,
index, subindex, size);
if (!(req = (ec_sdo_request_t *)
@@ -899,8 +898,8 @@ ec_voe_handler_t *ecrt_slave_config_create_voe_handler_err(
int ret;
if (sc->master->debug_level)
EC_DBG("ecrt_slave_config_create_voe_handler(sc = 0x%x, size = %u)\n",
(u32) sc, size);
EC_DBG("ecrt_slave_config_create_voe_handler(sc = 0x%p, size = %zu)\n",
sc, size);
if (!(voe = (ec_voe_handler_t *)
kmalloc(sizeof(ec_voe_handler_t), GFP_KERNEL))) {
+5 -4
View File
@@ -212,7 +212,7 @@ void ec_voe_handler_state_write_start(ec_voe_handler_t *voe)
uint8_t *data;
if (slave->master->debug_level) {
EC_DBG("Writing %u bytes of VoE data to slave %u.\n",
EC_DBG("Writing %zu bytes of VoE data to slave %u.\n",
voe->data_size, slave->ring_position);
ec_print_data(ecrt_voe_handler_data(voe), voe->data_size);
}
@@ -234,6 +234,7 @@ void ec_voe_handler_state_write_start(ec_voe_handler_t *voe)
EC_WRITE_U32(data, voe->vendor_id);
EC_WRITE_U16(data + 4, voe->vendor_type);
/* data already in datagram */
voe->retries = EC_FSM_RETRIES;
voe->jiffies_start = jiffies;
@@ -419,7 +420,7 @@ void ec_voe_handler_state_read_response(ec_voe_handler_t *voe)
if (rec_size < EC_VOE_HEADER_SIZE) {
voe->state = ec_voe_handler_state_error;
voe->request_state = EC_INT_REQUEST_FAILURE;
EC_ERR("Received VoE header is incomplete (%u bytes)!\n", rec_size);
EC_ERR("Received VoE header is incomplete (%zu bytes)!\n", rec_size);
return;
}
@@ -488,7 +489,7 @@ void ec_voe_handler_state_read_nosync_response(ec_voe_handler_t *voe)
voe->state = ec_voe_handler_state_error;
voe->request_state = EC_INT_REQUEST_FAILURE;
if (master->debug_level)
EC_DBG("Slave %u did not send VoE data.", slave->ring_position);
EC_DBG("Slave %u did not send VoE data.\n", slave->ring_position);
return;
}
@@ -519,7 +520,7 @@ void ec_voe_handler_state_read_nosync_response(ec_voe_handler_t *voe)
if (rec_size < EC_VOE_HEADER_SIZE) {
voe->state = ec_voe_handler_state_error;
voe->request_state = EC_INT_REQUEST_FAILURE;
EC_ERR("Received VoE header is incomplete (%u bytes)!\n", rec_size);
EC_ERR("Received VoE header is incomplete (%zu bytes)!\n", rec_size);
return;
}
+12 -6
View File
@@ -173,13 +173,17 @@ start)
if ! ${MODINFO} ${ECMODULE} > /dev/null; then
continue # ec_* module not found
fi
if lsmod | grep "^${MODULE} " > /dev/null; then
if ! ${RMMOD} ${MODULE}; then
exit_fail
if [ ${MODULE} != "generic" ]; then
if lsmod | grep "^${MODULE} " > /dev/null; then
if ! ${RMMOD} ${MODULE}; then
exit_fail
fi
fi
fi
if ! ${MODPROBE} ${MODPROBE_FLAGS} ${ECMODULE}; then
${MODPROBE} ${MODPROBE_FLAGS} ${MODULE} # try to restore module
if [ ${MODULE} != "generic" ]; then
${MODPROBE} ${MODPROBE_FLAGS} ${MODULE} # try to restore
fi
exit_fail
fi
done
@@ -205,8 +209,10 @@ stop)
# reload previous modules
for MODULE in ${DEVICE_MODULES}; do
if ! ${MODPROBE} ${MODPROBE_FLAGS} ${MODULE}; then
echo Warning: Failed to restore ${MODULE}.
if [ ${MODULE} != "generic" ]; then
if ! ${MODPROBE} ${MODPROBE_FLAGS} ${MODULE}; then
echo Warning: Failed to restore ${MODULE}.
fi
fi
done
+11 -7
View File
@@ -26,17 +26,21 @@ MASTER0_DEVICE=""
#MASTER1_DEVICE=""
#
# Ethernet driver modules to replace with EtherCAT-capable ones.
# Ethernet driver modules to use for EtherCAT operation.
#
# The init script will try to unload the Ethernet driver modules in the list
# and replace them with the EtherCAT-capable ones, respectively. If a certain
# (EtherCAT-capable) driver is not found, a warning will appear.
# Specify a non-empty list of Ethernet drivers, that shall be used for EtherCAT
# operation.
#
# Possible values: 8139too, e100, e1000, r8169.
# Except for the generic Ethernet driver module, the init script will try to
# unload the usual Ethernet driver modules in the list and replace them with
# the EtherCAT-capable ones. If a certain (EtherCAT-capable) driver is not
# found, a warning will appear.
#
# Possible values: 8139too, e100, e1000, r8169, generic.
# Separate multiple drivers with spaces.
#
# Note: The e100, e1000 and r8169 drivers are not built by default. Enable them
# with the --enable-<driver> configure switches.
# Note: The e100, e1000, r8169 and generic drivers are not built by default.
# Enable them with the --enable-<driver> configure switches.
#
DEVICE_MODULES=""
+5 -5
View File
@@ -191,18 +191,18 @@ void CommandXml::generateSlaveXml(
if (entry.bit_length == 1) {
cout << "BOOL";
} else if (!(entry.bit_length % 8)) {
if (entry.bit_length <= 64)
if (entry.bit_length <= 64) {
cout << "UINT" << (unsigned int) entry.bit_length;
else
} else {
cout << "STRING("
<< (unsigned int) (entry.bit_length / 8)
<< ")";
}
} else {
cerr << "Invalid bit length "
<< (unsigned int) entry.bit_length << endl;
cout << "BIT" << (unsigned int) entry.bit_length;
}
cout << "</DataType>" << endl;
cout << "</DataType>" << endl;
}
cout << in << " </Entry>" << endl;
+47
View File
@@ -0,0 +1,47 @@
#------------------------------------------------------------------------------
#
# $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_tty.o
ec_tty-objs := \
module.o
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)
#------------------------------------------------------------------------------
+60
View File
@@ -0,0 +1,60 @@
#------------------------------------------------------------------------------
#
# $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 \
README
BUILT_SOURCES = \
Kbuild
modules:
$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" modules
modules_install:
mkdir -p $(DESTDIR)$(LINUX_MOD_PATH)
cp $(srcdir)/ec_tty.ko $(DESTDIR)$(LINUX_MOD_PATH)
clean-local:
$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" clean
modulesdir=@prefix@/modules
SYMVERS=`echo $(top_builddir)/Module*.symvers`
install-data-local:
@test -n "$(SYMVERS)" && \
mkdir -p $(DESTDIR)$(modulesdir) && \
cp -vf $(SYMVERS) \
$(DESTDIR)$(modulesdir)/ec_tty.symvers
#------------------------------------------------------------------------------
+25
View File
@@ -0,0 +1,25 @@
$Id$
vim700: spelllang=en spell
Virtual TTY interface driver for EtherCAT slave supporting serial comm
Quick installation guide:
./configure --with-linux-dir=/your/linux/directory --enable-tty
make all modules
make modules_install install
rcethercat start
insmod tty/ec_tty.ko
insmod examples/tty/ec_tty_example.ko
The default settings for the serial line are 9600 8 N 1.
The tty example operates a Beckhoff EL6002 at ring position 1. For a short
test, connect port X1 with a serial port via null modem cable. If a minicom is
started on that port and the below command is entered, the output should be
visible in minicom:
echo "Hello World" > /dev/ttyEC0
Have a lot of fun!
+696
View File
File diff suppressed because it is too large Load Diff