author | Gavin Lambert <gavinl@compacsort.com> |
Sat, 31 May 2014 14:49:02 +1200 | |
changeset 2616 | f99e5b11806c |
parent 2614 | 9b29d7bfa230 |
child 2627 | 04c83089bac2 |
permissions | -rwxr-xr-x |
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" |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
44 |
#include "datagram_pair.h" |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
45 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
46 |
/** Extra debug output for redundancy functions. |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
47 |
*/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
48 |
#define DEBUG_REDUNDANCY 0 |
325
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 |
/*****************************************************************************/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
51 |
|
809 | 52 |
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
|
53 |
|
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
54 |
/*****************************************************************************/ |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
55 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
56 |
/** Domain constructor. |
993
8c32564252fd
Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents:
985
diff
changeset
|
57 |
*/ |
8c32564252fd
Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents:
985
diff
changeset
|
58 |
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
|
59 |
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
|
60 |
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
|
61 |
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
|
62 |
) |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
63 |
{ |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
64 |
unsigned int dev_idx; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
65 |
|
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
66 |
domain->master = master; |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
166
diff
changeset
|
67 |
domain->index = index; |
985
90bcaf9ce3d5
Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents:
950
diff
changeset
|
68 |
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
|
69 |
domain->data_size = 0; |
809 | 70 |
domain->data = NULL; |
71 |
domain->data_origin = EC_ORIG_INTERNAL; |
|
985
90bcaf9ce3d5
Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents:
950
diff
changeset
|
72 |
domain->logical_base_address = 0x00000000; |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
73 |
INIT_LIST_HEAD(&domain->datagram_pairs); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
74 |
for (dev_idx = EC_DEVICE_MAIN; dev_idx < ec_master_num_devices(master); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
75 |
dev_idx++) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
76 |
domain->working_counter[dev_idx] = 0x0000; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
77 |
} |
985
90bcaf9ce3d5
Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents:
950
diff
changeset
|
78 |
domain->expected_working_counter = 0x0000; |
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
79 |
domain->working_counter_changes = 0; |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
80 |
domain->redundancy_active = 0; |
344
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
343
diff
changeset
|
81 |
domain->notify_jiffies = 0; |
2612
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
82 |
|
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
83 |
/* Used by ec_domain_add_fmmu_config */ |
2611
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
84 |
memset(domain->offset_used, 0, sizeof(domain->offset_used)); |
2612
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
85 |
domain->sc_in_work = 0; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
86 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
87 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
88 |
/*****************************************************************************/ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
89 |
|
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
90 |
/** Domain destructor. |
993
8c32564252fd
Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents:
985
diff
changeset
|
91 |
*/ |
8c32564252fd
Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents:
985
diff
changeset
|
92 |
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
|
93 |
{ |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
94 |
ec_datagram_pair_t *datagram_pair, *next_pair; |
993
8c32564252fd
Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents:
985
diff
changeset
|
95 |
|
8c32564252fd
Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents:
985
diff
changeset
|
96 |
// dequeue and free datagrams |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
97 |
list_for_each_entry_safe(datagram_pair, next_pair, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
98 |
&domain->datagram_pairs, list) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
99 |
ec_datagram_pair_clear(datagram_pair); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
100 |
kfree(datagram_pair); |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
138
diff
changeset
|
101 |
} |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
97
diff
changeset
|
102 |
|
809 | 103 |
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
|
104 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
105 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
106 |
/*****************************************************************************/ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
107 |
|
809 | 108 |
/** Frees internally allocated memory. |
109 |
*/ |
|
110 |
void ec_domain_clear_data( |
|
111 |
ec_domain_t *domain /**< EtherCAT domain. */ |
|
112 |
) |
|
113 |
{ |
|
2101
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
114 |
if (domain->data_origin == EC_ORIG_INTERNAL && domain->data) { |
809 | 115 |
kfree(domain->data); |
2101
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
116 |
} |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
117 |
|
809 | 118 |
domain->data = NULL; |
119 |
domain->data_origin = EC_ORIG_INTERNAL; |
|
120 |
} |
|
121 |
||
122 |
/*****************************************************************************/ |
|
123 |
||
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
124 |
/** Adds an FMMU configuration to the domain. |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
125 |
*/ |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
126 |
void ec_domain_add_fmmu_config( |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
127 |
ec_domain_t *domain, /**< EtherCAT domain. */ |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
128 |
ec_fmmu_config_t *fmmu /**< FMMU configuration. */ |
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 |
{ |
2611
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
131 |
const ec_slave_config_t *sc; |
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
132 |
uint32_t logical_domain_offset; |
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
133 |
unsigned fmmu_data_size; |
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
134 |
|
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
135 |
fmmu->domain = domain; |
2611
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
136 |
sc = fmmu->sc; |
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
137 |
|
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
138 |
fmmu_data_size = ec_pdo_list_total_size( |
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
139 |
&sc->sync_configs[fmmu->sync_index].pdos); |
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
140 |
|
2612
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
141 |
if (sc->allow_overlapping_pdos && (sc == domain->sc_in_work)) { |
2611
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
142 |
// If we permit overlapped PDOs, and we already have an allocated FMMU |
2612
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
143 |
// for this slave, allocate the subsequent FMMU offsets by direction |
2611
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
144 |
logical_domain_offset = domain->offset_used[fmmu->dir]; |
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
145 |
} else { |
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
146 |
// otherwise, allocate to the furthest extent of any allocated |
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
147 |
// FMMU on this domain. |
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
148 |
logical_domain_offset = max(domain->offset_used[EC_DIR_INPUT], |
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
149 |
domain->offset_used[EC_DIR_OUTPUT]); |
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
150 |
// rebase the free offsets to the current position |
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
151 |
domain->offset_used[EC_DIR_INPUT] = logical_domain_offset; |
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
152 |
domain->offset_used[EC_DIR_OUTPUT] = logical_domain_offset; |
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
153 |
} |
2612
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
154 |
domain->sc_in_work = sc; |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
155 |
|
2611
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
156 |
// consume the offset space for this FMMU's direction |
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
157 |
domain->offset_used[fmmu->dir] += fmmu_data_size; |
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
158 |
|
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
159 |
ec_fmmu_set_domain_offset_size(fmmu, logical_domain_offset, fmmu_data_size); |
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
160 |
|
950
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
944
diff
changeset
|
161 |
list_add_tail(&fmmu->list, &domain->fmmu_configs); |
2612
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
162 |
|
2611
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
163 |
// Determine domain size from furthest extent of FMMU data |
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
164 |
domain->data_size = max(domain->offset_used[EC_DIR_INPUT], |
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
165 |
domain->offset_used[EC_DIR_OUTPUT]); |
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
|
166 |
|
1921 | 167 |
EC_MASTER_DBG(domain->master, 1, "Domain %u:" |
2611
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
168 |
" Added %u bytes at %u.\n", |
f09b0623a2c1
overlapping PDO initial working. datagram size is not correct
Dave Page <dave.page@gleeble.com>
parents:
2610
diff
changeset
|
169 |
domain->index, fmmu->data_size, logical_domain_offset); |
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
170 |
} |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
171 |
|
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
172 |
/*****************************************************************************/ |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
173 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
174 |
/** Allocates a domain datagram pair and appends it to the list. |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
175 |
* |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
176 |
* The datagrams' types and expected working counters are determined by the |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
177 |
* 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
|
178 |
* |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1304
diff
changeset
|
179 |
* \retval 0 Success. |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1304
diff
changeset
|
180 |
* \retval <0 Error code. |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
181 |
*/ |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
182 |
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
|
183 |
ec_domain_t *domain, /**< EtherCAT domain. */ |
809 | 184 |
uint32_t logical_offset, /**< Logical offset. */ |
185 |
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
|
186 |
uint8_t *data, /**< Process data. */ |
2101
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
187 |
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
|
188 |
) |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
189 |
{ |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
190 |
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
|
191 |
int ret; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
192 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
193 |
if (!(datagram_pair = kmalloc(sizeof(ec_datagram_pair_t), GFP_KERNEL))) { |
1921 | 194 |
EC_MASTER_ERR(domain->master, |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
195 |
"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
|
196 |
return -ENOMEM; |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
138
diff
changeset
|
197 |
} |
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
138
diff
changeset
|
198 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
199 |
ret = ec_datagram_pair_init(datagram_pair, domain, logical_offset, data, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
200 |
data_size, used); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
201 |
if (ret) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
202 |
kfree(datagram_pair); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
203 |
return ret; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
204 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
205 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
206 |
domain->expected_working_counter += |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
207 |
datagram_pair->expected_working_counter; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
208 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
209 |
EC_MASTER_DBG(domain->master, 1, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
210 |
"Adding datagram pair with expected WC %u.\n", |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
211 |
datagram_pair->expected_working_counter); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
212 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
213 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
214 |
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
|
215 |
return 0; |
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
138
diff
changeset
|
216 |
} |
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
138
diff
changeset
|
217 |
|
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
138
diff
changeset
|
218 |
/*****************************************************************************/ |
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
138
diff
changeset
|
219 |
|
2101
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
220 |
/** Domain finish helper function. |
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
221 |
* |
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
222 |
* Detects, if a slave configuration has already been taken into account for |
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
223 |
* a datagram's expected working counter calculation. |
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
224 |
* |
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
225 |
* Walks through the list of all FMMU configurations for the current datagram |
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
226 |
* and ends before the current datagram. |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
227 |
* |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
228 |
* \return Non-zero if slave connfig was already counted. |
2101
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
229 |
*/ |
2612
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
230 |
static int shall_count( |
2101
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
231 |
const ec_fmmu_config_t *cur_fmmu, /**< Current FMMU with direction to |
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
232 |
search for. */ |
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
233 |
const ec_fmmu_config_t *first_fmmu /**< Datagram's first FMMU. */ |
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
234 |
) |
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
235 |
{ |
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
236 |
for (; first_fmmu != cur_fmmu; |
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
237 |
first_fmmu = list_entry(first_fmmu->list.next, |
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
238 |
ec_fmmu_config_t, list)) { |
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
239 |
|
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
240 |
if (first_fmmu->sc == cur_fmmu->sc |
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
241 |
&& first_fmmu->dir == cur_fmmu->dir) { |
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
242 |
return 0; // was already counted |
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
243 |
} |
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
244 |
} |
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
245 |
|
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
246 |
return 1; |
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
247 |
} |
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
248 |
|
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
249 |
/*****************************************************************************/ |
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
250 |
|
2612
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
251 |
/** Domain finish helper function. |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
252 |
* |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
253 |
* Known boundaries for a datagram have been identified. Scans the datagram |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
254 |
* FMMU boundaries for WKC counters and then creates the datagram_pair. |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
255 |
* |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
256 |
* \param domain The parent domain |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
257 |
* \param datagram_begin_offset Datagram's logical beginning offset |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
258 |
* \param datagram_end_offset Logical end offset (one past last byte) |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
259 |
* \param datagram_first_fmmu The begin FMMU in the datagram |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
260 |
* \param datagram_end_fmmu The end (one past last) FMMU |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
261 |
* |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
262 |
* \return Non-zero if error emplacing domain |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
263 |
*/ |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
264 |
static int emplace_datagram(ec_domain_t *domain, |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
265 |
uint32_t datagram_begin_offset, |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
266 |
uint32_t datagram_end_offset, |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
267 |
const ec_fmmu_config_t *datagram_first_fmmu, |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
268 |
const ec_fmmu_config_t *datagram_end_fmmu |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
269 |
) |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
270 |
{ |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
271 |
unsigned int datagram_used[EC_DIR_COUNT]; |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
272 |
const ec_fmmu_config_t *curr_fmmu; |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
273 |
size_t data_size; |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
274 |
|
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
275 |
data_size = datagram_end_offset - datagram_begin_offset; |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
276 |
|
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
277 |
memset(datagram_used, 0, sizeof(datagram_used)); |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
278 |
for (curr_fmmu = datagram_first_fmmu; |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
279 |
&curr_fmmu->list != &datagram_end_fmmu->list; |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
280 |
curr_fmmu = list_next_entry(curr_fmmu, list)) { |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
281 |
if (shall_count(curr_fmmu, datagram_first_fmmu)) { |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
282 |
datagram_used[curr_fmmu->dir]++; |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
283 |
} |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
284 |
} |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
285 |
|
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
286 |
return ec_domain_add_datagram_pair(domain, |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
287 |
domain->logical_base_address + datagram_begin_offset, |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
288 |
data_size, |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
289 |
domain->data + datagram_begin_offset, |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
290 |
datagram_used); |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
291 |
} |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
292 |
|
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
293 |
/*****************************************************************************/ |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
294 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
295 |
/** Finishes a domain. |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
296 |
* |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
297 |
* 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
|
298 |
* 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
|
299 |
* |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1304
diff
changeset
|
300 |
* \retval 0 Success |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1304
diff
changeset
|
301 |
* \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
|
302 |
*/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
303 |
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
|
304 |
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
|
305 |
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
|
306 |
) |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
307 |
{ |
2612
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
308 |
uint32_t datagram_offset = 0; |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
309 |
unsigned int datagram_count = 0; |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
310 |
ec_fmmu_config_t *fmmu; |
2101
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
311 |
const ec_fmmu_config_t *datagram_first_fmmu = NULL; |
2612
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
312 |
const ec_fmmu_config_t *valid_fmmu = NULL; |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
313 |
unsigned candidate_start = 0; |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
314 |
unsigned valid_start = 0; |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
315 |
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
|
316 |
int ret; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
317 |
|
809 | 318 |
domain->logical_base_address = base_address; |
319 |
||
320 |
if (domain->data_size && domain->data_origin == EC_ORIG_INTERNAL) { |
|
321 |
if (!(domain->data = |
|
322 |
(uint8_t *) kmalloc(domain->data_size, GFP_KERNEL))) { |
|
1921 | 323 |
EC_MASTER_ERR(domain->master, "Failed to allocate %zu bytes" |
324 |
" internal memory for domain %u!\n", |
|
325 |
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
|
326 |
return -ENOMEM; |
809 | 327 |
} |
328 |
} |
|
329 |
||
2101
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
330 |
// Cycle through all domain FMMUs and |
985
90bcaf9ce3d5
Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents:
950
diff
changeset
|
331 |
// - correct the logical base addresses |
90bcaf9ce3d5
Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents:
950
diff
changeset
|
332 |
// - set up the datagrams to carry the process data |
2101
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
333 |
// - calculate the datagrams' expected working counters |
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
334 |
if (!list_empty(&domain->fmmu_configs)) { |
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
335 |
datagram_first_fmmu = |
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
336 |
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
|
337 |
} |
dd276ae226b4
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
1798
diff
changeset
|
338 |
|
985
90bcaf9ce3d5
Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents:
950
diff
changeset
|
339 |
list_for_each_entry(fmmu, &domain->fmmu_configs, list) { |
2612
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
340 |
if (fmmu->data_size > EC_MAX_DATA_SIZE) { |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
341 |
EC_MASTER_ERR(domain->master, |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
342 |
"FMMU size %u bytes exceeds maximum data size %u", |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
343 |
fmmu->data_size, EC_MAX_DATA_SIZE); |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
344 |
return -EINVAL; |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
345 |
} |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
346 |
if (fmmu->logical_domain_offset >= candidate_start) { |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
347 |
// As FMMU offsets increase monotonically, and candidate start |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
348 |
// offset has never been contradicted, it can now never be |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
349 |
// contradicted, as no future FMMU can cross it. |
2614
9b29d7bfa230
Fix datagram overflow layout issue
Dave Page <dave.page@gleeble.com>
parents:
2612
diff
changeset
|
350 |
// All FMMUs prior to this point approved for next datagram |
9b29d7bfa230
Fix datagram overflow layout issue
Dave Page <dave.page@gleeble.com>
parents:
2612
diff
changeset
|
351 |
valid_fmmu = fmmu; |
9b29d7bfa230
Fix datagram overflow layout issue
Dave Page <dave.page@gleeble.com>
parents:
2612
diff
changeset
|
352 |
valid_start = candidate_start; |
9b29d7bfa230
Fix datagram overflow layout issue
Dave Page <dave.page@gleeble.com>
parents:
2612
diff
changeset
|
353 |
if (fmmu->logical_domain_offset + fmmu->data_size - datagram_offset |
9b29d7bfa230
Fix datagram overflow layout issue
Dave Page <dave.page@gleeble.com>
parents:
2612
diff
changeset
|
354 |
> EC_MAX_DATA_SIZE) { |
2612
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
355 |
// yet the new candidate exceeds the datagram size, so we |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
356 |
// use the last known valid candidate to create the datagram |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
357 |
ret = emplace_datagram(domain, datagram_offset, valid_start, |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
358 |
datagram_first_fmmu, valid_fmmu); |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
359 |
if (ret < 0) |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
360 |
return ret; |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
361 |
|
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
362 |
datagram_offset = valid_start; |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
363 |
datagram_count++; |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
364 |
datagram_first_fmmu = fmmu; |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
365 |
} |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
366 |
} |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
367 |
if (fmmu->logical_domain_offset + fmmu->data_size > candidate_start) { |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
368 |
candidate_start = fmmu->logical_domain_offset + fmmu->data_size; |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
369 |
} |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
370 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
371 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
372 |
/* Allocate last datagram pair, if data are left (this is also the case if |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
373 |
* the process data fit into a single datagram) */ |
2612
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
374 |
if (domain->data_size > datagram_offset) { |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
375 |
ret = emplace_datagram(domain, datagram_offset, domain->data_size, |
668aa5e31137
overlapping PDO split datagram support
Dave Page <dave.page@gleeble.com>
parents:
2611
diff
changeset
|
376 |
datagram_first_fmmu, fmmu); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1304
diff
changeset
|
377 |
if (ret < 0) |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1304
diff
changeset
|
378 |
return ret; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
379 |
datagram_count++; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
380 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
381 |
|
1921 | 382 |
EC_MASTER_INFO(domain->master, "Domain%u: Logical address 0x%08x," |
383 |
" %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
|
384 |
domain->logical_base_address, domain->data_size, |
90bcaf9ce3d5
Fixed calculation of expected working counter.
Florian Pose <fp@igh-essen.com>
parents:
950
diff
changeset
|
385 |
domain->expected_working_counter); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
386 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
387 |
list_for_each_entry(datagram_pair, &domain->datagram_pairs, list) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
388 |
const ec_datagram_t *datagram = |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
389 |
&datagram_pair->datagrams[EC_DEVICE_MAIN]; |
1921 | 390 |
EC_MASTER_INFO(domain->master, " Datagram %s: Logical offset 0x%08x," |
2614
9b29d7bfa230
Fix datagram overflow layout issue
Dave Page <dave.page@gleeble.com>
parents:
2612
diff
changeset
|
391 |
" %zu byte, type %s at %p.\n", datagram->name, |
1921 | 392 |
EC_READ_U32(datagram->address), datagram->data_size, |
2614
9b29d7bfa230
Fix datagram overflow layout issue
Dave Page <dave.page@gleeble.com>
parents:
2612
diff
changeset
|
393 |
ec_datagram_type_string(datagram), datagram); |
817
118dea2fa505
Support for slaves that don't support the LRW datagram type.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
394 |
} |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
395 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
396 |
return 0; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
397 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
398 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
399 |
/*****************************************************************************/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
400 |
|
1092 | 401 |
/** Get the number of FMMU configurations of the domain. |
402 |
*/ |
|
950
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
944
diff
changeset
|
403 |
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
|
404 |
{ |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
944
diff
changeset
|
405 |
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
|
406 |
unsigned int num = 0; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
944
diff
changeset
|
407 |
|
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
944
diff
changeset
|
408 |
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
|
409 |
num++; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
944
diff
changeset
|
410 |
} |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
944
diff
changeset
|
411 |
|
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
944
diff
changeset
|
412 |
return num; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
944
diff
changeset
|
413 |
} |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
944
diff
changeset
|
414 |
|
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
944
diff
changeset
|
415 |
/*****************************************************************************/ |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
944
diff
changeset
|
416 |
|
1092 | 417 |
/** Get a certain FMMU configuration via its position in the list. |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
418 |
* |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
419 |
* \return FMMU at position \a pos, or NULL. |
1092 | 420 |
*/ |
950
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
944
diff
changeset
|
421 |
const ec_fmmu_config_t *ec_domain_find_fmmu( |
1092 | 422 |
const ec_domain_t *domain, /**< EtherCAT domain. */ |
423 |
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
|
424 |
) |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
944
diff
changeset
|
425 |
{ |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
944
diff
changeset
|
426 |
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
|
427 |
|
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
944
diff
changeset
|
428 |
list_for_each_entry(fmmu, &domain->fmmu_configs, list) { |
1092 | 429 |
if (pos--) |
950
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
944
diff
changeset
|
430 |
continue; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
944
diff
changeset
|
431 |
return fmmu; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
944
diff
changeset
|
432 |
} |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
944
diff
changeset
|
433 |
|
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
944
diff
changeset
|
434 |
return NULL; |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
944
diff
changeset
|
435 |
} |
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
944
diff
changeset
|
436 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
437 |
/*****************************************************************************/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
438 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
439 |
#if EC_MAX_NUM_DEVICES > 1 |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
440 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
441 |
/** Process received data. |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
442 |
*/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
443 |
int data_changed( |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
444 |
uint8_t *send_buffer, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
445 |
const ec_datagram_t *datagram, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
446 |
size_t offset, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
447 |
size_t size |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
448 |
) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
449 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
450 |
uint8_t *sent = send_buffer + offset; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
451 |
uint8_t *recv = datagram->data + offset; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
452 |
size_t i; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
453 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
454 |
for (i = 0; i < size; i++) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
455 |
if (recv[i] != sent[i]) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
456 |
return 1; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
457 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
458 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
459 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
460 |
return 0; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
461 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
462 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
463 |
#endif |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
464 |
|
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
465 |
/****************************************************************************** |
2101
01b30593e942
Avoided casting-away constness in expected working counter calculation.
Florian Pose <fp@igh-essen.com>
parents:
2028
diff
changeset
|
466 |
* Application interface |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
467 |
*****************************************************************************/ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
468 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
469 |
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
|
470 |
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
|
471 |
{ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
472 |
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
|
473 |
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
|
474 |
int ret; |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
475 |
|
1921 | 476 |
EC_MASTER_DBG(domain->master, 1, "ecrt_domain_reg_pdo_entry_list(" |
477 |
"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
|
478 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
479 |
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
|
480 |
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
|
481 |
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
|
482 |
if (IS_ERR(sc)) |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1304
diff
changeset
|
483 |
return PTR_ERR(sc); |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1304
diff
changeset
|
484 |
|
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1304
diff
changeset
|
485 |
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
|
486 |
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
|
487 |
if (ret < 0) |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1304
diff
changeset
|
488 |
return ret; |
916
db73994fbdac
Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents:
912
diff
changeset
|
489 |
|
db73994fbdac
Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents:
912
diff
changeset
|
490 |
*reg->offset = ret; |
db73994fbdac
Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents:
912
diff
changeset
|
491 |
} |
db73994fbdac
Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents:
912
diff
changeset
|
492 |
|
db73994fbdac
Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents:
912
diff
changeset
|
493 |
return 0; |
db73994fbdac
Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents:
912
diff
changeset
|
494 |
} |
db73994fbdac
Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents:
912
diff
changeset
|
495 |
|
db73994fbdac
Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents:
912
diff
changeset
|
496 |
/*****************************************************************************/ |
db73994fbdac
Added bitwise Pdo registration.
Florian Pose <fp@igh-essen.com>
parents:
912
diff
changeset
|
497 |
|
1257
9844ac126275
Made ecrt_domain_size() const.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
498 |
size_t ecrt_domain_size(const ec_domain_t *domain) |
809 | 499 |
{ |
500 |
return domain->data_size; |
|
501 |
} |
|
502 |
||
503 |
/*****************************************************************************/ |
|
504 |
||
505 |
void ecrt_domain_external_memory(ec_domain_t *domain, uint8_t *mem) |
|
506 |
{ |
|
1921 | 507 |
EC_MASTER_DBG(domain->master, 1, "ecrt_domain_external_memory(" |
508 |
"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
|
509 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
510 |
down(&domain->master->master_sem); |
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
|
511 |
|
809 | 512 |
ec_domain_clear_data(domain); |
513 |
||
514 |
domain->data = mem; |
|
515 |
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
|
516 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
517 |
up(&domain->master->master_sem); |
809 | 518 |
} |
519 |
||
520 |
/*****************************************************************************/ |
|
521 |
||
522 |
uint8_t *ecrt_domain_data(ec_domain_t *domain) |
|
523 |
{ |
|
524 |
return domain->data; |
|
525 |
} |
|
526 |
||
527 |
/*****************************************************************************/ |
|
528 |
||
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
529 |
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
|
530 |
{ |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
531 |
uint16_t wc_sum[EC_MAX_NUM_DEVICES] = {}, wc_total; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
532 |
ec_datagram_pair_t *pair; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
533 |
#if EC_MAX_NUM_DEVICES > 1 |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
534 |
uint16_t datagram_pair_wc, redundant_wc; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
535 |
unsigned int datagram_offset; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
536 |
ec_fmmu_config_t *fmmu = list_first_entry(&domain->fmmu_configs, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
537 |
ec_fmmu_config_t, list); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
538 |
unsigned int redundancy; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
539 |
#endif |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
540 |
unsigned int dev_idx; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
541 |
#ifdef EC_RT_SYSLOG |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
542 |
unsigned int wc_change; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
543 |
#endif |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
544 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
545 |
#if DEBUG_REDUNDANCY |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
546 |
EC_MASTER_DBG(domain->master, 1, "domain %u process\n", domain->index); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
547 |
#endif |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
548 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
549 |
list_for_each_entry(pair, &domain->datagram_pairs, list) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
550 |
#if EC_MAX_NUM_DEVICES > 1 |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
551 |
datagram_pair_wc = ec_datagram_pair_process(pair, wc_sum); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
552 |
#else |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
553 |
ec_datagram_pair_process(pair, wc_sum); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
554 |
#endif |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
555 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
556 |
#if EC_MAX_NUM_DEVICES > 1 |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
557 |
if (ec_master_num_devices(domain->master) > 1) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
558 |
ec_datagram_t *main_datagram = &pair->datagrams[EC_DEVICE_MAIN]; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
559 |
uint32_t logical_datagram_address = |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
560 |
EC_READ_U32(main_datagram->address); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
561 |
size_t datagram_size = main_datagram->data_size; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
562 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
563 |
#if DEBUG_REDUNDANCY |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
564 |
EC_MASTER_DBG(domain->master, 1, "dgram %s log=%u\n", |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
565 |
main_datagram->name, logical_datagram_address); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
566 |
#endif |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
567 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
568 |
/* Redundancy: Go through FMMU configs to detect data changes. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
569 |
list_for_each_entry_from(fmmu, &domain->fmmu_configs, list) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
570 |
ec_datagram_t *backup_datagram = |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
571 |
&pair->datagrams[EC_DEVICE_BACKUP]; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
572 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
573 |
if (fmmu->dir != EC_DIR_INPUT) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
574 |
continue; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
575 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
576 |
|
2610
f0fdcce9874b
Refactor fmmu->logical_start_address to fmmu->logical_domain_offset
Dave Page <dave.page@gleeble.com>
parents:
2589
diff
changeset
|
577 |
if (fmmu->logical_domain_offset >= datagram_size) { |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
578 |
// fmmu data contained in next datagram pair |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
579 |
break; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
580 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
581 |
|
2610
f0fdcce9874b
Refactor fmmu->logical_start_address to fmmu->logical_domain_offset
Dave Page <dave.page@gleeble.com>
parents:
2589
diff
changeset
|
582 |
datagram_offset = fmmu->logical_domain_offset; |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
583 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
584 |
#if DEBUG_REDUNDANCY |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
585 |
EC_MASTER_DBG(domain->master, 1, |
2610
f0fdcce9874b
Refactor fmmu->logical_start_address to fmmu->logical_domain_offset
Dave Page <dave.page@gleeble.com>
parents:
2589
diff
changeset
|
586 |
"input fmmu log_off=%u size=%u offset=%u\n", |
f0fdcce9874b
Refactor fmmu->logical_start_address to fmmu->logical_domain_offset
Dave Page <dave.page@gleeble.com>
parents:
2589
diff
changeset
|
587 |
fmmu->logical_domain_offset, fmmu->data_size, |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
588 |
datagram_offset); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
589 |
if (domain->master->debug_level > 0) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
590 |
ec_print_data(pair->send_buffer + datagram_offset, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
591 |
fmmu->data_size); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
592 |
ec_print_data(main_datagram->data + datagram_offset, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
593 |
fmmu->data_size); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
594 |
ec_print_data(backup_datagram->data + datagram_offset, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
595 |
fmmu->data_size); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
596 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
597 |
#endif |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
598 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
599 |
if (data_changed(pair->send_buffer, main_datagram, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
600 |
datagram_offset, fmmu->data_size)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
601 |
/* data changed on main link: no copying necessary. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
602 |
#if DEBUG_REDUNDANCY |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
603 |
EC_MASTER_DBG(domain->master, 1, "main changed\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
604 |
#endif |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
605 |
} else if (data_changed(pair->send_buffer, backup_datagram, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
606 |
datagram_offset, fmmu->data_size)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
607 |
/* data changed on backup link: copy to main memory. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
608 |
#if DEBUG_REDUNDANCY |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
609 |
EC_MASTER_DBG(domain->master, 1, "backup changed\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
610 |
#endif |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
611 |
memcpy(main_datagram->data + datagram_offset, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
612 |
backup_datagram->data + datagram_offset, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
613 |
fmmu->data_size); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
614 |
} else if (datagram_pair_wc == |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
615 |
pair->expected_working_counter) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
616 |
/* no change, but WC complete: use main data. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
617 |
#if DEBUG_REDUNDANCY |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
618 |
EC_MASTER_DBG(domain->master, 1, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
619 |
"no change but complete\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
620 |
#endif |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
621 |
} else { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
622 |
/* no change and WC incomplete: mark WC as zero to avoid |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
623 |
* data.dependent WC flickering. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
624 |
datagram_pair_wc = 0; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
625 |
#if DEBUG_REDUNDANCY |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
626 |
EC_MASTER_DBG(domain->master, 1, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
627 |
"no change and incomplete\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
628 |
#endif |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
629 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
630 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
631 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
632 |
#endif // EC_MAX_NUM_DEVICES > 1 |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
633 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
634 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
635 |
#if EC_MAX_NUM_DEVICES > 1 |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
636 |
redundant_wc = 0; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
637 |
for (dev_idx = EC_DEVICE_BACKUP; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
638 |
dev_idx < ec_master_num_devices(domain->master); dev_idx++) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
639 |
redundant_wc += wc_sum[dev_idx]; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
640 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
641 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
642 |
redundancy = redundant_wc > 0; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
643 |
if (redundancy != domain->redundancy_active) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
644 |
#ifdef EC_RT_SYSLOG |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
645 |
if (redundancy) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
646 |
EC_MASTER_WARN(domain->master, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
647 |
"Domain %u: Redundant link in use!\n", |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
648 |
domain->index); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
649 |
} else { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
650 |
EC_MASTER_INFO(domain->master, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
651 |
"Domain %u: Redundant link unused again.\n", |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
652 |
domain->index); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
653 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
654 |
#endif |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
655 |
domain->redundancy_active = redundancy; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
656 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
657 |
#else |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
658 |
domain->redundancy_active = 0; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
659 |
#endif |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
660 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
661 |
#ifdef EC_RT_SYSLOG |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
662 |
wc_change = 0; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
663 |
#endif |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
664 |
wc_total = 0; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
665 |
for (dev_idx = EC_DEVICE_MAIN; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
666 |
dev_idx < ec_master_num_devices(domain->master); dev_idx++) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
667 |
if (wc_sum[dev_idx] != domain->working_counter[dev_idx]) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
668 |
#ifdef EC_RT_SYSLOG |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
669 |
wc_change = 1; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
670 |
#endif |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
671 |
domain->working_counter[dev_idx] = wc_sum[dev_idx]; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
672 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
673 |
wc_total += wc_sum[dev_idx]; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
674 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
675 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
676 |
#ifdef EC_RT_SYSLOG |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
677 |
if (wc_change) { |
332
e16093374dfd
New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
678 |
domain->working_counter_changes++; |
e16093374dfd
New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
679 |
} |
e16093374dfd
New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
680 |
|
e16093374dfd
New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
681 |
if (domain->working_counter_changes && |
344
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
343
diff
changeset
|
682 |
jiffies - domain->notify_jiffies > HZ) { |
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
343
diff
changeset
|
683 |
domain->notify_jiffies = jiffies; |
332
e16093374dfd
New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
684 |
if (domain->working_counter_changes == 1) { |
1921 | 685 |
EC_MASTER_INFO(domain->master, "Domain %u: Working counter" |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
686 |
" changed to %u/%u", domain->index, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
687 |
wc_total, domain->expected_working_counter); |
1921 | 688 |
} else { |
689 |
EC_MASTER_INFO(domain->master, "Domain %u: %u working counter" |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
690 |
" changes - now %u/%u", domain->index, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
691 |
domain->working_counter_changes, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
692 |
wc_total, domain->expected_working_counter); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
693 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
694 |
#if EC_MAX_NUM_DEVICES > 1 |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
695 |
if (ec_master_num_devices(domain->master) > 1) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
696 |
printk(" ("); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
697 |
for (dev_idx = EC_DEVICE_MAIN; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
698 |
dev_idx < ec_master_num_devices(domain->master); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
699 |
dev_idx++) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
700 |
printk("%u", domain->working_counter[dev_idx]); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
701 |
if (dev_idx + 1 < ec_master_num_devices(domain->master)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
702 |
printk("+"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
703 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
704 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
705 |
printk(")"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
706 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
707 |
#endif |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
708 |
printk(".\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
709 |
|
332
e16093374dfd
New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
710 |
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
|
711 |
} |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
712 |
#endif |
494
178b1b43a88c
Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents:
484
diff
changeset
|
713 |
} |
178b1b43a88c
Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents:
484
diff
changeset
|
714 |
|
178b1b43a88c
Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents:
484
diff
changeset
|
715 |
/*****************************************************************************/ |
178b1b43a88c
Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents:
484
diff
changeset
|
716 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
717 |
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
|
718 |
{ |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
719 |
ec_datagram_pair_t *datagram_pair; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
720 |
ec_device_index_t dev_idx; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
721 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
722 |
list_for_each_entry(datagram_pair, &domain->datagram_pairs, list) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
723 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
724 |
#if EC_MAX_NUM_DEVICES > 1 |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
725 |
/* copy main data to send buffer */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
726 |
memcpy(datagram_pair->send_buffer, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
727 |
datagram_pair->datagrams[EC_DEVICE_MAIN].data, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
728 |
datagram_pair->datagrams[EC_DEVICE_MAIN].data_size); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
729 |
#endif |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
730 |
ec_master_queue_datagram(domain->master, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
731 |
&datagram_pair->datagrams[EC_DEVICE_MAIN]); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
732 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
733 |
/* copy main data to backup datagram */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
734 |
for (dev_idx = EC_DEVICE_BACKUP; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
735 |
dev_idx < ec_master_num_devices(domain->master); dev_idx++) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
736 |
memcpy(datagram_pair->datagrams[dev_idx].data, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
737 |
datagram_pair->datagrams[EC_DEVICE_MAIN].data, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
738 |
datagram_pair->datagrams[EC_DEVICE_MAIN].data_size); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
739 |
ec_master_queue_datagram(domain->master, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
740 |
&datagram_pair->datagrams[dev_idx]); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
741 |
} |
494
178b1b43a88c
Version 1.2.0-rc1, re-introduced ecrt_domain_queue().
Florian Pose <fp@igh-essen.com>
parents:
484
diff
changeset
|
742 |
} |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
743 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
744 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
745 |
/*****************************************************************************/ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
58
diff
changeset
|
746 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
747 |
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
|
748 |
{ |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
749 |
unsigned int dev_idx; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
750 |
uint16_t wc = 0; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
751 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
752 |
for (dev_idx = EC_DEVICE_MAIN; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
753 |
dev_idx < ec_master_num_devices(domain->master); dev_idx++) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
754 |
wc += domain->working_counter[dev_idx]; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
755 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
756 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
757 |
state->working_counter = wc; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
758 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
759 |
if (wc) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
760 |
if (wc == domain->expected_working_counter) { |
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
761 |
state->wc_state = EC_WC_COMPLETE; |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
762 |
} else { |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
763 |
state->wc_state = EC_WC_INCOMPLETE; |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
764 |
} |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
765 |
} else { |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
766 |
state->wc_state = EC_WC_ZERO; |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
817
diff
changeset
|
767 |
} |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
768 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2101
diff
changeset
|
769 |
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
|
770 |
} |
fad6709a526f
Dom?nen-Status (ecrt_domain_state) hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
771 |
|
fad6709a526f
Dom?nen-Status (ecrt_domain_state) hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
772 |
/*****************************************************************************/ |
fad6709a526f
Dom?nen-Status (ecrt_domain_state) hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
773 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
774 |
/** \cond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
775 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
783
diff
changeset
|
776 |
EXPORT_SYMBOL(ecrt_domain_reg_pdo_entry_list); |
809 | 777 |
EXPORT_SYMBOL(ecrt_domain_size); |
778 |
EXPORT_SYMBOL(ecrt_domain_external_memory); |
|
779 |
EXPORT_SYMBOL(ecrt_domain_data); |
|
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
780 |
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
|
781 |
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
|
782 |
EXPORT_SYMBOL(ecrt_domain_state); |
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
783 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
784 |
/** \endcond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
785 |
|
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
786 |
/*****************************************************************************/ |