Merged
This commit is contained in:
commit
10e265ca58
|
|
@ -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
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
|
|
|||
10
Makefile.am
10
Makefile.am
|
|
@ -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
NEWS
1
NEWS
|
|
@ -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),
|
||||
|
|
|
|||
17
TODO
17
TODO
|
|
@ -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
configure.ac
50
configure.ac
|
|
@ -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,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
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
|
@ -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 */
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -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
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ DIST_SUBDIRS = \
|
|||
dc_user \
|
||||
mini \
|
||||
rtai \
|
||||
tty \
|
||||
user
|
||||
|
||||
EXTRA_DIST = \
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
|
@ -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
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
|
@ -0,0 +1,552 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* $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.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include <linux/version.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/timer.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/err.h>
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
|
||||
#include <linux/semaphore.h>
|
||||
#else
|
||||
#include <asm/semaphore.h>
|
||||
#endif
|
||||
|
||||
#include "../../include/ecrt.h" // EtherCAT realtime interface
|
||||
#include "../../include/ectty.h" // EtherCAT TTY interface
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
// Module parameters
|
||||
#define FREQUENCY 100
|
||||
|
||||
// Optional features
|
||||
|
||||
#define PFX "ec_tty_example: "
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
// EtherCAT
|
||||
static ec_master_t *master = NULL;
|
||||
static ec_master_state_t master_state = {};
|
||||
struct semaphore master_sem;
|
||||
|
||||
static ec_domain_t *domain1 = NULL;
|
||||
static ec_domain_state_t domain1_state = {};
|
||||
|
||||
// Timer
|
||||
static struct timer_list timer;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
// process data
|
||||
static uint8_t *domain1_pd; // process data memory
|
||||
|
||||
#define BusCouplerPos 0, 0
|
||||
#define SerialPos 0, 1
|
||||
|
||||
#define Beckhoff_EK1100 0x00000002, 0x044c2c52
|
||||
#define Beckhoff_EL6002 0x00000002, 0x17723052
|
||||
|
||||
// offsets for PDO entries
|
||||
static unsigned int off_ctrl;
|
||||
static unsigned int off_tx;
|
||||
static unsigned int off_status;
|
||||
static unsigned int off_rx;
|
||||
|
||||
const static ec_pdo_entry_reg_t domain1_regs[] = {
|
||||
{SerialPos, Beckhoff_EL6002, 0x7001, 0x01, &off_ctrl},
|
||||
{SerialPos, Beckhoff_EL6002, 0x7000, 0x11, &off_tx},
|
||||
{SerialPos, Beckhoff_EL6002, 0x6001, 0x01, &off_status},
|
||||
{SerialPos, Beckhoff_EL6002, 0x6000, 0x11, &off_rx},
|
||||
{}
|
||||
};
|
||||
|
||||
static unsigned int counter = 0;
|
||||
|
||||
typedef enum {
|
||||
SER_REQUEST_INIT,
|
||||
SER_WAIT_FOR_INIT_RESPONSE,
|
||||
SER_READY
|
||||
} serial_state_t;
|
||||
|
||||
typedef struct {
|
||||
size_t max_tx_data_size;
|
||||
size_t max_rx_data_size;
|
||||
|
||||
uint8_t *tx_data;
|
||||
uint8_t tx_data_size;
|
||||
|
||||
serial_state_t state;
|
||||
|
||||
uint8_t tx_request_toggle;
|
||||
uint8_t tx_accepted_toggle;
|
||||
|
||||
uint8_t rx_request_toggle;
|
||||
uint8_t rx_accepted_toggle;
|
||||
|
||||
uint16_t control;
|
||||
} serial_device_t;
|
||||
|
||||
static serial_device_t *ser = NULL;
|
||||
static ec_tty_t *tty = NULL;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* Slave 1, "EL6002"
|
||||
* Vendor ID: 0x00000002
|
||||
* Product code: 0x17723052
|
||||
* Revision number: 0x00100000
|
||||
*/
|
||||
|
||||
ec_pdo_entry_info_t slave_1_pdo_entries[] = {
|
||||
{0x7001, 0x01, 16}, /* Ctrl */
|
||||
{0x7000, 0x11, 8}, /* Data Out 0 */
|
||||
{0x7000, 0x12, 8}, /* Data Out 1 */
|
||||
{0x7000, 0x13, 8}, /* Data Out 2 */
|
||||
{0x7000, 0x14, 8}, /* Data Out 3 */
|
||||
{0x7000, 0x15, 8}, /* Data Out 4 */
|
||||
{0x7000, 0x16, 8}, /* Data Out 5 */
|
||||
{0x7000, 0x17, 8}, /* Data Out 6 */
|
||||
{0x7000, 0x18, 8}, /* Data Out 7 */
|
||||
{0x7000, 0x19, 8}, /* Data Out 8 */
|
||||
{0x7000, 0x1a, 8}, /* Data Out 9 */
|
||||
{0x7000, 0x1b, 8}, /* Data Out 10 */
|
||||
{0x7000, 0x1c, 8}, /* Data Out 11 */
|
||||
{0x7000, 0x1d, 8}, /* Data Out 12 */
|
||||
{0x7000, 0x1e, 8}, /* Data Out 13 */
|
||||
{0x7000, 0x1f, 8}, /* Data Out 14 */
|
||||
{0x7000, 0x20, 8}, /* Data Out 15 */
|
||||
{0x7000, 0x21, 8}, /* Data Out 16 */
|
||||
{0x7000, 0x22, 8}, /* Data Out 17 */
|
||||
{0x7000, 0x23, 8}, /* Data Out 18 */
|
||||
{0x7000, 0x24, 8}, /* Data Out 19 */
|
||||
{0x7000, 0x25, 8}, /* Data Out 20 */
|
||||
{0x7000, 0x26, 8}, /* Data Out 21 */
|
||||
{0x7011, 0x01, 16}, /* Ctrl */
|
||||
{0x7010, 0x11, 8}, /* Data Out 0 */
|
||||
{0x7010, 0x12, 8}, /* Data Out 1 */
|
||||
{0x7010, 0x13, 8}, /* Data Out 2 */
|
||||
{0x7010, 0x14, 8}, /* Data Out 3 */
|
||||
{0x7010, 0x15, 8}, /* Data Out 4 */
|
||||
{0x7010, 0x16, 8}, /* Data Out 5 */
|
||||
{0x7010, 0x17, 8}, /* Data Out 6 */
|
||||
{0x7010, 0x18, 8}, /* Data Out 7 */
|
||||
{0x7010, 0x19, 8}, /* Data Out 8 */
|
||||
{0x7010, 0x1a, 8}, /* Data Out 9 */
|
||||
{0x7010, 0x1b, 8}, /* Data Out 10 */
|
||||
{0x7010, 0x1c, 8}, /* Data Out 11 */
|
||||
{0x7010, 0x1d, 8}, /* Data Out 12 */
|
||||
{0x7010, 0x1e, 8}, /* Data Out 13 */
|
||||
{0x7010, 0x1f, 8}, /* Data Out 14 */
|
||||
{0x7010, 0x20, 8}, /* Data Out 15 */
|
||||
{0x7010, 0x21, 8}, /* Data Out 16 */
|
||||
{0x7010, 0x22, 8}, /* Data Out 17 */
|
||||
{0x7010, 0x23, 8}, /* Data Out 18 */
|
||||
{0x7010, 0x24, 8}, /* Data Out 19 */
|
||||
{0x7010, 0x25, 8}, /* Data Out 20 */
|
||||
{0x7010, 0x26, 8}, /* Data Out 21 */
|
||||
{0x6001, 0x01, 16}, /* Status */
|
||||
{0x6000, 0x11, 8}, /* Data In 0 */
|
||||
{0x6000, 0x12, 8}, /* Data In 1 */
|
||||
{0x6000, 0x13, 8}, /* Data In 2 */
|
||||
{0x6000, 0x14, 8}, /* Data In 3 */
|
||||
{0x6000, 0x15, 8}, /* Data In 4 */
|
||||
{0x6000, 0x16, 8}, /* Data In 5 */
|
||||
{0x6000, 0x17, 8}, /* Data In 6 */
|
||||
{0x6000, 0x18, 8}, /* Data In 7 */
|
||||
{0x6000, 0x19, 8}, /* Data In 8 */
|
||||
{0x6000, 0x1a, 8}, /* Data In 9 */
|
||||
{0x6000, 0x1b, 8}, /* Data In 10 */
|
||||
{0x6000, 0x1c, 8}, /* Data In 11 */
|
||||
{0x6000, 0x1d, 8}, /* Data In 12 */
|
||||
{0x6000, 0x1e, 8}, /* Data In 13 */
|
||||
{0x6000, 0x1f, 8}, /* Data In 14 */
|
||||
{0x6000, 0x20, 8}, /* Data In 15 */
|
||||
{0x6000, 0x21, 8}, /* Data In 16 */
|
||||
{0x6000, 0x22, 8}, /* Data In 17 */
|
||||
{0x6000, 0x23, 8}, /* Data In 18 */
|
||||
{0x6000, 0x24, 8}, /* Data In 19 */
|
||||
{0x6000, 0x25, 8}, /* Data In 20 */
|
||||
{0x6000, 0x26, 8}, /* Data In 21 */
|
||||
{0x6011, 0x01, 16}, /* Status */
|
||||
{0x6010, 0x11, 8}, /* Data In 0 */
|
||||
{0x6010, 0x12, 8}, /* Data In 1 */
|
||||
{0x6010, 0x13, 8}, /* Data In 2 */
|
||||
{0x6010, 0x14, 8}, /* Data In 3 */
|
||||
{0x6010, 0x15, 8}, /* Data In 4 */
|
||||
{0x6010, 0x16, 8}, /* Data In 5 */
|
||||
{0x6010, 0x17, 8}, /* Data In 6 */
|
||||
{0x6010, 0x18, 8}, /* Data In 7 */
|
||||
{0x6010, 0x19, 8}, /* Data In 8 */
|
||||
{0x6010, 0x1a, 8}, /* Data In 9 */
|
||||
{0x6010, 0x1b, 8}, /* Data In 10 */
|
||||
{0x6010, 0x1c, 8}, /* Data In 11 */
|
||||
{0x6010, 0x1d, 8}, /* Data In 12 */
|
||||
{0x6010, 0x1e, 8}, /* Data In 13 */
|
||||
{0x6010, 0x1f, 8}, /* Data In 14 */
|
||||
{0x6010, 0x20, 8}, /* Data In 15 */
|
||||
{0x6010, 0x21, 8}, /* Data In 16 */
|
||||
{0x6010, 0x22, 8}, /* Data In 17 */
|
||||
{0x6010, 0x23, 8}, /* Data In 18 */
|
||||
{0x6010, 0x24, 8}, /* Data In 19 */
|
||||
{0x6010, 0x25, 8}, /* Data In 20 */
|
||||
{0x6010, 0x26, 8}, /* Data In 21 */
|
||||
};
|
||||
|
||||
ec_pdo_info_t slave_1_pdos[] = {
|
||||
{0x1604, 23, slave_1_pdo_entries + 0}, /* COM RxPDO-Map Outputs Ch.1 */
|
||||
{0x1605, 23, slave_1_pdo_entries + 23}, /* COM RxPDO-Map Outputs Ch.2 */
|
||||
{0x1a04, 23, slave_1_pdo_entries + 46}, /* COM TxPDO-Map Inputs Ch.1 */
|
||||
{0x1a05, 23, slave_1_pdo_entries + 69}, /* COM TxPDO-Map Inputs Ch.2 */
|
||||
};
|
||||
|
||||
ec_sync_info_t slave_1_syncs[] = {
|
||||
{0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
|
||||
{1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
|
||||
{2, EC_DIR_OUTPUT, 2, slave_1_pdos + 0, EC_WD_DISABLE},
|
||||
{3, EC_DIR_INPUT, 2, slave_1_pdos + 2, EC_WD_DISABLE},
|
||||
{0xff}
|
||||
};
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
int serial_init(serial_device_t *ser, size_t max_tx, size_t max_rx)
|
||||
{
|
||||
ser->max_tx_data_size = max_tx;
|
||||
ser->max_rx_data_size = max_rx;
|
||||
ser->tx_data = NULL;
|
||||
ser->tx_data_size = 0;
|
||||
ser->state = SER_REQUEST_INIT;
|
||||
ser->tx_request_toggle = 0;
|
||||
ser->rx_accepted_toggle = 0;
|
||||
ser->control = 0x0000;
|
||||
|
||||
if (max_tx > 0) {
|
||||
ser->tx_data = kmalloc(max_tx, GFP_KERNEL);
|
||||
if (ser->tx_data == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
void serial_clear(serial_device_t *ser)
|
||||
{
|
||||
if (ser->tx_data) {
|
||||
kfree(ser->tx_data);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
void serial_run(serial_device_t *ser, uint16_t status, uint8_t *rx_data)
|
||||
{
|
||||
uint8_t tx_accepted_toggle, rx_request_toggle;
|
||||
|
||||
switch (ser->state) {
|
||||
case SER_READY:
|
||||
|
||||
/* Send data */
|
||||
|
||||
tx_accepted_toggle = status & 0x0001;
|
||||
if (tx_accepted_toggle != ser->tx_accepted_toggle) { // ready
|
||||
ser->tx_data_size =
|
||||
ectty_tx_data(tty, ser->tx_data, ser->max_tx_data_size);
|
||||
if (ser->tx_data_size) {
|
||||
printk(KERN_INFO PFX "Sending %u bytes.\n", ser->tx_data_size);
|
||||
ser->tx_request_toggle = !ser->tx_request_toggle;
|
||||
ser->tx_accepted_toggle = tx_accepted_toggle;
|
||||
}
|
||||
}
|
||||
|
||||
/* Receive data */
|
||||
|
||||
rx_request_toggle = status & 0x0002;
|
||||
if (rx_request_toggle != ser->rx_request_toggle) {
|
||||
uint8_t rx_data_size = status >> 8;
|
||||
ser->rx_request_toggle = rx_request_toggle;
|
||||
printk(KERN_INFO PFX "Received %u bytes.\n", rx_data_size);
|
||||
ectty_rx_data(tty, rx_data, rx_data_size);
|
||||
ser->rx_accepted_toggle = !ser->rx_accepted_toggle;
|
||||
}
|
||||
|
||||
ser->control =
|
||||
ser->tx_request_toggle |
|
||||
ser->rx_accepted_toggle << 1 |
|
||||
ser->tx_data_size << 8;
|
||||
break;
|
||||
|
||||
case SER_REQUEST_INIT:
|
||||
if (status & (1 << 2)) {
|
||||
ser->control = 0x0000;
|
||||
ser->state = SER_WAIT_FOR_INIT_RESPONSE;
|
||||
} else {
|
||||
ser->control = 1 << 2; // CW.2, request initialization
|
||||
}
|
||||
break;
|
||||
|
||||
case SER_WAIT_FOR_INIT_RESPONSE:
|
||||
if (!(status & (1 << 2))) {
|
||||
printk(KERN_INFO PFX "Init successful.\n");
|
||||
ser->tx_accepted_toggle = 1;
|
||||
ser->control = 0x0000;
|
||||
ser->state = SER_READY;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void check_domain1_state(void)
|
||||
{
|
||||
ec_domain_state_t ds;
|
||||
|
||||
down(&master_sem);
|
||||
ecrt_domain_state(domain1, &ds);
|
||||
up(&master_sem);
|
||||
|
||||
if (ds.working_counter != domain1_state.working_counter)
|
||||
printk(KERN_INFO PFX "Domain1: WC %u.\n", ds.working_counter);
|
||||
if (ds.wc_state != domain1_state.wc_state)
|
||||
printk(KERN_INFO PFX "Domain1: State %u.\n", ds.wc_state);
|
||||
|
||||
domain1_state = ds;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void check_master_state(void)
|
||||
{
|
||||
ec_master_state_t ms;
|
||||
|
||||
down(&master_sem);
|
||||
ecrt_master_state(master, &ms);
|
||||
up(&master_sem);
|
||||
|
||||
if (ms.slaves_responding != master_state.slaves_responding)
|
||||
printk(KERN_INFO PFX "%u slave(s).\n", ms.slaves_responding);
|
||||
if (ms.al_states != master_state.al_states)
|
||||
printk(KERN_INFO PFX "AL states: 0x%02X.\n", ms.al_states);
|
||||
if (ms.link_up != master_state.link_up)
|
||||
printk(KERN_INFO PFX "Link is %s.\n", ms.link_up ? "up" : "down");
|
||||
|
||||
master_state = ms;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void cyclic_task(unsigned long data)
|
||||
{
|
||||
// receive process data
|
||||
down(&master_sem);
|
||||
ecrt_master_receive(master);
|
||||
ecrt_domain_process(domain1);
|
||||
up(&master_sem);
|
||||
|
||||
// check process data state (optional)
|
||||
check_domain1_state();
|
||||
|
||||
if (counter) {
|
||||
counter--;
|
||||
} else { // do this at 1 Hz
|
||||
counter = FREQUENCY;
|
||||
|
||||
// check for master state (optional)
|
||||
check_master_state();
|
||||
}
|
||||
|
||||
serial_run(ser, EC_READ_U16(domain1_pd + off_status), domain1_pd + off_rx);
|
||||
EC_WRITE_U16(domain1_pd + off_ctrl, ser->control);
|
||||
memcpy(domain1_pd + off_tx, ser->tx_data, 22);
|
||||
|
||||
// send process data
|
||||
down(&master_sem);
|
||||
ecrt_domain_queue(domain1);
|
||||
ecrt_master_send(master);
|
||||
up(&master_sem);
|
||||
|
||||
// restart timer
|
||||
timer.expires += HZ / FREQUENCY;
|
||||
add_timer(&timer);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void send_callback(void *cb_data)
|
||||
{
|
||||
ec_master_t *m = (ec_master_t *) cb_data;
|
||||
down(&master_sem);
|
||||
ecrt_master_send_ext(m);
|
||||
up(&master_sem);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void receive_callback(void *cb_data)
|
||||
{
|
||||
ec_master_t *m = (ec_master_t *) cb_data;
|
||||
down(&master_sem);
|
||||
ecrt_master_receive(m);
|
||||
up(&master_sem);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
int __init init_mini_module(void)
|
||||
{
|
||||
int ret = -1;
|
||||
ec_slave_config_t *sc;
|
||||
|
||||
printk(KERN_INFO PFX "Starting...\n");
|
||||
|
||||
ser = kmalloc(sizeof(*ser), GFP_KERNEL);
|
||||
if (!ser) {
|
||||
printk(KERN_ERR PFX "Failed to allocate serial device object.\n");
|
||||
ret = -ENOMEM;
|
||||
goto out_return;
|
||||
}
|
||||
|
||||
ret = serial_init(ser, 22, 22);
|
||||
if (ret) {
|
||||
printk(KERN_ERR PFX "Failed to init serial device object.\n");
|
||||
goto out_free_serial;
|
||||
}
|
||||
|
||||
tty = ectty_create();
|
||||
if (IS_ERR(tty)) {
|
||||
printk(KERN_ERR PFX "Failed to create tty.\n");
|
||||
ret = PTR_ERR(tty);
|
||||
goto out_serial;
|
||||
}
|
||||
|
||||
master = ecrt_request_master(0);
|
||||
if (!master) {
|
||||
ret = -EBUSY;
|
||||
printk(KERN_ERR PFX "Requesting master 0 failed.\n");
|
||||
goto out_tty;
|
||||
}
|
||||
|
||||
sema_init(&master_sem, 1);
|
||||
ecrt_master_callbacks(master, send_callback, receive_callback, master);
|
||||
|
||||
printk(KERN_INFO PFX "Registering domain...\n");
|
||||
if (!(domain1 = ecrt_master_create_domain(master))) {
|
||||
printk(KERN_ERR PFX "Domain creation failed!\n");
|
||||
goto out_release_master;
|
||||
}
|
||||
|
||||
// Create configuration for bus coupler
|
||||
sc = ecrt_master_slave_config(master, BusCouplerPos, Beckhoff_EK1100);
|
||||
if (!sc)
|
||||
return -1;
|
||||
|
||||
if (!(sc = ecrt_master_slave_config(
|
||||
master, SerialPos, Beckhoff_EL6002))) {
|
||||
printk(KERN_ERR PFX "Failed to get slave configuration.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printk("Configuring PDOs...\n");
|
||||
if (ecrt_slave_config_pdos(sc, EC_END, slave_1_syncs)) {
|
||||
printk(KERN_ERR PFX "Failed to configure PDOs.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) {
|
||||
printk(KERN_ERR PFX "PDO entry registration failed!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printk(KERN_INFO PFX "Activating master...\n");
|
||||
if (ecrt_master_activate(master)) {
|
||||
printk(KERN_ERR PFX "Failed to activate master!\n");
|
||||
goto out_release_master;
|
||||
}
|
||||
|
||||
// Get internal process data for domain
|
||||
domain1_pd = ecrt_domain_data(domain1);
|
||||
|
||||
printk(KERN_INFO PFX "Starting cyclic sample thread.\n");
|
||||
init_timer(&timer);
|
||||
timer.function = cyclic_task;
|
||||
timer.expires = jiffies + 10;
|
||||
add_timer(&timer);
|
||||
|
||||
printk(KERN_INFO PFX "Started.\n");
|
||||
return 0;
|
||||
|
||||
out_release_master:
|
||||
printk(KERN_ERR PFX "Releasing master...\n");
|
||||
ecrt_release_master(master);
|
||||
out_tty:
|
||||
ectty_free(tty);
|
||||
out_serial:
|
||||
serial_clear(ser);
|
||||
out_free_serial:
|
||||
kfree(ser);
|
||||
out_return:
|
||||
printk(KERN_ERR PFX "Failed to load. Aborting.\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void __exit cleanup_mini_module(void)
|
||||
{
|
||||
printk(KERN_INFO PFX "Stopping...\n");
|
||||
|
||||
del_timer_sync(&timer);
|
||||
|
||||
printk(KERN_INFO PFX "Releasing master...\n");
|
||||
ecrt_release_master(master);
|
||||
|
||||
ectty_free(tty);
|
||||
serial_clear(ser);
|
||||
kfree(ser);
|
||||
|
||||
printk(KERN_INFO PFX "Unloading.\n");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Florian Pose <fp@igh-essen.com>");
|
||||
MODULE_DESCRIPTION("EtherCAT minimal test environment");
|
||||
|
||||
module_init(init_mini_module);
|
||||
module_exit(cleanup_mini_module);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -31,6 +31,8 @@
|
|||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
include_HEADERS = ecrt.h
|
||||
include_HEADERS = \
|
||||
ecrt.h \
|
||||
ectty.h
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 *);
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
343
master/fsm_coe.c
343
master/fsm_coe.c
|
|
@ -45,6 +45,10 @@
|
|||
*/
|
||||
#define EC_FSM_COE_DICT_TIMEOUT 3000
|
||||
|
||||
#define EC_COE_DOWN_REQ_HEADER_SIZE 10
|
||||
#define EC_COE_DOWN_SEG_REQ_HEADER_SIZE 3
|
||||
#define EC_COE_DOWN_SEG_MIN_DATA_SIZE 7
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void ec_fsm_coe_dict_start(ec_fsm_coe_t *);
|
||||
|
|
@ -62,6 +66,8 @@ void ec_fsm_coe_down_start(ec_fsm_coe_t *);
|
|||
void ec_fsm_coe_down_request(ec_fsm_coe_t *);
|
||||
void ec_fsm_coe_down_check(ec_fsm_coe_t *);
|
||||
void ec_fsm_coe_down_response(ec_fsm_coe_t *);
|
||||
void ec_fsm_coe_down_seg_check(ec_fsm_coe_t *);
|
||||
void ec_fsm_coe_down_seg_response(ec_fsm_coe_t *);
|
||||
|
||||
void ec_fsm_coe_up_start(ec_fsm_coe_t *);
|
||||
void ec_fsm_coe_up_request(ec_fsm_coe_t *);
|
||||
|
|
@ -446,7 +452,7 @@ void ec_fsm_coe_dict_response(ec_fsm_coe_t *fsm /**< finite state machine */)
|
|||
}
|
||||
|
||||
if (rec_size < 3) {
|
||||
EC_ERR("Received corrupted SDO dictionary response (size %u).\n",
|
||||
EC_ERR("Received corrupted SDO dictionary response (size %zu).\n",
|
||||
rec_size);
|
||||
fsm->state = ec_fsm_coe_error;
|
||||
return;
|
||||
|
|
@ -480,7 +486,7 @@ void ec_fsm_coe_dict_response(ec_fsm_coe_t *fsm /**< finite state machine */)
|
|||
}
|
||||
|
||||
if (rec_size < 8 || rec_size % 2) {
|
||||
EC_ERR("Invalid data size %u!\n", rec_size);
|
||||
EC_ERR("Invalid data size %zu!\n", rec_size);
|
||||
ec_print_data(data, rec_size);
|
||||
fsm->state = ec_fsm_coe_error;
|
||||
return;
|
||||
|
|
@ -690,7 +696,7 @@ void ec_fsm_coe_dict_desc_response(ec_fsm_coe_t *fsm
|
|||
}
|
||||
|
||||
if (rec_size < 3) {
|
||||
EC_ERR("Received corrupted SDO description response (size %u).\n",
|
||||
EC_ERR("Received corrupted SDO description response (size %zu).\n",
|
||||
rec_size);
|
||||
fsm->state = ec_fsm_coe_error;
|
||||
return;
|
||||
|
|
@ -707,7 +713,7 @@ void ec_fsm_coe_dict_desc_response(ec_fsm_coe_t *fsm
|
|||
}
|
||||
|
||||
if (rec_size < 8) {
|
||||
EC_ERR("Received corrupted SDO description response (size %u).\n",
|
||||
EC_ERR("Received corrupted SDO description response (size %zu).\n",
|
||||
rec_size);
|
||||
fsm->state = ec_fsm_coe_error;
|
||||
return;
|
||||
|
|
@ -929,7 +935,7 @@ void ec_fsm_coe_dict_entry_response(ec_fsm_coe_t *fsm
|
|||
|
||||
if (rec_size < 3) {
|
||||
EC_ERR("Received corrupted SDO entry description response "
|
||||
"(size %u).\n", rec_size);
|
||||
"(size %zu).\n", rec_size);
|
||||
fsm->state = ec_fsm_coe_error;
|
||||
return;
|
||||
}
|
||||
|
|
@ -946,7 +952,7 @@ void ec_fsm_coe_dict_entry_response(ec_fsm_coe_t *fsm
|
|||
|
||||
if (rec_size < 9) {
|
||||
EC_ERR("Received corrupted SDO entry description response "
|
||||
"(size %u).\n", rec_size);
|
||||
"(size %zu).\n", rec_size);
|
||||
fsm->state = ec_fsm_coe_error;
|
||||
return;
|
||||
}
|
||||
|
|
@ -969,7 +975,7 @@ void ec_fsm_coe_dict_entry_response(ec_fsm_coe_t *fsm
|
|||
}
|
||||
|
||||
if (rec_size < 16) {
|
||||
EC_ERR("Invalid data size %u!\n", rec_size);
|
||||
EC_ERR("Invalid data size %zu!\n", rec_size);
|
||||
ec_print_data(data, rec_size);
|
||||
fsm->state = ec_fsm_coe_error;
|
||||
return;
|
||||
|
|
@ -1061,17 +1067,17 @@ void ec_fsm_coe_dict_entry_response(ec_fsm_coe_t *fsm
|
|||
* CoE state machine
|
||||
*****************************************************************************/
|
||||
|
||||
/**
|
||||
CoE state: DOWN START.
|
||||
*/
|
||||
|
||||
void ec_fsm_coe_down_start(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||
/** CoE state: DOWN START.
|
||||
*/
|
||||
void ec_fsm_coe_down_start(
|
||||
ec_fsm_coe_t *fsm /**< finite state machine */
|
||||
)
|
||||
{
|
||||
ec_datagram_t *datagram = fsm->datagram;
|
||||
ec_slave_t *slave = fsm->slave;
|
||||
ec_sdo_request_t *request = fsm->request;
|
||||
uint8_t *data;
|
||||
uint8_t size;
|
||||
uint8_t data_set_size;
|
||||
|
||||
if (fsm->slave->master->debug_level) {
|
||||
char subidxstr[10];
|
||||
|
|
@ -1091,18 +1097,28 @@ void ec_fsm_coe_down_start(ec_fsm_coe_t *fsm /**< finite state machine */)
|
|||
return;
|
||||
}
|
||||
|
||||
if (slave->configured_rx_mailbox_size <
|
||||
EC_MBOX_HEADER_SIZE + EC_COE_DOWN_REQ_HEADER_SIZE) {
|
||||
EC_ERR("Mailbox too small!\n");
|
||||
fsm->state = ec_fsm_coe_error;
|
||||
return;
|
||||
}
|
||||
|
||||
if (request->data_size <= 4) { // use expedited transfer type
|
||||
data = ec_slave_mbox_prepare_send(slave, datagram, 0x03, 10);
|
||||
data = ec_slave_mbox_prepare_send(slave, datagram, 0x03,
|
||||
EC_COE_DOWN_REQ_HEADER_SIZE);
|
||||
if (IS_ERR(data)) {
|
||||
fsm->state = ec_fsm_coe_error;
|
||||
return;
|
||||
}
|
||||
|
||||
size = 4 - request->data_size;
|
||||
fsm->remaining = 0;
|
||||
|
||||
data_set_size = 4 - request->data_size;
|
||||
|
||||
EC_WRITE_U16(data, 0x2 << 12); // SDO request
|
||||
EC_WRITE_U8 (data + 2, (0x3 // size specified, expedited
|
||||
| size << 2
|
||||
| data_set_size << 2
|
||||
| ((request->complete_access ? 1 : 0) << 4)
|
||||
| 0x1 << 5)); // Download request
|
||||
EC_WRITE_U16(data + 3, request->index);
|
||||
|
|
@ -1113,36 +1129,54 @@ void ec_fsm_coe_down_start(ec_fsm_coe_t *fsm /**< finite state machine */)
|
|||
|
||||
if (slave->master->debug_level) {
|
||||
EC_DBG("Expedited download request:\n");
|
||||
ec_print_data(data, 10);
|
||||
ec_print_data(data, EC_COE_DOWN_REQ_HEADER_SIZE);
|
||||
}
|
||||
}
|
||||
else { // request->data_size > 4, use normal transfer type
|
||||
if (slave->configured_rx_mailbox_size < 6 + 10 + request->data_size) {
|
||||
EC_ERR("SDO fragmenting not supported yet!\n"); // FIXME
|
||||
fsm->state = ec_fsm_coe_error;
|
||||
return;
|
||||
size_t data_size,
|
||||
max_data_size =
|
||||
slave->configured_rx_mailbox_size - EC_MBOX_HEADER_SIZE,
|
||||
required_data_size =
|
||||
EC_COE_DOWN_REQ_HEADER_SIZE + request->data_size;
|
||||
|
||||
if (max_data_size < required_data_size) {
|
||||
// segmenting needed
|
||||
data_size = max_data_size;
|
||||
} else {
|
||||
data_size = required_data_size;
|
||||
}
|
||||
|
||||
data = ec_slave_mbox_prepare_send(slave, datagram, 0x03,
|
||||
request->data_size + 10);
|
||||
data_size);
|
||||
if (IS_ERR(data)) {
|
||||
fsm->state = ec_fsm_coe_error;
|
||||
return;
|
||||
}
|
||||
|
||||
fsm->offset = 0;
|
||||
fsm->remaining = request->data_size;
|
||||
|
||||
EC_WRITE_U16(data, 0x2 << 12); // SDO request
|
||||
EC_WRITE_U8 (data + 2, (0x1 // size indicator, normal
|
||||
| ((request->complete_access ? 1 : 0) << 4)
|
||||
| 0x1 << 5)); // Download request
|
||||
EC_WRITE_U8(data + 2,
|
||||
0x1 // size indicator, normal
|
||||
| ((request->complete_access ? 1 : 0) << 4)
|
||||
| 0x1 << 5); // Download request
|
||||
EC_WRITE_U16(data + 3, request->index);
|
||||
EC_WRITE_U8 (data + 5,
|
||||
request->complete_access ? 0x00 : request->subindex);
|
||||
EC_WRITE_U32(data + 6, request->data_size);
|
||||
memcpy(data + 10, request->data, request->data_size);
|
||||
|
||||
if (data_size > EC_COE_DOWN_REQ_HEADER_SIZE) {
|
||||
size_t segment_size = data_size - EC_COE_DOWN_REQ_HEADER_SIZE;
|
||||
memcpy(data + EC_COE_DOWN_REQ_HEADER_SIZE,
|
||||
request->data, segment_size);
|
||||
fsm->offset += segment_size;
|
||||
fsm->remaining -= segment_size;
|
||||
}
|
||||
|
||||
if (slave->master->debug_level) {
|
||||
EC_DBG("Normal download request:\n");
|
||||
ec_print_data(data, 10 + request->data_size);
|
||||
ec_print_data(data, data_size);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1255,6 +1289,69 @@ void ec_fsm_coe_down_check(ec_fsm_coe_t *fsm /**< finite state machine */)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
void ec_fsm_coe_down_prepare_segment_request(
|
||||
ec_fsm_coe_t *fsm /**< finite state machine */
|
||||
)
|
||||
{
|
||||
ec_datagram_t *datagram = fsm->datagram;
|
||||
ec_slave_t *slave = fsm->slave;
|
||||
ec_sdo_request_t *request = fsm->request;
|
||||
size_t max_segment_size =
|
||||
slave->configured_rx_mailbox_size
|
||||
- EC_MBOX_HEADER_SIZE
|
||||
- EC_COE_DOWN_SEG_REQ_HEADER_SIZE;
|
||||
size_t segment_size, data_size;
|
||||
uint8_t last_segment, seg_data_size, *data;
|
||||
|
||||
if (fsm->remaining > max_segment_size) {
|
||||
segment_size = max_segment_size;
|
||||
last_segment = 0;
|
||||
} else {
|
||||
segment_size = fsm->remaining;
|
||||
last_segment = 1;
|
||||
}
|
||||
|
||||
if (segment_size > EC_COE_DOWN_SEG_MIN_DATA_SIZE) {
|
||||
seg_data_size = 0x00;
|
||||
data_size = EC_COE_DOWN_SEG_REQ_HEADER_SIZE + segment_size;
|
||||
} else {
|
||||
seg_data_size = EC_COE_DOWN_SEG_MIN_DATA_SIZE - segment_size;
|
||||
data_size = EC_COE_DOWN_SEG_REQ_HEADER_SIZE
|
||||
+ EC_COE_DOWN_SEG_MIN_DATA_SIZE;
|
||||
}
|
||||
|
||||
data = ec_slave_mbox_prepare_send(slave, datagram, 0x03,
|
||||
data_size);
|
||||
if (IS_ERR(data)) {
|
||||
fsm->state = ec_fsm_coe_error;
|
||||
return;
|
||||
}
|
||||
|
||||
EC_WRITE_U16(data, 0x2 << 12); // SDO request
|
||||
EC_WRITE_U8(data + 2, (last_segment ? 1 : 0)
|
||||
| (seg_data_size << 1)
|
||||
| (fsm->toggle << 4)
|
||||
| (0x00 << 5)); // Download segment request
|
||||
memcpy(data + EC_COE_DOWN_SEG_REQ_HEADER_SIZE,
|
||||
request->data + fsm->offset, segment_size);
|
||||
if (segment_size < EC_COE_DOWN_SEG_MIN_DATA_SIZE) {
|
||||
memset(data + EC_COE_DOWN_SEG_REQ_HEADER_SIZE + segment_size, 0x00,
|
||||
EC_COE_DOWN_SEG_MIN_DATA_SIZE - segment_size);
|
||||
}
|
||||
|
||||
fsm->offset += segment_size;
|
||||
fsm->remaining -= segment_size;
|
||||
|
||||
if (slave->master->debug_level) {
|
||||
EC_DBG("Download segment request:\n");
|
||||
ec_print_data(data, data_size);
|
||||
}
|
||||
|
||||
fsm->state = ec_fsm_coe_down_seg_check;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
CoE state: DOWN RESPONSE.
|
||||
\todo Timeout behavior
|
||||
|
|
@ -1314,7 +1411,7 @@ void ec_fsm_coe_down_response(ec_fsm_coe_t *fsm /**< finite state machine */)
|
|||
|
||||
if (rec_size < 6) {
|
||||
fsm->state = ec_fsm_coe_error;
|
||||
EC_ERR("Received data are too small (%u bytes):\n", rec_size);
|
||||
EC_ERR("Received data are too small (%zu bytes):\n", rec_size);
|
||||
ec_print_data(data, rec_size);
|
||||
return;
|
||||
}
|
||||
|
|
@ -1328,7 +1425,7 @@ void ec_fsm_coe_down_response(ec_fsm_coe_t *fsm /**< finite state machine */)
|
|||
} else {
|
||||
sprintf(subidxstr, ":%02X", request->subindex);
|
||||
}
|
||||
EC_ERR("SDO download 0x%04X%s (%u bytes) aborted on slave %u.\n",
|
||||
EC_ERR("SDO download 0x%04X%s (%zu bytes) aborted on slave %u.\n",
|
||||
request->index, subidxstr, request->data_size,
|
||||
slave->ring_position);
|
||||
if (rec_size < 10) {
|
||||
|
|
@ -1357,7 +1454,182 @@ void ec_fsm_coe_down_response(ec_fsm_coe_t *fsm /**< finite state machine */)
|
|||
return;
|
||||
}
|
||||
|
||||
fsm->state = ec_fsm_coe_end; // success
|
||||
if (fsm->remaining) { // more segments to download
|
||||
fsm->toggle = 0;
|
||||
ec_fsm_coe_down_prepare_segment_request(fsm);
|
||||
} else {
|
||||
fsm->state = ec_fsm_coe_end; // success
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
CoE state: DOWN SEG CHECK.
|
||||
*/
|
||||
|
||||
void ec_fsm_coe_down_seg_check(ec_fsm_coe_t *fsm /**< finite state machine */)
|
||||
{
|
||||
ec_datagram_t *datagram = fsm->datagram;
|
||||
ec_slave_t *slave = fsm->slave;
|
||||
|
||||
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--)
|
||||
return;
|
||||
|
||||
if (datagram->state != EC_DATAGRAM_RECEIVED) {
|
||||
fsm->state = ec_fsm_coe_error;
|
||||
EC_ERR("Failed to receive CoE mailbox check datagram for slave %u"
|
||||
" (datagram state %u).\n",
|
||||
slave->ring_position, datagram->state);
|
||||
return;
|
||||
}
|
||||
|
||||
if (datagram->working_counter != 1) {
|
||||
fsm->state = ec_fsm_coe_error;
|
||||
EC_ERR("Reception of CoE mailbox segment check"
|
||||
" datagram failed on slave %u: ", slave->ring_position);
|
||||
ec_datagram_print_wc_error(datagram);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ec_slave_mbox_check(datagram)) {
|
||||
unsigned long diff_ms =
|
||||
(datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ;
|
||||
if (diff_ms >= fsm->request->response_timeout) {
|
||||
fsm->state = ec_fsm_coe_error;
|
||||
EC_ERR("Timeout while waiting for SDO download segment response "
|
||||
"on slave %u.\n", slave->ring_position);
|
||||
return;
|
||||
}
|
||||
|
||||
ec_slave_mbox_prepare_check(slave, datagram); // can not fail.
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
return;
|
||||
}
|
||||
|
||||
// Fetch response
|
||||
ec_slave_mbox_prepare_fetch(slave, datagram); // can not fail.
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
fsm->state = ec_fsm_coe_down_seg_response;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
CoE state: DOWN SEG RESPONSE.
|
||||
\todo Timeout behavior
|
||||
*/
|
||||
|
||||
void ec_fsm_coe_down_seg_response(
|
||||
ec_fsm_coe_t *fsm /**< finite state machine */
|
||||
)
|
||||
{
|
||||
ec_datagram_t *datagram = fsm->datagram;
|
||||
ec_slave_t *slave = fsm->slave;
|
||||
uint8_t *data, mbox_prot;
|
||||
size_t rec_size;
|
||||
ec_sdo_request_t *request = fsm->request;
|
||||
|
||||
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--)
|
||||
return; // FIXME: request again?
|
||||
|
||||
if (datagram->state != EC_DATAGRAM_RECEIVED) {
|
||||
fsm->state = ec_fsm_coe_error;
|
||||
EC_ERR("Failed to receive CoE download response datagram from"
|
||||
" slave %u (datagram state %u).\n",
|
||||
slave->ring_position, datagram->state);
|
||||
return;
|
||||
}
|
||||
|
||||
if (datagram->working_counter != 1) {
|
||||
fsm->state = ec_fsm_coe_error;
|
||||
EC_ERR("Reception of CoE download response failed on slave %u: ",
|
||||
slave->ring_position);
|
||||
ec_datagram_print_wc_error(datagram);
|
||||
return;
|
||||
}
|
||||
|
||||
data = ec_slave_mbox_fetch(slave, datagram, &mbox_prot, &rec_size);
|
||||
if (IS_ERR(data)) {
|
||||
fsm->state = ec_fsm_coe_error;
|
||||
return;
|
||||
}
|
||||
|
||||
if (mbox_prot != 0x03) { // CoE
|
||||
fsm->state = ec_fsm_coe_error;
|
||||
EC_ERR("Received mailbox protocol 0x%02X as response.\n", mbox_prot);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ec_fsm_coe_check_emergency(fsm, data, rec_size)) {
|
||||
// check for CoE response again
|
||||
ec_slave_mbox_prepare_check(slave, datagram); // can not fail.
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
fsm->state = ec_fsm_coe_down_check;
|
||||
return;
|
||||
}
|
||||
|
||||
if (slave->master->debug_level) {
|
||||
EC_DBG("Download response:\n");
|
||||
ec_print_data(data, rec_size);
|
||||
}
|
||||
|
||||
if (rec_size < 6) {
|
||||
fsm->state = ec_fsm_coe_error;
|
||||
EC_ERR("Received data are too small (%zu bytes):\n", rec_size);
|
||||
ec_print_data(data, rec_size);
|
||||
return;
|
||||
}
|
||||
|
||||
if (EC_READ_U16(data) >> 12 == 0x2 && // SDO request
|
||||
EC_READ_U8 (data + 2) >> 5 == 0x4) { // abort SDO transfer request
|
||||
char subidxstr[10];
|
||||
fsm->state = ec_fsm_coe_error;
|
||||
if (request->complete_access) {
|
||||
subidxstr[0] = 0x00;
|
||||
} else {
|
||||
sprintf(subidxstr, ":%02X", request->subindex);
|
||||
}
|
||||
EC_ERR("SDO download 0x%04X%s (%zu bytes) aborted on slave %u.\n",
|
||||
request->index, subidxstr, request->data_size,
|
||||
slave->ring_position);
|
||||
if (rec_size < 10) {
|
||||
EC_ERR("Incomplete abort command:\n");
|
||||
ec_print_data(data, rec_size);
|
||||
} else {
|
||||
fsm->request->abort_code = EC_READ_U32(data + 6);
|
||||
ec_canopen_abort_msg(fsm->request->abort_code);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (EC_READ_U16(data) >> 12 != 0x3 ||
|
||||
((EC_READ_U8(data + 2) >> 5) != 0x01)) { // segment response
|
||||
if (slave->master->debug_level) {
|
||||
EC_DBG("Invalid SDO download response at slave %u! Retrying...\n",
|
||||
slave->ring_position);
|
||||
ec_print_data(data, rec_size);
|
||||
}
|
||||
// check for CoE response again
|
||||
ec_slave_mbox_prepare_check(slave, datagram); // can not fail.
|
||||
fsm->retries = EC_FSM_RETRIES;
|
||||
fsm->state = ec_fsm_coe_down_seg_check;
|
||||
return;
|
||||
}
|
||||
|
||||
if (((EC_READ_U8(data + 2) >> 4) & 0x01) != fsm->toggle) {
|
||||
EC_ERR("Invalid toggle received during segmented download:\n");
|
||||
ec_print_data(data, rec_size);
|
||||
fsm->state = ec_fsm_coe_error;
|
||||
return;
|
||||
}
|
||||
|
||||
if (fsm->remaining) { // more segments to download
|
||||
fsm->toggle = !fsm->toggle;
|
||||
ec_fsm_coe_down_prepare_segment_request(fsm);
|
||||
} else {
|
||||
fsm->state = ec_fsm_coe_end; // success
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -1526,6 +1798,7 @@ void ec_fsm_coe_up_prepare_segment_request(
|
|||
EC_WRITE_U16(data, 0x2 << 12); // SDO request
|
||||
EC_WRITE_U8 (data + 2, (fsm->toggle << 4 // toggle
|
||||
| 0x3 << 5)); // upload segment request
|
||||
memset(data + 3, 0x00, 7);
|
||||
|
||||
if (fsm->slave->master->debug_level) {
|
||||
EC_DBG("Upload segment request:\n");
|
||||
|
|
@ -1597,7 +1870,7 @@ void ec_fsm_coe_up_response(ec_fsm_coe_t *fsm /**< finite state machine */)
|
|||
|
||||
if (rec_size < 6) {
|
||||
fsm->state = ec_fsm_coe_error;
|
||||
EC_ERR("Received currupted SDO upload response (%u bytes)!\n", rec_size);
|
||||
EC_ERR("Received currupted SDO upload response (%zu bytes)!\n", rec_size);
|
||||
ec_print_data(data, rec_size);
|
||||
return;
|
||||
}
|
||||
|
|
@ -1657,7 +1930,7 @@ void ec_fsm_coe_up_response(ec_fsm_coe_t *fsm /**< finite state machine */)
|
|||
if (rec_size < 6 + fsm->complete_size) {
|
||||
fsm->state = ec_fsm_coe_error;
|
||||
EC_ERR("Received currupted SDO expedited upload"
|
||||
" response (only %u bytes)!\n", rec_size);
|
||||
" response (only %zu bytes)!\n", rec_size);
|
||||
ec_print_data(data, rec_size);
|
||||
return;
|
||||
}
|
||||
|
|
@ -1670,7 +1943,7 @@ void ec_fsm_coe_up_response(ec_fsm_coe_t *fsm /**< finite state machine */)
|
|||
if (rec_size < 10) {
|
||||
fsm->state = ec_fsm_coe_error;
|
||||
EC_ERR("Received currupted SDO normal upload"
|
||||
" response (only %u bytes)!\n", rec_size);
|
||||
" response (only %zu bytes)!\n", rec_size);
|
||||
ec_print_data(data, rec_size);
|
||||
return;
|
||||
}
|
||||
|
|
@ -1699,7 +1972,7 @@ void ec_fsm_coe_up_response(ec_fsm_coe_t *fsm /**< finite state machine */)
|
|||
|
||||
if (data_size < fsm->complete_size) {
|
||||
if (master->debug_level)
|
||||
EC_DBG("SDO data incomplete (%u / %u). Segmenting...\n",
|
||||
EC_DBG("SDO data incomplete (%zu / %u). Segmenting...\n",
|
||||
data_size, fsm->complete_size);
|
||||
|
||||
ec_fsm_coe_up_prepare_segment_request(fsm);
|
||||
|
|
@ -1927,7 +2200,7 @@ void ec_fsm_coe_up_seg_response(ec_fsm_coe_t *fsm /**< finite state machine */)
|
|||
|
||||
if (request->data_size != fsm->complete_size) {
|
||||
EC_WARN("SDO upload 0x%04X:%02X on slave %u: Assembled data"
|
||||
" size (%u) does not match complete size (%u)!\n",
|
||||
" size (%zu) does not match complete size (%u)!\n",
|
||||
request->index, request->subindex, slave->ring_position,
|
||||
request->data_size, fsm->complete_size);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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. */
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 *);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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))) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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=""
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
|
@ -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
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
|
@ -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!
|
||||
|
|
@ -0,0 +1,696 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* $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 tty driver module.
|
||||
*/
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/tty.h>
|
||||
#include <linux/tty_driver.h>
|
||||
#include <linux/tty_flip.h>
|
||||
#include <linux/termios.h>
|
||||
#include <linux/timer.h>
|
||||
|
||||
#include "../master/globals.h"
|
||||
#include "../include/ectty.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define PFX "ec_tty: "
|
||||
|
||||
#define EC_TTY_MAX_DEVICES 10
|
||||
#define EC_TTY_TX_BUFFER_SIZE 100
|
||||
#define EC_TTY_RX_BUFFER_SIZE 100
|
||||
|
||||
#define EC_TTY_DEBUG 0
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
char *ec_master_version_str = EC_MASTER_VERSION; /**< Version string. */
|
||||
unsigned int debug_level = 0;
|
||||
|
||||
static struct tty_driver *tty_driver = NULL;
|
||||
ec_tty_t *ttys[EC_TTY_MAX_DEVICES];
|
||||
struct semaphore tty_sem;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/** \cond */
|
||||
|
||||
MODULE_AUTHOR("Florian Pose <fp@igh-essen.com>");
|
||||
MODULE_DESCRIPTION("EtherCAT TTY driver module");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_VERSION(EC_MASTER_VERSION);
|
||||
|
||||
module_param_named(debug_level, debug_level, uint, S_IRUGO);
|
||||
MODULE_PARM_DESC(debug_level, "Debug level");
|
||||
|
||||
/** \endcond */
|
||||
|
||||
static struct ktermios ec_tty_std_termios = {
|
||||
.c_iflag = ICRNL | IXON,
|
||||
.c_oflag = OPOST,
|
||||
.c_cflag = B38400 | CS8 | CREAD | HUPCL,
|
||||
.c_lflag = ISIG | ICANON | ECHO | ECHOE | ECHOK | ECHOCTL | ECHOKE | IEXTEN,
|
||||
.c_cc = INIT_C_CC,
|
||||
};
|
||||
|
||||
struct ec_tty {
|
||||
int minor;
|
||||
struct device *dev;
|
||||
|
||||
uint8_t tx_buffer[EC_TTY_TX_BUFFER_SIZE];
|
||||
unsigned int tx_read_idx;
|
||||
unsigned int tx_write_idx;
|
||||
unsigned int wakeup;
|
||||
|
||||
uint8_t rx_buffer[EC_TTY_RX_BUFFER_SIZE];
|
||||
unsigned int rx_read_idx;
|
||||
unsigned int rx_write_idx;
|
||||
|
||||
struct timer_list timer;
|
||||
struct tty_struct *tty;
|
||||
};
|
||||
|
||||
static const struct tty_operations ec_tty_ops; // see below
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Module initialization.
|
||||
*
|
||||
* \return 0 on success, else < 0
|
||||
*/
|
||||
int __init ec_tty_init_module(void)
|
||||
{
|
||||
int i, ret = 0;
|
||||
|
||||
printk(KERN_INFO PFX "TTY driver %s\n", EC_MASTER_VERSION);
|
||||
|
||||
init_MUTEX(&tty_sem);
|
||||
|
||||
for (i = 0; i < EC_TTY_MAX_DEVICES; i++) {
|
||||
ttys[i] = NULL;
|
||||
}
|
||||
|
||||
tty_driver = alloc_tty_driver(EC_TTY_MAX_DEVICES);
|
||||
if (!tty_driver) {
|
||||
printk(KERN_ERR PFX "Failed to allocate tty driver.\n");
|
||||
ret = -ENOMEM;
|
||||
goto out_return;
|
||||
}
|
||||
|
||||
tty_driver->owner = THIS_MODULE;
|
||||
tty_driver->driver_name = "EtherCAT TTY";
|
||||
tty_driver->name = "ttyEC";
|
||||
tty_driver->major = 0;
|
||||
tty_driver->minor_start = 0;
|
||||
tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
|
||||
tty_driver->subtype = SERIAL_TYPE_NORMAL;
|
||||
tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
|
||||
tty_driver->init_termios = ec_tty_std_termios;
|
||||
tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
|
||||
tty_set_operations(tty_driver, &ec_tty_ops);
|
||||
|
||||
ret = tty_register_driver(tty_driver);
|
||||
if (ret) {
|
||||
printk(KERN_ERR PFX "Failed to register tty driver.\n");
|
||||
goto out_put;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
out_put:
|
||||
put_tty_driver(tty_driver);
|
||||
out_return:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Module cleanup.
|
||||
*
|
||||
* Clears all master instances.
|
||||
*/
|
||||
void __exit ec_tty_cleanup_module(void)
|
||||
{
|
||||
tty_unregister_driver(tty_driver);
|
||||
put_tty_driver(tty_driver);
|
||||
printk(KERN_INFO PFX "Module unloading.\n");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned int ec_tty_tx_size(ec_tty_t *tty)
|
||||
{
|
||||
unsigned int ret;
|
||||
|
||||
if (tty->tx_write_idx >= tty->tx_read_idx) {
|
||||
ret = tty->tx_write_idx - tty->tx_read_idx;
|
||||
} else {
|
||||
ret = EC_TTY_TX_BUFFER_SIZE + tty->tx_write_idx - tty->tx_read_idx;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned int ec_tty_tx_space(ec_tty_t *tty)
|
||||
{
|
||||
return EC_TTY_TX_BUFFER_SIZE - 1 - ec_tty_tx_size(tty);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned int ec_tty_rx_size(ec_tty_t *tty)
|
||||
{
|
||||
unsigned int ret;
|
||||
|
||||
if (tty->rx_write_idx >= tty->rx_read_idx) {
|
||||
ret = tty->rx_write_idx - tty->rx_read_idx;
|
||||
} else {
|
||||
ret = EC_TTY_RX_BUFFER_SIZE + tty->rx_write_idx - tty->rx_read_idx;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned int ec_tty_rx_space(ec_tty_t *tty)
|
||||
{
|
||||
return EC_TTY_RX_BUFFER_SIZE - 1 - ec_tty_rx_size(tty);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void ec_tty_wakeup(unsigned long data)
|
||||
{
|
||||
ec_tty_t *tty = (ec_tty_t *) data;
|
||||
size_t to_recv;
|
||||
|
||||
/* Wake up any process waiting to send data */
|
||||
if (tty->wakeup) {
|
||||
if (tty->tty) {
|
||||
#if EC_TTY_DEBUG >= 1
|
||||
printk(KERN_INFO PFX "Waking up.\n");
|
||||
#endif
|
||||
tty_wakeup(tty->tty);
|
||||
}
|
||||
tty->wakeup = 0;
|
||||
}
|
||||
|
||||
/* Push received data into TTY core. */
|
||||
to_recv = ec_tty_rx_size(tty);
|
||||
if (to_recv && tty->tty) {
|
||||
unsigned char *cbuf;
|
||||
int space = tty_prepare_flip_string(tty->tty, &cbuf, to_recv);
|
||||
|
||||
if (space < to_recv) {
|
||||
printk(KERN_WARNING PFX "Insufficient space to_recv=%d space=%d\n",
|
||||
to_recv, space);
|
||||
}
|
||||
|
||||
if (space < 0) {
|
||||
to_recv = 0;
|
||||
} else {
|
||||
to_recv = space;
|
||||
}
|
||||
|
||||
if (to_recv) {
|
||||
unsigned int i;
|
||||
|
||||
#if EC_TTY_DEBUG >= 1
|
||||
printk(KERN_INFO PFX "Pushing %u bytes to TTY core.\n", to_recv);
|
||||
#endif
|
||||
|
||||
for (i = 0; i < to_recv; i++) {
|
||||
cbuf[i] = tty->rx_buffer[tty->rx_read_idx];
|
||||
tty->rx_read_idx = (tty->rx_read_idx + 1) % EC_TTY_RX_BUFFER_SIZE;
|
||||
}
|
||||
tty_flip_buffer_push(tty->tty);
|
||||
}
|
||||
}
|
||||
|
||||
tty->timer.expires += 1;
|
||||
add_timer(&tty->timer);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
int ec_tty_init(ec_tty_t *tty, int minor)
|
||||
{
|
||||
tty->minor = minor;
|
||||
tty->tx_read_idx = 0;
|
||||
tty->tx_write_idx = 0;
|
||||
tty->wakeup = 0;
|
||||
tty->rx_read_idx = 0;
|
||||
tty->rx_write_idx = 0;
|
||||
init_timer(&tty->timer);
|
||||
tty->tty = NULL;
|
||||
|
||||
tty->dev = tty_register_device(tty_driver, tty->minor, NULL);
|
||||
if (IS_ERR(tty->dev)) {
|
||||
printk(KERN_ERR PFX "Failed to register tty device.\n");
|
||||
return PTR_ERR(tty->dev);
|
||||
}
|
||||
|
||||
tty->timer.function = ec_tty_wakeup;
|
||||
tty->timer.data = (unsigned long) tty;
|
||||
tty->timer.expires = jiffies + 10;
|
||||
add_timer(&tty->timer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void ec_tty_clear(ec_tty_t *tty)
|
||||
{
|
||||
del_timer_sync(&tty->timer);
|
||||
tty_unregister_device(tty_driver, tty->minor);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Device callbacks
|
||||
*****************************************************************************/
|
||||
|
||||
static int ec_tty_open(struct tty_struct *tty, struct file *file)
|
||||
{
|
||||
ec_tty_t *t;
|
||||
int line = tty->index;
|
||||
|
||||
#if EC_TTY_DEBUG >= 1
|
||||
printk(KERN_INFO PFX "Opening line %i.\n", line);
|
||||
#endif
|
||||
|
||||
if (line < 0 || line >= EC_TTY_MAX_DEVICES) {
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
t = ttys[line];
|
||||
if (!t) {
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
if (t->tty) {
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
t->tty = tty;
|
||||
tty->driver_data = t;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void ec_tty_close(struct tty_struct *tty, struct file *file)
|
||||
{
|
||||
ec_tty_t *t = (ec_tty_t *) tty->driver_data;
|
||||
|
||||
#if EC_TTY_DEBUG >= 1
|
||||
printk(KERN_INFO PFX "Closing line %i.\n", tty->index);
|
||||
#endif
|
||||
|
||||
if (t->tty == tty) {
|
||||
t->tty = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static int ec_tty_write(
|
||||
struct tty_struct *tty,
|
||||
const unsigned char *buffer,
|
||||
int count
|
||||
)
|
||||
{
|
||||
ec_tty_t *t = (ec_tty_t *) tty->driver_data;
|
||||
unsigned int data_size, i;
|
||||
|
||||
#if EC_TTY_DEBUG >= 1
|
||||
printk(KERN_INFO PFX "%s(count=%i)\n", __func__, count);
|
||||
#endif
|
||||
|
||||
if (count <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
data_size = min(ec_tty_tx_space(t), (unsigned int) count);
|
||||
for (i = 0; i < data_size; i++) {
|
||||
t->tx_buffer[t->tx_write_idx] = buffer[i];
|
||||
t->tx_write_idx = (t->tx_write_idx + 1) % EC_TTY_TX_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
#if EC_TTY_DEBUG >= 1
|
||||
printk(KERN_INFO PFX "%s(): %u bytes written.\n", __func__, data_size);
|
||||
#endif
|
||||
return data_size;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void ec_tty_put_char(struct tty_struct *tty, unsigned char ch)
|
||||
{
|
||||
ec_tty_t *t = (ec_tty_t *) tty->driver_data;
|
||||
|
||||
#if EC_TTY_DEBUG >= 1
|
||||
printk(KERN_INFO PFX "%s(): c=%02x.\n", __func__, (unsigned int) ch);
|
||||
#endif
|
||||
|
||||
if (ec_tty_tx_space(t)) {
|
||||
t->tx_buffer[t->tx_write_idx] = ch;
|
||||
t->tx_write_idx = (t->tx_write_idx + 1) % EC_TTY_TX_BUFFER_SIZE;
|
||||
} else {
|
||||
printk(KERN_WARNING PFX "%s(): Dropped a byte!\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static int ec_tty_write_room(struct tty_struct *tty)
|
||||
{
|
||||
ec_tty_t *t = (ec_tty_t *) tty->driver_data;
|
||||
int ret = ec_tty_tx_space(t);
|
||||
|
||||
#if EC_TTY_DEBUG >= 2
|
||||
printk(KERN_INFO PFX "%s() = %i.\n", __func__, ret);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static int ec_tty_chars_in_buffer(struct tty_struct *tty)
|
||||
{
|
||||
ec_tty_t *t = (ec_tty_t *) tty->driver_data;
|
||||
int ret;
|
||||
|
||||
#if EC_TTY_DEBUG >= 2
|
||||
printk(KERN_INFO PFX "%s().\n", __func__);
|
||||
#endif
|
||||
|
||||
ret = ec_tty_tx_size(t);
|
||||
|
||||
#if EC_TTY_DEBUG >= 2
|
||||
printk(KERN_INFO PFX "%s() = %i.\n", __func__, ret);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void ec_tty_flush_buffer(struct tty_struct *tty)
|
||||
{
|
||||
#if EC_TTY_DEBUG >= 2
|
||||
printk(KERN_INFO PFX "%s().\n", __func__);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static int ec_tty_ioctl(struct tty_struct *tty, struct file *file,
|
||||
unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
#if EC_TTY_DEBUG >= 2
|
||||
printk(KERN_INFO PFX "%s().\n", __func__);
|
||||
#endif
|
||||
return -ENOTTY;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void ec_tty_throttle(struct tty_struct *tty)
|
||||
{
|
||||
#if EC_TTY_DEBUG >= 2
|
||||
printk(KERN_INFO PFX "%s().\n", __func__);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void ec_tty_unthrottle(struct tty_struct *tty)
|
||||
{
|
||||
#if EC_TTY_DEBUG >= 2
|
||||
printk(KERN_INFO PFX "%s().\n", __func__);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void ec_tty_set_termios(struct tty_struct *tty,
|
||||
struct ktermios *old_termios)
|
||||
{
|
||||
#if EC_TTY_DEBUG >= 2
|
||||
printk(KERN_INFO PFX "%s().\n", __func__);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void ec_tty_stop(struct tty_struct *tty)
|
||||
{
|
||||
#if EC_TTY_DEBUG >= 2
|
||||
printk(KERN_INFO PFX "%s().\n", __func__);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void ec_tty_start(struct tty_struct *tty)
|
||||
{
|
||||
#if EC_TTY_DEBUG >= 2
|
||||
printk(KERN_INFO PFX "%s().\n", __func__);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void ec_tty_hangup(struct tty_struct *tty)
|
||||
{
|
||||
#if EC_TTY_DEBUG >= 2
|
||||
printk(KERN_INFO PFX "%s().\n", __func__);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void ec_tty_break(struct tty_struct *tty, int break_state)
|
||||
{
|
||||
#if EC_TTY_DEBUG >= 2
|
||||
printk(KERN_INFO PFX "%s(break_state = %i).\n", __func__, break_state);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void ec_tty_send_xchar(struct tty_struct *tty, char ch)
|
||||
{
|
||||
#if EC_TTY_DEBUG >= 2
|
||||
printk(KERN_INFO PFX "%s(ch=%02x).\n", __func__, (unsigned int) ch);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void ec_tty_wait_until_sent(struct tty_struct *tty, int timeout)
|
||||
{
|
||||
#if EC_TTY_DEBUG >= 2
|
||||
printk(KERN_INFO PFX "%s(timeout=%i).\n", __func__, timeout);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static int ec_tty_tiocmget(struct tty_struct *tty, struct file *file)
|
||||
{
|
||||
#if EC_TTY_DEBUG >= 2
|
||||
printk(KERN_INFO PFX "%s().\n", __func__);
|
||||
#endif
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static int ec_tty_tiocmset(struct tty_struct *tty, struct file *file,
|
||||
unsigned int set, unsigned int clear)
|
||||
{
|
||||
#if EC_TTY_DEBUG >= 2
|
||||
printk(KERN_INFO PFX "%s(set=%u, clear=%u).\n", __func__, set, clear);
|
||||
#endif
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static const struct tty_operations ec_tty_ops = {
|
||||
.open = ec_tty_open,
|
||||
.close = ec_tty_close,
|
||||
.write = ec_tty_write,
|
||||
.put_char = ec_tty_put_char,
|
||||
.write_room = ec_tty_write_room,
|
||||
.chars_in_buffer = ec_tty_chars_in_buffer,
|
||||
.flush_buffer = ec_tty_flush_buffer,
|
||||
.ioctl = ec_tty_ioctl,
|
||||
.throttle = ec_tty_throttle,
|
||||
.unthrottle = ec_tty_unthrottle,
|
||||
.set_termios = ec_tty_set_termios,
|
||||
.stop = ec_tty_stop,
|
||||
.start = ec_tty_start,
|
||||
.hangup = ec_tty_hangup,
|
||||
.break_ctl = ec_tty_break,
|
||||
.send_xchar = ec_tty_send_xchar,
|
||||
.wait_until_sent = ec_tty_wait_until_sent,
|
||||
.tiocmget = ec_tty_tiocmget,
|
||||
.tiocmset = ec_tty_tiocmset,
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
* Public functions and methods
|
||||
*****************************************************************************/
|
||||
|
||||
ec_tty_t *ectty_create(void)
|
||||
{
|
||||
ec_tty_t *tty;
|
||||
int minor, ret;
|
||||
|
||||
if (down_interruptible(&tty_sem)) {
|
||||
return ERR_PTR(-EINTR);
|
||||
}
|
||||
|
||||
for (minor = 0; minor < EC_TTY_MAX_DEVICES; minor++) {
|
||||
if (!ttys[minor]) {
|
||||
printk(KERN_INFO PFX "Creating TTY interface %i.\n", minor);
|
||||
|
||||
tty = kmalloc(sizeof(ec_tty_t), GFP_KERNEL);
|
||||
if (!tty) {
|
||||
up(&tty_sem);
|
||||
printk(KERN_ERR PFX "Failed to allocate memory.\n");
|
||||
return ERR_PTR(-ENOMEM);
|
||||
}
|
||||
|
||||
ret = ec_tty_init(tty, minor);
|
||||
if (ret) {
|
||||
up(&tty_sem);
|
||||
kfree(tty);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
|
||||
ttys[minor] = tty;
|
||||
up(&tty_sem);
|
||||
return tty;
|
||||
}
|
||||
}
|
||||
|
||||
up(&tty_sem);
|
||||
printk(KERN_ERR PFX "No free interfaces avaliable.\n");
|
||||
return ERR_PTR(-EBUSY);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void ectty_free(ec_tty_t *tty)
|
||||
{
|
||||
printk(KERN_INFO PFX "Freeing TTY interface %i.\n", tty->minor);
|
||||
|
||||
ec_tty_clear(tty);
|
||||
ttys[tty->minor] = NULL;
|
||||
kfree(tty);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned int ectty_tx_data(ec_tty_t *tty, uint8_t *buffer, size_t size)
|
||||
{
|
||||
unsigned int data_size = min(ec_tty_tx_size(tty), size), i;
|
||||
|
||||
if (data_size) {
|
||||
#if EC_TTY_DEBUG >= 1
|
||||
printk(KERN_INFO PFX "Fetching %u bytes to send.\n", data_size);
|
||||
#endif
|
||||
}
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
buffer[i] = tty->tx_buffer[tty->tx_read_idx];
|
||||
tty->tx_read_idx = (tty->tx_read_idx + 1) % EC_TTY_TX_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
if (data_size) {
|
||||
tty->wakeup = 1;
|
||||
}
|
||||
|
||||
return data_size;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void ectty_rx_data(ec_tty_t *tty, const uint8_t *buffer, size_t size)
|
||||
{
|
||||
size_t to_recv;
|
||||
|
||||
if (size) {
|
||||
unsigned int i;
|
||||
|
||||
#if EC_TTY_DEBUG >= 1
|
||||
printk(KERN_INFO PFX "Received %u bytes.\n", size);
|
||||
#endif
|
||||
|
||||
to_recv = min(ec_tty_rx_space(tty), size);
|
||||
|
||||
if (to_recv < size) {
|
||||
printk(KERN_WARNING PFX "Dropping %u bytes.\n", size - to_recv);
|
||||
}
|
||||
|
||||
for (i = 0; i < size; i++) {
|
||||
tty->rx_buffer[tty->rx_write_idx] = buffer[i];
|
||||
tty->rx_write_idx = (tty->rx_write_idx + 1) % EC_TTY_RX_BUFFER_SIZE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/** \cond */
|
||||
|
||||
module_init(ec_tty_init_module);
|
||||
module_exit(ec_tty_cleanup_module);
|
||||
|
||||
EXPORT_SYMBOL(ectty_create);
|
||||
EXPORT_SYMBOL(ectty_free);
|
||||
EXPORT_SYMBOL(ectty_tx_data);
|
||||
EXPORT_SYMBOL(ectty_rx_data);
|
||||
|
||||
/** \endcond */
|
||||
|
||||
/*****************************************************************************/
|
||||
Loading…
Reference in New Issue