master/domain.c
author Florian Pose <fp@igh-essen.com>
Thu, 02 Oct 2008 07:14:00 +0000
changeset 1243 13cb18b91627
parent 1225 4d5b739edcb5
child 1257 9844ac126275
permissions -rw-r--r--
Added changes since 1.4.0-rc2.
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
 *
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
     5
 *  Copyright (C) 2006  Florian Pose, Ingenieurgemeinschaft IgH
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
 *
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
     9
 *  The IgH EtherCAT Master is free software; you can redistribute it
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    10
 *  and/or modify it under the terms of the GNU General Public License
246
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
    11
 *  as published by the Free Software Foundation; either version 2 of the
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
    12
 *  License, or (at your option) any later version.
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    13
 *
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    14
 *  The IgH EtherCAT Master is distributed in the hope that it will be
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    15
 *  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    17
 *  GNU General Public License for more details.
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    18
 *
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    19
 *  You should have received a copy of the GNU General Public License
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    20
 *  along with the IgH EtherCAT Master; if not, write to the Free Software
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    21
 *  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
    22
 *
246
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
    23
 *  The right to use EtherCAT Technology is granted and comes free of
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
    24
 *  charge under condition of compatibility of product made by
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
    25
 *  Licensee. People intending to distribute/sell products based on the
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
    26
 *  code, have to sign an agreement to guarantee that products using
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
    27
 *  software based on IgH EtherCAT master stay compatible with the actual
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
    28
 *  EtherCAT specification (which are released themselves as an open
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
    29
 *  standard) as the (only) precondition to have the right to use EtherCAT
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
    30
 *  Technology, IP and trade marks.
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
    31
 *
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
 *****************************************************************************/
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
199
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
   \file
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    36
   EtherCAT domain methods.
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    37
*/
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    38
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    39
/*****************************************************************************/
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    40
294
feea8d850c65 Applied include patch by M. Schwerin.
Florian Pose <fp@igh-essen.com>
parents: 293
diff changeset
    41
#include <linux/module.h>
feea8d850c65 Applied include patch by M. Schwerin.
Florian Pose <fp@igh-essen.com>
parents: 293
diff changeset
    42
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    43
#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
    44
#include "master.h"
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
    45
#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
    46
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    47
#include "domain.h"
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
/*****************************************************************************/
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
    50
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
    51
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
    52
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
    53
/*****************************************************************************/
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
    54
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
    55
/** Domain constructor.
993
8c32564252fd Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents: 985
diff changeset
    56
 */
8c32564252fd Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents: 985
diff changeset
    57
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
    58
        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
    59
        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
    60
        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
    61
        )
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
    62
{
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
    63
    domain->master = master;
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 166
diff changeset
    64
    domain->index = index;
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
    65
    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
    66
    domain->data_size = 0;
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
    67
    domain->data = NULL;
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
    68
    domain->data_origin = EC_ORIG_INTERNAL;
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
    69
    domain->logical_base_address = 0x00000000;
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
    70
    INIT_LIST_HEAD(&domain->datagrams);
1032
748c34ab66b6 working_counter = 0x0000;
Florian Pose <fp@igh-essen.com>
parents: 1010
diff changeset
    71
    domain->working_counter = 0x0000;
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
    72
    domain->expected_working_counter = 0x0000;
818
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
    73
    domain->working_counter_changes = 0;
344
5d8281f1aa2a Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents: 343
diff changeset
    74
    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
    75
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
    76
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
    77
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
    78
818
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
    79
/** Domain destructor.
993
8c32564252fd Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents: 985
diff changeset
    80
 */
8c32564252fd Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents: 985
diff changeset
    81
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
    82
{
8c32564252fd Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents: 985
diff changeset
    83
    ec_datagram_t *datagram, *next;
8c32564252fd Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents: 985
diff changeset
    84
8c32564252fd Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents: 985
diff changeset
    85
    // dequeue and free datagrams
8c32564252fd Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents: 985
diff changeset
    86
    list_for_each_entry_safe(datagram, next, &domain->datagrams, list) {
448
e4b76dc7910c FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents: 446
diff changeset
    87
        if (!list_empty(&datagram->queue)) // datagram queued?
993
8c32564252fd Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents: 985
diff changeset
    88
            list_del(&datagram->queue);
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
    89
        ec_datagram_clear(datagram);
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
    90
        kfree(datagram);
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    91
    }
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
    92
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
    93
    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
    94
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
    95
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
    96
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
    97
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
    98
/** Frees internally allocated memory.
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
    99
 */
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   100
void ec_domain_clear_data(
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   101
        ec_domain_t *domain /**< EtherCAT domain. */
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   102
        )
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
    if (domain->data_origin == EC_ORIG_INTERNAL && domain->data)
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   105
        kfree(domain->data);
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   106
    domain->data = NULL;
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   107
    domain->data_origin = EC_ORIG_INTERNAL;
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   108
}
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   109
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   110
/*****************************************************************************/
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   111
818
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   112
/** Adds an FMMU configuration to the domain.
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   113
 */
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   114
void ec_domain_add_fmmu_config(
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   115
        ec_domain_t *domain, /**< EtherCAT domain. */
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   116
        ec_fmmu_config_t *fmmu /**< FMMU configuration. */
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   117
        )
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   118
{
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   119
    fmmu->domain = domain;
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   120
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   121
    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
   122
    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
   123
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
   124
    if (domain->master->debug_level)
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   125
        EC_DBG("Domain %u: Added %u bytes, total %u.\n", domain->index,
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   126
                fmmu->data_size, domain->data_size);
818
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   127
}
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   128
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   129
/*****************************************************************************/
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   130
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   131
/** Allocates a domain datagram and appends it to the list.
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   132
 *
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   133
 * The datagram type and expected working counters are determined by the
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   134
 * number of input and output fmmus that share the datagram.
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   135
 *
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   136
 * \return 0 in case of success, else < 0
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   137
 */
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   138
int ec_domain_add_datagram(
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   139
        ec_domain_t *domain, /**< EtherCAT domain. */
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   140
        uint32_t logical_offset, /**< Logical offset. */
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   141
        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
   142
        uint8_t *data, /**< Process data. */
118dea2fa505 Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   143
        const unsigned int used[] /**< Used by inputs/outputs. */
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 628
diff changeset
   144
        )
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   145
{
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   146
    ec_datagram_t *datagram;
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   147
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   148
    if (!(datagram = kmalloc(sizeof(ec_datagram_t), GFP_KERNEL))) {
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   149
        EC_ERR("Failed to allocate domain datagram!\n");
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   150
        return -1;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   151
    }
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   152
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   153
    ec_datagram_init(datagram);
719
03d5b96632fb Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents: 708
diff changeset
   154
    snprintf(datagram->name, EC_DATAGRAM_NAME_SIZE,
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   155
            "domain%u-%u", domain->index, logical_offset);
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   156
817
118dea2fa505 Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   157
    if (used[EC_DIR_OUTPUT] && used[EC_DIR_INPUT]) { // inputs and outputs
118dea2fa505 Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   158
        if (ec_datagram_lrw(datagram, logical_offset, data_size, data)) {
118dea2fa505 Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   159
            kfree(datagram);
118dea2fa505 Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   160
            return -1;
118dea2fa505 Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   161
        }
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   162
        // If LRW is used, output FMMUs increment the working counter by 2,
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   163
        // while input FMMUs increment it by 1.
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   164
        domain->expected_working_counter =
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   165
            used[EC_DIR_OUTPUT] * 2 + used[EC_DIR_INPUT];
817
118dea2fa505 Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   166
    } else if (used[EC_DIR_OUTPUT]) { // outputs only
118dea2fa505 Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   167
        if (ec_datagram_lwr(datagram, logical_offset, data_size, data)) {
118dea2fa505 Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   168
            kfree(datagram);
118dea2fa505 Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   169
            return -1;
118dea2fa505 Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   170
        }
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   171
        domain->expected_working_counter = used[EC_DIR_OUTPUT];
817
118dea2fa505 Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   172
    } else { // inputs only (or nothing)
118dea2fa505 Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   173
        if (ec_datagram_lrd(datagram, logical_offset, data_size, data)) {
118dea2fa505 Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   174
            kfree(datagram);
118dea2fa505 Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   175
            return -1;
118dea2fa505 Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   176
        }
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   177
        domain->expected_working_counter = used[EC_DIR_INPUT];
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   178
    }
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   179
1225
4d5b739edcb5 Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents: 1181
diff changeset
   180
    ec_datagram_zero(datagram);
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   181
    list_add_tail(&datagram->list, &domain->datagrams);
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   182
    return 0;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   183
}
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   184
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   185
/*****************************************************************************/
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   186
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   187
/** Finishes a domain.
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   188
 *
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   189
 * 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
   190
 * 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
   191
 *
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   192
 * \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
   193
 *
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   194
 * \retval 0 in case of success
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   195
 * \retval <0 on failure.
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   196
 */
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   197
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
   198
        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
   199
        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
   200
        )
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   201
{
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   202
    uint32_t datagram_offset;
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   203
    size_t datagram_size;
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   204
    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
   205
    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
   206
    ec_fmmu_config_t *fmmu;
817
118dea2fa505 Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   207
    const ec_datagram_t *datagram;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   208
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   209
    domain->logical_base_address = base_address;
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   210
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   211
    if (domain->data_size && domain->data_origin == EC_ORIG_INTERNAL) {
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   212
        if (!(domain->data =
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   213
                    (uint8_t *) kmalloc(domain->data_size, GFP_KERNEL))) {
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   214
            EC_ERR("Failed to allocate %u bytes internal memory for"
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   215
                    " domain %u!\n", domain->data_size, domain->index);
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   216
            return -1;
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   217
        }
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   218
    }
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   219
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   220
    // Cycle through all domain FMMUS and
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   221
    // - correct the logical base addresses
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   222
    // - set up the datagrams to carry the process data
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   223
    datagram_offset = 0;
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   224
    datagram_size = 0;
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   225
    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
   226
    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
   227
    datagram_used[EC_DIR_INPUT] = 0;
118dea2fa505 Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   228
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   229
    list_for_each_entry(fmmu, &domain->fmmu_configs, list) {
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   230
        // Correct logical FMMU address
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   231
        fmmu->logical_start_address += base_address;
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   232
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   233
        // 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
   234
        // and calculate expected working counters
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   235
        datagram_used[fmmu->dir]++;
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   236
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   237
        // 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
   238
        // allocate a new one.
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   239
        if (datagram_size + fmmu->data_size > EC_MAX_DATA_SIZE) {
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   240
            if (ec_domain_add_datagram(domain,
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   241
                        domain->logical_base_address + datagram_offset,
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   242
                        datagram_size, domain->data + datagram_offset,
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   243
                        datagram_used))
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   244
                return -1;
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   245
            datagram_offset += datagram_size;
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   246
            datagram_size = 0;
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   247
            datagram_count++;
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   248
            datagram_used[EC_DIR_OUTPUT] = 0;
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   249
            datagram_used[EC_DIR_INPUT] = 0;
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   250
        }
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   251
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   252
        datagram_size += fmmu->data_size;
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   253
    }
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   254
993
8c32564252fd Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents: 985
diff changeset
   255
    // Allocate last datagram, if data are left (this is also the case if the
8c32564252fd Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents: 985
diff changeset
   256
    // process data fit into a single datagram)
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   257
    if (datagram_size) {
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   258
        if (ec_domain_add_datagram(domain,
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   259
                    domain->logical_base_address + datagram_offset,
817
118dea2fa505 Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   260
                    datagram_size, domain->data + datagram_offset,
118dea2fa505 Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   261
                    datagram_used))
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   262
            return -1;
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   263
        datagram_count++;
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   264
    }
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   265
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   266
    EC_INFO("Domain%u: Logical address 0x%08x, %u byte, "
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   267
            "expected working counter %u.\n", domain->index,
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   268
            domain->logical_base_address, domain->data_size,
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   269
            domain->expected_working_counter);
817
118dea2fa505 Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   270
    list_for_each_entry(datagram, &domain->datagrams, list) {
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   271
        EC_INFO("  Datagram %s: Logical offset 0x%08x, %u byte, type %s.\n",
817
118dea2fa505 Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   272
                datagram->name, EC_READ_U32(datagram->address),
118dea2fa505 Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   273
                datagram->data_size, ec_datagram_type_string(datagram));
118dea2fa505 Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   274
    }
118dea2fa505 Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   275
    
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   276
    return 0;
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   277
}
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   278
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   279
/*****************************************************************************/
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   280
1092
69393cf60399 Improved source code doc.
Florian Pose <fp@igh-essen.com>
parents: 1075
diff changeset
   281
/** Get the number of FMMU configurations of the domain.
69393cf60399 Improved source code doc.
Florian Pose <fp@igh-essen.com>
parents: 1075
diff changeset
   282
 */
950
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   283
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
   284
{
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   285
    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
   286
    unsigned int num = 0;
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   287
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   288
    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
   289
        num++;
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   290
    }
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   291
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   292
    return num;
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   293
}
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   294
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   295
/*****************************************************************************/
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   296
1092
69393cf60399 Improved source code doc.
Florian Pose <fp@igh-essen.com>
parents: 1075
diff changeset
   297
/** 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
   298
 */
950
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   299
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
   300
        const ec_domain_t *domain, /**< EtherCAT domain. */
69393cf60399 Improved source code doc.
Florian Pose <fp@igh-essen.com>
parents: 1075
diff changeset
   301
        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
   302
        )
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   303
{
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   304
    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
   305
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   306
    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
   307
        if (pos--)
950
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   308
            continue;
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   309
        return fmmu;
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   310
    }
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   311
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   312
    return NULL;
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   313
}
8b00e63fff90 'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents: 944
diff changeset
   314
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   315
/******************************************************************************
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
   316
 *  Realtime interface
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   317
 *****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   318
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   319
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
   320
        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
   321
{
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   322
    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
   323
    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
   324
    int ret;
640
16e9ad7d8e12 Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents: 635
diff changeset
   325
    
1181
9e5954a2a46e Added debugging for configuration function of the application interface.
Florian Pose <fp@igh-essen.com>
parents: 1116
diff changeset
   326
    if (domain->master->debug_level)
9e5954a2a46e Added debugging for configuration function of the application interface.
Florian Pose <fp@igh-essen.com>
parents: 1116
diff changeset
   327
        EC_DBG("ecrt_domain_reg_pdo_entry_list(domain = 0x%x, regs = 0x%x)\n",
9e5954a2a46e Added debugging for configuration function of the application interface.
Florian Pose <fp@igh-essen.com>
parents: 1116
diff changeset
   328
                (u32) domain, (u32) regs);
9e5954a2a46e Added debugging for configuration function of the application interface.
Florian Pose <fp@igh-essen.com>
parents: 1116
diff changeset
   329
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   330
    for (reg = regs; reg->index; reg++) {
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   331
        if (!(sc = ecrt_master_slave_config(domain->master, reg->alias,
1010
6672b86e7b10 Reverted revision number checking from r1228.
Florian Pose <fp@igh-essen.com>
parents: 1009
diff changeset
   332
                        reg->position, reg->vendor_id, reg->product_code)))
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   333
            return -1;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   334
807
f8bca95ab75d Moved ecrt_domain_reg_pdo_entry() to
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
   335
        if ((ret = ecrt_slave_config_reg_pdo_entry(sc, reg->index,
925
939f3e9bba1e Some improvements concerning bit_position.
Florian Pose <fp@igh-essen.com>
parents: 923
diff changeset
   336
                        reg->subindex, domain, reg->bit_position)) < 0)
916
db73994fbdac Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents: 912
diff changeset
   337
            return -1;
db73994fbdac Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents: 912
diff changeset
   338
db73994fbdac Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents: 912
diff changeset
   339
        *reg->offset = ret;
db73994fbdac Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents: 912
diff changeset
   340
    }
db73994fbdac Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents: 912
diff changeset
   341
db73994fbdac Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents: 912
diff changeset
   342
    return 0;
db73994fbdac Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents: 912
diff changeset
   343
}
db73994fbdac Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents: 912
diff changeset
   344
db73994fbdac Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents: 912
diff changeset
   345
/*****************************************************************************/
db73994fbdac Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents: 912
diff changeset
   346
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   347
size_t ecrt_domain_size(ec_domain_t *domain)
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   348
{
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   349
    return domain->data_size;
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   350
}
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   351
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   352
/*****************************************************************************/
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   353
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   354
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
   355
{
1181
9e5954a2a46e Added debugging for configuration function of the application interface.
Florian Pose <fp@igh-essen.com>
parents: 1116
diff changeset
   356
    if (domain->master->debug_level)
9e5954a2a46e Added debugging for configuration function of the application interface.
Florian Pose <fp@igh-essen.com>
parents: 1116
diff changeset
   357
        EC_DBG("ecrt_domain_external_memory(domain = 0x%x, mem = 0x%x)\n",
9e5954a2a46e Added debugging for configuration function of the application interface.
Florian Pose <fp@igh-essen.com>
parents: 1116
diff changeset
   358
                (u32) domain, (u32) mem);
9e5954a2a46e Added debugging for configuration function of the application interface.
Florian Pose <fp@igh-essen.com>
parents: 1116
diff changeset
   359
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
   360
    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
   361
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   362
    ec_domain_clear_data(domain);
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   363
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   364
    domain->data = mem;
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   365
    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
   366
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
   367
    up(&domain->master->master_sem);
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   368
}
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   369
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   370
/*****************************************************************************/
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   371
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   372
uint8_t *ecrt_domain_data(ec_domain_t *domain)
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   373
{
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   374
    return domain->data;
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   375
}
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   376
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   377
/*****************************************************************************/
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   378
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   379
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
   380
{
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   381
    uint16_t working_counter_sum;
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   382
    ec_datagram_t *datagram;
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   383
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   384
    working_counter_sum = 0x0000;
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   385
    list_for_each_entry(datagram, &domain->datagrams, list) {
719
03d5b96632fb Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents: 708
diff changeset
   386
        ec_datagram_output_stats(datagram);
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 315
diff changeset
   387
        if (datagram->state == EC_DATAGRAM_RECEIVED) {
293
14aeb79aa992 Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents: 275
diff changeset
   388
            working_counter_sum += datagram->working_counter;
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   389
        }
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   390
    }
73
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
    if (working_counter_sum != domain->working_counter) {
332
e16093374dfd New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   393
        domain->working_counter_changes++;
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   394
        domain->working_counter = working_counter_sum;
332
e16093374dfd New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   395
    }
e16093374dfd New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   396
e16093374dfd New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   397
    if (domain->working_counter_changes &&
344
5d8281f1aa2a Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents: 343
diff changeset
   398
        jiffies - domain->notify_jiffies > HZ) {
5d8281f1aa2a Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents: 343
diff changeset
   399
        domain->notify_jiffies = jiffies;
332
e16093374dfd New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   400
        if (domain->working_counter_changes == 1) {
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
   401
            EC_INFO("Domain %u: Working counter changed to %u/%u.\n",
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
   402
                    domain->index, domain->working_counter,
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
   403
                    domain->expected_working_counter);
985
90bcaf9ce3d5 Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents: 950
diff changeset
   404
        } else {
1116
3f2df83335b8 Improved WC changes message.
Florian Pose <fp@igh-essen.com>
parents: 1092
diff changeset
   405
            EC_INFO("Domain %u: %u working counter changes - now %u/%u.\n",
3f2df83335b8 Improved WC changes message.
Florian Pose <fp@igh-essen.com>
parents: 1092
diff changeset
   406
                    domain->index, domain->working_counter_changes,
3f2df83335b8 Improved WC changes message.
Florian Pose <fp@igh-essen.com>
parents: 1092
diff changeset
   407
                    domain->working_counter, domain->expected_working_counter);
332
e16093374dfd New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   408
        }
e16093374dfd New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents: 325
diff changeset
   409
        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
   410
    }
494
178b1b43a88c Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   411
}
178b1b43a88c Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   412
178b1b43a88c Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   413
/*****************************************************************************/
178b1b43a88c Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   414
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   415
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
   416
{
178b1b43a88c Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   417
    ec_datagram_t *datagram;
178b1b43a88c Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   418
178b1b43a88c Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   419
    list_for_each_entry(datagram, &domain->datagrams, list) {
178b1b43a88c Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   420
        ec_master_queue_datagram(domain->master, datagram);
178b1b43a88c Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents: 484
diff changeset
   421
    }
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   422
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   423
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   424
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 58
diff changeset
   425
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   426
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
   427
{
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   428
    state->working_counter = domain->working_counter;
818
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   429
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   430
    if (domain->working_counter) {
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   431
        if (domain->working_counter == domain->expected_working_counter) {
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   432
            state->wc_state = EC_WC_COMPLETE;
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   433
        } else {
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   434
            state->wc_state = EC_WC_INCOMPLETE;
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   435
        }
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   436
    } else {
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   437
        state->wc_state = EC_WC_ZERO;
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 817
diff changeset
   438
    }
105
fad6709a526f Dom?nen-Status (ecrt_domain_state) hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   439
}
fad6709a526f Dom?nen-Status (ecrt_domain_state) hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   440
fad6709a526f Dom?nen-Status (ecrt_domain_state) hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   441
/*****************************************************************************/
fad6709a526f Dom?nen-Status (ecrt_domain_state) hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   442
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   443
/** \cond */
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   444
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 783
diff changeset
   445
EXPORT_SYMBOL(ecrt_domain_reg_pdo_entry_list);
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   446
EXPORT_SYMBOL(ecrt_domain_size);
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   447
EXPORT_SYMBOL(ecrt_domain_external_memory);
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 807
diff changeset
   448
EXPORT_SYMBOL(ecrt_domain_data);
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   449
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
   450
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
   451
EXPORT_SYMBOL(ecrt_domain_state);
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   452
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   453
/** \endcond */
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   454
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   455
/*****************************************************************************/