examples/xenomai_posix/main.c
author Florian Pose <fp@igh-essen.com>
Wed, 04 Jan 2012 14:04:24 +0100
changeset 2186 064fe2a6835c
parent 2057 23fca60b7ca2
child 2589 2b9c78543663
permissions -rw-r--r--
Added r8169 driver for 2.6.37.
2056
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
     2
 *
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
     3
 *  $Id$
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
     4
 *
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
     5
 *  main.c	        Copyright (C) 2011       IgH Andreas Stewering-Bone
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
     6
 *
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
     7
 *  This file is part of ethercatrtdm interface to IgH EtherCAT master 
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
     8
 *  
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
     9
 *  The IgH EtherCAT master is free software; you can
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    10
 *  redistribute it and/or modify it under the terms of the GNU Lesser General
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    11
 *  Public License as published by the Free Software Foundation; version 2.1
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    12
 *  of the License.
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    13
 *
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    14
 *  The IgH EtherCAT Master is free software; you can redistribute it and/or
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    15
 *  modify it under the terms of the GNU General Public License version 2, as
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    16
 *  published by the Free Software Foundation.
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    17
 *
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    18
 *  The IgH EtherCAT master userspace library is distributed in the hope that
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    19
 *  it will be useful, but WITHOUT ANY WARRANTY; without even the implied
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    20
 *  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    21
 *  GNU Lesser General Public License for more details.
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    22
 *
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    23
 *  You should have received a copy of the GNU Lesser General Public License
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    24
 *  along with the IgH EtherCAT master userspace library. If not, see
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    25
 *  <http://www.gnu.org/licenses/>.
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    26
 *  
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    27
 *  The license mentioned above concerns the source code only. Using the
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    28
 *  EtherCAT technology and brand is only permitted in compliance with the
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    29
 *  industrial property and similar rights of Beckhoff Automation GmbH.
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    30
 *
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    31
 *****************************************************************************/
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    32
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    33
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    34
#include <errno.h>
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    35
#include <mqueue.h>
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    36
#include <signal.h>
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    37
#include <pthread.h>
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    38
#include <stdio.h>
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    39
#include <stdlib.h>
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    40
#include <string.h>
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    41
#include <unistd.h>
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    42
#include <limits.h>
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    43
#include <sys/ioctl.h>
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    44
#include <sys/mman.h>
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    45
#include <time.h>
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    46
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    47
#include <rtdm/rtdm.h>
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    48
#include <rtdk.h>
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    49
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    50
#include "../../include/ecrt.h"
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    51
#include "../../include/ec_rtdm.h"
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    52
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    53
#define NSEC_PER_SEC 1000000000
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    54
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    55
static unsigned int cycle = 1000; /* 1 ms */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    56
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    57
static pthread_t cyclicthread;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    58
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    59
int rt_fd = -1;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    60
int run=0;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    61
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    62
unsigned int sync_ref_counter = 0;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    63
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    64
CstructMstrAttach MstrAttach;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    65
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    66
/****************************************************************************/
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    67
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    68
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    69
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    70
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    71
// Optional features
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    72
#define CONFIGURE_PDOS  1
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    73
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    74
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    75
/****************************************************************************/
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    76
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    77
// EtherCAT
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    78
static ec_master_t *master = NULL;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    79
static ec_master_state_t master_state = {};
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    80
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    81
static ec_domain_t *domain1 = NULL;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    82
static ec_domain_state_t domain1_state = {};
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    83
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    84
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    85
/****************************************************************************/
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    86
static uint8_t *domain1_pd = NULL;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    87
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    88
// process data
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    89
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    90
#define BusCoupler01_Pos    0, 0
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    91
#define DigOutSlave01_Pos   0, 1
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    92
#define DigOutSlave02_Pos   0, 2
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    93
#define DigInSlave01_Pos    0, 3
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    94
#define AnaOutSlave01_Pos   0, 4
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    95
#define AnaInSlave01_Pos    0, 5
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    96
#define BusCoupler02_Pos    0, 6
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    97
#define AnaInSlave02_Pos    0, 7
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    98
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
    99
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   100
#define Beckhoff_EK1100 0x00000002, 0x044c2c52
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   101
#define Beckhoff_EL1014 0x00000002, 0x03f63052
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   102
#define Beckhoff_EL2004 0x00000002, 0x07d43052
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   103
#define Beckhoff_EL4132 0x00000002, 0x10243052
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   104
#define Beckhoff_EL3102 0x00000002, 0x0c1e3052
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   105
#define Beckhoff_EL4102 0x00000002, 0x10063052
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   106
#define Beckhoff_EL6731 0x00000002, 0x1a4b3052
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   107
#define Beckhoff_EL6600 0x00000002, 0x19c93052
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   108
#define Beckhoff_EL3602 0x00000002, 0x0e123052
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   109
#define Beckhoff_EL5151 0x00000002, 0x141f3052
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   110
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   111
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   112
// offsets for PDO entries
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   113
static unsigned int off_dig_out0      = 0;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   114
static unsigned int off_dig_out1      = 0;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   115
static unsigned int off_dig_out2      = 0;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   116
static unsigned int off_dig_out3      = 0;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   117
static unsigned int off_dig_in0       = 0;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   118
static unsigned int off_ana_out0      = 0;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   119
static unsigned int off_ana_out1      = 0;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   120
static unsigned int off_ana_in0_status = 0;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   121
static unsigned int off_ana_in0_value  = 0;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   122
static unsigned int off_ana_in1_status = 0;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   123
static unsigned int off_ana_in1_value  = 0;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   124
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   125
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   126
// process data
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   127
unsigned int bit_position0=0; /* Pointer to a variable to store a bit */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   128
unsigned int bit_position1=0; /* Pointer to a variable to store a bit */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   129
unsigned int bit_position2=0; /* Pointer to a variable to store a bit */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   130
unsigned int bit_position3=0; /* Pointer to a variable to store a bit */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   131
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   132
const static ec_pdo_entry_reg_t domain1_regs[] = {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   133
   {DigOutSlave01_Pos, Beckhoff_EL2004, 0x7000, 0x01, &off_dig_out0, &bit_position0},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   134
   {DigOutSlave01_Pos, Beckhoff_EL2004, 0x7010, 0x01, &off_dig_out1, &bit_position1},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   135
   {DigOutSlave01_Pos, Beckhoff_EL2004, 0x7020, 0x01, &off_dig_out2, &bit_position2},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   136
   {DigOutSlave01_Pos, Beckhoff_EL2004, 0x7030, 0x01, &off_dig_out3, &bit_position3},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   137
   {DigInSlave01_Pos,  Beckhoff_EL1014, 0x6000, 0x01, &off_dig_in0},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   138
   {AnaOutSlave01_Pos, Beckhoff_EL4132, 0x3001, 0x01, &off_ana_out0},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   139
   {AnaOutSlave01_Pos, Beckhoff_EL4132, 0x3002, 0x01, &off_ana_out1},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   140
   {AnaInSlave01_Pos,  Beckhoff_EL3102, 0x3101, 0x01, &off_ana_in0_status},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   141
   {AnaInSlave01_Pos,  Beckhoff_EL3102, 0x3101, 0x02, &off_ana_in0_value},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   142
   {AnaInSlave01_Pos,  Beckhoff_EL3102, 0x3102, 0x01, &off_ana_in1_status},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   143
   {AnaInSlave01_Pos,  Beckhoff_EL3102, 0x3102, 0x02, &off_ana_in1_value},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   144
   {}
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   145
};
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   146
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   147
char rt_dev_file[64];
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   148
static unsigned int blink = 0;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   149
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   150
static ec_slave_config_t *sc_dig_out_01 = NULL;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   151
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   152
static ec_slave_config_t *sc_dig_out_02 = NULL;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   153
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   154
static ec_slave_config_t *sc_dig_in_01 = NULL;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   155
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   156
static ec_slave_config_t *sc_ana_out_01 = NULL;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   157
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   158
static ec_slave_config_t *sc_ana_in_01 = NULL;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   159
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   160
static ec_slave_config_t *sc_ana_in_02 = NULL;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   161
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   162
/*****************************************************************************/
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   163
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   164
/* Slave 1, "EL2004"
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   165
 * Vendor ID:       0x00000002
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   166
 * Product code:    0x07d43052
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   167
 * Revision number: 0x00100000
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   168
 */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   169
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   170
ec_pdo_entry_info_t slave_1_pdo_entries[] = {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   171
   {0x7000, 0x01, 1}, /* Output */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   172
   {0x7010, 0x01, 1}, /* Output */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   173
   {0x7020, 0x01, 1}, /* Output */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   174
   {0x7030, 0x01, 1}, /* Output */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   175
};
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   176
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   177
ec_pdo_info_t slave_1_pdos[] = {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   178
   {0x1600, 1, slave_1_pdo_entries + 0}, /* Channel 1 */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   179
   {0x1601, 1, slave_1_pdo_entries + 1}, /* Channel 2 */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   180
   {0x1602, 1, slave_1_pdo_entries + 2}, /* Channel 3 */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   181
   {0x1603, 1, slave_1_pdo_entries + 3}, /* Channel 4 */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   182
};
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   183
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   184
ec_sync_info_t slave_1_syncs[] = {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   185
   {0, EC_DIR_OUTPUT, 4, slave_1_pdos + 0, EC_WD_ENABLE},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   186
   {0xff}
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   187
};
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   188
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   189
/* Slave 2, "EL2004"
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   190
 * Vendor ID:       0x00000002
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   191
 * Product code:    0x07d43052
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   192
 * Revision number: 0x00100000
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   193
 */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   194
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   195
ec_pdo_entry_info_t slave_2_pdo_entries[] = {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   196
   {0x7000, 0x01, 1}, /* Output */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   197
   {0x7010, 0x01, 1}, /* Output */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   198
   {0x7020, 0x01, 1}, /* Output */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   199
   {0x7030, 0x01, 1}, /* Output */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   200
};
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   201
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   202
ec_pdo_info_t slave_2_pdos[] = {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   203
   {0x1600, 1, slave_2_pdo_entries + 0}, /* Channel 1 */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   204
   {0x1601, 1, slave_2_pdo_entries + 1}, /* Channel 2 */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   205
   {0x1602, 1, slave_2_pdo_entries + 2}, /* Channel 3 */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   206
   {0x1603, 1, slave_2_pdo_entries + 3}, /* Channel 4 */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   207
};
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   208
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   209
ec_sync_info_t slave_2_syncs[] = {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   210
   {0, EC_DIR_OUTPUT, 4, slave_2_pdos + 0, EC_WD_ENABLE},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   211
   {0xff}
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   212
};
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   213
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   214
/* Slave 3, "EL1014"
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   215
 * Vendor ID:       0x00000002
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   216
 * Product code:    0x03f63052
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   217
 * Revision number: 0x00100000
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   218
 */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   219
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   220
ec_pdo_entry_info_t slave_3_pdo_entries[] = {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   221
   {0x6000, 0x01, 1}, /* Input */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   222
   {0x6010, 0x01, 1}, /* Input */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   223
   {0x6020, 0x01, 1}, /* Input */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   224
   {0x6030, 0x01, 1}, /* Input */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   225
};
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   226
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   227
ec_pdo_info_t slave_3_pdos[] = {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   228
   {0x1a00, 1, slave_3_pdo_entries + 0}, /* Channel 1 */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   229
   {0x1a01, 1, slave_3_pdo_entries + 1}, /* Channel 2 */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   230
   {0x1a02, 1, slave_3_pdo_entries + 2}, /* Channel 3 */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   231
   {0x1a03, 1, slave_3_pdo_entries + 3}, /* Channel 4 */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   232
};
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   233
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   234
ec_sync_info_t slave_3_syncs[] = {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   235
   {0, EC_DIR_INPUT, 4, slave_3_pdos + 0, EC_WD_DISABLE},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   236
   {0xff}
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   237
};
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   238
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   239
/* Slave 4, "EL4132"
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   240
 * Vendor ID:       0x00000002
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   241
 * Product code:    0x10243052
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   242
 * Revision number: 0x03f90000
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   243
 */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   244
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   245
ec_pdo_entry_info_t slave_4_pdo_entries[] = {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   246
   {0x3001, 0x01, 16}, /* Output */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   247
   {0x3002, 0x01, 16}, /* Output */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   248
};
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   249
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   250
ec_pdo_info_t slave_4_pdos[] = {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   251
   {0x1600, 1, slave_4_pdo_entries + 0}, /* RxPDO 01 mapping */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   252
   {0x1601, 1, slave_4_pdo_entries + 1}, /* RxPDO 02 mapping */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   253
};
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   254
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   255
ec_sync_info_t slave_4_syncs[] = {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   256
   {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   257
   {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   258
   {2, EC_DIR_OUTPUT, 2, slave_4_pdos + 0, EC_WD_DISABLE},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   259
   {3, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   260
   {0xff}
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   261
};
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   262
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   263
/* Slave 5, "EL3102"
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   264
 * Vendor ID:       0x00000002
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   265
 * Product code:    0x0c1e3052
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   266
 * Revision number: 0x00000000
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   267
 */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   268
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   269
ec_pdo_entry_info_t slave_5_pdo_entries[] = {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   270
   {0x3101, 0x01, 8}, /* Status */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   271
   {0x3101, 0x02, 16}, /* Value */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   272
   {0x3102, 0x01, 8}, /* Status */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   273
   {0x3102, 0x02, 16}, /* Value */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   274
};
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   275
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   276
ec_pdo_info_t slave_5_pdos[] = {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   277
   {0x1a00, 2, slave_5_pdo_entries + 0}, /* TxPDO 001 mapping */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   278
   {0x1a01, 2, slave_5_pdo_entries + 2}, /* TxPDO 002 mapping */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   279
};
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   280
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   281
ec_sync_info_t slave_5_syncs[] = {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   282
   {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   283
   {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   284
   {2, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   285
   {3, EC_DIR_INPUT, 2, slave_5_pdos + 0, EC_WD_DISABLE},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   286
   {0xff}
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   287
};
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   288
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   289
/* Slave 6, "EL6731-0010"
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   290
 * Vendor ID:       0x00000002
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   291
 * Product code:    0x1a4b3052
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   292
 * Revision number: 0x0011000a
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   293
 */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   294
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   295
ec_sync_info_t slave_6_syncs[] = {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   296
   {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   297
   {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   298
   {2, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   299
   {3, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   300
};
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   301
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   302
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   303
/* Slave 7, "EL6601"
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   304
 * Vendor ID:       0x00000002
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   305
 * Product code:    0x19c93052
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   306
 * Revision number: 0x00110000
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   307
 */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   308
/*
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   309
ec_sync_info_t slave_7_syncs[] = {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   310
   {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   311
   {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   312
   {2, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   313
   {3, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   314
   {0xff}
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   315
};
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   316
*/
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   317
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   318
/* Master 0, Slave 7, "EL3602"
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   319
 * Vendor ID:       0x00000002
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   320
 * Product code:    0x0e123052
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   321
 * Revision number: 0x00100000
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   322
 */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   323
ec_pdo_entry_info_t slave_7_pdo_entries[] = {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   324
   {0x6000, 0x01, 1}, /* Underrange */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   325
   {0x6000, 0x02, 1}, /* Overrange */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   326
   {0x6000, 0x03, 2}, /* Limit 1 */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   327
   {0x6000, 0x05, 2}, /* Limit 2 */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   328
   {0x6000, 0x07, 1}, /* Error */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   329
   {0x0000, 0x00, 7}, /* Gap */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   330
   {0x1800, 0x07, 1},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   331
   {0x1800, 0x09, 1},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   332
   {0x6000, 0x11, 32}, /* Value */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   333
   {0x6010, 0x01, 1}, /* Underrange */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   334
   {0x6010, 0x02, 1}, /* Overrange */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   335
   {0x6010, 0x03, 2}, /* Limit 1 */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   336
   {0x6010, 0x05, 2}, /* Limit 2 */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   337
   {0x6010, 0x07, 1}, /* Error */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   338
   {0x0000, 0x00, 7}, /* Gap */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   339
   {0x1801, 0x07, 1},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   340
   {0x1801, 0x09, 1},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   341
   {0x6010, 0x11, 32}, /* Value */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   342
};
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   343
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   344
ec_pdo_info_t slave_7_pdos[] = {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   345
   {0x1a00, 9, slave_7_pdo_entries + 0}, /* AI TxPDO-Map Inputs Ch.1 */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   346
   {0x1a01, 9, slave_7_pdo_entries + 9}, /* AI TxPDO-Map Inputs Ch.2 */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   347
};
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   348
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   349
ec_sync_info_t slave_7_syncs[] = {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   350
   {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   351
   {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   352
   {2, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   353
   {3, EC_DIR_INPUT, 2, slave_7_pdos + 0, EC_WD_DISABLE},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   354
   {0xff}
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   355
};
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   356
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   357
/* Master 0, Slave 8, "EL5151"
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   358
 * Vendor ID:       0x00000002
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   359
 * Product code:    0x141f3052
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   360
 * Revision number: 0x00130000
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   361
 */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   362
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   363
ec_pdo_entry_info_t slave_8_pdo_entries[] = {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   364
   {0x6000, 0x01, 1},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   365
   {0x6000, 0x02, 1},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   366
   {0x6000, 0x03, 1},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   367
   {0x0000, 0x00, 4}, /* Gap */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   368
   {0x6000, 0x08, 1},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   369
   {0x6000, 0x09, 1},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   370
   {0x6000, 0x0a, 1},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   371
   {0x6000, 0x0b, 1},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   372
   {0x0000, 0x00, 1}, /* Gap */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   373
   {0x6000, 0x0d, 1},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   374
   {0x1c32, 0x20, 1},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   375
   {0x0000, 0x00, 1}, /* Gap */
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   376
   {0x1800, 0x09, 1},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   377
   {0x6000, 0x11, 32},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   378
   {0x6000, 0x12, 32},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   379
   {0x6000, 0x14, 32},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   380
};
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   381
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   382
ec_pdo_info_t slave_8_pdos[] = {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   383
   {0x0000, 0, NULL},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   384
   {0x1a00, 15, slave_8_pdo_entries + 0},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   385
   {0x1a02, 1, slave_8_pdo_entries + 15},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   386
};
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   387
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   388
ec_sync_info_t slave_8_syncs[] = {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   389
   {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   390
   {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   391
   {2, EC_DIR_OUTPUT, 1, slave_8_pdos + 0, EC_WD_DISABLE},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   392
   {3, EC_DIR_INPUT, 2, slave_8_pdos + 1, EC_WD_DISABLE},
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   393
   {0xff}
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   394
};
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   395
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   396
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   397
/*****************************************************************************/
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   398
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   399
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   400
void rt_check_domain_state(void)
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   401
{
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   402
    ec_domain_state_t ds;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   403
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   404
    if (rt_fd>=0)
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   405
      {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   406
          ecrt_rtdm_domain_state(rt_fd,&ds);  
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   407
      }
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   408
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   409
    if (ds.working_counter != domain1_state.working_counter)
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   410
     {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   411
        rt_printf("Domain1: WC %u.\n", ds.working_counter);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   412
     }
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   413
    if (ds.wc_state != domain1_state.wc_state)
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   414
     {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   415
    	rt_printf("Domain1: State %u.\n", ds.wc_state);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   416
     }
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   417
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   418
    domain1_state = ds;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   419
}
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   420
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   421
void rt_check_master_state(void)
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   422
{
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   423
    ec_master_state_t ms;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   424
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   425
    if (rt_fd>=0)
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   426
      {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   427
          ecrt_rtdm_master_state(rt_fd,&ms);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   428
      }
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   429
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   430
    if (ms.slaves_responding != master_state.slaves_responding)
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   431
    {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   432
        rt_printf("%u slave(s).\n", ms.slaves_responding);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   433
    }
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   434
    if (ms.al_states != master_state.al_states)
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   435
    {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   436
        rt_printf("AL states: 0x%02X.\n", ms.al_states);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   437
    }
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   438
    if (ms.link_up != master_state.link_up)
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   439
    {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   440
        rt_printf("Link is %s.\n", ms.link_up ? "up" : "down");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   441
    }
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   442
    master_state = ms;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   443
}
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   444
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   445
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   446
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   447
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   448
void rt_sync()
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   449
{
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   450
  struct timespec now;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   451
  uint64_t now_ns;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   452
  clock_gettime(CLOCK_REALTIME,&now);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   453
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   454
  now_ns = 1000000000LL*now.tv_sec + now.tv_nsec;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   455
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   456
  if (rt_fd>=0)
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   457
  {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   458
      ecrt_rtdm_master_application_time(rt_fd, &now_ns);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   459
  }
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   460
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   461
  if (sync_ref_counter) {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   462
     sync_ref_counter--;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   463
  } else {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   464
     sync_ref_counter = 9;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   465
     if (rt_fd>=0)
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   466
     {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   467
         ecrt_rtdm_master_sync_reference_clock(rt_fd);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   468
     }
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   469
  }
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   470
  if (rt_fd>=0)
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   471
  {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   472
      ecrt_rtdm_master_sync_slave_clocks(rt_fd) ;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   473
  }
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   474
}
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   475
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   476
/*****************************************************************************/
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   477
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   478
/**********************************************************/
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   479
void cleanup_all(void)
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   480
{
2057
23fca60b7ca2 Working Xenomai Posix example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2056
diff changeset
   481
    run = 0;   
2056
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   482
}
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   483
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   484
void catch_signal(int sig)
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   485
{
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   486
    cleanup_all();    
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   487
}
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   488
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   489
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   490
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   491
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   492
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   493
void *my_thread(void *arg)
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   494
{
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   495
    struct timespec next_period;
2057
23fca60b7ca2 Working Xenomai Posix example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2056
diff changeset
   496
2056
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   497
    int counter = 0;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   498
    int divcounter = 0;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   499
    int divider = 10;
2057
23fca60b7ca2 Working Xenomai Posix example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2056
diff changeset
   500
23fca60b7ca2 Working Xenomai Posix example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2056
diff changeset
   501
23fca60b7ca2 Working Xenomai Posix example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2056
diff changeset
   502
    clock_gettime(CLOCK_REALTIME, &next_period);
2056
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   503
    while(1) {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   504
        next_period.tv_nsec += cycle * 1000;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   505
        while (next_period.tv_nsec >= NSEC_PER_SEC) {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   506
                next_period.tv_nsec -= NSEC_PER_SEC;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   507
                next_period.tv_sec++;
2057
23fca60b7ca2 Working Xenomai Posix example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2056
diff changeset
   508
                }
23fca60b7ca2 Working Xenomai Posix example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2056
diff changeset
   509
23fca60b7ca2 Working Xenomai Posix example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2056
diff changeset
   510
        clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, &next_period, NULL);
23fca60b7ca2 Working Xenomai Posix example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2056
diff changeset
   511
2056
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   512
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   513
        counter++;
2057
23fca60b7ca2 Working Xenomai Posix example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2056
diff changeset
   514
        if (counter>60000) {
2056
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   515
            run=0;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   516
            return NULL;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   517
        }
2057
23fca60b7ca2 Working Xenomai Posix example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2056
diff changeset
   518
23fca60b7ca2 Working Xenomai Posix example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2056
diff changeset
   519
        if(run ==  0) {
23fca60b7ca2 Working Xenomai Posix example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2056
diff changeset
   520
            return NULL;
23fca60b7ca2 Working Xenomai Posix example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2056
diff changeset
   521
        }
23fca60b7ca2 Working Xenomai Posix example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2056
diff changeset
   522
2056
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   523
        
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   524
        // receive ethercat
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   525
        ecrt_rtdm_master_recieve(rt_fd);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   526
        ecrt_rtdm_domain_process(rt_fd);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   527
        
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   528
        rt_check_domain_state();
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   529
        
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   530
        if (divcounter ==0)
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   531
            {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   532
                divcounter=divider;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   533
                rt_check_master_state();
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   534
            }
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   535
        divcounter--;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   536
        if ((counter % 200)==0)
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   537
            {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   538
                blink = !blink;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   539
                
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   540
            }
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   541
      
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   542
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   543
        EC_WRITE_U8(domain1_pd + off_dig_out0, blink ? 0x0 : 0x0F);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   544
        EC_WRITE_U16(domain1_pd + off_ana_out0, blink ? 0x0: 0xfff);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   545
        
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   546
        //sync DC
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   547
        rt_sync();
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   548
        
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   549
        // send process data
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   550
        ecrt_rtdm_domain_queque(rt_fd);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   551
        ecrt_rtdm_master_send(rt_fd);   
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   552
    }
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   553
    return NULL;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   554
}
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   555
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   556
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   557
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   558
int main(int argc, char *argv[])
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   559
{
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   560
    ec_slave_config_t *sc;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   561
    int rtstatus;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   562
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   563
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   564
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   565
    signal(SIGTERM, catch_signal);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   566
    signal(SIGINT, catch_signal);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   567
    signal(SIGHUP, catch_signal);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   568
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   569
    mlockall(MCL_CURRENT|MCL_FUTURE);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   570
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   571
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   572
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   573
    MstrAttach.masterindex = 0;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   574
    
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   575
    printf("request master\n");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   576
    master = ecrt_request_master(MstrAttach.masterindex);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   577
    if (!master)
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   578
        return -1;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   579
    
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   580
    
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   581
    domain1 = ecrt_master_create_domain(master);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   582
    if (!domain1)
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   583
        return -1;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   584
    
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   585
    
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   586
#ifdef CONFIGURE_PDOS
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   587
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   588
    printf("Configuring PDOs...\n");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   589
    
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   590
    printf("Get Configuring el2004...\n");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   591
    sc_dig_out_01 = ecrt_master_slave_config(master, DigOutSlave01_Pos, Beckhoff_EL2004);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   592
    if (!sc_dig_out_01) {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   593
        fprintf(stderr, "Failed to get slave configuration.\n");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   594
        return -1;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   595
    }
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   596
    
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   597
    printf("Configuring EL2004...\n");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   598
    if (ecrt_slave_config_pdos(sc_dig_out_01, EC_END, slave_1_syncs))
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   599
        {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   600
            fprintf(stderr, "Failed to configure PDOs.\n");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   601
            return -1;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   602
        }
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   603
    
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   604
    printf("Get Configuring el2004...\n");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   605
    sc_dig_out_02 = ecrt_master_slave_config(master, DigOutSlave02_Pos, Beckhoff_EL2004);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   606
    if (!sc_dig_out_02) {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   607
        fprintf(stderr, "Failed to get slave configuration.\n");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   608
        return -1;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   609
    }
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   610
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   611
    printf("Configuring EL2004...\n");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   612
    if (ecrt_slave_config_pdos(sc_dig_out_02, EC_END, slave_2_syncs)) {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   613
        fprintf(stderr, "Failed to configure PDOs.\n");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   614
        return -1;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   615
    }
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   616
    
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   617
    printf("Get Configuring el1014...\n");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   618
    sc_dig_in_01 = ecrt_master_slave_config(master, DigInSlave01_Pos, Beckhoff_EL1014);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   619
    if (!sc_dig_in_01) {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   620
        fprintf(stderr, "Failed to get slave configuration.\n");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   621
        return -1;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   622
    }
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   623
    
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   624
    printf("Configuring EL1014...\n");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   625
    if (ecrt_slave_config_pdos(sc_dig_in_01, EC_END, slave_3_syncs)) {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   626
        fprintf(stderr, "Failed to configure PDOs.\n");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   627
        return -1;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   628
    }
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   629
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   630
    printf("Get Configuring EL4132...\n");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   631
    sc_ana_out_01 = ecrt_master_slave_config(master, AnaOutSlave01_Pos, Beckhoff_EL4132);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   632
    if (!sc_ana_out_01) {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   633
        fprintf(stderr, "Failed to get slave configuration.\n");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   634
        return -1;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   635
    }
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   636
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   637
    printf("Configuring EL4132...\n");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   638
    if (ecrt_slave_config_pdos(sc_ana_out_01, EC_END, slave_4_syncs)) {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   639
        fprintf(stderr, "Failed to configure PDOs.\n");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   640
        return -1;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   641
    }
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   642
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   643
    printf("Get Configuring EL3102...\n");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   644
    sc_ana_in_01 = ecrt_master_slave_config(master, AnaInSlave01_Pos, Beckhoff_EL3102);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   645
    if (!sc_ana_in_01) {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   646
        fprintf(stderr, "Failed to get slave configuration.\n");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   647
        return -1;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   648
    }
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   649
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   650
    printf("Configuring EL3102...\n");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   651
    if (ecrt_slave_config_pdos(sc_ana_in_01, EC_END, slave_5_syncs)) {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   652
        fprintf(stderr, "Failed to configure PDOs.\n");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   653
        return -1;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   654
    }
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   655
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   656
    printf("Get Configuring EL3602...\n");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   657
	sc_ana_in_02 = ecrt_master_slave_config(master, AnaInSlave02_Pos, Beckhoff_EL3602);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   658
	if (!sc_ana_in_02) {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   659
        fprintf(stderr, "Failed to get slave configuration.\n");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   660
        return -1;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   661
	}
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   662
    
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   663
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   664
	printf("Configuring EL3602...\n");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   665
	if (ecrt_slave_config_pdos(sc_ana_in_02, EC_END, slave_7_syncs)) {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   666
        fprintf(stderr, "Failed to configure PDOs.\n");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   667
        return -1;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   668
	}
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   669
    
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   670
#endif
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   671
    
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   672
    // Create configuration for bus coupler
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   673
    sc = ecrt_master_slave_config(master, BusCoupler01_Pos, Beckhoff_EK1100);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   674
    if (!sc)
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   675
        return -1;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   676
    
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   677
#ifdef CONFIGURE_PDOS
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   678
    if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   679
        fprintf(stderr, "PDO entry registration failed!\n");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   680
        return -1;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   681
    }
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   682
#endif
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   683
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   684
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   685
        
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   686
    sprintf(&rt_dev_file[0],"%s%u",EC_RTDM_DEV_FILE_NAME,0);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   687
    
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   688
    
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   689
    rt_fd = rt_dev_open( &rt_dev_file[0], 0);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   690
    if (rt_fd < 0) {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   691
        printf("can't open %s\n", &rt_dev_file[0]);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   692
        return -1;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   693
    }
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   694
    
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   695
    MstrAttach.domainindex = ecrt_domain_index(domain1);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   696
    
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   697
    // attach the master over rtdm driver
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   698
    rtstatus=ecrt_rtdm_master_attach(rt_fd, &MstrAttach);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   699
    if (rtstatus < 0)
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   700
        {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   701
            printf("cannot attach to master over rtdm\n");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   702
            return -1;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   703
        }
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   704
    
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   705
    printf("Activating master...\n");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   706
    if (ecrt_master_activate(master))
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   707
        return -1;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   708
    
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   709
    if (!(domain1_pd = ecrt_domain_data(domain1))) {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   710
        return -1;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   711
    }
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   712
    fprintf(stderr, "domain1_pd:  0x%.6x\n", (unsigned int)domain1_pd);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   713
    
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   714
    
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   715
    
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   716
    int ret;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   717
    run=1;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   718
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   719
    /* Create cyclic RT-thread */
2057
23fca60b7ca2 Working Xenomai Posix example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2056
diff changeset
   720
    struct sched_param param = { .sched_priority = 82 };
23fca60b7ca2 Working Xenomai Posix example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2056
diff changeset
   721
    pthread_attr_t thattr;
2056
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   722
    pthread_attr_init(&thattr);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   723
    pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE);
2057
23fca60b7ca2 Working Xenomai Posix example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2056
diff changeset
   724
    pthread_attr_setinheritsched(&thattr, PTHREAD_EXPLICIT_SCHED);
23fca60b7ca2 Working Xenomai Posix example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2056
diff changeset
   725
    pthread_attr_setschedpolicy(&thattr, SCHED_FIFO);
23fca60b7ca2 Working Xenomai Posix example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2056
diff changeset
   726
    pthread_setschedparam(cyclicthread, SCHED_FIFO, &param);
23fca60b7ca2 Working Xenomai Posix example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2056
diff changeset
   727
    pthread_set_name_np(cyclicthread, "ec_xenomai_posix_test");
2056
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   728
    ret = pthread_create(&cyclicthread, &thattr, &my_thread, NULL);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   729
    if (ret) {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   730
        fprintf(stderr, "%s: pthread_create cyclic task failed\n",
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   731
                strerror(-ret));
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   732
        goto failure;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   733
    }
2057
23fca60b7ca2 Working Xenomai Posix example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2056
diff changeset
   734
2056
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   735
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   736
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   737
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   738
    while (run)
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   739
      {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   740
    	sched_yield();
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   741
      }
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   742
2057
23fca60b7ca2 Working Xenomai Posix example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2056
diff changeset
   743
23fca60b7ca2 Working Xenomai Posix example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2056
diff changeset
   744
23fca60b7ca2 Working Xenomai Posix example
Andreas Stewering-Bone <ab@igh-essen.com>
parents: 2056
diff changeset
   745
2056
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   746
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   747
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   748
    if (rt_fd >= 0)
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   749
        {
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   750
            printf("closing rt device %s\n", &rt_dev_file[0]);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   751
            
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   752
            rt_dev_close(rt_fd);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   753
            
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   754
        }
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   755
    
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   756
    printf("End of Program\n");
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   757
    ecrt_release_master(master);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   758
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   759
    return 0;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   760
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   761
 failure:
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   762
    pthread_kill(cyclicthread, SIGHUP);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   763
    pthread_join(cyclicthread, NULL);
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   764
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   765
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   766
    return 1;
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   767
}
a92e8f119723 Work on Xenomai Posix interface, to be tested
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
diff changeset
   768