master/domain.c
author Florian Pose <fp@igh-essen.com>
Thu, 06 Dec 2012 18:11:11 +0100
branchstable-1.5
changeset 2485 5535603c34a0
parent 2470 4f97d61a8671
child 2522 ec403cf308eb
permissions -rw-r--r--
Fixed io_sem usage in queue_external_datagrams().
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
 *  $Id$
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
1326
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
     5
 *  Copyright (C) 2006-2008  Florian Pose, Ingenieurgemeinschaft IgH
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
     6
 *
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
     7
 *  This file is part of the IgH EtherCAT Master.
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
     8
 *
1326
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
     9
 *  The IgH EtherCAT Master is free software; you can redistribute it and/or
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    10
 *  modify it under the terms of the GNU General Public License version 2, as
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    11
 *  published by the Free Software Foundation.
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    12
 *
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    13
 *  The IgH EtherCAT Master is distributed in the hope that it will be useful,
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    16
 *  Public License for more details.
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    17
 *
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    18
 *  You should have received a copy of the GNU General Public License along
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    19
 *  with the IgH EtherCAT Master; if not, write to the Free Software
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    20
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    21
 *
1363
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
    22
 *  ---
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
    23
 *
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
    24
 *  The license mentioned above concerns the source code only. Using the
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
    25
 *  EtherCAT technology and brand is only permitted in compliance with the
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
    26
 *  industrial property and similar rights of Beckhoff Automation GmbH.
246
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
    27
 *
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
 *****************************************************************************/
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    30
/**
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    31
   \file
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    32
   EtherCAT domain methods.
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    33
*/
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    34
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    35
/*****************************************************************************/
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    36
294
feea8d850c65 Applied include patch by M. Schwerin.
Florian Pose <fp@igh-essen.com>
parents: 293
diff changeset
    37
#include <linux/module.h>
feea8d850c65 Applied include patch by M. Schwerin.
Florian Pose <fp@igh-essen.com>
parents: 293
diff changeset
    38
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    39
#include "globals.h"
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
    40
#include "master.h"
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
    41
#include "slave_config.h"
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
    42
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    43
#include "domain.h"
2269
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
    44
#include "datagram_pair.h"
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
    45
2367
8527429b6137 Compare with send buffer; copy changed data.
Florian Pose <fp@igh-essen.com>
parents: 2366
diff changeset
    46
#define DEBUG_REDUNDANCY 0
8527429b6137 Compare with send buffer; copy changed data.
Florian Pose <fp@igh-essen.com>
parents: 2366
diff changeset
    47
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
    48
/*****************************************************************************/
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
    49
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
    50
void ec_domain_clear_data(ec_domain_t *);
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    51
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
    52
/*****************************************************************************/
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
    53
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
    54
/** Domain constructor.
993
8c32564252fd Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents: 985
diff changeset
    55
 */
8c32564252fd Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents: 985
diff changeset
    56
void ec_domain_init(
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
    57
        ec_domain_t *domain, /**< EtherCAT domain. */
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
    58
        ec_master_t *master, /**< Parent master. */
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
    59
        unsigned int index /**< Index. */
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
    60
        )
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
    61
{
2453
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
    62
    unsigned int dev_idx;
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
    63
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
    64
    domain->master = master;
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
    65
    domain->index = index;
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
    66
    INIT_LIST_HEAD(&domain->fmmu_configs);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
    67
    domain->data_size = 0;
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
    68
    domain->data = NULL;
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
    69
    domain->data_origin = EC_ORIG_INTERNAL;
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
    70
    domain->logical_base_address = 0x00000000;
2269
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
    71
    INIT_LIST_HEAD(&domain->datagram_pairs);
2453
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
    72
    for (dev_idx = EC_DEVICE_MAIN; dev_idx < ec_master_num_devices(master);
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
    73
            dev_idx++) {
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
    74
        domain->working_counter[dev_idx] = 0x0000;
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
    75
    }
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
    76
    domain->expected_working_counter = 0x0000;
818
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
    77
    domain->working_counter_changes = 0;
2368
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
    78
    domain->redundancy_active = 0;
344
5d8281f1aa2a Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents: 343
diff changeset
    79
    domain->notify_jiffies = 0;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
    80
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
    81
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
    82
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
    83
818
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
    84
/** Domain destructor.
993
8c32564252fd Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents: 985
diff changeset
    85
 */
8c32564252fd Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents: 985
diff changeset
    86
void ec_domain_clear(ec_domain_t *domain /**< EtherCAT domain */)
8c32564252fd Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents: 985
diff changeset
    87
{
2269
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
    88
    ec_datagram_pair_t *datagram_pair, *next_pair;
993
8c32564252fd Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents: 985
diff changeset
    89
8c32564252fd Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents: 985
diff changeset
    90
    // dequeue and free datagrams
2269
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
    91
    list_for_each_entry_safe(datagram_pair, next_pair,
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
    92
            &domain->datagram_pairs, list) {
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
    93
        ec_datagram_pair_clear(datagram_pair);
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
    94
        kfree(datagram_pair);
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    95
    }
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
    96
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
    97
    ec_domain_clear_data(domain);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
    98
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
    99
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   100
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   101
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   102
/** Frees internally allocated memory.
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   103
 */
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   104
void ec_domain_clear_data(
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   105
        ec_domain_t *domain /**< EtherCAT domain. */
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   106
        )
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   107
{
2269
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   108
    if (domain->data_origin == EC_ORIG_INTERNAL && domain->data) {
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   109
        kfree(domain->data);
2269
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   110
    }
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   111
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   112
    domain->data = NULL;
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   113
    domain->data_origin = EC_ORIG_INTERNAL;
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   114
}
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   115
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   116
/*****************************************************************************/
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   117
818
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   118
/** Adds an FMMU configuration to the domain.
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   119
 */
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   120
void ec_domain_add_fmmu_config(
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   121
        ec_domain_t *domain, /**< EtherCAT domain. */
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   122
        ec_fmmu_config_t *fmmu /**< FMMU configuration. */
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   123
        )
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   124
{
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   125
    fmmu->domain = domain;
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   126
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   127
    domain->data_size += fmmu->data_size;
950
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   128
    list_add_tail(&fmmu->list, &domain->fmmu_configs);
912
6630f4dbcfd2 Improved working counter output; fixed problem with slaves that have a single sync manager used for outputs.
Florian Pose <fp@igh-essen.com>
parents: 885
diff changeset
   129
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   130
    EC_MASTER_DBG(domain->master, 1, "Domain %u:"
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   131
            " Added %u bytes, total %zu.\n",
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   132
            domain->index, fmmu->data_size, domain->data_size);
818
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   133
}
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   134
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   135
/*****************************************************************************/
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   136
2269
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   137
/** Allocates a domain datagram pair and appends it to the list.
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   138
 *
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   139
 * The datagrams' types and expected working counters are determined by the
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   140
 * number of input and output fmmus that share the datagrams.
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   141
 *
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1304
diff changeset
   142
 * \retval  0 Success.
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1304
diff changeset
   143
 * \retval <0 Error code.
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   144
 */
2269
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   145
int ec_domain_add_datagram_pair(
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   146
        ec_domain_t *domain, /**< EtherCAT domain. */
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   147
        uint32_t logical_offset, /**< Logical offset. */
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   148
        size_t data_size, /**< Size of the data. */
817
118dea2fa505 Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   149
        uint8_t *data, /**< Process data. */
2366
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   150
        const unsigned int used[] /**< Slave config counter for in/out. */
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   151
        )
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   152
{
2269
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   153
    ec_datagram_pair_t *datagram_pair;
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1304
diff changeset
   154
    int ret;
2269
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   155
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   156
    if (!(datagram_pair = kmalloc(sizeof(ec_datagram_pair_t), GFP_KERNEL))) {
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   157
        EC_MASTER_ERR(domain->master,
2269
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   158
                "Failed to allocate domain datagram pair!\n");
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1304
diff changeset
   159
        return -ENOMEM;
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   160
    }
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   161
2367
8527429b6137 Compare with send buffer; copy changed data.
Florian Pose <fp@igh-essen.com>
parents: 2366
diff changeset
   162
    ret = ec_datagram_pair_init(datagram_pair, domain, logical_offset, data,
8527429b6137 Compare with send buffer; copy changed data.
Florian Pose <fp@igh-essen.com>
parents: 2366
diff changeset
   163
            data_size, used);
2269
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   164
    if (ret) {
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   165
        kfree(datagram_pair);
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   166
        return ret;
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   167
    }
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   168
2367
8527429b6137 Compare with send buffer; copy changed data.
Florian Pose <fp@igh-essen.com>
parents: 2366
diff changeset
   169
    domain->expected_working_counter +=
8527429b6137 Compare with send buffer; copy changed data.
Florian Pose <fp@igh-essen.com>
parents: 2366
diff changeset
   170
        datagram_pair->expected_working_counter;
8527429b6137 Compare with send buffer; copy changed data.
Florian Pose <fp@igh-essen.com>
parents: 2366
diff changeset
   171
8527429b6137 Compare with send buffer; copy changed data.
Florian Pose <fp@igh-essen.com>
parents: 2366
diff changeset
   172
    EC_MASTER_DBG(domain->master, 1,
8527429b6137 Compare with send buffer; copy changed data.
Florian Pose <fp@igh-essen.com>
parents: 2366
diff changeset
   173
            "Adding datagram pair with expected WC %u.\n",
8527429b6137 Compare with send buffer; copy changed data.
Florian Pose <fp@igh-essen.com>
parents: 2366
diff changeset
   174
            datagram_pair->expected_working_counter);
8527429b6137 Compare with send buffer; copy changed data.
Florian Pose <fp@igh-essen.com>
parents: 2366
diff changeset
   175
2269
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   176
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   177
    list_add_tail(&datagram_pair->list, &domain->datagram_pairs);
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   178
    return 0;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   179
}
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   180
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   181
/*****************************************************************************/
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   182
2366
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   183
/** Domain finish helper function.
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   184
 *
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   185
 * Detects, if a slave configuration has already been taken into account for
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   186
 * a datagram's expected working counter calculation.
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   187
 *
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   188
 * Walks through the list of all FMMU configurations for the current datagram
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   189
 * and ends before the current datagram.
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   190
 */
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   191
int shall_count(
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   192
        const ec_fmmu_config_t *cur_fmmu, /**< Current FMMU with direction to
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   193
                                            search for. */
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   194
        const ec_fmmu_config_t *first_fmmu /**< Datagram's first FMMU. */
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   195
        )
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   196
{
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   197
    for (; first_fmmu != cur_fmmu;
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   198
            first_fmmu = list_entry(first_fmmu->list.next,
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   199
                ec_fmmu_config_t, list)) {
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   200
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   201
        if (first_fmmu->sc == cur_fmmu->sc
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   202
                && first_fmmu->dir == cur_fmmu->dir) {
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   203
            return 0; // was already counted
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   204
        }
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   205
    }
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   206
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   207
    return 1;
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   208
}
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   209
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   210
/*****************************************************************************/
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   211
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   212
/** Finishes a domain.
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   213
 *
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   214
 * This allocates the necessary datagrams and writes the correct logical
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   215
 * addresses to every configured FMMU.
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   216
 *
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   217
 * \todo Check for FMMUs that do not fit into any datagram.
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   218
 *
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1304
diff changeset
   219
 * \retval  0 Success
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1304
diff changeset
   220
 * \retval <0 Error code.
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   221
 */
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   222
int ec_domain_finish(
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   223
        ec_domain_t *domain, /**< EtherCAT domain. */
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   224
        uint32_t base_address /**< Logical base address. */
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   225
        )
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   226
{
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   227
    uint32_t datagram_offset;
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   228
    size_t datagram_size;
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   229
    unsigned int datagram_count;
1055
2be8918682fa Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents: 1032
diff changeset
   230
    unsigned int datagram_used[EC_DIR_COUNT];
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   231
    ec_fmmu_config_t *fmmu;
2366
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   232
    const ec_fmmu_config_t *datagram_first_fmmu = NULL;
2269
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   233
    const ec_datagram_pair_t *datagram_pair;
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1304
diff changeset
   234
    int ret;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   235
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   236
    domain->logical_base_address = base_address;
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   237
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   238
    if (domain->data_size && domain->data_origin == EC_ORIG_INTERNAL) {
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   239
        if (!(domain->data =
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   240
                    (uint8_t *) kmalloc(domain->data_size, GFP_KERNEL))) {
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   241
            EC_MASTER_ERR(domain->master, "Failed to allocate %zu bytes"
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   242
                    " internal memory for domain %u!\n",
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   243
                    domain->data_size, domain->index);
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1304
diff changeset
   244
            return -ENOMEM;
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   245
        }
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   246
    }
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   247
2366
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   248
    // Cycle through all domain FMMUs and
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   249
    // - correct the logical base addresses
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   250
    // - set up the datagrams to carry the process data
2366
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   251
    // - calculate the datagrams' expected working counters
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   252
    datagram_offset = 0;
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   253
    datagram_size = 0;
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   254
    datagram_count = 0;
817
118dea2fa505 Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   255
    datagram_used[EC_DIR_OUTPUT] = 0;
118dea2fa505 Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   256
    datagram_used[EC_DIR_INPUT] = 0;
1907
dd276ae226b4 Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
   257
2366
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   258
    if (!list_empty(&domain->fmmu_configs)) {
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   259
        datagram_first_fmmu =
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   260
            list_entry(domain->fmmu_configs.next, ec_fmmu_config_t, list);
1907
dd276ae226b4 Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
   261
    }
dd276ae226b4 Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
   262
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   263
    list_for_each_entry(fmmu, &domain->fmmu_configs, list) {
2366
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   264
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   265
        // Correct logical FMMU address
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   266
        fmmu->logical_start_address += base_address;
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   267
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   268
        // Increment Input/Output counter to determine datagram types
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   269
        // and calculate expected working counters
2366
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   270
        if (shall_count(fmmu, datagram_first_fmmu)) {
1798
e7733f825982 Domain datagram working counter calculation bugfix: increment expected wc for a given slave & direction just once for each datagram
Dominik Staubli <ch1010252@ch10pc423>
parents: 1553
diff changeset
   271
            datagram_used[fmmu->dir]++;
e7733f825982 Domain datagram working counter calculation bugfix: increment expected wc for a given slave & direction just once for each datagram
Dominik Staubli <ch1010252@ch10pc423>
parents: 1553
diff changeset
   272
        }
1907
dd276ae226b4 Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents: 1798
diff changeset
   273
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   274
        // If the current FMMU's data do not fit in the current datagram,
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   275
        // allocate a new one.
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   276
        if (datagram_size + fmmu->data_size > EC_MAX_DATA_SIZE) {
2269
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   277
            ret = ec_domain_add_datagram_pair(domain,
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1304
diff changeset
   278
                    domain->logical_base_address + datagram_offset,
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1304
diff changeset
   279
                    datagram_size, domain->data + datagram_offset,
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1304
diff changeset
   280
                    datagram_used);
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1304
diff changeset
   281
            if (ret < 0)
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1304
diff changeset
   282
                return ret;
2366
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   283
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   284
            datagram_offset += datagram_size;
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   285
            datagram_size = 0;
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   286
            datagram_count++;
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   287
            datagram_used[EC_DIR_OUTPUT] = 0;
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   288
            datagram_used[EC_DIR_INPUT] = 0;
2366
5682b63f826a Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents: 2365
diff changeset
   289
            datagram_first_fmmu = fmmu;
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   290
        }
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   291
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   292
        datagram_size += fmmu->data_size;
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   293
    }
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   294
2269
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   295
    /* Allocate last datagram pair, if data are left (this is also the case if
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   296
     * the process data fit into a single datagram) */
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   297
    if (datagram_size) {
2269
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   298
        ret = ec_domain_add_datagram_pair(domain,
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1304
diff changeset
   299
                domain->logical_base_address + datagram_offset,
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1304
diff changeset
   300
                datagram_size, domain->data + datagram_offset,
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1304
diff changeset
   301
                datagram_used);
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1304
diff changeset
   302
        if (ret < 0)
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1304
diff changeset
   303
            return ret;
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   304
        datagram_count++;
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   305
    }
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   306
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   307
    EC_MASTER_INFO(domain->master, "Domain%u: Logical address 0x%08x,"
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   308
            " %zu byte, expected working counter %u.\n", domain->index,
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   309
            domain->logical_base_address, domain->data_size,
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   310
            domain->expected_working_counter);
2269
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   311
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   312
    list_for_each_entry(datagram_pair, &domain->datagram_pairs, list) {
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   313
        const ec_datagram_t *datagram =
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   314
            &datagram_pair->datagrams[EC_DEVICE_MAIN];
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   315
        EC_MASTER_INFO(domain->master, "  Datagram %s: Logical offset 0x%08x,"
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   316
                " %zu byte, type %s.\n", datagram->name,
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   317
                EC_READ_U32(datagram->address), datagram->data_size,
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   318
                ec_datagram_type_string(datagram));
817
118dea2fa505 Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   319
    }
2269
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   320
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   321
    return 0;
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   322
}
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   323
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   324
/*****************************************************************************/
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   325
1092
69393cf60399 Improved source code doc.
Florian Pose <fp@igh-essen.com>
parents: 1075
diff changeset
   326
/** Get the number of FMMU configurations of the domain.
69393cf60399 Improved source code doc.
Florian Pose <fp@igh-essen.com>
parents: 1075
diff changeset
   327
 */
950
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   328
unsigned int ec_domain_fmmu_count(const ec_domain_t *domain)
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   329
{
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   330
    const ec_fmmu_config_t *fmmu;
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   331
    unsigned int num = 0;
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   332
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   333
    list_for_each_entry(fmmu, &domain->fmmu_configs, list) {
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   334
        num++;
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   335
    }
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   336
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   337
    return num;
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   338
}
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   339
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   340
/*****************************************************************************/
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   341
1092
69393cf60399 Improved source code doc.
Florian Pose <fp@igh-essen.com>
parents: 1075
diff changeset
   342
/** Get a certain FMMU configuration via its position in the list.
69393cf60399 Improved source code doc.
Florian Pose <fp@igh-essen.com>
parents: 1075
diff changeset
   343
 */
950
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   344
const ec_fmmu_config_t *ec_domain_find_fmmu(
1092
69393cf60399 Improved source code doc.
Florian Pose <fp@igh-essen.com>
parents: 1075
diff changeset
   345
        const ec_domain_t *domain, /**< EtherCAT domain. */
69393cf60399 Improved source code doc.
Florian Pose <fp@igh-essen.com>
parents: 1075
diff changeset
   346
        unsigned int pos /**< List position. */
950
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   347
        )
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   348
{
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   349
    const ec_fmmu_config_t *fmmu;
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   350
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   351
    list_for_each_entry(fmmu, &domain->fmmu_configs, list) {
1092
69393cf60399 Improved source code doc.
Florian Pose <fp@igh-essen.com>
parents: 1075
diff changeset
   352
        if (pos--)
950
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   353
            continue;
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   354
        return fmmu;
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   355
    }
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   356
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   357
    return NULL;
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   358
}
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   359
2368
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   360
/*****************************************************************************/
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   361
2453
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   362
#if EC_MAX_NUM_DEVICES > 1
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   363
2368
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   364
/** Process received data.
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   365
 */
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   366
int data_changed(
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   367
        uint8_t *send_buffer,
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   368
        const ec_datagram_t *datagram,
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   369
        size_t offset,
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   370
        size_t size
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   371
        )
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   372
{
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   373
    uint8_t *sent = send_buffer + offset;
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   374
    uint8_t *recv = datagram->data + offset;
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   375
    size_t i;
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   376
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   377
    for (i = 0; i < size; i++) {
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   378
        if (recv[i] != sent[i]) {
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   379
            return 1;
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   380
        }
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   381
    }
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   382
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   383
    return 0;
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   384
}
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   385
2453
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   386
#endif
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   387
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   388
/******************************************************************************
2269
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   389
 *  Application interface
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   390
 *****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   391
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   392
int ecrt_domain_reg_pdo_entry_list(ec_domain_t *domain,
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   393
        const ec_pdo_entry_reg_t *regs)
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   394
{
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   395
    const ec_pdo_entry_reg_t *reg;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   396
    ec_slave_config_t *sc;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   397
    int ret;
2269
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   398
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   399
    EC_MASTER_DBG(domain->master, 1, "ecrt_domain_reg_pdo_entry_list("
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   400
            "domain = 0x%p, regs = 0x%p)\n", domain, regs);
1181
9e5954a2a46e Added debugging for configuration function of the application interface.
Florian Pose <fp@igh-essen.com>
parents: 1116
diff changeset
   401
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   402
    for (reg = regs; reg->index; reg++) {
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1304
diff changeset
   403
        sc = ecrt_master_slave_config_err(domain->master, reg->alias,
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1304
diff changeset
   404
                reg->position, reg->vendor_id, reg->product_code);
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1304
diff changeset
   405
        if (IS_ERR(sc))
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1304
diff changeset
   406
            return PTR_ERR(sc);
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1304
diff changeset
   407
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1304
diff changeset
   408
        ret = ecrt_slave_config_reg_pdo_entry(sc, reg->index,
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1304
diff changeset
   409
                        reg->subindex, domain, reg->bit_position);
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1304
diff changeset
   410
        if (ret < 0)
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1304
diff changeset
   411
            return ret;
916
db73994fbdac Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents: 912
diff changeset
   412
db73994fbdac Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents: 912
diff changeset
   413
        *reg->offset = ret;
db73994fbdac Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents: 912
diff changeset
   414
    }
db73994fbdac Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents: 912
diff changeset
   415
db73994fbdac Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents: 912
diff changeset
   416
    return 0;
db73994fbdac Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents: 912
diff changeset
   417
}
db73994fbdac Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents: 912
diff changeset
   418
db73994fbdac Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents: 912
diff changeset
   419
/*****************************************************************************/
db73994fbdac Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents: 912
diff changeset
   420
1257
9844ac126275 Made ecrt_domain_size() const.
Florian Pose <fp@igh-essen.com>
parents: 1225
diff changeset
   421
size_t ecrt_domain_size(const ec_domain_t *domain)
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   422
{
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   423
    return domain->data_size;
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   424
}
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   425
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   426
/*****************************************************************************/
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   427
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   428
void ecrt_domain_external_memory(ec_domain_t *domain, uint8_t *mem)
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   429
{
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   430
    EC_MASTER_DBG(domain->master, 1, "ecrt_domain_external_memory("
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   431
            "domain = 0x%p, mem = 0x%p)\n", domain, mem);
1181
9e5954a2a46e Added debugging for configuration function of the application interface.
Florian Pose <fp@igh-essen.com>
parents: 1116
diff changeset
   432
1075
94c6e36e0f8d Implemented master semaphore to secure concurrent access from ioctls, state machine and realtime interface.
Florian Pose <fp@igh-essen.com>
parents: 1055
diff changeset
   433
    down(&domain->master->master_sem);
94c6e36e0f8d Implemented master semaphore to secure concurrent access from ioctls, state machine and realtime interface.
Florian Pose <fp@igh-essen.com>
parents: 1055
diff changeset
   434
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   435
    ec_domain_clear_data(domain);
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   436
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   437
    domain->data = mem;
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   438
    domain->data_origin = EC_ORIG_EXTERNAL;
1075
94c6e36e0f8d Implemented master semaphore to secure concurrent access from ioctls, state machine and realtime interface.
Florian Pose <fp@igh-essen.com>
parents: 1055
diff changeset
   439
94c6e36e0f8d Implemented master semaphore to secure concurrent access from ioctls, state machine and realtime interface.
Florian Pose <fp@igh-essen.com>
parents: 1055
diff changeset
   440
    up(&domain->master->master_sem);
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   441
}
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   442
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   443
/*****************************************************************************/
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   444
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   445
uint8_t *ecrt_domain_data(ec_domain_t *domain)
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   446
{
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   447
    return domain->data;
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   448
}
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   449
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   450
/*****************************************************************************/
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   451
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   452
void ecrt_domain_process(ec_domain_t *domain)
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   453
{
2470
4f97d61a8671 Fixed ecrt_domain_process() broken in 71d38ff288b3.
Florian Pose <fp@igh-essen.com>
parents: 2468
diff changeset
   454
    uint16_t wc_sum[EC_MAX_NUM_DEVICES] = {}, wc_total;
4f97d61a8671 Fixed ecrt_domain_process() broken in 71d38ff288b3.
Florian Pose <fp@igh-essen.com>
parents: 2468
diff changeset
   455
    ec_datagram_pair_t *pair;
4f97d61a8671 Fixed ecrt_domain_process() broken in 71d38ff288b3.
Florian Pose <fp@igh-essen.com>
parents: 2468
diff changeset
   456
#if EC_MAX_NUM_DEVICES > 1
4f97d61a8671 Fixed ecrt_domain_process() broken in 71d38ff288b3.
Florian Pose <fp@igh-essen.com>
parents: 2468
diff changeset
   457
    uint16_t datagram_pair_wc, redundant_wc;
4f97d61a8671 Fixed ecrt_domain_process() broken in 71d38ff288b3.
Florian Pose <fp@igh-essen.com>
parents: 2468
diff changeset
   458
    unsigned int datagram_offset;
4f97d61a8671 Fixed ecrt_domain_process() broken in 71d38ff288b3.
Florian Pose <fp@igh-essen.com>
parents: 2468
diff changeset
   459
    ec_fmmu_config_t *fmmu = list_first_entry(&domain->fmmu_configs,
4f97d61a8671 Fixed ecrt_domain_process() broken in 71d38ff288b3.
Florian Pose <fp@igh-essen.com>
parents: 2468
diff changeset
   460
            ec_fmmu_config_t, list);
4f97d61a8671 Fixed ecrt_domain_process() broken in 71d38ff288b3.
Florian Pose <fp@igh-essen.com>
parents: 2468
diff changeset
   461
    unsigned int redundancy;
4f97d61a8671 Fixed ecrt_domain_process() broken in 71d38ff288b3.
Florian Pose <fp@igh-essen.com>
parents: 2468
diff changeset
   462
#endif
2453
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   463
    unsigned int dev_idx, wc_change;
2367
8527429b6137 Compare with send buffer; copy changed data.
Florian Pose <fp@igh-essen.com>
parents: 2366
diff changeset
   464
8527429b6137 Compare with send buffer; copy changed data.
Florian Pose <fp@igh-essen.com>
parents: 2366
diff changeset
   465
#if DEBUG_REDUNDANCY
8527429b6137 Compare with send buffer; copy changed data.
Florian Pose <fp@igh-essen.com>
parents: 2366
diff changeset
   466
    EC_MASTER_DBG(domain->master, 1, "domain %u process\n", domain->index);
8527429b6137 Compare with send buffer; copy changed data.
Florian Pose <fp@igh-essen.com>
parents: 2366
diff changeset
   467
#endif
2269
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   468
2470
4f97d61a8671 Fixed ecrt_domain_process() broken in 71d38ff288b3.
Florian Pose <fp@igh-essen.com>
parents: 2468
diff changeset
   469
    list_for_each_entry(pair, &domain->datagram_pairs, list) {
2463
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   470
#if EC_MAX_NUM_DEVICES > 1
2470
4f97d61a8671 Fixed ecrt_domain_process() broken in 71d38ff288b3.
Florian Pose <fp@igh-essen.com>
parents: 2468
diff changeset
   471
        datagram_pair_wc = ec_datagram_pair_process(pair, wc_sum);
4f97d61a8671 Fixed ecrt_domain_process() broken in 71d38ff288b3.
Florian Pose <fp@igh-essen.com>
parents: 2468
diff changeset
   472
#else
4f97d61a8671 Fixed ecrt_domain_process() broken in 71d38ff288b3.
Florian Pose <fp@igh-essen.com>
parents: 2468
diff changeset
   473
        ec_datagram_pair_process(pair, wc_sum);
4f97d61a8671 Fixed ecrt_domain_process() broken in 71d38ff288b3.
Florian Pose <fp@igh-essen.com>
parents: 2468
diff changeset
   474
#endif
4f97d61a8671 Fixed ecrt_domain_process() broken in 71d38ff288b3.
Florian Pose <fp@igh-essen.com>
parents: 2468
diff changeset
   475
4f97d61a8671 Fixed ecrt_domain_process() broken in 71d38ff288b3.
Florian Pose <fp@igh-essen.com>
parents: 2468
diff changeset
   476
#if EC_MAX_NUM_DEVICES > 1
4f97d61a8671 Fixed ecrt_domain_process() broken in 71d38ff288b3.
Florian Pose <fp@igh-essen.com>
parents: 2468
diff changeset
   477
        if (ec_master_num_devices(domain->master) > 1) {
2463
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   478
            ec_datagram_t *main_datagram = &pair->datagrams[EC_DEVICE_MAIN];
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   479
            uint32_t logical_datagram_address =
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   480
                EC_READ_U32(main_datagram->address);
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   481
            size_t datagram_size = main_datagram->data_size;
2368
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   482
2367
8527429b6137 Compare with send buffer; copy changed data.
Florian Pose <fp@igh-essen.com>
parents: 2366
diff changeset
   483
#if DEBUG_REDUNDANCY
2463
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   484
            EC_MASTER_DBG(domain->master, 1, "dgram %s log=%u\n",
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   485
                    main_datagram->name, logical_datagram_address);
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   486
#endif
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   487
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   488
            /* Redundancy: Go through FMMU configs to detect data changes. */
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   489
            list_for_each_entry_from(fmmu, &domain->fmmu_configs, list) {
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   490
                ec_datagram_t *backup_datagram =
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   491
                    &pair->datagrams[EC_DEVICE_BACKUP];
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   492
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   493
                if (fmmu->dir != EC_DIR_INPUT) {
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   494
                    continue;
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   495
                }
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   496
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   497
                if (fmmu->logical_start_address >=
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   498
                        logical_datagram_address + datagram_size) {
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   499
                    // fmmu data contained in next datagram pair
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   500
                    break;
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   501
                }
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   502
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   503
                datagram_offset =
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   504
                    fmmu->logical_start_address - logical_datagram_address;
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   505
2368
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   506
#if DEBUG_REDUNDANCY
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   507
                EC_MASTER_DBG(domain->master, 1,
2463
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   508
                        "input fmmu log=%u size=%u offset=%u\n",
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   509
                        fmmu->logical_start_address, fmmu->data_size,
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   510
                        datagram_offset);
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   511
                if (domain->master->debug_level > 0) {
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   512
                    ec_print_data(pair->send_buffer + datagram_offset,
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   513
                            fmmu->data_size);
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   514
                    ec_print_data(main_datagram->data + datagram_offset,
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   515
                            fmmu->data_size);
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   516
                    ec_print_data(backup_datagram->data + datagram_offset,
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   517
                            fmmu->data_size);
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   518
                }
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   519
#endif
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   520
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   521
                if (data_changed(pair->send_buffer, main_datagram,
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   522
                            datagram_offset, fmmu->data_size)) {
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   523
                    /* data changed on main link: no copying necessary. */
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   524
#if DEBUG_REDUNDANCY
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   525
                    EC_MASTER_DBG(domain->master, 1, "main changed\n");
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   526
#endif
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   527
                } else if (data_changed(pair->send_buffer, backup_datagram,
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   528
                            datagram_offset, fmmu->data_size)) {
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   529
                    /* data changed on backup link: copy to main memory. */
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   530
#if DEBUG_REDUNDANCY
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   531
                    EC_MASTER_DBG(domain->master, 1, "backup changed\n");
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   532
#endif
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   533
                    memcpy(main_datagram->data + datagram_offset,
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   534
                            backup_datagram->data + datagram_offset,
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   535
                            fmmu->data_size);
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   536
                } else if (datagram_pair_wc ==
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   537
                        pair->expected_working_counter) {
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   538
                    /* no change, but WC complete: use main data. */
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   539
#if DEBUG_REDUNDANCY
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   540
                    EC_MASTER_DBG(domain->master, 1,
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   541
                            "no change but complete\n");
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   542
#endif
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   543
                } else {
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   544
                    /* no change and WC incomplete: mark WC as zero to avoid
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   545
                     * data.dependent WC flickering. */
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   546
                    datagram_pair_wc = 0;
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   547
#if DEBUG_REDUNDANCY
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   548
                    EC_MASTER_DBG(domain->master, 1,
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   549
                            "no change and incomplete\n");
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   550
#endif
71d38ff288b3 Improved preprocessor macro usage reg. redundancy.
Florian Pose <fp@igh-essen.com>
parents: 2453
diff changeset
   551
                }
2368
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   552
            }
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   553
        }
2453
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   554
#endif // EC_MAX_NUM_DEVICES > 1
2470
4f97d61a8671 Fixed ecrt_domain_process() broken in 71d38ff288b3.
Florian Pose <fp@igh-essen.com>
parents: 2468
diff changeset
   555
    }
4f97d61a8671 Fixed ecrt_domain_process() broken in 71d38ff288b3.
Florian Pose <fp@igh-essen.com>
parents: 2468
diff changeset
   556
4f97d61a8671 Fixed ecrt_domain_process() broken in 71d38ff288b3.
Florian Pose <fp@igh-essen.com>
parents: 2468
diff changeset
   557
#if EC_MAX_NUM_DEVICES > 1
2453
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   558
    redundant_wc = 0;
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   559
    for (dev_idx = EC_DEVICE_BACKUP;
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   560
            dev_idx < ec_master_num_devices(domain->master); dev_idx++) {
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   561
        redundant_wc += wc_sum[dev_idx];
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   562
    }
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   563
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   564
    redundancy = redundant_wc > 0;
2368
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   565
    if (redundancy != domain->redundancy_active) {
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   566
        if (redundancy) {
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   567
            EC_MASTER_WARN(domain->master,
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   568
                    "Domain %u: Redundant link in use!\n",
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   569
                    domain->index);
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   570
        } else {
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   571
            EC_MASTER_INFO(domain->master,
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   572
                    "Domain %u: Redundant link unused again.\n",
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   573
                    domain->index);
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   574
        }
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   575
        domain->redundancy_active = redundancy;
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   576
    }
2470
4f97d61a8671 Fixed ecrt_domain_process() broken in 71d38ff288b3.
Florian Pose <fp@igh-essen.com>
parents: 2468
diff changeset
   577
#else
4f97d61a8671 Fixed ecrt_domain_process() broken in 71d38ff288b3.
Florian Pose <fp@igh-essen.com>
parents: 2468
diff changeset
   578
    domain->redundancy_active = 0;
4f97d61a8671 Fixed ecrt_domain_process() broken in 71d38ff288b3.
Florian Pose <fp@igh-essen.com>
parents: 2468
diff changeset
   579
#endif
2368
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   580
2453
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   581
    wc_change = 0;
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   582
    wc_total = 0;
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   583
    for (dev_idx = EC_DEVICE_MAIN;
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   584
            dev_idx < ec_master_num_devices(domain->master); dev_idx++) {
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   585
        if (wc_sum[dev_idx] != domain->working_counter[dev_idx]) {
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   586
            wc_change = 1;
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   587
            domain->working_counter[dev_idx] = wc_sum[dev_idx];
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   588
        }
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   589
        wc_total += wc_sum[dev_idx];
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   590
    }
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   591
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   592
    if (wc_change) {
332
e16093374dfd New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   593
        domain->working_counter_changes++;
e16093374dfd New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   594
    }
e16093374dfd New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   595
e16093374dfd New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   596
    if (domain->working_counter_changes &&
344
5d8281f1aa2a Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents: 343
diff changeset
   597
        jiffies - domain->notify_jiffies > HZ) {
5d8281f1aa2a Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents: 343
diff changeset
   598
        domain->notify_jiffies = jiffies;
332
e16093374dfd New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   599
        if (domain->working_counter_changes == 1) {
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   600
            EC_MASTER_INFO(domain->master, "Domain %u: Working counter"
2453
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   601
                    " changed to %u/%u", domain->index,
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   602
                    wc_total, domain->expected_working_counter);
1921
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   603
        } else {
d9cf40facbc4 Improved syslog macros.
Florian Pose <fp@igh-essen.com>
parents: 1907
diff changeset
   604
            EC_MASTER_INFO(domain->master, "Domain %u: %u working counter"
2453
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   605
                    " changes - now %u/%u", domain->index,
2368
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   606
                    domain->working_counter_changes,
2453
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   607
                    wc_total, domain->expected_working_counter);
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   608
        }
2470
4f97d61a8671 Fixed ecrt_domain_process() broken in 71d38ff288b3.
Florian Pose <fp@igh-essen.com>
parents: 2468
diff changeset
   609
#if EC_MAX_NUM_DEVICES > 1
2453
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   610
        if (ec_master_num_devices(domain->master) > 1) {
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   611
            printk(" (");
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   612
            for (dev_idx = EC_DEVICE_MAIN;
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   613
                    dev_idx < ec_master_num_devices(domain->master);
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   614
                    dev_idx++) {
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   615
                printk("%u", domain->working_counter[dev_idx]);
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   616
                if (dev_idx + 1 < ec_master_num_devices(domain->master)) {
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   617
                    printk("+");
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   618
                }
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   619
            }
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   620
            printk(")");
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   621
        }
2470
4f97d61a8671 Fixed ecrt_domain_process() broken in 71d38ff288b3.
Florian Pose <fp@igh-essen.com>
parents: 2468
diff changeset
   622
#endif
2453
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   623
        printk(".\n");
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   624
332
e16093374dfd New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   625
        domain->working_counter_changes = 0;
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   626
    }
494
178b1b43a88c Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   627
}
178b1b43a88c Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   628
178b1b43a88c Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   629
/*****************************************************************************/
178b1b43a88c Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   630
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   631
void ecrt_domain_queue(ec_domain_t *domain)
494
178b1b43a88c Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   632
{
2269
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   633
    ec_datagram_pair_t *datagram_pair;
2374
e898451c054a Slave scanning and configuration on all links.
Florian Pose <fp@igh-essen.com>
parents: 2368
diff changeset
   634
    ec_device_index_t dev_idx;
2269
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   635
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   636
    list_for_each_entry(datagram_pair, &domain->datagram_pairs, list) {
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   637
2453
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   638
#if EC_MAX_NUM_DEVICES > 1
2367
8527429b6137 Compare with send buffer; copy changed data.
Florian Pose <fp@igh-essen.com>
parents: 2366
diff changeset
   639
        /* copy main data to send buffer */
8527429b6137 Compare with send buffer; copy changed data.
Florian Pose <fp@igh-essen.com>
parents: 2366
diff changeset
   640
        memcpy(datagram_pair->send_buffer,
8527429b6137 Compare with send buffer; copy changed data.
Florian Pose <fp@igh-essen.com>
parents: 2366
diff changeset
   641
                datagram_pair->datagrams[EC_DEVICE_MAIN].data,
8527429b6137 Compare with send buffer; copy changed data.
Florian Pose <fp@igh-essen.com>
parents: 2366
diff changeset
   642
                datagram_pair->datagrams[EC_DEVICE_MAIN].data_size);
2453
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   643
#endif
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   644
        ec_master_queue_datagram(domain->master,
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   645
                &datagram_pair->datagrams[EC_DEVICE_MAIN]);
2367
8527429b6137 Compare with send buffer; copy changed data.
Florian Pose <fp@igh-essen.com>
parents: 2366
diff changeset
   646
2269
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   647
        /* copy main data to backup datagram */
2453
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   648
        for (dev_idx = EC_DEVICE_BACKUP;
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   649
                dev_idx < ec_master_num_devices(domain->master); dev_idx++) {
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   650
            memcpy(datagram_pair->datagrams[dev_idx].data,
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   651
                    datagram_pair->datagrams[EC_DEVICE_MAIN].data,
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   652
                    datagram_pair->datagrams[EC_DEVICE_MAIN].data_size);
2269
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   653
            ec_master_queue_datagram(domain->master,
2374
e898451c054a Slave scanning and configuration on all links.
Florian Pose <fp@igh-essen.com>
parents: 2368
diff changeset
   654
                    &datagram_pair->datagrams[dev_idx]);
2269
1d0711235a61 Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents: 2268
diff changeset
   655
        }
494
178b1b43a88c Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   656
    }
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   657
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   658
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   659
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   660
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   661
void ecrt_domain_state(const ec_domain_t *domain, ec_domain_state_t *state)
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   662
{
2453
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   663
    unsigned int dev_idx;
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   664
    uint16_t wc = 0;
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   665
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   666
    for (dev_idx = EC_DEVICE_MAIN;
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   667
            dev_idx < ec_master_num_devices(domain->master); dev_idx++) {
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   668
        wc += domain->working_counter[dev_idx];
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   669
    }
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   670
d461b1f07296 Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents: 2374
diff changeset
   671
    state->working_counter = wc;
2368
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   672
2468
3134b7255f3d Minor change.
Florian Pose <fp@igh-essen.com>
parents: 2463
diff changeset
   673
    if (wc) {
3134b7255f3d Minor change.
Florian Pose <fp@igh-essen.com>
parents: 2463
diff changeset
   674
        if (wc == domain->expected_working_counter) {
818
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   675
            state->wc_state = EC_WC_COMPLETE;
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   676
        } else {
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   677
            state->wc_state = EC_WC_INCOMPLETE;
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   678
        }
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   679
    } else {
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   680
        state->wc_state = EC_WC_ZERO;
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   681
    }
2368
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   682
dd84ef164869 Loop through datagrams, then FMMUs; redundancy flag in domain state.
Florian Pose <fp@igh-essen.com>
parents: 2367
diff changeset
   683
    state->redundancy_active = domain->redundancy_active;
105
fad6709a526f Dom?nen-Status (ecrt_domain_state) hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   684
}
fad6709a526f Dom?nen-Status (ecrt_domain_state) hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   685
fad6709a526f Dom?nen-Status (ecrt_domain_state) hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   686
/*****************************************************************************/
fad6709a526f Dom?nen-Status (ecrt_domain_state) hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   687
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   688
/** \cond */
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   689
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   690
EXPORT_SYMBOL(ecrt_domain_reg_pdo_entry_list);
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   691
EXPORT_SYMBOL(ecrt_domain_size);
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   692
EXPORT_SYMBOL(ecrt_domain_external_memory);
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   693
EXPORT_SYMBOL(ecrt_domain_data);
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   694
EXPORT_SYMBOL(ecrt_domain_process);
494
178b1b43a88c Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   695
EXPORT_SYMBOL(ecrt_domain_queue);
105
fad6709a526f Dom?nen-Status (ecrt_domain_state) hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   696
EXPORT_SYMBOL(ecrt_domain_state);
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   697
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   698
/** \endcond */
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   699
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   700
/*****************************************************************************/