author | Florian Pose <fp@igh-essen.com> |
Mon, 23 Jul 2012 15:32:42 +0200 | |
changeset 2398 | a6e2874fb0bd |
parent 2270 | 51d2b26a5d1c |
child 2589 | 2b9c78543663 |
permissions | -rw-r--r-- |
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
35
diff
changeset
|
1 |
/****************************************************************************** |
0 | 2 |
* |
2240
b45438edf869
Avoided unused variable warnings.
Florian Pose <fp@igh-essen.com>
parents:
2166
diff
changeset
|
3 |
* $Id$ |
0 | 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:
1335
diff
changeset
|
22 |
* --- |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
23 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
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:
1335
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:
1335
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:
239
diff
changeset
|
27 |
* |
1873
219be3742274
Added missing queue_external_datagram(); removed tabs.
Florian Pose <fp@igh-essen.com>
parents:
1856
diff
changeset
|
28 |
* vim: expandtab |
219be3742274
Added missing queue_external_datagram(); removed tabs.
Florian Pose <fp@igh-essen.com>
parents:
1856
diff
changeset
|
29 |
* |
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
35
diff
changeset
|
30 |
*****************************************************************************/ |
0 | 31 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
32 |
/** |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
33 |
\file |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
34 |
EtherCAT master methods. |
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 |
|
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
37 |
/*****************************************************************************/ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
38 |
|
24
d417dd9bdc2f
Wilhelms ?nderungen ?bernommen.
Florian Pose <fp@igh-essen.com>
parents:
23
diff
changeset
|
39 |
#include <linux/module.h> |
0 | 40 |
#include <linux/kernel.h> |
41 |
#include <linux/string.h> |
|
42 |
#include <linux/slab.h> |
|
43 |
#include <linux/delay.h> |
|
1015
24efac66a647
Added support for different versions of class_device_create().
Florian Pose <fp@igh-essen.com>
parents:
1013
diff
changeset
|
44 |
#include <linux/device.h> |
24efac66a647
Added support for different versions of class_device_create().
Florian Pose <fp@igh-essen.com>
parents:
1013
diff
changeset
|
45 |
#include <linux/version.h> |
1600
e36c92cf58a9
use given send interval to limit SDO/FOE traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
46 |
#include <linux/hrtimer.h> |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
47 |
#include "globals.h" |
55
059a9e712aa7
Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents:
54
diff
changeset
|
48 |
#include "slave.h" |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
49 |
#include "slave_config.h" |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
50 |
#include "device.h" |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
51 |
#include "datagram.h" |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
52 |
#ifdef EC_EOE |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
53 |
#include "ethernet.h" |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
54 |
#endif |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
55 |
#include "master.h" |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
56 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
57 |
/*****************************************************************************/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
58 |
|
2039
629d3cf05180
Minor changes (consistent variable naming)
Martin Troxler <ch1010277@ch10pc446>
parents:
2038
diff
changeset
|
59 |
/** Set to 1 to enable fsm datagram injection debugging. |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
60 |
*/ |
2037
ea0319750e13
Optionally compile with trace_printk support
Martin Troxler <ch1010277@ch10pc446>
parents:
2036
diff
changeset
|
61 |
#ifdef USE_TRACE_PRINTK |
ea0319750e13
Optionally compile with trace_printk support
Martin Troxler <ch1010277@ch10pc446>
parents:
2036
diff
changeset
|
62 |
#define DEBUG_INJECT 1 |
ea0319750e13
Optionally compile with trace_printk support
Martin Troxler <ch1010277@ch10pc446>
parents:
2036
diff
changeset
|
63 |
#else |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
64 |
#define DEBUG_INJECT 0 |
2037
ea0319750e13
Optionally compile with trace_printk support
Martin Troxler <ch1010277@ch10pc446>
parents:
2036
diff
changeset
|
65 |
#endif |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
66 |
|
1279
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
67 |
#ifdef EC_HAVE_CYCLES |
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
68 |
|
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
69 |
/** Frame timeout in cycles. |
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
70 |
*/ |
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
71 |
static cycles_t timeout_cycles; |
1906
96805a6eae3d
Renamed sdo_injecton_timeout to ext_injection_timeout.
Florian Pose <fp@igh-essen.com>
parents:
1873
diff
changeset
|
72 |
|
2022
393e7aef6706
renamed ext_injection_timeout -> fsm_injection_timeout
Martin Troxler <ch1010277@ch10pc446>
parents:
2021
diff
changeset
|
73 |
/** Timeout for fsm datagram injection [cycles]. |
393e7aef6706
renamed ext_injection_timeout -> fsm_injection_timeout
Martin Troxler <ch1010277@ch10pc446>
parents:
2021
diff
changeset
|
74 |
*/ |
393e7aef6706
renamed ext_injection_timeout -> fsm_injection_timeout
Martin Troxler <ch1010277@ch10pc446>
parents:
2021
diff
changeset
|
75 |
static cycles_t fsm_injection_timeout_cycles; |
1906
96805a6eae3d
Renamed sdo_injecton_timeout to ext_injection_timeout.
Florian Pose <fp@igh-essen.com>
parents:
1873
diff
changeset
|
76 |
|
1279
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
77 |
#else |
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
78 |
|
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
79 |
/** Frame timeout in jiffies. |
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
80 |
*/ |
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
81 |
static unsigned long timeout_jiffies; |
1906
96805a6eae3d
Renamed sdo_injecton_timeout to ext_injection_timeout.
Florian Pose <fp@igh-essen.com>
parents:
1873
diff
changeset
|
82 |
|
2022
393e7aef6706
renamed ext_injection_timeout -> fsm_injection_timeout
Martin Troxler <ch1010277@ch10pc446>
parents:
2021
diff
changeset
|
83 |
/** Timeout for fsm datagram injection [jiffies]. |
393e7aef6706
renamed ext_injection_timeout -> fsm_injection_timeout
Martin Troxler <ch1010277@ch10pc446>
parents:
2021
diff
changeset
|
84 |
*/ |
393e7aef6706
renamed ext_injection_timeout -> fsm_injection_timeout
Martin Troxler <ch1010277@ch10pc446>
parents:
2021
diff
changeset
|
85 |
static unsigned long fsm_injection_timeout_jiffies; |
1585
1f640e321ee4
ecrt_master_set_max_cycle_size: limit SDO traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
86 |
|
1279
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
87 |
#endif |
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
88 |
|
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
89 |
/*****************************************************************************/ |
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
90 |
|
995
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
994
diff
changeset
|
91 |
void ec_master_clear_slave_configs(ec_master_t *); |
993
8c32564252fd
Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents:
992
diff
changeset
|
92 |
void ec_master_clear_domains(ec_master_t *); |
1241
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
93 |
static int ec_master_idle_thread(void *); |
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
94 |
static int ec_master_operation_thread(void *); |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
95 |
#ifdef EC_EOE |
2020
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
96 |
static int ec_master_eoe_processing(ec_master_t *); |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
97 |
#endif |
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
98 |
void ec_master_find_dc_ref_clock(ec_master_t *); |
179
fb4c9dd11ca0
Sourced SysFS attribute show method prototypes out of headers.
Florian Pose <fp@igh-essen.com>
parents:
178
diff
changeset
|
99 |
|
fb4c9dd11ca0
Sourced SysFS attribute show method prototypes out of headers.
Florian Pose <fp@igh-essen.com>
parents:
178
diff
changeset
|
100 |
/*****************************************************************************/ |
fb4c9dd11ca0
Sourced SysFS attribute show method prototypes out of headers.
Florian Pose <fp@igh-essen.com>
parents:
178
diff
changeset
|
101 |
|
1279
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
102 |
/** Static variables initializer. |
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
103 |
*/ |
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
104 |
void ec_master_init_static(void) |
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
105 |
{ |
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
106 |
#ifdef EC_HAVE_CYCLES |
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
107 |
timeout_cycles = (cycles_t) EC_IO_TIMEOUT /* us */ * (cpu_khz / 1000); |
2022
393e7aef6706
renamed ext_injection_timeout -> fsm_injection_timeout
Martin Troxler <ch1010277@ch10pc446>
parents:
2021
diff
changeset
|
108 |
fsm_injection_timeout_cycles = (cycles_t) EC_FSM_INJECTION_TIMEOUT /* us */ * (cpu_khz / 1000); |
1279
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
109 |
#else |
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
110 |
// one jiffy may always elapse between time measurement |
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
111 |
timeout_jiffies = max(EC_IO_TIMEOUT * HZ / 1000000, 1); |
2022
393e7aef6706
renamed ext_injection_timeout -> fsm_injection_timeout
Martin Troxler <ch1010277@ch10pc446>
parents:
2021
diff
changeset
|
112 |
fsm_injection_timeout_jiffies = max(EC_FSM_INJECTION_TIMEOUT * HZ / 1000000, 1); |
1279
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
113 |
#endif |
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
114 |
} |
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
115 |
|
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
116 |
/*****************************************************************************/ |
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
117 |
|
0 | 118 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
119 |
Master constructor. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
120 |
\return 0 in case of success, else < 0 |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
121 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
122 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
123 |
int ec_master_init(ec_master_t *master, /**< EtherCAT master */ |
576
158c5a3d0a2a
New module file /sys/ethercat, masters moved to /sys/ethercat/masterX.
Florian Pose <fp@igh-essen.com>
parents:
573
diff
changeset
|
124 |
unsigned int index, /**< master index */ |
639
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
125 |
const uint8_t *main_mac, /**< MAC address of main device */ |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
902
diff
changeset
|
126 |
const uint8_t *backup_mac, /**< MAC address of backup device */ |
1013
52256b75f975
Create class device with device_number information in sysfs.
Florian Pose <fp@igh-essen.com>
parents:
1010
diff
changeset
|
127 |
dev_t device_number, /**< Character device number. */ |
1399
f79d4bb5b23a
Added debug_level module parameter. debug_level is now unsigned int.
Florian Pose <fp@igh-essen.com>
parents:
1396
diff
changeset
|
128 |
struct class *class, /**< Device class. */ |
f79d4bb5b23a
Added debug_level module parameter. debug_level is now unsigned int.
Florian Pose <fp@igh-essen.com>
parents:
1396
diff
changeset
|
129 |
unsigned int debug_level /**< Debug level (module parameter). */ |
576
158c5a3d0a2a
New module file /sys/ethercat, masters moved to /sys/ethercat/masterX.
Florian Pose <fp@igh-essen.com>
parents:
573
diff
changeset
|
130 |
) |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
131 |
{ |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
132 |
int ret; |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
133 |
|
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
134 |
master->index = index; |
647
dc556a8c8fed
Replaced master variable 'atomic_t available' by integer and used
Florian Pose <fp@igh-essen.com>
parents:
646
diff
changeset
|
135 |
master->reserved = 0; |
446 | 136 |
|
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
137 |
ec_mutex_init(&master->master_mutex); |
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
|
138 |
|
639
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
139 |
master->main_mac = main_mac; |
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
140 |
master->backup_mac = backup_mac; |
1579
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1507
diff
changeset
|
141 |
|
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
142 |
ec_mutex_init(&master->device_mutex); |
446 | 143 |
|
1029
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
144 |
master->phase = EC_ORPHANED; |
1530
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
145 |
master->active = 0; |
1925
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
146 |
master->config_changed = 0; |
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
147 |
master->injection_seq_fsm = 0; |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
148 |
master->injection_seq_rt = 0; |
446 | 149 |
|
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
150 |
master->slaves = NULL; |
446 | 151 |
master->slave_count = 0; |
1987
f452c93f7723
Improved distributed clock offset calculation to speed-up initial drift compensation
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1981
diff
changeset
|
152 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
153 |
INIT_LIST_HEAD(&master->configs); |
2165
1d94f77784a0
Fixed missing initialisation of allow_config flag.
Florian Pose <fp@igh-essen.com>
parents:
2164
diff
changeset
|
154 |
INIT_LIST_HEAD(&master->domains); |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
155 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
156 |
master->app_time = 0ULL; |
2165
1d94f77784a0
Fixed missing initialisation of allow_config flag.
Florian Pose <fp@igh-essen.com>
parents:
2164
diff
changeset
|
157 |
master->app_start_time = 0ULL; |
1d94f77784a0
Fixed missing initialisation of allow_config flag.
Florian Pose <fp@igh-essen.com>
parents:
2164
diff
changeset
|
158 |
master->has_app_time = 0; |
1987
f452c93f7723
Improved distributed clock offset calculation to speed-up initial drift compensation
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1981
diff
changeset
|
159 |
#ifdef EC_HAVE_CYCLES |
2001
2e05246f3b00
renamed dc_cycles_app_time -> dc_cycles_app_start_time & dc_jiffies_app_time -> dc_jiffies_app_start_time
Martin Troxler <ch1010277@ch10pc446>
parents:
2000
diff
changeset
|
160 |
master->dc_cycles_app_start_time = 0; |
2e05246f3b00
renamed dc_cycles_app_time -> dc_cycles_app_start_time & dc_jiffies_app_time -> dc_jiffies_app_start_time
Martin Troxler <ch1010277@ch10pc446>
parents:
2000
diff
changeset
|
161 |
#endif |
2e05246f3b00
renamed dc_cycles_app_time -> dc_cycles_app_start_time & dc_jiffies_app_time -> dc_jiffies_app_start_time
Martin Troxler <ch1010277@ch10pc446>
parents:
2000
diff
changeset
|
162 |
master->dc_jiffies_app_start_time = 0; |
1408 | 163 |
|
900
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
164 |
master->scan_busy = 0; |
2165
1d94f77784a0
Fixed missing initialisation of allow_config flag.
Florian Pose <fp@igh-essen.com>
parents:
2164
diff
changeset
|
165 |
master->allow_scan = 1; |
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
166 |
ec_mutex_init(&master->scan_mutex); |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
167 |
init_waitqueue_head(&master->scan_queue); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
168 |
|
900
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
169 |
master->config_busy = 0; |
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
170 |
ec_mutex_init(&master->config_mutex); |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
171 |
init_waitqueue_head(&master->config_queue); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
172 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
173 |
INIT_LIST_HEAD(&master->datagram_queue); |
446 | 174 |
master->datagram_index = 0; |
175 |
||
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
176 |
ec_mutex_init(&master->fsm_queue_mutex); |
2018
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
177 |
INIT_LIST_HEAD(&master->fsm_datagram_queue); |
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
178 |
|
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
179 |
// send interval in IDLE phase |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
180 |
ec_master_set_send_interval(master, 1000000 / HZ); |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1580
diff
changeset
|
181 |
|
1399
f79d4bb5b23a
Added debug_level module parameter. debug_level is now unsigned int.
Florian Pose <fp@igh-essen.com>
parents:
1396
diff
changeset
|
182 |
master->debug_level = debug_level; |
446 | 183 |
master->stats.timeouts = 0; |
184 |
master->stats.corrupted = 0; |
|
185 |
master->stats.unmatched = 0; |
|
186 |
master->stats.output_jiffies = 0; |
|
187 |
||
1241
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
188 |
master->thread = NULL; |
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
189 |
|
1041
42c9ac58d9ce
Removed state machine cycle time measuring.
Florian Pose <fp@igh-essen.com>
parents:
1040
diff
changeset
|
190 |
#ifdef EC_EOE |
1489
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
191 |
master->eoe_thread = NULL; |
446 | 192 |
INIT_LIST_HEAD(&master->eoe_handlers); |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
193 |
#endif |
446 | 194 |
|
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
195 |
ec_mutex_init(&master->io_mutex); |
2024
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
196 |
master->fsm_queue_lock_cb = NULL; |
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
197 |
master->fsm_queue_unlock_cb = NULL; |
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
198 |
master->fsm_queue_locking_data = NULL; |
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
199 |
master->app_fsm_queue_lock_cb = NULL; |
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
200 |
master->app_fsm_queue_unlock_cb = NULL; |
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
201 |
master->app_fsm_queue_locking_data = NULL; |
446 | 202 |
|
872 | 203 |
INIT_LIST_HEAD(&master->sii_requests); |
204 |
init_waitqueue_head(&master->sii_queue); |
|
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
597
diff
changeset
|
205 |
|
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1369
diff
changeset
|
206 |
INIT_LIST_HEAD(&master->reg_requests); |
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1369
diff
changeset
|
207 |
init_waitqueue_head(&master->reg_queue); |
1200 | 208 |
|
579
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
578
diff
changeset
|
209 |
// init devices |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
210 |
ret = ec_device_init(&master->main_device, master); |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
211 |
if (ret < 0) |
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
212 |
goto out_return; |
579
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
578
diff
changeset
|
213 |
|
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
214 |
ret = ec_device_init(&master->backup_device, master); |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
215 |
if (ret < 0) |
579
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
578
diff
changeset
|
216 |
goto out_clear_main; |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
578
diff
changeset
|
217 |
|
528
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
527
diff
changeset
|
218 |
// init state machine datagram |
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
527
diff
changeset
|
219 |
ec_datagram_init(&master->fsm_datagram); |
719
03d5b96632fb
Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents:
715
diff
changeset
|
220 |
snprintf(master->fsm_datagram.name, EC_DATAGRAM_NAME_SIZE, "master-fsm"); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
221 |
ret = ec_datagram_prealloc(&master->fsm_datagram, EC_MAX_DATA_SIZE); |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
222 |
if (ret < 0) { |
1394
e77728ddf0f9
Introduced ecrt_master_sync() for synchronizing slave clocks to reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
223 |
ec_datagram_clear(&master->fsm_datagram); |
1921 | 224 |
EC_MASTER_ERR(master, "Failed to allocate FSM datagram.\n"); |
659
d7c5a958bad0
Removed unecessary clearing of EoE handlers in master init function;
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
225 |
goto out_clear_backup; |
528
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
527
diff
changeset
|
226 |
} |
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
527
diff
changeset
|
227 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
228 |
// create state machine object |
2165
1d94f77784a0
Fixed missing initialisation of allow_config flag.
Florian Pose <fp@igh-essen.com>
parents:
2164
diff
changeset
|
229 |
ec_mbox_init(&master->fsm_mbox, &master->fsm_datagram); |
528
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
527
diff
changeset
|
230 |
ec_fsm_master_init(&master->fsm, master, &master->fsm_datagram); |
226
07247920a7ba
EoE with workqueue; bugfix in ec_master_init()
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
231 |
|
1396
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1394
diff
changeset
|
232 |
// init reference sync datagram |
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1394
diff
changeset
|
233 |
ec_datagram_init(&master->ref_sync_datagram); |
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1394
diff
changeset
|
234 |
snprintf(master->ref_sync_datagram.name, EC_DATAGRAM_NAME_SIZE, "refsync"); |
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1394
diff
changeset
|
235 |
ret = ec_datagram_apwr(&master->ref_sync_datagram, 0, 0x0910, 8); |
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1394
diff
changeset
|
236 |
if (ret < 0) { |
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1394
diff
changeset
|
237 |
ec_datagram_clear(&master->ref_sync_datagram); |
1921 | 238 |
EC_MASTER_ERR(master, "Failed to allocate reference" |
239 |
" synchronisation datagram.\n"); |
|
1396
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1394
diff
changeset
|
240 |
goto out_clear_fsm; |
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1394
diff
changeset
|
241 |
} |
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1394
diff
changeset
|
242 |
|
1394
e77728ddf0f9
Introduced ecrt_master_sync() for synchronizing slave clocks to reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
243 |
// init sync datagram |
e77728ddf0f9
Introduced ecrt_master_sync() for synchronizing slave clocks to reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
244 |
ec_datagram_init(&master->sync_datagram); |
e77728ddf0f9
Introduced ecrt_master_sync() for synchronizing slave clocks to reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
245 |
snprintf(master->sync_datagram.name, EC_DATAGRAM_NAME_SIZE, "sync"); |
1408 | 246 |
ret = ec_datagram_prealloc(&master->sync_datagram, 4); |
1394
e77728ddf0f9
Introduced ecrt_master_sync() for synchronizing slave clocks to reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
247 |
if (ret < 0) { |
e77728ddf0f9
Introduced ecrt_master_sync() for synchronizing slave clocks to reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
248 |
ec_datagram_clear(&master->sync_datagram); |
1921 | 249 |
EC_MASTER_ERR(master, "Failed to allocate" |
250 |
" synchronisation datagram.\n"); |
|
1396
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1394
diff
changeset
|
251 |
goto out_clear_ref_sync; |
1394
e77728ddf0f9
Introduced ecrt_master_sync() for synchronizing slave clocks to reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
252 |
} |
1535
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
253 |
|
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
254 |
// init sync monitor datagram |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
255 |
ec_datagram_init(&master->sync_mon_datagram); |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
256 |
snprintf(master->sync_mon_datagram.name, EC_DATAGRAM_NAME_SIZE, "syncmon"); |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
257 |
ret = ec_datagram_brd(&master->sync_mon_datagram, 0x092c, 4); |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
258 |
if (ret < 0) { |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
259 |
ec_datagram_clear(&master->sync_mon_datagram); |
1921 | 260 |
EC_MASTER_ERR(master, "Failed to allocate sync" |
261 |
" monitoring datagram.\n"); |
|
1535
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
262 |
goto out_clear_sync; |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
263 |
} |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
264 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
265 |
ec_master_find_dc_ref_clock(master); |
1394
e77728ddf0f9
Introduced ecrt_master_sync() for synchronizing slave clocks to reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
266 |
|
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
267 |
// init character device |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
268 |
ret = ec_cdev_init(&master->cdev, master, device_number); |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
269 |
if (ret) |
1535
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
270 |
goto out_clear_sync_mon; |
1013
52256b75f975
Create class device with device_number information in sysfs.
Florian Pose <fp@igh-essen.com>
parents:
1010
diff
changeset
|
271 |
|
1369
61793d845ad6
Preparations to compile against 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
272 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) |
61793d845ad6
Preparations to compile against 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
273 |
master->class_device = device_create(class, NULL, |
61793d845ad6
Preparations to compile against 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
274 |
MKDEV(MAJOR(device_number), master->index), NULL, |
61793d845ad6
Preparations to compile against 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
275 |
"EtherCAT%u", master->index); |
61793d845ad6
Preparations to compile against 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
276 |
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26) |
1250
642048176899
Applied patch by Mario Witkowski to support the new class/device
Florian Pose <fp@igh-essen.com>
parents:
1245
diff
changeset
|
277 |
master->class_device = device_create(class, NULL, |
642048176899
Applied patch by Mario Witkowski to support the new class/device
Florian Pose <fp@igh-essen.com>
parents:
1245
diff
changeset
|
278 |
MKDEV(MAJOR(device_number), master->index), |
642048176899
Applied patch by Mario Witkowski to support the new class/device
Florian Pose <fp@igh-essen.com>
parents:
1245
diff
changeset
|
279 |
"EtherCAT%u", master->index); |
642048176899
Applied patch by Mario Witkowski to support the new class/device
Florian Pose <fp@igh-essen.com>
parents:
1245
diff
changeset
|
280 |
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 15) |
642048176899
Applied patch by Mario Witkowski to support the new class/device
Florian Pose <fp@igh-essen.com>
parents:
1245
diff
changeset
|
281 |
master->class_device = class_device_create(class, NULL, |
1369
61793d845ad6
Preparations to compile against 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
282 |
MKDEV(MAJOR(device_number), master->index), NULL, |
61793d845ad6
Preparations to compile against 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
283 |
"EtherCAT%u", master->index); |
1015
24efac66a647
Added support for different versions of class_device_create().
Florian Pose <fp@igh-essen.com>
parents:
1013
diff
changeset
|
284 |
#else |
1250
642048176899
Applied patch by Mario Witkowski to support the new class/device
Florian Pose <fp@igh-essen.com>
parents:
1245
diff
changeset
|
285 |
master->class_device = class_device_create(class, |
1369
61793d845ad6
Preparations to compile against 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
286 |
MKDEV(MAJOR(device_number), master->index), NULL, |
61793d845ad6
Preparations to compile against 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
287 |
"EtherCAT%u", master->index); |
1015
24efac66a647
Added support for different versions of class_device_create().
Florian Pose <fp@igh-essen.com>
parents:
1013
diff
changeset
|
288 |
#endif |
1013
52256b75f975
Create class device with device_number information in sysfs.
Florian Pose <fp@igh-essen.com>
parents:
1010
diff
changeset
|
289 |
if (IS_ERR(master->class_device)) { |
1921 | 290 |
EC_MASTER_ERR(master, "Failed to create class device!\n"); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
291 |
ret = PTR_ERR(master->class_device); |
1013
52256b75f975
Create class device with device_number information in sysfs.
Florian Pose <fp@igh-essen.com>
parents:
1010
diff
changeset
|
292 |
goto out_clear_cdev; |
52256b75f975
Create class device with device_number information in sysfs.
Florian Pose <fp@igh-essen.com>
parents:
1010
diff
changeset
|
293 |
} |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
140
diff
changeset
|
294 |
|
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
295 |
return 0; |
226
07247920a7ba
EoE with workqueue; bugfix in ec_master_init()
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
296 |
|
1013
52256b75f975
Create class device with device_number information in sysfs.
Florian Pose <fp@igh-essen.com>
parents:
1010
diff
changeset
|
297 |
out_clear_cdev: |
52256b75f975
Create class device with device_number information in sysfs.
Florian Pose <fp@igh-essen.com>
parents:
1010
diff
changeset
|
298 |
ec_cdev_clear(&master->cdev); |
1535
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
299 |
out_clear_sync_mon: |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
300 |
ec_datagram_clear(&master->sync_mon_datagram); |
1394
e77728ddf0f9
Introduced ecrt_master_sync() for synchronizing slave clocks to reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
301 |
out_clear_sync: |
e77728ddf0f9
Introduced ecrt_master_sync() for synchronizing slave clocks to reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
302 |
ec_datagram_clear(&master->sync_datagram); |
1396
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1394
diff
changeset
|
303 |
out_clear_ref_sync: |
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1394
diff
changeset
|
304 |
ec_datagram_clear(&master->ref_sync_datagram); |
659
d7c5a958bad0
Removed unecessary clearing of EoE handlers in master init function;
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
305 |
out_clear_fsm: |
d7c5a958bad0
Removed unecessary clearing of EoE handlers in master init function;
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
306 |
ec_fsm_master_clear(&master->fsm); |
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
307 |
ec_datagram_clear(&master->fsm_datagram); |
659
d7c5a958bad0
Removed unecessary clearing of EoE handlers in master init function;
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
308 |
out_clear_backup: |
579
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
578
diff
changeset
|
309 |
ec_device_clear(&master->backup_device); |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
578
diff
changeset
|
310 |
out_clear_main: |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
578
diff
changeset
|
311 |
ec_device_clear(&master->main_device); |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
578
diff
changeset
|
312 |
out_return: |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
313 |
return ret; |
0 | 314 |
} |
315 |
||
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
35
diff
changeset
|
316 |
/*****************************************************************************/ |
0 | 317 |
|
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
318 |
/** Destructor. |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
319 |
*/ |
639
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
320 |
void ec_master_clear( |
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
321 |
ec_master_t *master /**< EtherCAT master */ |
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
322 |
) |
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
323 |
{ |
1250
642048176899
Applied patch by Mario Witkowski to support the new class/device
Florian Pose <fp@igh-essen.com>
parents:
1245
diff
changeset
|
324 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26) |
642048176899
Applied patch by Mario Witkowski to support the new class/device
Florian Pose <fp@igh-essen.com>
parents:
1245
diff
changeset
|
325 |
device_unregister(master->class_device); |
642048176899
Applied patch by Mario Witkowski to support the new class/device
Florian Pose <fp@igh-essen.com>
parents:
1245
diff
changeset
|
326 |
#else |
1013
52256b75f975
Create class device with device_number information in sysfs.
Florian Pose <fp@igh-essen.com>
parents:
1010
diff
changeset
|
327 |
class_device_unregister(master->class_device); |
1250
642048176899
Applied patch by Mario Witkowski to support the new class/device
Florian Pose <fp@igh-essen.com>
parents:
1245
diff
changeset
|
328 |
#endif |
1394
e77728ddf0f9
Introduced ecrt_master_sync() for synchronizing slave clocks to reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
329 |
|
995
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
994
diff
changeset
|
330 |
ec_cdev_clear(&master->cdev); |
2045
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
2040
diff
changeset
|
331 |
|
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
332 |
#ifdef EC_EOE |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
333 |
ec_master_clear_eoe_handlers(master); |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
334 |
#endif |
994
e29edcced328
Clear domains before slave configs, because domain references the FMMU
Florian Pose <fp@igh-essen.com>
parents:
993
diff
changeset
|
335 |
ec_master_clear_domains(master); |
995
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
994
diff
changeset
|
336 |
ec_master_clear_slave_configs(master); |
992
50a44cbd30af
Removed kobjects from sdo and slave.
Florian Pose <fp@igh-essen.com>
parents:
990
diff
changeset
|
337 |
ec_master_clear_slaves(master); |
1394
e77728ddf0f9
Introduced ecrt_master_sync() for synchronizing slave clocks to reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
338 |
|
1535
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
339 |
ec_datagram_clear(&master->sync_mon_datagram); |
1394
e77728ddf0f9
Introduced ecrt_master_sync() for synchronizing slave clocks to reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
340 |
ec_datagram_clear(&master->sync_datagram); |
1396
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1394
diff
changeset
|
341 |
ec_datagram_clear(&master->ref_sync_datagram); |
528
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
527
diff
changeset
|
342 |
ec_fsm_master_clear(&master->fsm); |
2045
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
2040
diff
changeset
|
343 |
ec_mbox_clear(&master->fsm_mbox); |
528
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
527
diff
changeset
|
344 |
ec_datagram_clear(&master->fsm_datagram); |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
345 |
ec_device_clear(&master->backup_device); |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
346 |
ec_device_clear(&master->main_device); |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
347 |
} |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
348 |
|
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
349 |
/*****************************************************************************/ |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
350 |
|
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
351 |
#ifdef EC_EOE |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
352 |
/** Clear and free all EoE handlers. |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
353 |
*/ |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
354 |
void ec_master_clear_eoe_handlers( |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
355 |
ec_master_t *master /**< EtherCAT master */ |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
356 |
) |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
357 |
{ |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
358 |
ec_eoe_t *eoe, *next; |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
359 |
|
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
360 |
list_for_each_entry_safe(eoe, next, &master->eoe_handlers, list) { |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
361 |
list_del(&eoe->list); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
362 |
ec_eoe_clear(eoe); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
363 |
kfree(eoe); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
364 |
} |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
365 |
} |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
366 |
#endif |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
367 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
368 |
/*****************************************************************************/ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
369 |
|
995
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
994
diff
changeset
|
370 |
/** Clear all slave configurations. |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
371 |
*/ |
995
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
994
diff
changeset
|
372 |
void ec_master_clear_slave_configs(ec_master_t *master) |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
373 |
{ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
374 |
ec_slave_config_t *sc, *next; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
375 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
376 |
list_for_each_entry_safe(sc, next, &master->configs, list) { |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
377 |
list_del(&sc->list); |
995
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
994
diff
changeset
|
378 |
ec_slave_config_clear(sc); |
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
994
diff
changeset
|
379 |
kfree(sc); |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
380 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
381 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
382 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
383 |
/*****************************************************************************/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
384 |
|
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
385 |
/** Clear all slaves. |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
386 |
*/ |
992
50a44cbd30af
Removed kobjects from sdo and slave.
Florian Pose <fp@igh-essen.com>
parents:
990
diff
changeset
|
387 |
void ec_master_clear_slaves(ec_master_t *master) |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
388 |
{ |
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
389 |
ec_slave_t *slave; |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
390 |
|
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
391 |
master->dc_ref_clock = NULL; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
392 |
|
1538
cf2fa3be6add
Fixed clearing slaves: Also clear external requests before. Thanks to Martin
Florian Pose <fp@igh-essen.com>
parents:
1535
diff
changeset
|
393 |
// external requests are obsolete, so we wake pending waiters and remove |
cf2fa3be6add
Fixed clearing slaves: Also clear external requests before. Thanks to Martin
Florian Pose <fp@igh-essen.com>
parents:
1535
diff
changeset
|
394 |
// them from the list |
1921 | 395 |
|
396 |
while (!list_empty(&master->sii_requests)) { |
|
397 |
ec_sii_write_request_t *request = |
|
398 |
list_entry(master->sii_requests.next, |
|
399 |
ec_sii_write_request_t, list); |
|
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
400 |
list_del_init(&request->list); // dequeue |
1921 | 401 |
EC_MASTER_WARN(master, "Discarding SII request, slave %u about" |
402 |
" to be deleted.\n", request->slave->ring_position); |
|
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
403 |
request->state = EC_INT_REQUEST_FAILURE; |
2030
2bd8ad8bf41f
Sii write wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_sii_write_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2028
diff
changeset
|
404 |
kref_put(&request->refcount,ec_master_sii_write_request_release); |
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
405 |
wake_up(&master->sii_queue); |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
406 |
} |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
407 |
|
1921 | 408 |
while (!list_empty(&master->reg_requests)) { |
409 |
ec_reg_request_t *request = |
|
410 |
list_entry(master->reg_requests.next, ec_reg_request_t, list); |
|
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
411 |
list_del_init(&request->list); // dequeue |
1921 | 412 |
EC_MASTER_WARN(master, "Discarding register request, slave %u" |
413 |
" about to be deleted.\n", request->slave->ring_position); |
|
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
414 |
request->state = EC_INT_REQUEST_FAILURE; |
2031
7a025a9e192d
Register read/write wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_reg_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2030
diff
changeset
|
415 |
kref_put(&request->refcount,ec_master_reg_request_release); |
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
416 |
wake_up(&master->reg_queue); |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
417 |
} |
1538
cf2fa3be6add
Fixed clearing slaves: Also clear external requests before. Thanks to Martin
Florian Pose <fp@igh-essen.com>
parents:
1535
diff
changeset
|
418 |
|
2107
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
419 |
// we must lock the io_mutex here because the slave's fsm_datagram |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
420 |
// will be unqueued |
2040
45706e3273fd
lock io_mutex when unqueueing datagrams; unqueue datagrams from send-receive queue.
Martin Troxler <ch1010277@ch10pc446>
parents:
2039
diff
changeset
|
421 |
ec_mutex_lock(&master->io_mutex); |
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
422 |
for (slave = master->slaves; |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
423 |
slave < master->slaves + master->slave_count; |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
424 |
slave++) { |
992
50a44cbd30af
Removed kobjects from sdo and slave.
Florian Pose <fp@igh-essen.com>
parents:
990
diff
changeset
|
425 |
ec_slave_clear(slave); |
1004
990b89d8ad03
Fixed duplicate kfree() bug.
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
426 |
} |
2040
45706e3273fd
lock io_mutex when unqueueing datagrams; unqueue datagrams from send-receive queue.
Martin Troxler <ch1010277@ch10pc446>
parents:
2039
diff
changeset
|
427 |
ec_mutex_unlock(&master->io_mutex); |
1004
990b89d8ad03
Fixed duplicate kfree() bug.
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
428 |
|
990b89d8ad03
Fixed duplicate kfree() bug.
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
429 |
if (master->slaves) { |
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
430 |
kfree(master->slaves); |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
431 |
master->slaves = NULL; |
1004
990b89d8ad03
Fixed duplicate kfree() bug.
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
432 |
} |
990b89d8ad03
Fixed duplicate kfree() bug.
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
433 |
|
990b89d8ad03
Fixed duplicate kfree() bug.
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
434 |
master->slave_count = 0; |
74
9bf603942791
Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
435 |
} |
9bf603942791
Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
436 |
|
9bf603942791
Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
437 |
/*****************************************************************************/ |
9bf603942791
Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
438 |
|
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
439 |
/** Clear all domains. |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
440 |
*/ |
993
8c32564252fd
Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents:
992
diff
changeset
|
441 |
void ec_master_clear_domains(ec_master_t *master) |
448
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
442 |
{ |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
443 |
ec_domain_t *domain, *next; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
444 |
|
2107
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
445 |
// we must lock the io_mutex here because the domains's datagram |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
446 |
// will be unqueued |
2040
45706e3273fd
lock io_mutex when unqueueing datagrams; unqueue datagrams from send-receive queue.
Martin Troxler <ch1010277@ch10pc446>
parents:
2039
diff
changeset
|
447 |
ec_mutex_lock(&master->io_mutex); |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
448 |
list_for_each_entry_safe(domain, next, &master->domains, list) { |
448
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
449 |
list_del(&domain->list); |
993
8c32564252fd
Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents:
992
diff
changeset
|
450 |
ec_domain_clear(domain); |
8c32564252fd
Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents:
992
diff
changeset
|
451 |
kfree(domain); |
448
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
452 |
} |
2040
45706e3273fd
lock io_mutex when unqueueing datagrams; unqueue datagrams from send-receive queue.
Martin Troxler <ch1010277@ch10pc446>
parents:
2039
diff
changeset
|
453 |
ec_mutex_unlock(&master->io_mutex); |
448
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
454 |
} |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
455 |
|
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
456 |
/*****************************************************************************/ |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
457 |
|
1939
1ba48f78a0a5
Fixed bug that caused the configuration not to be cleared when reserved but
Florian Pose <fp@igh-essen.com>
parents:
1930
diff
changeset
|
458 |
/** Clear the configuration applied by the application. |
1ba48f78a0a5
Fixed bug that caused the configuration not to be cleared when reserved but
Florian Pose <fp@igh-essen.com>
parents:
1930
diff
changeset
|
459 |
*/ |
1ba48f78a0a5
Fixed bug that caused the configuration not to be cleared when reserved but
Florian Pose <fp@igh-essen.com>
parents:
1930
diff
changeset
|
460 |
void ec_master_clear_config( |
1ba48f78a0a5
Fixed bug that caused the configuration not to be cleared when reserved but
Florian Pose <fp@igh-essen.com>
parents:
1930
diff
changeset
|
461 |
ec_master_t *master /**< EtherCAT master. */ |
1ba48f78a0a5
Fixed bug that caused the configuration not to be cleared when reserved but
Florian Pose <fp@igh-essen.com>
parents:
1930
diff
changeset
|
462 |
) |
1ba48f78a0a5
Fixed bug that caused the configuration not to be cleared when reserved but
Florian Pose <fp@igh-essen.com>
parents:
1930
diff
changeset
|
463 |
{ |
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
464 |
ec_mutex_lock(&master->master_mutex); |
1939
1ba48f78a0a5
Fixed bug that caused the configuration not to be cleared when reserved but
Florian Pose <fp@igh-essen.com>
parents:
1930
diff
changeset
|
465 |
ec_master_clear_domains(master); |
1ba48f78a0a5
Fixed bug that caused the configuration not to be cleared when reserved but
Florian Pose <fp@igh-essen.com>
parents:
1930
diff
changeset
|
466 |
ec_master_clear_slave_configs(master); |
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
467 |
ec_mutex_unlock(&master->master_mutex); |
1939
1ba48f78a0a5
Fixed bug that caused the configuration not to be cleared when reserved but
Florian Pose <fp@igh-essen.com>
parents:
1930
diff
changeset
|
468 |
} |
1ba48f78a0a5
Fixed bug that caused the configuration not to be cleared when reserved but
Florian Pose <fp@igh-essen.com>
parents:
1930
diff
changeset
|
469 |
|
1ba48f78a0a5
Fixed bug that caused the configuration not to be cleared when reserved but
Florian Pose <fp@igh-essen.com>
parents:
1930
diff
changeset
|
470 |
/*****************************************************************************/ |
1ba48f78a0a5
Fixed bug that caused the configuration not to be cleared when reserved but
Florian Pose <fp@igh-essen.com>
parents:
1930
diff
changeset
|
471 |
|
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
472 |
/** Starts the master thread. |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
473 |
* |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
474 |
* \retval 0 Success. |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
475 |
* \retval <0 Error code. |
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
476 |
*/ |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
477 |
int ec_master_thread_start( |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
478 |
ec_master_t *master, /**< EtherCAT master */ |
1241
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
479 |
int (*thread_func)(void *), /**< thread function to start */ |
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
480 |
const char *name /**< Thread name. */ |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
481 |
) |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
482 |
{ |
1921 | 483 |
EC_MASTER_INFO(master, "Starting %s thread.\n", name); |
1241
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
484 |
master->thread = kthread_run(thread_func, master, name); |
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
485 |
if (IS_ERR(master->thread)) { |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
486 |
int err = (int) PTR_ERR(master->thread); |
1921 | 487 |
EC_MASTER_ERR(master, "Failed to start master thread (error %i)!\n", |
488 |
err); |
|
1241
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
489 |
master->thread = NULL; |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
490 |
return err; |
1241
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
491 |
} |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
492 |
|
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
493 |
return 0; |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
494 |
} |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
495 |
|
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
496 |
/*****************************************************************************/ |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
497 |
|
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
498 |
/** Stops the master thread. |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
499 |
*/ |
1029
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
500 |
void ec_master_thread_stop( |
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
501 |
ec_master_t *master /**< EtherCAT master */ |
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
502 |
) |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
503 |
{ |
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
504 |
unsigned long sleep_jiffies; |
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
505 |
|
1241
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
506 |
if (!master->thread) { |
1921 | 507 |
EC_MASTER_WARN(master, "%s(): Already finished!\n", __func__); |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
508 |
return; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
509 |
} |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
510 |
|
1921 | 511 |
EC_MASTER_DBG(master, 1, "Stopping master thread.\n"); |
1006
90db4c3de57b
Added a few debugging messages.
Florian Pose <fp@igh-essen.com>
parents:
1004
diff
changeset
|
512 |
|
1241
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
513 |
kthread_stop(master->thread); |
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
514 |
master->thread = NULL; |
1921 | 515 |
EC_MASTER_INFO(master, "Master thread exited.\n"); |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
516 |
|
1198
be606e9caba4
Fixed race concerning thread signaling when master thread had no
Florian Pose <fp@igh-essen.com>
parents:
1197
diff
changeset
|
517 |
if (master->fsm_datagram.state != EC_DATAGRAM_SENT) |
be606e9caba4
Fixed race concerning thread signaling when master thread had no
Florian Pose <fp@igh-essen.com>
parents:
1197
diff
changeset
|
518 |
return; |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
519 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
520 |
// wait for FSM datagram |
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
521 |
sleep_jiffies = max(HZ / 100, 1); // 10 ms, at least 1 jiffy |
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
522 |
schedule_timeout(sleep_jiffies); |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
523 |
} |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
524 |
|
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
525 |
/*****************************************************************************/ |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
526 |
|
1029
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
527 |
/** Transition function from ORPHANED to IDLE phase. |
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
528 |
*/ |
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
529 |
int ec_master_enter_idle_phase( |
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
530 |
ec_master_t *master /**< EtherCAT master */ |
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
531 |
) |
446 | 532 |
{ |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
533 |
int ret; |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
534 |
|
1921 | 535 |
EC_MASTER_DBG(master, 1, "ORPHANED -> IDLE.\n"); |
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
|
536 |
|
2024
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
537 |
master->fsm_queue_lock_cb = NULL; |
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
538 |
master->fsm_queue_unlock_cb = NULL; |
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
539 |
master->fsm_queue_locking_data = NULL; |
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
540 |
|
1029
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
541 |
master->phase = EC_IDLE; |
2166
1d5a5303f15c
Improved resetting number of responding slaves.
Florian Pose <fp@igh-essen.com>
parents:
2165
diff
changeset
|
542 |
|
1d5a5303f15c
Improved resetting number of responding slaves.
Florian Pose <fp@igh-essen.com>
parents:
2165
diff
changeset
|
543 |
// reset number of responding slaves to trigger scanning |
1d5a5303f15c
Improved resetting number of responding slaves.
Florian Pose <fp@igh-essen.com>
parents:
2165
diff
changeset
|
544 |
master->fsm.slaves_responding = 0; |
1d5a5303f15c
Improved resetting number of responding slaves.
Florian Pose <fp@igh-essen.com>
parents:
2165
diff
changeset
|
545 |
|
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
546 |
ret = ec_master_thread_start(master, ec_master_idle_thread, |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
547 |
"EtherCAT-IDLE"); |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
548 |
if (ret) |
1029
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
549 |
master->phase = EC_ORPHANED; |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
550 |
|
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
551 |
return ret; |
446 | 552 |
} |
553 |
||
554 |
/*****************************************************************************/ |
|
555 |
||
1029
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
556 |
/** Transition function from IDLE to ORPHANED phase. |
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
557 |
*/ |
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
558 |
void ec_master_leave_idle_phase(ec_master_t *master /**< EtherCAT master */) |
446 | 559 |
{ |
1921 | 560 |
EC_MASTER_DBG(master, 1, "IDLE -> ORPHANED.\n"); |
1006
90db4c3de57b
Added a few debugging messages.
Florian Pose <fp@igh-essen.com>
parents:
1004
diff
changeset
|
561 |
|
1029
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
562 |
master->phase = EC_ORPHANED; |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
563 |
|
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
564 |
ec_master_thread_stop(master); |
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
|
565 |
|
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
566 |
ec_mutex_lock(&master->master_mutex); |
992
50a44cbd30af
Removed kobjects from sdo and slave.
Florian Pose <fp@igh-essen.com>
parents:
990
diff
changeset
|
567 |
ec_master_clear_slaves(master); |
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
568 |
ec_mutex_unlock(&master->master_mutex); |
446 | 569 |
} |
570 |
||
571 |
/*****************************************************************************/ |
|
572 |
||
1029
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
573 |
/** Transition function from IDLE to OPERATION phase. |
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
574 |
*/ |
2110
455126b35650
Fixed compiler error; added SDO debugging.
Florian Pose <fp@igh-essen.com>
parents:
2107
diff
changeset
|
575 |
int ec_master_enter_operation_phase( |
2107
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
576 |
ec_master_t *master /**< EtherCAT master */ |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
577 |
) |
446 | 578 |
{ |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
579 |
int ret = 0; |
446 | 580 |
ec_slave_t *slave; |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
581 |
#ifdef EC_EOE |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
582 |
ec_eoe_t *eoe; |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
583 |
#endif |
446 | 584 |
|
1921 | 585 |
EC_MASTER_DBG(master, 1, "IDLE -> OPERATION.\n"); |
1006
90db4c3de57b
Added a few debugging messages.
Florian Pose <fp@igh-essen.com>
parents:
1004
diff
changeset
|
586 |
|
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
587 |
ec_mutex_lock(&master->config_mutex); |
900
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
588 |
if (master->config_busy) { |
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
589 |
ec_mutex_unlock(&master->config_mutex); |
900
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
590 |
|
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
591 |
// wait for slave configuration to complete |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
592 |
ret = wait_event_interruptible(master->config_queue, |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
593 |
!master->config_busy); |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
594 |
if (ret) { |
1921 | 595 |
EC_MASTER_INFO(master, "Finishing slave configuration" |
596 |
" interrupted by signal.\n"); |
|
2270
51d2b26a5d1c
Fixed reset of allow_scanning flag if ecrt_master_activate() was not called.
Florian Pose <fp@igh-essen.com>
parents:
2249
diff
changeset
|
597 |
goto out_return; |
900
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
598 |
} |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
599 |
|
1921 | 600 |
EC_MASTER_DBG(master, 1, "Waiting for pending slave" |
601 |
" configuration returned.\n"); |
|
900
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
602 |
} else { |
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
603 |
ec_mutex_unlock(&master->config_mutex); |
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
604 |
} |
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
605 |
|
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
606 |
ec_mutex_lock(&master->scan_mutex); |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
607 |
master->allow_scan = 0; // 'lock' the slave list |
900
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
608 |
if (!master->scan_busy) { |
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
609 |
ec_mutex_unlock(&master->scan_mutex); |
900
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
610 |
} else { |
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
611 |
ec_mutex_unlock(&master->scan_mutex); |
900
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
612 |
|
794
684dea874956
Allow bus configuration when link is down.
Florian Pose <fp@igh-essen.com>
parents:
792
diff
changeset
|
613 |
// wait for slave scan to complete |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
614 |
ret = wait_event_interruptible(master->scan_queue, !master->scan_busy); |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
615 |
if (ret) { |
1921 | 616 |
EC_MASTER_INFO(master, "Waiting for slave scan" |
617 |
" interrupted by signal.\n"); |
|
794
684dea874956
Allow bus configuration when link is down.
Florian Pose <fp@igh-essen.com>
parents:
792
diff
changeset
|
618 |
goto out_allow; |
684dea874956
Allow bus configuration when link is down.
Florian Pose <fp@igh-essen.com>
parents:
792
diff
changeset
|
619 |
} |
900
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
620 |
|
1921 | 621 |
EC_MASTER_DBG(master, 1, "Waiting for pending" |
622 |
" slave scan returned.\n"); |
|
900
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
623 |
} |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
624 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
625 |
// set states for all slaves |
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
626 |
for (slave = master->slaves; |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
627 |
slave < master->slaves + master->slave_count; |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
628 |
slave++) { |
643
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
629 |
ec_slave_request_state(slave, EC_SLAVE_STATE_PREOP); |
446 | 630 |
} |
1451
78fbafbf08ba
Always set DC reference clock to OP.
Florian Pose <fp@igh-essen.com>
parents:
1436
diff
changeset
|
631 |
|
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
632 |
#ifdef EC_EOE |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
633 |
// ... but set EoE slaves to OP |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
634 |
list_for_each_entry(eoe, &master->eoe_handlers, list) { |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
635 |
if (ec_eoe_is_open(eoe)) |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
636 |
ec_slave_request_state(eoe->slave, EC_SLAVE_STATE_OP); |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
637 |
} |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
638 |
#endif |
446 | 639 |
|
1029
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
640 |
master->phase = EC_OPERATION; |
2024
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
641 |
master->app_fsm_queue_lock_cb = NULL; |
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
642 |
master->app_fsm_queue_unlock_cb = NULL; |
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
643 |
master->app_fsm_queue_locking_data = NULL; |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
644 |
return ret; |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
645 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
646 |
out_allow: |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
647 |
master->allow_scan = 1; |
2270
51d2b26a5d1c
Fixed reset of allow_scanning flag if ecrt_master_activate() was not called.
Florian Pose <fp@igh-essen.com>
parents:
2249
diff
changeset
|
648 |
out_return: |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
649 |
return ret; |
446 | 650 |
} |
651 |
||
652 |
/*****************************************************************************/ |
|
653 |
||
1029
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
654 |
/** Transition function from OPERATION to IDLE phase. |
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
655 |
*/ |
1530
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
656 |
void ec_master_leave_operation_phase( |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
657 |
ec_master_t *master /**< EtherCAT master */ |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
658 |
) |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
659 |
{ |
1939
1ba48f78a0a5
Fixed bug that caused the configuration not to be cleared when reserved but
Florian Pose <fp@igh-essen.com>
parents:
1930
diff
changeset
|
660 |
if (master->active) { |
1ba48f78a0a5
Fixed bug that caused the configuration not to be cleared when reserved but
Florian Pose <fp@igh-essen.com>
parents:
1930
diff
changeset
|
661 |
ecrt_master_deactivate(master); // also clears config |
1ba48f78a0a5
Fixed bug that caused the configuration not to be cleared when reserved but
Florian Pose <fp@igh-essen.com>
parents:
1930
diff
changeset
|
662 |
} else { |
1ba48f78a0a5
Fixed bug that caused the configuration not to be cleared when reserved but
Florian Pose <fp@igh-essen.com>
parents:
1930
diff
changeset
|
663 |
ec_master_clear_config(master); |
1ba48f78a0a5
Fixed bug that caused the configuration not to be cleared when reserved but
Florian Pose <fp@igh-essen.com>
parents:
1930
diff
changeset
|
664 |
} |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
665 |
|
2270
51d2b26a5d1c
Fixed reset of allow_scanning flag if ecrt_master_activate() was not called.
Florian Pose <fp@igh-essen.com>
parents:
2249
diff
changeset
|
666 |
/* Re-allow scanning for IDLE phase. */ |
51d2b26a5d1c
Fixed reset of allow_scanning flag if ecrt_master_activate() was not called.
Florian Pose <fp@igh-essen.com>
parents:
2249
diff
changeset
|
667 |
master->allow_scan = 1; |
51d2b26a5d1c
Fixed reset of allow_scanning flag if ecrt_master_activate() was not called.
Florian Pose <fp@igh-essen.com>
parents:
2249
diff
changeset
|
668 |
|
1921 | 669 |
EC_MASTER_DBG(master, 1, "OPERATION -> IDLE.\n"); |
1006
90db4c3de57b
Added a few debugging messages.
Florian Pose <fp@igh-essen.com>
parents:
1004
diff
changeset
|
670 |
|
1029
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
671 |
master->phase = EC_IDLE; |
446 | 672 |
} |
673 |
||
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1580
diff
changeset
|
674 |
/*****************************************************************************/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1580
diff
changeset
|
675 |
|
2018
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
676 |
/** Injects fsm datagrams that fit into the datagram queue. |
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
677 |
*/ |
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
678 |
void ec_master_inject_fsm_datagrams( |
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
679 |
ec_master_t *master /**< EtherCAT master */ |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
680 |
) |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
681 |
{ |
2039
629d3cf05180
Minor changes (consistent variable naming)
Martin Troxler <ch1010277@ch10pc446>
parents:
2038
diff
changeset
|
682 |
ec_datagram_t *datagram, *next; |
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
683 |
size_t queue_size = 0; |
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
684 |
|
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
685 |
if (master->fsm_queue_lock_cb) { |
2024
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
686 |
master->fsm_queue_lock_cb(master->fsm_queue_locking_data); |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
687 |
} |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
688 |
|
2038
770e86a39c98
Datagram queue race fixed: insert datagrams into master-fsm_queue with fsm_queue list_head
Martin Troxler <ch1010277@ch10pc446>
parents:
2037
diff
changeset
|
689 |
if (ec_mutex_trylock(&master->fsm_queue_mutex) == 0) { |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
690 |
goto unlock_cb; |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
691 |
} |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
692 |
|
2018
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
693 |
if (list_empty(&master->fsm_datagram_queue)) { |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
694 |
goto unlock; |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
695 |
} |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
696 |
|
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
697 |
list_for_each_entry(datagram, &master->datagram_queue, queue) { |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
698 |
queue_size += datagram->data_size; |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
699 |
} |
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
700 |
|
2039
629d3cf05180
Minor changes (consistent variable naming)
Martin Troxler <ch1010277@ch10pc446>
parents:
2038
diff
changeset
|
701 |
list_for_each_entry_safe(datagram, next, &master->fsm_datagram_queue, |
2038
770e86a39c98
Datagram queue race fixed: insert datagrams into master-fsm_queue with fsm_queue list_head
Martin Troxler <ch1010277@ch10pc446>
parents:
2037
diff
changeset
|
702 |
fsm_queue) { |
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
703 |
queue_size += datagram->data_size; |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
704 |
if (queue_size <= master->max_queue_size) { |
2038
770e86a39c98
Datagram queue race fixed: insert datagrams into master-fsm_queue with fsm_queue list_head
Martin Troxler <ch1010277@ch10pc446>
parents:
2037
diff
changeset
|
705 |
list_del_init(&datagram->fsm_queue); |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
706 |
#if DEBUG_INJECT |
2037
ea0319750e13
Optionally compile with trace_printk support
Martin Troxler <ch1010277@ch10pc446>
parents:
2036
diff
changeset
|
707 |
EC_MASTER_DBG(master, 2, "Injecting fsm datagram %p" |
2018
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
708 |
" size=%zu, queue_size=%zu\n", datagram, |
1921 | 709 |
datagram->data_size, queue_size); |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
710 |
#endif |
1585
1f640e321ee4
ecrt_master_set_max_cycle_size: limit SDO traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
711 |
#ifdef EC_HAVE_CYCLES |
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
712 |
datagram->cycles_sent = 0; |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
713 |
#endif |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
714 |
datagram->jiffies_sent = 0; // FIXME why? |
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
715 |
ec_master_queue_datagram(master, datagram); |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
716 |
} else { |
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
717 |
if (datagram->data_size > master->max_queue_size) { |
2038
770e86a39c98
Datagram queue race fixed: insert datagrams into master-fsm_queue with fsm_queue list_head
Martin Troxler <ch1010277@ch10pc446>
parents:
2037
diff
changeset
|
718 |
list_del_init(&datagram->fsm_queue); |
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
719 |
datagram->state = EC_DATAGRAM_ERROR; |
2018
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
720 |
EC_MASTER_ERR(master, "Fsm datagram %p is too large," |
1930
59a50053ccc6
Made send_interval variable an unsigned int; fixed format specifiers for
Florian Pose <fp@igh-essen.com>
parents:
1925
diff
changeset
|
721 |
" size=%zu, max_queue_size=%zu\n", |
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
722 |
datagram, datagram->data_size, |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
723 |
master->max_queue_size); |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
724 |
} else { |
1585
1f640e321ee4
ecrt_master_set_max_cycle_size: limit SDO traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
725 |
#ifdef EC_HAVE_CYCLES |
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
726 |
cycles_t cycles_now = get_cycles(); |
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
727 |
|
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
728 |
if (cycles_now - datagram->cycles_sent |
2022
393e7aef6706
renamed ext_injection_timeout -> fsm_injection_timeout
Martin Troxler <ch1010277@ch10pc446>
parents:
2021
diff
changeset
|
729 |
> fsm_injection_timeout_cycles) |
1585
1f640e321ee4
ecrt_master_set_max_cycle_size: limit SDO traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
730 |
#else |
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
731 |
if (jiffies - datagram->jiffies_sent |
2022
393e7aef6706
renamed ext_injection_timeout -> fsm_injection_timeout
Martin Troxler <ch1010277@ch10pc446>
parents:
2021
diff
changeset
|
732 |
> fsm_injection_timeout_jiffies) |
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
733 |
#endif |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
734 |
{ |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
735 |
unsigned int time_us; |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
736 |
|
2038
770e86a39c98
Datagram queue race fixed: insert datagrams into master-fsm_queue with fsm_queue list_head
Martin Troxler <ch1010277@ch10pc446>
parents:
2037
diff
changeset
|
737 |
list_del_init(&datagram->fsm_queue); |
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
738 |
datagram->state = EC_DATAGRAM_ERROR; |
1585
1f640e321ee4
ecrt_master_set_max_cycle_size: limit SDO traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
739 |
#ifdef EC_HAVE_CYCLES |
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
740 |
time_us = (unsigned int) |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
741 |
((cycles_now - datagram->cycles_sent) * 1000LL) |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
742 |
/ cpu_khz; |
1585
1f640e321ee4
ecrt_master_set_max_cycle_size: limit SDO traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
743 |
#else |
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
744 |
time_us = (unsigned int) |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
745 |
((jiffies - datagram->jiffies_sent) * 1000000 / HZ); |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
746 |
#endif |
1921 | 747 |
EC_MASTER_ERR(master, "Timeout %u us: Injecting" |
2018
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
748 |
" fsm datagram %p size=%zu," |
1930
59a50053ccc6
Made send_interval variable an unsigned int; fixed format specifiers for
Florian Pose <fp@igh-essen.com>
parents:
1925
diff
changeset
|
749 |
" max_queue_size=%zu\n", time_us, datagram, |
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
750 |
datagram->data_size, master->max_queue_size); |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
751 |
} |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
752 |
#if DEBUG_INJECT |
1921 | 753 |
else { |
2037
ea0319750e13
Optionally compile with trace_printk support
Martin Troxler <ch1010277@ch10pc446>
parents:
2036
diff
changeset
|
754 |
EC_MASTER_DBG(master, 2, "Deferred injecting" |
2018
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
755 |
" of fsm datagram %p" |
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
756 |
" size=%zu, queue_size=%zu\n", |
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
757 |
datagram, datagram->data_size, queue_size); |
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
758 |
} |
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
759 |
#endif |
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
760 |
} |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
761 |
} |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
762 |
} |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
763 |
|
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
764 |
unlock: |
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
765 |
ec_mutex_unlock(&master->fsm_queue_mutex); |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
766 |
unlock_cb: |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
767 |
if (master->fsm_queue_unlock_cb) { |
2024
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
768 |
master->fsm_queue_unlock_cb(master->fsm_queue_locking_data); |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
769 |
} |
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
770 |
} |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
771 |
|
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
772 |
/*****************************************************************************/ |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
773 |
|
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
774 |
/** Sets the expected interval between calls to ecrt_master_send |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
775 |
* and calculates the maximum amount of data to queue. |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
776 |
*/ |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
777 |
void ec_master_set_send_interval( |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
778 |
ec_master_t *master, /**< EtherCAT master */ |
1930
59a50053ccc6
Made send_interval variable an unsigned int; fixed format specifiers for
Florian Pose <fp@igh-essen.com>
parents:
1925
diff
changeset
|
779 |
unsigned int send_interval /**< Send interval */ |
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
780 |
) |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
781 |
{ |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
782 |
master->send_interval = send_interval; |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
783 |
master->max_queue_size = |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
784 |
(send_interval * 1000) / EC_BYTE_TRANSMISSION_TIME_NS; |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
785 |
master->max_queue_size -= master->max_queue_size / 10; |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
786 |
} |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1580
diff
changeset
|
787 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1580
diff
changeset
|
788 |
/*****************************************************************************/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1580
diff
changeset
|
789 |
|
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
790 |
/** Places an request (SDO/FoE/SoE/EoE) fsm datagram in the sdo datagram |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
791 |
* queue. |
2018
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
792 |
*/ |
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
793 |
void ec_master_queue_request_fsm_datagram( |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1580
diff
changeset
|
794 |
ec_master_t *master, /**< EtherCAT master */ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1580
diff
changeset
|
795 |
ec_datagram_t *datagram /**< datagram */ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1580
diff
changeset
|
796 |
) |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1580
diff
changeset
|
797 |
{ |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
798 |
ec_master_queue_fsm_datagram(master, datagram); |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
799 |
master->fsm.idle = 0; // pump the bus as fast as possible |
2018
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
800 |
} |
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
801 |
|
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
802 |
/*****************************************************************************/ |
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
803 |
|
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
804 |
/** Places an fsm datagram in the sdo datagram queue. |
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
805 |
*/ |
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
806 |
void ec_master_queue_fsm_datagram( |
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
807 |
ec_master_t *master, /**< EtherCAT master */ |
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
808 |
ec_datagram_t *datagram /**< datagram */ |
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
809 |
) |
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
810 |
{ |
1804 | 811 |
ec_datagram_t *queued_datagram; |
1600
e36c92cf58a9
use given send interval to limit SDO/FOE traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
812 |
|
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
813 |
if (master->fsm_queue_lock_cb) { |
2024
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
814 |
master->fsm_queue_lock_cb(master->fsm_queue_locking_data); |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
815 |
} |
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
816 |
ec_mutex_lock(&master->fsm_queue_mutex); |
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
817 |
|
1804 | 818 |
// check, if the datagram is already queued |
2018
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
819 |
list_for_each_entry(queued_datagram, &master->fsm_datagram_queue, |
2038
770e86a39c98
Datagram queue race fixed: insert datagrams into master-fsm_queue with fsm_queue list_head
Martin Troxler <ch1010277@ch10pc446>
parents:
2037
diff
changeset
|
820 |
fsm_queue) { |
1804 | 821 |
if (queued_datagram == datagram) { |
822 |
datagram->state = EC_DATAGRAM_QUEUED; |
|
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
823 |
goto unlock; |
1804 | 824 |
} |
825 |
} |
|
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
826 |
|
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
827 |
#if DEBUG_INJECT |
2037
ea0319750e13
Optionally compile with trace_printk support
Martin Troxler <ch1010277@ch10pc446>
parents:
2036
diff
changeset
|
828 |
EC_MASTER_DBG(master, 2, "Requesting fsm datagram %p size=%zu\n", |
1921 | 829 |
datagram, datagram->data_size); |
1804 | 830 |
#endif |
831 |
||
2038
770e86a39c98
Datagram queue race fixed: insert datagrams into master-fsm_queue with fsm_queue list_head
Martin Troxler <ch1010277@ch10pc446>
parents:
2037
diff
changeset
|
832 |
list_add_tail(&datagram->fsm_queue, &master->fsm_datagram_queue); |
1804 | 833 |
datagram->state = EC_DATAGRAM_QUEUED; |
1585
1f640e321ee4
ecrt_master_set_max_cycle_size: limit SDO traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
834 |
#ifdef EC_HAVE_CYCLES |
1804 | 835 |
datagram->cycles_sent = get_cycles(); |
836 |
#endif |
|
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
837 |
datagram->jiffies_sent = jiffies; // FIXME why? |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
838 |
|
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
839 |
unlock: |
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
840 |
ec_mutex_unlock(&master->fsm_queue_mutex); |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
841 |
if (master->fsm_queue_unlock_cb) { |
2024
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
842 |
master->fsm_queue_unlock_cb(master->fsm_queue_locking_data); |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
843 |
} |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1580
diff
changeset
|
844 |
} |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1580
diff
changeset
|
845 |
|
446 | 846 |
/*****************************************************************************/ |
847 |
||
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
848 |
/** Places a datagram in the datagram queue. |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
849 |
*/ |
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
850 |
void ec_master_queue_datagram( |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
851 |
ec_master_t *master, /**< EtherCAT master */ |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
852 |
ec_datagram_t *datagram /**< datagram */ |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
853 |
) |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
854 |
{ |
2084
eefccfa312ef
Fixed bug in ec_master_queue_datagram() introduced in c9d32805d984.
Florian Pose <fp@igh-essen.com>
parents:
2080
diff
changeset
|
855 |
ec_datagram_t *queued_datagram; |
eefccfa312ef
Fixed bug in ec_master_queue_datagram() introduced in c9d32805d984.
Florian Pose <fp@igh-essen.com>
parents:
2080
diff
changeset
|
856 |
|
eefccfa312ef
Fixed bug in ec_master_queue_datagram() introduced in c9d32805d984.
Florian Pose <fp@igh-essen.com>
parents:
2080
diff
changeset
|
857 |
/* It is possible, that a datagram in the queue is re-initialized with the |
eefccfa312ef
Fixed bug in ec_master_queue_datagram() introduced in c9d32805d984.
Florian Pose <fp@igh-essen.com>
parents:
2080
diff
changeset
|
858 |
* ec_datagram_<type>() methods and then shall be queued with this method. |
eefccfa312ef
Fixed bug in ec_master_queue_datagram() introduced in c9d32805d984.
Florian Pose <fp@igh-essen.com>
parents:
2080
diff
changeset
|
859 |
* In that case, the state is already reset to EC_DATAGRAM_INIT. Check if |
eefccfa312ef
Fixed bug in ec_master_queue_datagram() introduced in c9d32805d984.
Florian Pose <fp@igh-essen.com>
parents:
2080
diff
changeset
|
860 |
* the datagram is queued to avoid duplicate queuing (which results in an |
eefccfa312ef
Fixed bug in ec_master_queue_datagram() introduced in c9d32805d984.
Florian Pose <fp@igh-essen.com>
parents:
2080
diff
changeset
|
861 |
* infinite loop!). Set the state to EC_DATAGRAM_QUEUED again, probably |
eefccfa312ef
Fixed bug in ec_master_queue_datagram() introduced in c9d32805d984.
Florian Pose <fp@igh-essen.com>
parents:
2080
diff
changeset
|
862 |
* causing an unmatched datagram. */ |
eefccfa312ef
Fixed bug in ec_master_queue_datagram() introduced in c9d32805d984.
Florian Pose <fp@igh-essen.com>
parents:
2080
diff
changeset
|
863 |
list_for_each_entry(queued_datagram, &master->datagram_queue, queue) { |
eefccfa312ef
Fixed bug in ec_master_queue_datagram() introduced in c9d32805d984.
Florian Pose <fp@igh-essen.com>
parents:
2080
diff
changeset
|
864 |
if (queued_datagram == datagram) { |
eefccfa312ef
Fixed bug in ec_master_queue_datagram() introduced in c9d32805d984.
Florian Pose <fp@igh-essen.com>
parents:
2080
diff
changeset
|
865 |
datagram->skip_count++; |
2095
53b5128e1313
Fixed skipped datagrams output again; added datagram information on skip.
Florian Pose <fp@igh-essen.com>
parents:
2094
diff
changeset
|
866 |
if (master->debug_level) { |
53b5128e1313
Fixed skipped datagrams output again; added datagram information on skip.
Florian Pose <fp@igh-essen.com>
parents:
2094
diff
changeset
|
867 |
EC_MASTER_DBG(master, 1, "Skipping datagram %p (", datagram); |
53b5128e1313
Fixed skipped datagrams output again; added datagram information on skip.
Florian Pose <fp@igh-essen.com>
parents:
2094
diff
changeset
|
868 |
ec_datagram_output_info(datagram); |
53b5128e1313
Fixed skipped datagrams output again; added datagram information on skip.
Florian Pose <fp@igh-essen.com>
parents:
2094
diff
changeset
|
869 |
printk(")\n"); |
53b5128e1313
Fixed skipped datagrams output again; added datagram information on skip.
Florian Pose <fp@igh-essen.com>
parents:
2094
diff
changeset
|
870 |
} |
53b5128e1313
Fixed skipped datagrams output again; added datagram information on skip.
Florian Pose <fp@igh-essen.com>
parents:
2094
diff
changeset
|
871 |
goto queued; |
2084
eefccfa312ef
Fixed bug in ec_master_queue_datagram() introduced in c9d32805d984.
Florian Pose <fp@igh-essen.com>
parents:
2080
diff
changeset
|
872 |
} |
eefccfa312ef
Fixed bug in ec_master_queue_datagram() introduced in c9d32805d984.
Florian Pose <fp@igh-essen.com>
parents:
2080
diff
changeset
|
873 |
} |
eefccfa312ef
Fixed bug in ec_master_queue_datagram() introduced in c9d32805d984.
Florian Pose <fp@igh-essen.com>
parents:
2080
diff
changeset
|
874 |
|
eefccfa312ef
Fixed bug in ec_master_queue_datagram() introduced in c9d32805d984.
Florian Pose <fp@igh-essen.com>
parents:
2080
diff
changeset
|
875 |
list_add_tail(&datagram->queue, &master->datagram_queue); |
2095
53b5128e1313
Fixed skipped datagrams output again; added datagram information on skip.
Florian Pose <fp@igh-essen.com>
parents:
2094
diff
changeset
|
876 |
queued: |
2084
eefccfa312ef
Fixed bug in ec_master_queue_datagram() introduced in c9d32805d984.
Florian Pose <fp@igh-essen.com>
parents:
2080
diff
changeset
|
877 |
datagram->state = EC_DATAGRAM_QUEUED; |
eefccfa312ef
Fixed bug in ec_master_queue_datagram() introduced in c9d32805d984.
Florian Pose <fp@igh-essen.com>
parents:
2080
diff
changeset
|
878 |
} |
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
879 |
|
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
880 |
/*****************************************************************************/ |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
881 |
|
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
882 |
/** Sends the datagrams in the queue. |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
883 |
* |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
884 |
*/ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
885 |
void ec_master_send_datagrams(ec_master_t *master /**< EtherCAT master */) |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
886 |
{ |
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
887 |
ec_datagram_t *datagram, *next; |
1804 | 888 |
size_t datagram_size; |
1981
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
889 |
uint8_t *frame_data, *cur_data, *frame_datagram_data; |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
890 |
void *follows_word; |
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
891 |
#ifdef EC_HAVE_CYCLES |
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
892 |
cycles_t cycles_start, cycles_sent, cycles_end; |
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
893 |
#endif |
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
894 |
unsigned long jiffies_sent; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
895 |
unsigned int frame_count, more_datagrams_waiting; |
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
896 |
struct list_head sent_datagrams; |
1981
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
897 |
ec_fmmu_config_t* domain_fmmu; |
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
898 |
|
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
899 |
#ifdef EC_HAVE_CYCLES |
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
900 |
cycles_start = get_cycles(); |
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
901 |
#endif |
176 | 902 |
frame_count = 0; |
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
903 |
INIT_LIST_HEAD(&sent_datagrams); |
208
b7797f8a813d
command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents:
206
diff
changeset
|
904 |
|
1921 | 905 |
EC_MASTER_DBG(master, 2, "ec_master_send_datagrams\n"); |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
906 |
|
176 | 907 |
do { |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
908 |
// fetch pointer to transmit socket buffer |
579
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
578
diff
changeset
|
909 |
frame_data = ec_device_tx_data(&master->main_device); |
176 | 910 |
cur_data = frame_data + EC_FRAME_HEADER_SIZE; |
911 |
follows_word = NULL; |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
912 |
more_datagrams_waiting = 0; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
913 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
914 |
// fill current frame with datagrams |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
915 |
list_for_each_entry(datagram, &master->datagram_queue, queue) { |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
916 |
if (datagram->state != EC_DATAGRAM_QUEUED) continue; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
917 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
918 |
// does the current datagram fit in the frame? |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
919 |
datagram_size = EC_DATAGRAM_HEADER_SIZE + datagram->data_size |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
920 |
+ EC_DATAGRAM_FOOTER_SIZE; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
921 |
if (cur_data - frame_data + datagram_size > ETH_DATA_LEN) { |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
922 |
more_datagrams_waiting = 1; |
176 | 923 |
break; |
924 |
} |
|
925 |
||
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
926 |
list_add_tail(&datagram->sent, &sent_datagrams); |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
927 |
datagram->index = master->datagram_index++; |
176 | 928 |
|
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
929 |
EC_MASTER_DBG(master, 2, "Adding datagram %p i=0x%02X size=%zu\n", |
2095
53b5128e1313
Fixed skipped datagrams output again; added datagram information on skip.
Florian Pose <fp@igh-essen.com>
parents:
2094
diff
changeset
|
930 |
datagram, datagram->index, datagram_size); |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
931 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
932 |
// set "datagram following" flag in previous frame |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
933 |
if (follows_word) { |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
934 |
EC_WRITE_U16(follows_word, |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
935 |
EC_READ_U16(follows_word) | 0x8000); |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
936 |
} |
176 | 937 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
938 |
// EtherCAT datagram header |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
939 |
EC_WRITE_U8 (cur_data, datagram->type); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
940 |
EC_WRITE_U8 (cur_data + 1, datagram->index); |
708
90bdb315f560
Fixed EtherCAT addressing problem on big-endian systems. The slaves
Florian Pose <fp@igh-essen.com>
parents:
697
diff
changeset
|
941 |
memcpy(cur_data + 2, datagram->address, EC_ADDR_LEN); |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
942 |
EC_WRITE_U16(cur_data + 6, datagram->data_size & 0x7FF); |
176 | 943 |
EC_WRITE_U16(cur_data + 8, 0x0000); |
944 |
follows_word = cur_data + 6; |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
945 |
cur_data += EC_DATAGRAM_HEADER_SIZE; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
946 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
947 |
// EtherCAT datagram data |
1981
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
948 |
frame_datagram_data = cur_data; |
2103
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
949 |
|
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
950 |
// distinguish between domain and non-domain datagrams... |
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
951 |
// this is not nice... FIXME |
1981
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
952 |
if (datagram->domain) { |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
953 |
unsigned int datagram_address = |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
954 |
EC_READ_U32(datagram->address); |
1981
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
955 |
int i = 0; |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
956 |
uint8_t *domain_data = datagram->data; |
2103
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
957 |
|
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
958 |
// FIXME all FMMU configs are taken into acount, |
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
959 |
// maybe the belong to another datagram? |
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
960 |
// test with large process data! |
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
961 |
|
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
962 |
list_for_each_entry(domain_fmmu, |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
963 |
&datagram->domain->fmmu_configs, list) { |
2103
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
964 |
if (domain_fmmu->dir == EC_DIR_OUTPUT) { |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
965 |
unsigned int frame_offset = |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
966 |
domain_fmmu->logical_start_address |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
967 |
- datagram_address; |
2103
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
968 |
memcpy(frame_datagram_data + frame_offset, |
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
969 |
domain_data, domain_fmmu->data_size); |
1981
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
970 |
if (unlikely(master->debug_level > 1)) { |
2103
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
971 |
EC_MASTER_DBG(master, 0, "Sending datagram %p" |
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
972 |
" i=0x%02X FMMU %u fp=%u" |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
973 |
" dp=%zu size=%u\n", |
2103
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
974 |
datagram, datagram->index, i, frame_offset, |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
975 |
domain_data - datagram->data, |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
976 |
domain_fmmu->data_size); |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
977 |
ec_print_data(domain_data, |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
978 |
domain_fmmu->data_size); |
1981
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
979 |
} |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
980 |
} |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
981 |
domain_data += domain_fmmu->data_size; |
2103
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
982 |
i++; |
1981
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
983 |
} |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
984 |
} else { |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
985 |
memcpy(frame_datagram_data, datagram->data, |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
986 |
datagram->data_size); |
1981
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
987 |
} |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
988 |
cur_data += datagram->data_size; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
989 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
990 |
// EtherCAT datagram footer |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
991 |
EC_WRITE_U16(cur_data, 0x0000); // reset working counter |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
992 |
cur_data += EC_DATAGRAM_FOOTER_SIZE; |
176 | 993 |
} |
994 |
||
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
995 |
if (list_empty(&sent_datagrams)) { |
1921 | 996 |
EC_MASTER_DBG(master, 2, "nothing to send.\n"); |
176 | 997 |
break; |
998 |
} |
|
999 |
||
1000 |
// EtherCAT frame header |
|
1001 |
EC_WRITE_U16(frame_data, ((cur_data - frame_data |
|
1002 |
- EC_FRAME_HEADER_SIZE) & 0x7FF) | 0x1000); |
|
1003 |
||
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1004 |
// pad frame |
211
c684b6b7adaf
Using kernel Ethernet constants.
Florian Pose <fp@igh-essen.com>
parents:
208
diff
changeset
|
1005 |
while (cur_data - frame_data < ETH_ZLEN - ETH_HLEN) |
176 | 1006 |
EC_WRITE_U8(cur_data++, 0x00); |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1007 |
|
1921 | 1008 |
EC_MASTER_DBG(master, 2, "frame size: %zu\n", cur_data - frame_data); |
176 | 1009 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1010 |
// send frame |
579
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
578
diff
changeset
|
1011 |
ec_device_send(&master->main_device, cur_data - frame_data); |
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
1012 |
#ifdef EC_HAVE_CYCLES |
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1013 |
cycles_sent = get_cycles(); |
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
1014 |
#endif |
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1015 |
jiffies_sent = jiffies; |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1016 |
|
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1017 |
// set datagram states and sending timestamps |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1018 |
list_for_each_entry_safe(datagram, next, &sent_datagrams, sent) { |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1019 |
datagram->state = EC_DATAGRAM_SENT; |
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
1020 |
#ifdef EC_HAVE_CYCLES |
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1021 |
datagram->cycles_sent = cycles_sent; |
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
1022 |
#endif |
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1023 |
datagram->jiffies_sent = jiffies_sent; |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1024 |
list_del_init(&datagram->sent); // empty list of sent datagrams |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1025 |
} |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1026 |
|
176 | 1027 |
frame_count++; |
1028 |
} |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1029 |
while (more_datagrams_waiting); |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1030 |
|
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
1031 |
#ifdef EC_HAVE_CYCLES |
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
1032 |
if (unlikely(master->debug_level > 1)) { |
344
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
1033 |
cycles_end = get_cycles(); |
1921 | 1034 |
EC_MASTER_DBG(master, 0, "ec_master_send_datagrams" |
1035 |
" sent %u frames in %uus.\n", frame_count, |
|
344
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
1036 |
(unsigned int) (cycles_end - cycles_start) * 1000 / cpu_khz); |
176 | 1037 |
} |
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
1038 |
#endif |
176 | 1039 |
} |
1040 |
||
1041 |
/*****************************************************************************/ |
|
1042 |
||
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
1043 |
/** Processes a received frame. |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
1044 |
* |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
1045 |
* This function is called by the network driver for every received frame. |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
1046 |
* |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
1047 |
* \return 0 in case of success, else < 0 |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
1048 |
*/ |
2103
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
1049 |
void ec_master_receive_datagrams( |
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
1050 |
ec_master_t *master, /**< EtherCAT master */ |
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
1051 |
const uint8_t *frame_data, /**< Frame data */ |
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
1052 |
size_t size /**< Size of the received data */ |
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
1053 |
) |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1054 |
{ |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1055 |
size_t frame_size, data_size; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1056 |
uint8_t datagram_type, datagram_index; |
2103
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
1057 |
unsigned int datagram_follows, matched; |
1981
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
1058 |
const uint8_t *cur_data, *frame_datagram_data; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1059 |
ec_datagram_t *datagram; |
1981
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
1060 |
ec_fmmu_config_t* domain_fmmu; |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1061 |
|
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1062 |
if (unlikely(size < EC_FRAME_HEADER_SIZE)) { |
1303
448f2e9fa483
Output corrupted frame reasons.
Florian Pose <fp@igh-essen.com>
parents:
1279
diff
changeset
|
1063 |
if (master->debug_level) { |
1921 | 1064 |
EC_MASTER_DBG(master, 0, "Corrupted frame received" |
1065 |
" (size %zu < %u byte):\n", |
|
1303
448f2e9fa483
Output corrupted frame reasons.
Florian Pose <fp@igh-essen.com>
parents:
1279
diff
changeset
|
1066 |
size, EC_FRAME_HEADER_SIZE); |
448f2e9fa483
Output corrupted frame reasons.
Florian Pose <fp@igh-essen.com>
parents:
1279
diff
changeset
|
1067 |
ec_print_data(frame_data, size); |
448f2e9fa483
Output corrupted frame reasons.
Florian Pose <fp@igh-essen.com>
parents:
1279
diff
changeset
|
1068 |
} |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1069 |
master->stats.corrupted++; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1070 |
ec_master_output_stats(master); |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1071 |
return; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1072 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1073 |
|
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1074 |
cur_data = frame_data; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1075 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1076 |
// check length of entire frame |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1077 |
frame_size = EC_READ_U16(cur_data) & 0x07FF; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1078 |
cur_data += EC_FRAME_HEADER_SIZE; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1079 |
|
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1080 |
if (unlikely(frame_size > size)) { |
1303
448f2e9fa483
Output corrupted frame reasons.
Florian Pose <fp@igh-essen.com>
parents:
1279
diff
changeset
|
1081 |
if (master->debug_level) { |
1921 | 1082 |
EC_MASTER_DBG(master, 0, "Corrupted frame received" |
1083 |
" (invalid frame size %zu for " |
|
1543
373cd456dc26
Avoid warnings on x86_64 platform. Thanks to Thomas Elste.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
1084 |
"received size %zu):\n", frame_size, size); |
1303
448f2e9fa483
Output corrupted frame reasons.
Florian Pose <fp@igh-essen.com>
parents:
1279
diff
changeset
|
1085 |
ec_print_data(frame_data, size); |
448f2e9fa483
Output corrupted frame reasons.
Florian Pose <fp@igh-essen.com>
parents:
1279
diff
changeset
|
1086 |
} |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1087 |
master->stats.corrupted++; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1088 |
ec_master_output_stats(master); |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1089 |
return; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1090 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1091 |
|
2103
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
1092 |
datagram_follows = 1; |
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
1093 |
|
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
1094 |
while (datagram_follows) { |
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
1095 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1096 |
// process datagram header |
2103
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
1097 |
datagram_type = EC_READ_U8(cur_data); |
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
1098 |
datagram_index = EC_READ_U8(cur_data + 1); |
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
1099 |
data_size = EC_READ_U16(cur_data + 6) & 0x07FF; |
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
1100 |
datagram_follows = EC_READ_U16(cur_data + 6) & 0x8000; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1101 |
cur_data += EC_DATAGRAM_HEADER_SIZE; |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1102 |
|
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1103 |
if (unlikely(cur_data - frame_data |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1104 |
+ data_size + EC_DATAGRAM_FOOTER_SIZE > size)) { |
1303
448f2e9fa483
Output corrupted frame reasons.
Florian Pose <fp@igh-essen.com>
parents:
1279
diff
changeset
|
1105 |
if (master->debug_level) { |
1921 | 1106 |
EC_MASTER_DBG(master, 0, "Corrupted frame received" |
1107 |
" (invalid data size %zu):\n", data_size); |
|
1303
448f2e9fa483
Output corrupted frame reasons.
Florian Pose <fp@igh-essen.com>
parents:
1279
diff
changeset
|
1108 |
ec_print_data(frame_data, size); |
448f2e9fa483
Output corrupted frame reasons.
Florian Pose <fp@igh-essen.com>
parents:
1279
diff
changeset
|
1109 |
} |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1110 |
master->stats.corrupted++; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1111 |
ec_master_output_stats(master); |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1112 |
return; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1113 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1114 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1115 |
// search for matching datagram in the queue |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1116 |
matched = 0; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1117 |
list_for_each_entry(datagram, &master->datagram_queue, queue) { |
690
5e231f6a3d2e
Re-ordered criteria for datagram matching.
Florian Pose <fp@igh-essen.com>
parents:
688
diff
changeset
|
1118 |
if (datagram->index == datagram_index |
5e231f6a3d2e
Re-ordered criteria for datagram matching.
Florian Pose <fp@igh-essen.com>
parents:
688
diff
changeset
|
1119 |
&& datagram->state == EC_DATAGRAM_SENT |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1120 |
&& datagram->type == datagram_type |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1121 |
&& datagram->data_size == data_size) { |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1122 |
matched = 1; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1123 |
break; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1124 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1125 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1126 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1127 |
// no matching datagram was found |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1128 |
if (!matched) { |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1129 |
master->stats.unmatched++; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1130 |
ec_master_output_stats(master); |
684
bf991809dcf0
Added debugging output for unmatched frames and those that timed out.
Florian Pose <fp@igh-essen.com>
parents:
664
diff
changeset
|
1131 |
|
bf991809dcf0
Added debugging output for unmatched frames and those that timed out.
Florian Pose <fp@igh-essen.com>
parents:
664
diff
changeset
|
1132 |
if (unlikely(master->debug_level > 0)) { |
1921 | 1133 |
EC_MASTER_DBG(master, 0, "UNMATCHED datagram:\n"); |
684
bf991809dcf0
Added debugging output for unmatched frames and those that timed out.
Florian Pose <fp@igh-essen.com>
parents:
664
diff
changeset
|
1134 |
ec_print_data(cur_data - EC_DATAGRAM_HEADER_SIZE, |
bf991809dcf0
Added debugging output for unmatched frames and those that timed out.
Florian Pose <fp@igh-essen.com>
parents:
664
diff
changeset
|
1135 |
EC_DATAGRAM_HEADER_SIZE + data_size |
bf991809dcf0
Added debugging output for unmatched frames and those that timed out.
Florian Pose <fp@igh-essen.com>
parents:
664
diff
changeset
|
1136 |
+ EC_DATAGRAM_FOOTER_SIZE); |
692
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
691
diff
changeset
|
1137 |
#ifdef EC_DEBUG_RING |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
691
diff
changeset
|
1138 |
ec_device_debug_ring_print(&master->main_device); |
fe7cf37c33f1
Implemented debug frame ring to output the last n frames for debugging
Florian Pose <fp@igh-essen.com>
parents:
691
diff
changeset
|
1139 |
#endif |
684
bf991809dcf0
Added debugging output for unmatched frames and those that timed out.
Florian Pose <fp@igh-essen.com>
parents:
664
diff
changeset
|
1140 |
} |
bf991809dcf0
Added debugging output for unmatched frames and those that timed out.
Florian Pose <fp@igh-essen.com>
parents:
664
diff
changeset
|
1141 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1142 |
cur_data += data_size + EC_DATAGRAM_FOOTER_SIZE; |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1143 |
continue; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1144 |
} |
2103
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
1145 |
|
1981
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
1146 |
frame_datagram_data = cur_data; |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
1147 |
|
2103
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
1148 |
// distinguish between domain and non-domain datagrams |
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
1149 |
// this is not nice FIXME |
1981
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
1150 |
if (datagram->domain) { |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
1151 |
size_t datagram_address = EC_READ_U32(datagram->address); |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
1152 |
int i = 0; |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
1153 |
uint8_t *domain_data = datagram->data; |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
1154 |
|
2103
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
1155 |
// FIXME see ecrt_master_send_datagrams() |
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
1156 |
// it is not correct to walk though *all* FMMU configs, |
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
1157 |
// because they may not all belong to the same frame! |
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
1158 |
|
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
1159 |
list_for_each_entry(domain_fmmu, &datagram->domain->fmmu_configs, |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
1160 |
list) { |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
1161 |
if (domain_fmmu->dir == EC_DIR_INPUT) { |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
1162 |
unsigned int frame_offset = |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
1163 |
domain_fmmu->logical_start_address - datagram_address; |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
1164 |
memcpy(domain_data, frame_datagram_data + frame_offset, |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
1165 |
domain_fmmu->data_size); |
1981
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
1166 |
if (unlikely(master->debug_level > 1)) { |
2103
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
1167 |
EC_MASTER_DBG(master, 0, "Receiving datagram %p" |
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
1168 |
" i=0x%02X fmmu %u fp=%u" |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
1169 |
" dp=%zu size=%u\n", |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
1170 |
datagram, datagram->index, i, |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
1171 |
frame_offset, domain_data - datagram->data, |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
1172 |
domain_fmmu->data_size); |
1981
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
1173 |
ec_print_data(domain_data, domain_fmmu->data_size); |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
1174 |
} |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
1175 |
} |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
1176 |
domain_data += domain_fmmu->data_size; |
2103
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
1177 |
i++; |
1981
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
1178 |
} |
2116
1448a40b5af5
Don not copy frame data to datagram memory, if datagram type is write-only.
Florian Pose <fp@igh-essen.com>
parents:
2110
diff
changeset
|
1179 |
} else if (datagram->type != EC_DATAGRAM_APWR && |
1448a40b5af5
Don not copy frame data to datagram memory, if datagram type is write-only.
Florian Pose <fp@igh-essen.com>
parents:
2110
diff
changeset
|
1180 |
datagram->type != EC_DATAGRAM_FPWR && |
1448a40b5af5
Don not copy frame data to datagram memory, if datagram type is write-only.
Florian Pose <fp@igh-essen.com>
parents:
2110
diff
changeset
|
1181 |
datagram->type != EC_DATAGRAM_BWR && |
1448a40b5af5
Don not copy frame data to datagram memory, if datagram type is write-only.
Florian Pose <fp@igh-essen.com>
parents:
2110
diff
changeset
|
1182 |
datagram->type != EC_DATAGRAM_LWR) { |
1448a40b5af5
Don not copy frame data to datagram memory, if datagram type is write-only.
Florian Pose <fp@igh-essen.com>
parents:
2110
diff
changeset
|
1183 |
// copy received data into the datagram memory, |
1448a40b5af5
Don not copy frame data to datagram memory, if datagram type is write-only.
Florian Pose <fp@igh-essen.com>
parents:
2110
diff
changeset
|
1184 |
// if something has been read |
1981
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
1185 |
memcpy(datagram->data, frame_datagram_data, data_size); |
c14b6bb14fdf
Inplace I/O: let input Pdos use the same bus space as Output Pdos
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1980
diff
changeset
|
1186 |
} |
2103
8c63d804ead9
Fixed spacing and added some thoughts about the overlapping PDOs
Florian Pose <fp@igh-essen.com>
parents:
2095
diff
changeset
|
1187 |
|
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1188 |
cur_data += data_size; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1189 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1190 |
// set the datagram's working counter |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1191 |
datagram->working_counter = EC_READ_U16(cur_data); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1192 |
cur_data += EC_DATAGRAM_FOOTER_SIZE; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1193 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1194 |
// dequeue the received datagram |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
1195 |
datagram->state = EC_DATAGRAM_RECEIVED; |
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
1196 |
#ifdef EC_HAVE_CYCLES |
579
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
578
diff
changeset
|
1197 |
datagram->cycles_received = master->main_device.cycles_poll; |
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
1198 |
#endif |
579
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
578
diff
changeset
|
1199 |
datagram->jiffies_received = master->main_device.jiffies_poll; |
2037
ea0319750e13
Optionally compile with trace_printk support
Martin Troxler <ch1010277@ch10pc446>
parents:
2036
diff
changeset
|
1200 |
EC_MASTER_DBG(master, 2, "removing datagram %p i=0x%02X\n",datagram, |
ea0319750e13
Optionally compile with trace_printk support
Martin Troxler <ch1010277@ch10pc446>
parents:
2036
diff
changeset
|
1201 |
datagram->index); |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1202 |
list_del_init(&datagram->queue); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1203 |
} |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1204 |
} |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1205 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1206 |
/*****************************************************************************/ |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1207 |
|
1029
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
1208 |
/** Output master statistics. |
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
1209 |
* |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
1210 |
* This function outputs statistical data on demand, but not more often than |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
1211 |
* necessary. The output happens at most once a second. |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
1212 |
*/ |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1213 |
void ec_master_output_stats(ec_master_t *master /**< EtherCAT master */) |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1214 |
{ |
344
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
1215 |
if (unlikely(jiffies - master->stats.output_jiffies >= HZ)) { |
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
1216 |
master->stats.output_jiffies = jiffies; |
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
1217 |
|
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1218 |
if (master->stats.timeouts) { |
1921 | 1219 |
EC_MASTER_WARN(master, "%u datagram%s TIMED OUT!\n", |
1220 |
master->stats.timeouts, |
|
396 | 1221 |
master->stats.timeouts == 1 ? "" : "s"); |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1222 |
master->stats.timeouts = 0; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1223 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1224 |
if (master->stats.corrupted) { |
1921 | 1225 |
EC_MASTER_WARN(master, "%u frame%s CORRUPTED!\n", |
1226 |
master->stats.corrupted, |
|
396 | 1227 |
master->stats.corrupted == 1 ? "" : "s"); |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1228 |
master->stats.corrupted = 0; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1229 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1230 |
if (master->stats.unmatched) { |
1921 | 1231 |
EC_MASTER_WARN(master, "%u datagram%s UNMATCHED!\n", |
1232 |
master->stats.unmatched, |
|
396 | 1233 |
master->stats.unmatched == 1 ? "" : "s"); |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1234 |
master->stats.unmatched = 0; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1235 |
} |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1236 |
} |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
1237 |
} |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
1238 |
|
1600
e36c92cf58a9
use given send interval to limit SDO/FOE traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
1239 |
|
e36c92cf58a9
use given send interval to limit SDO/FOE traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
1240 |
/*****************************************************************************/ |
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1241 |
|
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1242 |
#ifdef EC_USE_HRTIMER |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1243 |
|
1600
e36c92cf58a9
use given send interval to limit SDO/FOE traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
1244 |
/* |
e36c92cf58a9
use given send interval to limit SDO/FOE traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
1245 |
* Sleep related functions: |
e36c92cf58a9
use given send interval to limit SDO/FOE traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
1246 |
*/ |
e36c92cf58a9
use given send interval to limit SDO/FOE traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
1247 |
static enum hrtimer_restart ec_master_nanosleep_wakeup(struct hrtimer *timer) |
e36c92cf58a9
use given send interval to limit SDO/FOE traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
1248 |
{ |
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1249 |
struct hrtimer_sleeper *t = |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1250 |
container_of(timer, struct hrtimer_sleeper, timer); |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1251 |
struct task_struct *task = t->task; |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1252 |
|
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1253 |
t->task = NULL; |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1254 |
if (task) |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1255 |
wake_up_process(task); |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1256 |
|
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1257 |
return HRTIMER_NORESTART; |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1258 |
} |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1259 |
|
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1260 |
/*****************************************************************************/ |
1600
e36c92cf58a9
use given send interval to limit SDO/FOE traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
1261 |
|
1603
8e528f806dc5
fix build for recent kernel versions (tested with 2.6.31)
Matthias Luescher <ch1010472@ch10lt140>
parents:
1600
diff
changeset
|
1262 |
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) |
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1263 |
|
1603
8e528f806dc5
fix build for recent kernel versions (tested with 2.6.31)
Matthias Luescher <ch1010472@ch10lt140>
parents:
1600
diff
changeset
|
1264 |
/* compatibility with new hrtimer interface */ |
8e528f806dc5
fix build for recent kernel versions (tested with 2.6.31)
Matthias Luescher <ch1010472@ch10lt140>
parents:
1600
diff
changeset
|
1265 |
static inline ktime_t hrtimer_get_expires(const struct hrtimer *timer) |
8e528f806dc5
fix build for recent kernel versions (tested with 2.6.31)
Matthias Luescher <ch1010472@ch10lt140>
parents:
1600
diff
changeset
|
1266 |
{ |
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1267 |
return timer->expires; |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1268 |
} |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1269 |
|
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1270 |
/*****************************************************************************/ |
1603
8e528f806dc5
fix build for recent kernel versions (tested with 2.6.31)
Matthias Luescher <ch1010472@ch10lt140>
parents:
1600
diff
changeset
|
1271 |
|
8e528f806dc5
fix build for recent kernel versions (tested with 2.6.31)
Matthias Luescher <ch1010472@ch10lt140>
parents:
1600
diff
changeset
|
1272 |
static inline void hrtimer_set_expires(struct hrtimer *timer, ktime_t time) |
8e528f806dc5
fix build for recent kernel versions (tested with 2.6.31)
Matthias Luescher <ch1010472@ch10lt140>
parents:
1600
diff
changeset
|
1273 |
{ |
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1274 |
timer->expires = time; |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1275 |
} |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1276 |
|
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1277 |
#endif |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1278 |
|
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1279 |
/*****************************************************************************/ |
1603
8e528f806dc5
fix build for recent kernel versions (tested with 2.6.31)
Matthias Luescher <ch1010472@ch10lt140>
parents:
1600
diff
changeset
|
1280 |
|
1600
e36c92cf58a9
use given send interval to limit SDO/FOE traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
1281 |
void ec_master_nanosleep(const unsigned long nsecs) |
e36c92cf58a9
use given send interval to limit SDO/FOE traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
1282 |
{ |
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1283 |
struct hrtimer_sleeper t; |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1284 |
enum hrtimer_mode mode = HRTIMER_MODE_REL; |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1285 |
|
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1286 |
hrtimer_init(&t.timer, CLOCK_MONOTONIC, mode); |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1287 |
t.timer.function = ec_master_nanosleep_wakeup; |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1288 |
t.task = current; |
1600
e36c92cf58a9
use given send interval to limit SDO/FOE traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
1289 |
#ifdef CONFIG_HIGH_RES_TIMERS |
1603
8e528f806dc5
fix build for recent kernel versions (tested with 2.6.31)
Matthias Luescher <ch1010472@ch10lt140>
parents:
1600
diff
changeset
|
1290 |
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 24) |
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1291 |
t.timer.cb_mode = HRTIMER_CB_IRQSAFE_NO_RESTART; |
1603
8e528f806dc5
fix build for recent kernel versions (tested with 2.6.31)
Matthias Luescher <ch1010472@ch10lt140>
parents:
1600
diff
changeset
|
1292 |
#elif LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 26) |
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1293 |
t.timer.cb_mode = HRTIMER_CB_IRQSAFE_NO_SOFTIRQ; |
1603
8e528f806dc5
fix build for recent kernel versions (tested with 2.6.31)
Matthias Luescher <ch1010472@ch10lt140>
parents:
1600
diff
changeset
|
1294 |
#elif LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 28) |
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1295 |
t.timer.cb_mode = HRTIMER_CB_IRQSAFE_UNLOCKED; |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1296 |
#endif |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1297 |
#endif |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1298 |
hrtimer_set_expires(&t.timer, ktime_set(0, nsecs)); |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1299 |
|
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1300 |
do { |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1301 |
set_current_state(TASK_INTERRUPTIBLE); |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1302 |
hrtimer_start(&t.timer, hrtimer_get_expires(&t.timer), mode); |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1303 |
|
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1304 |
if (likely(t.task)) |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1305 |
schedule(); |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1306 |
|
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1307 |
hrtimer_cancel(&t.timer); |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1308 |
mode = HRTIMER_MODE_ABS; |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1309 |
|
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1310 |
} while (t.task && !signal_pending(current)); |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1311 |
} |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1312 |
|
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1313 |
#endif // EC_USE_HRTIMER |
1600
e36c92cf58a9
use given send interval to limit SDO/FOE traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
1314 |
|
68
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
66
diff
changeset
|
1315 |
/*****************************************************************************/ |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
66
diff
changeset
|
1316 |
|
1029
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
1317 |
/** Master kernel thread function for IDLE phase. |
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
1318 |
*/ |
1241
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
1319 |
static int ec_master_idle_thread(void *priv_data) |
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
1320 |
{ |
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
1321 |
ec_master_t *master = (ec_master_t *) priv_data; |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1580
diff
changeset
|
1322 |
ec_slave_t *slave = NULL; |
2240
b45438edf869
Avoided unused variable warnings.
Florian Pose <fp@igh-essen.com>
parents:
2166
diff
changeset
|
1323 |
#ifdef EC_USE_HRTIMER |
1804 | 1324 |
size_t sent_bytes; |
2240
b45438edf869
Avoided unused variable warnings.
Florian Pose <fp@igh-essen.com>
parents:
2166
diff
changeset
|
1325 |
#endif |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
1326 |
|
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
1327 |
// send interval in IDLE phase |
1804 | 1328 |
ec_master_set_send_interval(master, 1000000 / HZ); |
1329 |
||
1930
59a50053ccc6
Made send_interval variable an unsigned int; fixed format specifiers for
Florian Pose <fp@igh-essen.com>
parents:
1925
diff
changeset
|
1330 |
EC_MASTER_DBG(master, 1, "Idle thread running with send interval = %u us," |
59a50053ccc6
Made send_interval variable an unsigned int; fixed format specifiers for
Florian Pose <fp@igh-essen.com>
parents:
1925
diff
changeset
|
1331 |
" max data size=%zu\n", master->send_interval, |
1921 | 1332 |
master->max_queue_size); |
1241
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
1333 |
|
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
1334 |
while (!kthread_should_stop()) { |
719
03d5b96632fb
Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents:
715
diff
changeset
|
1335 |
ec_datagram_output_stats(&master->fsm_datagram); |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
1336 |
|
1031
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
1337 |
// receive |
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
1338 |
ec_mutex_lock(&master->io_mutex); |
1031
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
1339 |
ecrt_master_receive(master); |
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
1340 |
ec_mutex_unlock(&master->io_mutex); |
1031
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
1341 |
|
2018
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
1342 |
// execute master & slave state machines |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
1343 |
if (ec_mutex_lock_interruptible(&master->master_mutex)) { |
2018
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
1344 |
break; |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
1345 |
} |
2018
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
1346 |
if (ec_fsm_master_exec(&master->fsm)) { |
2045
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
2040
diff
changeset
|
1347 |
ec_master_mbox_queue_datagrams(master, &master->fsm_mbox); |
2018
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
1348 |
} |
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
1349 |
for (slave = master->slaves; |
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
1350 |
slave < master->slaves + master->slave_count; |
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
1351 |
slave++) { |
2039
629d3cf05180
Minor changes (consistent variable naming)
Martin Troxler <ch1010277@ch10pc446>
parents:
2038
diff
changeset
|
1352 |
ec_fsm_slave_exec(&slave->fsm); // may queue datagram in fsm queue |
2018
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
1353 |
} |
2020
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1354 |
#if defined(EC_EOE) |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
1355 |
if (!ec_master_eoe_processing(master)) { |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
1356 |
master->fsm.idle = 0; // pump the bus as fast as possible |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
1357 |
} |
2020
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1358 |
#endif |
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
1359 |
ec_mutex_unlock(&master->master_mutex); |
2018
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
1360 |
|
2017
4b16e2dce5fb
Increment injection_seq on slave state changes
Martin Troxler <ch1010277@ch10pc446>
parents:
2016
diff
changeset
|
1361 |
// queue and send |
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
1362 |
ec_mutex_lock(&master->io_mutex); |
1031
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
1363 |
ecrt_master_send(master); |
2240
b45438edf869
Avoided unused variable warnings.
Florian Pose <fp@igh-essen.com>
parents:
2166
diff
changeset
|
1364 |
#ifdef EC_USE_HRTIMER |
1804 | 1365 |
sent_bytes = master->main_device.tx_skb[ |
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
1366 |
master->main_device.tx_ring_index]->len; |
2240
b45438edf869
Avoided unused variable warnings.
Florian Pose <fp@igh-essen.com>
parents:
2166
diff
changeset
|
1367 |
#endif |
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
1368 |
ec_mutex_unlock(&master->io_mutex); |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1580
diff
changeset
|
1369 |
|
1804 | 1370 |
if (ec_fsm_master_idle(&master->fsm)) { |
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1371 |
#ifdef EC_USE_HRTIMER |
1804 | 1372 |
ec_master_nanosleep(master->send_interval * 1000); |
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1373 |
#else |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1374 |
set_current_state(TASK_INTERRUPTIBLE); |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1375 |
schedule_timeout(1); |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1376 |
#endif |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1377 |
} else { |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1378 |
#ifdef EC_USE_HRTIMER |
1804 | 1379 |
ec_master_nanosleep(sent_bytes * EC_BYTE_TRANSMISSION_TIME_NS); |
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1380 |
#else |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1381 |
schedule(); |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1382 |
#endif |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1383 |
} |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
1384 |
} |
518
b6a1426ba724
Fixed race: Stop EoE processing when entering or leaving operation mode.
Florian Pose <fp@igh-essen.com>
parents:
517
diff
changeset
|
1385 |
|
1921 | 1386 |
EC_MASTER_DBG(master, 1, "Master IDLE thread exiting...\n"); |
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
1387 |
|
1241
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
1388 |
return 0; |
191 | 1389 |
} |
1390 |
||
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
1391 |
/*****************************************************************************/ |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
1392 |
|
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1580
diff
changeset
|
1393 |
/** Master kernel thread function for OPERATION phase. |
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
1394 |
*/ |
1241
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
1395 |
static int ec_master_operation_thread(void *priv_data) |
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
1396 |
{ |
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
1397 |
ec_master_t *master = (ec_master_t *) priv_data; |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1580
diff
changeset
|
1398 |
ec_slave_t *slave = NULL; |
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1399 |
|
1921 | 1400 |
EC_MASTER_DBG(master, 1, "Operation thread running" |
1930
59a50053ccc6
Made send_interval variable an unsigned int; fixed format specifiers for
Florian Pose <fp@igh-essen.com>
parents:
1925
diff
changeset
|
1401 |
" with fsm interval = %u us, max data size=%zu\n", |
1921 | 1402 |
master->send_interval, master->max_queue_size); |
1241
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
1403 |
|
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
1404 |
while (!kthread_should_stop()) { |
719
03d5b96632fb
Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents:
715
diff
changeset
|
1405 |
ec_datagram_output_stats(&master->fsm_datagram); |
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1406 |
|
2018
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
1407 |
// output statistics |
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
1408 |
ec_master_output_stats(master); |
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
1409 |
|
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
1410 |
// execute master & slave state machines |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
1411 |
if (ec_mutex_lock_interruptible(&master->master_mutex)) { |
2018
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
1412 |
break; |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
1413 |
} |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
1414 |
if (ec_fsm_master_exec(&master->fsm)) { |
2045
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
2040
diff
changeset
|
1415 |
ec_master_mbox_queue_datagrams(master, &master->fsm_mbox); |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
1416 |
} |
2018
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
1417 |
for (slave = master->slaves; |
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
1418 |
slave < master->slaves + master->slave_count; |
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
1419 |
slave++) { |
2039
629d3cf05180
Minor changes (consistent variable naming)
Martin Troxler <ch1010277@ch10pc446>
parents:
2038
diff
changeset
|
1420 |
ec_fsm_slave_exec(&slave->fsm); // may queue datagram in fsm queue |
2018
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
1421 |
} |
2020
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1422 |
#if defined(EC_EOE) |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1423 |
ec_master_eoe_processing(master); |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1424 |
#endif |
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
1425 |
ec_mutex_unlock(&master->master_mutex); |
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1426 |
|
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1427 |
#ifdef EC_USE_HRTIMER |
1804 | 1428 |
// the op thread should not work faster than the sending RT thread |
1429 |
ec_master_nanosleep(master->send_interval * 1000); |
|
1773
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1430 |
#else |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1431 |
if (ec_fsm_master_idle(&master->fsm)) { |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1432 |
set_current_state(TASK_INTERRUPTIBLE); |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1433 |
schedule_timeout(1); |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1434 |
} |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1435 |
else { |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1436 |
schedule(); |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1437 |
} |
5371f3e5f6a1
Disable use of hrtimer for scheduling by default. Does not work on some PPC targets.
Florian Pose <fp@igh-essen.com>
parents:
1611
diff
changeset
|
1438 |
#endif |
1804 | 1439 |
} |
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
1440 |
|
1921 | 1441 |
EC_MASTER_DBG(master, 1, "Master OP thread exiting...\n"); |
1241
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
1442 |
return 0; |
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
1443 |
} |
578
f402b4bd2f4d
Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents:
576
diff
changeset
|
1444 |
|
f402b4bd2f4d
Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents:
576
diff
changeset
|
1445 |
/*****************************************************************************/ |
f402b4bd2f4d
Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents:
576
diff
changeset
|
1446 |
|
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
1447 |
#ifdef EC_EOE |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1448 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1449 |
/*****************************************************************************/ |
441
ffa13db95e10
SDO uploading via Sysfs without master FSM calling wake_up().
Florian Pose <fp@igh-essen.com>
parents:
435
diff
changeset
|
1450 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
1451 |
/** Does the Ethernet over EtherCAT processing. |
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
1452 |
*/ |
2020
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1453 |
static int ec_master_eoe_processing(ec_master_t *master) |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1454 |
{ |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1455 |
ec_eoe_t *eoe; |
1489
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1456 |
unsigned int none_open, sth_to_send, all_idle; |
2020
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1457 |
none_open = 1; |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1458 |
all_idle = 1; |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1459 |
|
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1460 |
list_for_each_entry(eoe, &master->eoe_handlers, list) { |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1461 |
if (ec_eoe_is_open(eoe)) { |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1462 |
none_open = 0; |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1463 |
break; |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1464 |
} |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1465 |
} |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1466 |
if (none_open) |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1467 |
return all_idle; |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1468 |
|
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1469 |
// actual EoE processing |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1470 |
sth_to_send = 0; |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1471 |
list_for_each_entry(eoe, &master->eoe_handlers, list) { |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1472 |
ec_eoe_run(eoe); |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1473 |
if (eoe->queue_datagram) { |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1474 |
sth_to_send = 1; |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1475 |
} |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1476 |
if (!ec_eoe_is_idle(eoe)) { |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1477 |
all_idle = 0; |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1478 |
} |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1479 |
} |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1480 |
|
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1481 |
if (sth_to_send) { |
1489
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1482 |
list_for_each_entry(eoe, &master->eoe_handlers, list) { |
2020
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1483 |
ec_eoe_queue(eoe); |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1484 |
} |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1485 |
} |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1486 |
return all_idle; |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1487 |
} |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1488 |
|
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
1489 |
#endif // EC_EOE |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1490 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
1491 |
/*****************************************************************************/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
1492 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1493 |
/** Detaches the slave configurations from the slaves. |
640
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1494 |
*/ |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1495 |
void ec_master_detach_slave_configs( |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1496 |
ec_master_t *master /**< EtherCAT master. */ |
640
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1497 |
) |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1498 |
{ |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1499 |
ec_slave_config_t *sc; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1500 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1501 |
list_for_each_entry(sc, &master->configs, list) { |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1502 |
ec_slave_config_detach(sc); |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1503 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1504 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1505 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1506 |
/*****************************************************************************/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1507 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1508 |
/** Attaches the slave configurations to the slaves. |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1509 |
*/ |
1028
afdd4bdbb7ec
Removed configs_attached flag; changed return value of
Florian Pose <fp@igh-essen.com>
parents:
1024
diff
changeset
|
1510 |
void ec_master_attach_slave_configs( |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1511 |
ec_master_t *master /**< EtherCAT master. */ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1512 |
) |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1513 |
{ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1514 |
ec_slave_config_t *sc; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1515 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1516 |
list_for_each_entry(sc, &master->configs, list) { |
1028
afdd4bdbb7ec
Removed configs_attached flag; changed return value of
Florian Pose <fp@igh-essen.com>
parents:
1024
diff
changeset
|
1517 |
ec_slave_config_attach(sc); |
afdd4bdbb7ec
Removed configs_attached flag; changed return value of
Florian Pose <fp@igh-essen.com>
parents:
1024
diff
changeset
|
1518 |
} |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1519 |
} |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1520 |
|
927
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1521 |
/*****************************************************************************/ |
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1522 |
|
1077
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1523 |
/** Common implementation for ec_master_find_slave() |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1524 |
* and ec_master_find_slave_const(). |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1525 |
*/ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1526 |
#define EC_FIND_SLAVE \ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1527 |
do { \ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1528 |
if (alias) { \ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1529 |
for (; slave < master->slaves + master->slave_count; \ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1530 |
slave++) { \ |
1909
ea3eb4c74c1b
Introduced effective_alias variable to separate reg12 alias from SII alias.
Florian Pose <fp@igh-essen.com>
parents:
1906
diff
changeset
|
1531 |
if (slave->effective_alias == alias) \ |
1077
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1532 |
break; \ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1533 |
} \ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1534 |
if (slave == master->slaves + master->slave_count) \ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1535 |
return NULL; \ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1536 |
} \ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1537 |
\ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1538 |
slave += position; \ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1539 |
if (slave < master->slaves + master->slave_count) { \ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1540 |
return slave; \ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1541 |
} else { \ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1542 |
return NULL; \ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1543 |
} \ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1544 |
} while (0) |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1545 |
|
927
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1546 |
/** Finds a slave in the bus, given the alias and position. |
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1547 |
*/ |
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1548 |
ec_slave_t *ec_master_find_slave( |
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1549 |
ec_master_t *master, /**< EtherCAT master. */ |
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1550 |
uint16_t alias, /**< Slave alias. */ |
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1551 |
uint16_t position /**< Slave position. */ |
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1552 |
) |
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1553 |
{ |
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
1554 |
ec_slave_t *slave = master->slaves; |
1077
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1555 |
EC_FIND_SLAVE; |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1556 |
} |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1557 |
|
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1558 |
/** Finds a slave in the bus, given the alias and position. |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1559 |
* |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1560 |
* Const version. |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1561 |
*/ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1562 |
const ec_slave_t *ec_master_find_slave_const( |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1563 |
const ec_master_t *master, /**< EtherCAT master. */ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1564 |
uint16_t alias, /**< Slave alias. */ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1565 |
uint16_t position /**< Slave position. */ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1566 |
) |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1567 |
{ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1568 |
const ec_slave_t *slave = master->slaves; |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1569 |
EC_FIND_SLAVE; |
927
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1570 |
} |
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1571 |
|
946
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1572 |
/*****************************************************************************/ |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1573 |
|
1092 | 1574 |
/** Get the number of slave configurations provided by the application. |
1575 |
* |
|
1576 |
* \return Number of configurations. |
|
1577 |
*/ |
|
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1578 |
unsigned int ec_master_config_count( |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1579 |
const ec_master_t *master /**< EtherCAT master. */ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1580 |
) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1581 |
{ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1582 |
const ec_slave_config_t *sc; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1583 |
unsigned int count = 0; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1584 |
|
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1585 |
list_for_each_entry(sc, &master->configs, list) { |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1586 |
count++; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1587 |
} |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1588 |
|
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1589 |
return count; |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1590 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1591 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1592 |
/*****************************************************************************/ |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1593 |
|
1252
0b411da5fd24
Added ec_master_get_config().
Florian Pose <fp@igh-essen.com>
parents:
1250
diff
changeset
|
1594 |
/** Common implementation for ec_master_get_config() |
0b411da5fd24
Added ec_master_get_config().
Florian Pose <fp@igh-essen.com>
parents:
1250
diff
changeset
|
1595 |
* and ec_master_get_config_const(). |
0b411da5fd24
Added ec_master_get_config().
Florian Pose <fp@igh-essen.com>
parents:
1250
diff
changeset
|
1596 |
*/ |
0b411da5fd24
Added ec_master_get_config().
Florian Pose <fp@igh-essen.com>
parents:
1250
diff
changeset
|
1597 |
#define EC_FIND_CONFIG \ |
0b411da5fd24
Added ec_master_get_config().
Florian Pose <fp@igh-essen.com>
parents:
1250
diff
changeset
|
1598 |
do { \ |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1599 |
list_for_each_entry(sc, &master->configs, list) { \ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1600 |
if (pos--) \ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1601 |
continue; \ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1602 |
return sc; \ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1603 |
} \ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1604 |
return NULL; \ |
1252
0b411da5fd24
Added ec_master_get_config().
Florian Pose <fp@igh-essen.com>
parents:
1250
diff
changeset
|
1605 |
} while (0) |
0b411da5fd24
Added ec_master_get_config().
Florian Pose <fp@igh-essen.com>
parents:
1250
diff
changeset
|
1606 |
|
0b411da5fd24
Added ec_master_get_config().
Florian Pose <fp@igh-essen.com>
parents:
1250
diff
changeset
|
1607 |
/** Get a slave configuration via its position in the list. |
0b411da5fd24
Added ec_master_get_config().
Florian Pose <fp@igh-essen.com>
parents:
1250
diff
changeset
|
1608 |
* |
0b411da5fd24
Added ec_master_get_config().
Florian Pose <fp@igh-essen.com>
parents:
1250
diff
changeset
|
1609 |
* \return Slave configuration or \a NULL. |
0b411da5fd24
Added ec_master_get_config().
Florian Pose <fp@igh-essen.com>
parents:
1250
diff
changeset
|
1610 |
*/ |
0b411da5fd24
Added ec_master_get_config().
Florian Pose <fp@igh-essen.com>
parents:
1250
diff
changeset
|
1611 |
ec_slave_config_t *ec_master_get_config( |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1612 |
const ec_master_t *master, /**< EtherCAT master. */ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1613 |
unsigned int pos /**< List position. */ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1614 |
) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1615 |
{ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1616 |
ec_slave_config_t *sc; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1617 |
EC_FIND_CONFIG; |
1252
0b411da5fd24
Added ec_master_get_config().
Florian Pose <fp@igh-essen.com>
parents:
1250
diff
changeset
|
1618 |
} |
0b411da5fd24
Added ec_master_get_config().
Florian Pose <fp@igh-essen.com>
parents:
1250
diff
changeset
|
1619 |
|
1092 | 1620 |
/** Get a slave configuration via its position in the list. |
1621 |
* |
|
1622 |
* Const version. |
|
1623 |
* |
|
1624 |
* \return Slave configuration or \a NULL. |
|
1625 |
*/ |
|
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1626 |
const ec_slave_config_t *ec_master_get_config_const( |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1627 |
const ec_master_t *master, /**< EtherCAT master. */ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1628 |
unsigned int pos /**< List position. */ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1629 |
) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1630 |
{ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1631 |
const ec_slave_config_t *sc; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1632 |
EC_FIND_CONFIG; |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1633 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1634 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1635 |
/*****************************************************************************/ |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1636 |
|
1092 | 1637 |
/** Get the number of domains. |
1638 |
* |
|
1639 |
* \return Number of domains. |
|
1640 |
*/ |
|
946
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1641 |
unsigned int ec_master_domain_count( |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1642 |
const ec_master_t *master /**< EtherCAT master. */ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1643 |
) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1644 |
{ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1645 |
const ec_domain_t *domain; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1646 |
unsigned int count = 0; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1647 |
|
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1648 |
list_for_each_entry(domain, &master->domains, list) { |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1649 |
count++; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1650 |
} |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1651 |
|
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1652 |
return count; |
946
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1653 |
} |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1654 |
|
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1655 |
/*****************************************************************************/ |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1656 |
|
1082
ff06c58e269c
Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
1657 |
/** Common implementation for ec_master_find_domain() and |
ff06c58e269c
Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
1658 |
* ec_master_find_domain_const(). |
ff06c58e269c
Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
1659 |
*/ |
1078
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1660 |
#define EC_FIND_DOMAIN \ |
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1661 |
do { \ |
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1662 |
list_for_each_entry(domain, &master->domains, list) { \ |
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1663 |
if (index--) \ |
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1664 |
continue; \ |
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1665 |
return domain; \ |
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1666 |
} \ |
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1667 |
\ |
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1668 |
return NULL; \ |
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1669 |
} while (0) |
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1670 |
|
1092 | 1671 |
/** Get a domain via its position in the list. |
1672 |
* |
|
1673 |
* \return Domain pointer, or \a NULL if not found. |
|
1674 |
*/ |
|
946
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1675 |
ec_domain_t *ec_master_find_domain( |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1676 |
ec_master_t *master, /**< EtherCAT master. */ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1677 |
unsigned int index /**< Domain index. */ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1678 |
) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1679 |
{ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1680 |
ec_domain_t *domain; |
1078
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1681 |
EC_FIND_DOMAIN; |
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1682 |
} |
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1683 |
|
2054
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
2009
diff
changeset
|
1684 |
/** Wrapper Function for external usage |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
2009
diff
changeset
|
1685 |
* |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
2009
diff
changeset
|
1686 |
* \return Domain pointer, or \a NULL if not found. |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
2009
diff
changeset
|
1687 |
*/ |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
2009
diff
changeset
|
1688 |
ec_domain_t *ecrt_master_find_domain( |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
2009
diff
changeset
|
1689 |
ec_master_t *master, /**< EtherCAT master. */ |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
2009
diff
changeset
|
1690 |
unsigned int index /**< Domain index. */ |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
2009
diff
changeset
|
1691 |
) |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
2009
diff
changeset
|
1692 |
{ |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
2009
diff
changeset
|
1693 |
return ec_master_find_domain( |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
2009
diff
changeset
|
1694 |
master, |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
2009
diff
changeset
|
1695 |
index); |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
2009
diff
changeset
|
1696 |
} |
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
2009
diff
changeset
|
1697 |
|
1092 | 1698 |
/** Get a domain via its position in the list. |
1699 |
* |
|
1700 |
* Const version. |
|
1701 |
* |
|
1702 |
* \return Domain pointer, or \a NULL if not found. |
|
1703 |
*/ |
|
1078
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1704 |
const ec_domain_t *ec_master_find_domain_const( |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1705 |
const ec_master_t *master, /**< EtherCAT master. */ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1706 |
unsigned int index /**< Domain index. */ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1707 |
) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1708 |
{ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1709 |
const ec_domain_t *domain; |
1078
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1710 |
EC_FIND_DOMAIN; |
946
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1711 |
} |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1712 |
|
956
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1713 |
/*****************************************************************************/ |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1714 |
|
1516
e3b09f847512
Fixed compiler error on --disable-eoe.
Florian Pose <fp@igh-essen.com>
parents:
1513
diff
changeset
|
1715 |
#ifdef EC_EOE |
e3b09f847512
Fixed compiler error on --disable-eoe.
Florian Pose <fp@igh-essen.com>
parents:
1513
diff
changeset
|
1716 |
|
1485 | 1717 |
/** Get the number of EoE handlers. |
1718 |
* |
|
1719 |
* \return Number of EoE handlers. |
|
1720 |
*/ |
|
1721 |
uint16_t ec_master_eoe_handler_count( |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1722 |
const ec_master_t *master /**< EtherCAT master. */ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1723 |
) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1724 |
{ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1725 |
const ec_eoe_t *eoe; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1726 |
unsigned int count = 0; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1727 |
|
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1728 |
list_for_each_entry(eoe, &master->eoe_handlers, list) { |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1729 |
count++; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1730 |
} |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1731 |
|
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1732 |
return count; |
1485 | 1733 |
} |
1734 |
||
1735 |
/*****************************************************************************/ |
|
1736 |
||
1737 |
/** Get an EoE handler via its position in the list. |
|
1738 |
* |
|
1739 |
* Const version. |
|
1740 |
* |
|
1741 |
* \return EoE handler pointer, or \a NULL if not found. |
|
1742 |
*/ |
|
1743 |
const ec_eoe_t *ec_master_get_eoe_handler_const( |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1744 |
const ec_master_t *master, /**< EtherCAT master. */ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1745 |
uint16_t index /**< EoE handler index. */ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1746 |
) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1747 |
{ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1748 |
const ec_eoe_t *eoe; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1749 |
|
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1750 |
list_for_each_entry(eoe, &master->eoe_handlers, list) { |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1751 |
if (index--) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1752 |
continue; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1753 |
return eoe; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1754 |
} |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1755 |
|
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1756 |
return NULL; |
1485 | 1757 |
} |
1758 |
||
1516
e3b09f847512
Fixed compiler error on --disable-eoe.
Florian Pose <fp@igh-essen.com>
parents:
1513
diff
changeset
|
1759 |
#endif |
e3b09f847512
Fixed compiler error on --disable-eoe.
Florian Pose <fp@igh-essen.com>
parents:
1513
diff
changeset
|
1760 |
|
1485 | 1761 |
/*****************************************************************************/ |
1762 |
||
1092 | 1763 |
/** Set the debug level. |
1764 |
* |
|
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
1765 |
* \retval 0 Success. |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
1766 |
* \retval -EINVAL Invalid debug level. |
1092 | 1767 |
*/ |
956
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1768 |
int ec_master_debug_level( |
1092 | 1769 |
ec_master_t *master, /**< EtherCAT master. */ |
1399
f79d4bb5b23a
Added debug_level module parameter. debug_level is now unsigned int.
Florian Pose <fp@igh-essen.com>
parents:
1396
diff
changeset
|
1770 |
unsigned int level /**< Debug level. May be 0, 1 or 2. */ |
956
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1771 |
) |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1772 |
{ |
1399
f79d4bb5b23a
Added debug_level module parameter. debug_level is now unsigned int.
Florian Pose <fp@igh-essen.com>
parents:
1396
diff
changeset
|
1773 |
if (level > 2) { |
1921 | 1774 |
EC_MASTER_ERR(master, "Invalid debug level %u!\n", level); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
1775 |
return -EINVAL; |
956
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1776 |
} |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1777 |
|
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1778 |
if (level != master->debug_level) { |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1779 |
master->debug_level = level; |
1921 | 1780 |
EC_MASTER_INFO(master, "Master debug level set to %u.\n", |
1781 |
master->debug_level); |
|
956
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1782 |
} |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1783 |
|
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1784 |
return 0; |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1785 |
} |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1786 |
|
1408 | 1787 |
/*****************************************************************************/ |
1788 |
||
1789 |
/** Finds the DC reference clock. |
|
1790 |
*/ |
|
1791 |
void ec_master_find_dc_ref_clock( |
|
1792 |
ec_master_t *master /**< EtherCAT master. */ |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1793 |
) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1794 |
{ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1795 |
ec_slave_t *slave, *ref = NULL; |
1408 | 1796 |
|
1797 |
for (slave = master->slaves; |
|
1798 |
slave < master->slaves + master->slave_count; |
|
1799 |
slave++) { |
|
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1800 |
if (slave->base_dc_supported && slave->has_dc_system_time) { |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1801 |
ref = slave; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1802 |
break; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1803 |
} |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1804 |
} |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1805 |
|
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1806 |
master->dc_ref_clock = ref; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1807 |
|
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1808 |
// This call always succeeds, because the datagram has been pre-allocated. |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1809 |
ec_datagram_frmw(&master->sync_datagram, |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1810 |
ref ? ref->station_address : 0xffff, 0x0910, 4); |
1408 | 1811 |
} |
1812 |
||
1421 | 1813 |
/*****************************************************************************/ |
1814 |
||
1815 |
/** Calculates the bus topology; recursion function. |
|
1816 |
*/ |
|
1817 |
int ec_master_calc_topology_rec( |
|
1818 |
ec_master_t *master, /**< EtherCAT master. */ |
|
1819 |
ec_slave_t *port0_slave, /**< Slave at port 0. */ |
|
1820 |
unsigned int *slave_position /**< Slave position. */ |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1821 |
) |
1421 | 1822 |
{ |
1823 |
ec_slave_t *slave = master->slaves + *slave_position; |
|
1824 |
unsigned int i; |
|
1825 |
int ret; |
|
1826 |
||
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1827 |
slave->ports[0].next_slave = port0_slave; |
1421 | 1828 |
|
1998
0330fdcbdd1f
Use ESC port order (0-3-1-2) for bus topology and DC delay calculation
Martin Troxler <ch1010277@ch10pc446>
parents:
1995
diff
changeset
|
1829 |
i = 3; |
0330fdcbdd1f
Use ESC port order (0-3-1-2) for bus topology and DC delay calculation
Martin Troxler <ch1010277@ch10pc446>
parents:
1995
diff
changeset
|
1830 |
while (i != 0) { |
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1831 |
if (!slave->ports[i].link.loop_closed) { |
1421 | 1832 |
*slave_position = *slave_position + 1; |
1833 |
if (*slave_position < master->slave_count) { |
|
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1834 |
slave->ports[i].next_slave = master->slaves + *slave_position; |
1421 | 1835 |
ret = ec_master_calc_topology_rec(master, |
1836 |
slave, slave_position); |
|
1837 |
if (ret) |
|
1838 |
return ret; |
|
1839 |
} else { |
|
1840 |
return -1; |
|
1841 |
} |
|
1842 |
} |
|
1998
0330fdcbdd1f
Use ESC port order (0-3-1-2) for bus topology and DC delay calculation
Martin Troxler <ch1010277@ch10pc446>
parents:
1995
diff
changeset
|
1843 |
switch (i) |
0330fdcbdd1f
Use ESC port order (0-3-1-2) for bus topology and DC delay calculation
Martin Troxler <ch1010277@ch10pc446>
parents:
1995
diff
changeset
|
1844 |
{ |
0330fdcbdd1f
Use ESC port order (0-3-1-2) for bus topology and DC delay calculation
Martin Troxler <ch1010277@ch10pc446>
parents:
1995
diff
changeset
|
1845 |
case 0: i = 3; break; |
0330fdcbdd1f
Use ESC port order (0-3-1-2) for bus topology and DC delay calculation
Martin Troxler <ch1010277@ch10pc446>
parents:
1995
diff
changeset
|
1846 |
case 1: i = 2; break; |
0330fdcbdd1f
Use ESC port order (0-3-1-2) for bus topology and DC delay calculation
Martin Troxler <ch1010277@ch10pc446>
parents:
1995
diff
changeset
|
1847 |
case 3: i = 1; break; |
0330fdcbdd1f
Use ESC port order (0-3-1-2) for bus topology and DC delay calculation
Martin Troxler <ch1010277@ch10pc446>
parents:
1995
diff
changeset
|
1848 |
case 2: |
0330fdcbdd1f
Use ESC port order (0-3-1-2) for bus topology and DC delay calculation
Martin Troxler <ch1010277@ch10pc446>
parents:
1995
diff
changeset
|
1849 |
default:i = 0; break; |
0330fdcbdd1f
Use ESC port order (0-3-1-2) for bus topology and DC delay calculation
Martin Troxler <ch1010277@ch10pc446>
parents:
1995
diff
changeset
|
1850 |
} |
1421 | 1851 |
} |
1852 |
||
1853 |
return 0; |
|
1854 |
} |
|
1855 |
||
1856 |
/*****************************************************************************/ |
|
1857 |
||
1858 |
/** Calculates the bus topology. |
|
1859 |
*/ |
|
1860 |
void ec_master_calc_topology( |
|
1861 |
ec_master_t *master /**< EtherCAT master. */ |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1862 |
) |
1421 | 1863 |
{ |
1864 |
unsigned int slave_position = 0; |
|
1865 |
||
1866 |
if (master->slave_count == 0) |
|
1867 |
return; |
|
1868 |
||
1869 |
if (ec_master_calc_topology_rec(master, NULL, &slave_position)) |
|
1921 | 1870 |
EC_MASTER_ERR(master, "Failed to calculate bus topology.\n"); |
1421 | 1871 |
} |
1872 |
||
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1873 |
/*****************************************************************************/ |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1874 |
|
1426 | 1875 |
/** Calculates the bus transmission delays. |
1876 |
*/ |
|
1877 |
void ec_master_calc_transmission_delays( |
|
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1878 |
ec_master_t *master /**< EtherCAT master. */ |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1879 |
) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1880 |
{ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1881 |
ec_slave_t *slave; |
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1882 |
|
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1883 |
for (slave = master->slaves; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1884 |
slave < master->slaves + master->slave_count; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1885 |
slave++) { |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1886 |
ec_slave_calc_port_delays(slave); |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1887 |
} |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1888 |
|
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1889 |
if (master->dc_ref_clock) { |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1890 |
uint32_t delay = 0; |
1426 | 1891 |
ec_slave_calc_transmission_delays_rec(master->dc_ref_clock, &delay); |
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1892 |
} |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1893 |
} |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1894 |
|
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1895 |
/*****************************************************************************/ |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1896 |
|
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1897 |
/** Distributed-clocks calculations. |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1898 |
*/ |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1899 |
void ec_master_calc_dc( |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1900 |
ec_master_t *master /**< EtherCAT master. */ |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1901 |
) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1902 |
{ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1903 |
// find DC reference clock |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1904 |
ec_master_find_dc_ref_clock(master); |
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1905 |
|
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1906 |
// calculate bus topology |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1907 |
ec_master_calc_topology(master); |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1908 |
|
1426 | 1909 |
ec_master_calc_transmission_delays(master); |
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1910 |
} |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1911 |
|
1925
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1912 |
/*****************************************************************************/ |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1913 |
|
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1914 |
/** Request OP state for configured slaves. |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1915 |
*/ |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1916 |
void ec_master_request_op( |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1917 |
ec_master_t *master /**< EtherCAT master. */ |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1918 |
) |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1919 |
{ |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1920 |
unsigned int i; |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1921 |
ec_slave_t *slave; |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1922 |
|
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1923 |
if (!master->active) |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1924 |
return; |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1925 |
|
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1926 |
EC_MASTER_DBG(master, 1, "Requesting OP...\n"); |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1927 |
|
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1928 |
// request OP for all configured slaves |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1929 |
for (i = 0; i < master->slave_count; i++) { |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1930 |
slave = master->slaves + i; |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1931 |
if (slave->config) { |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1932 |
ec_slave_request_state(slave, EC_SLAVE_STATE_OP); |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1933 |
} |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1934 |
} |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1935 |
|
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1936 |
// always set DC reference clock to OP |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1937 |
if (master->dc_ref_clock) { |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1938 |
ec_slave_request_state(master->dc_ref_clock, |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1939 |
EC_SLAVE_STATE_OP); |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1940 |
} |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1941 |
} |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1942 |
|
640
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1943 |
/****************************************************************************** |
1394
e77728ddf0f9
Introduced ecrt_master_sync() for synchronizing slave clocks to reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
1944 |
* Application interface |
640
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1945 |
*****************************************************************************/ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1946 |
|
1332
d62633fea8ed
merge -c1610 branches/stable-1.4: Added missing doxygen docs.
Florian Pose <fp@igh-essen.com>
parents:
1329
diff
changeset
|
1947 |
/** Same as ecrt_master_create_domain(), but with ERR_PTR() return value. |
d62633fea8ed
merge -c1610 branches/stable-1.4: Added missing doxygen docs.
Florian Pose <fp@igh-essen.com>
parents:
1329
diff
changeset
|
1948 |
*/ |
1312
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
1949 |
ec_domain_t *ecrt_master_create_domain_err( |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
1950 |
ec_master_t *master /**< master */ |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
1951 |
) |
640
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1952 |
{ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1953 |
ec_domain_t *domain, *last_domain; |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1954 |
unsigned int index; |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1955 |
|
1921 | 1956 |
EC_MASTER_DBG(master, 1, "ecrt_master_create_domain(master = 0x%p)\n", |
1957 |
master); |
|
1181
9e5954a2a46e
Added debugging for configuration function of the application interface.
Florian Pose <fp@igh-essen.com>
parents:
1178
diff
changeset
|
1958 |
|
2107
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
1959 |
if (!(domain = |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
1960 |
(ec_domain_t *) kmalloc(sizeof(ec_domain_t), GFP_KERNEL))) { |
1921 | 1961 |
EC_MASTER_ERR(master, "Error allocating domain memory!\n"); |
1312
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
1962 |
return ERR_PTR(-ENOMEM); |
640
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1963 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1964 |
|
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
1965 |
ec_mutex_lock(&master->master_mutex); |
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
|
1966 |
|
993
8c32564252fd
Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents:
992
diff
changeset
|
1967 |
if (list_empty(&master->domains)) { |
8c32564252fd
Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents:
992
diff
changeset
|
1968 |
index = 0; |
8c32564252fd
Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents:
992
diff
changeset
|
1969 |
} else { |
640
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1970 |
last_domain = list_entry(master->domains.prev, ec_domain_t, list); |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1971 |
index = last_domain->index + 1; |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1972 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1973 |
|
993
8c32564252fd
Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents:
992
diff
changeset
|
1974 |
ec_domain_init(domain, master, index); |
640
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1975 |
list_add_tail(&domain->list, &master->domains); |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1976 |
|
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
1977 |
ec_mutex_unlock(&master->master_mutex); |
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
|
1978 |
|
1921 | 1979 |
EC_MASTER_DBG(master, 1, "Created domain %u.\n", domain->index); |
1181
9e5954a2a46e
Added debugging for configuration function of the application interface.
Florian Pose <fp@igh-essen.com>
parents:
1178
diff
changeset
|
1980 |
|
640
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1981 |
return domain; |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1982 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1983 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1984 |
/*****************************************************************************/ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1985 |
|
1312
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
1986 |
ec_domain_t *ecrt_master_create_domain( |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
1987 |
ec_master_t *master /**< master */ |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
1988 |
) |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
1989 |
{ |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
1990 |
ec_domain_t *d = ecrt_master_create_domain_err(master); |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
1991 |
return IS_ERR(d) ? NULL : d; |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
1992 |
} |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
1993 |
|
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
1994 |
/*****************************************************************************/ |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
1995 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1996 |
int ecrt_master_activate(ec_master_t *master) |
640
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1997 |
{ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1998 |
uint32_t domain_offset; |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1999 |
ec_domain_t *domain; |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
2000 |
int ret; |
640
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2001 |
|
1921 | 2002 |
EC_MASTER_DBG(master, 1, "ecrt_master_activate(master = 0x%p)\n", master); |
1181
9e5954a2a46e
Added debugging for configuration function of the application interface.
Florian Pose <fp@igh-essen.com>
parents:
1178
diff
changeset
|
2003 |
|
1530
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2004 |
if (master->active) { |
1921 | 2005 |
EC_MASTER_WARN(master, "%s: Master already active!\n", __func__); |
1530
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2006 |
return 0; |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2007 |
} |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2008 |
|
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
2009 |
ec_mutex_lock(&master->master_mutex); |
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
|
2010 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2011 |
// finish all domains |
640
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2012 |
domain_offset = 0; |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2013 |
list_for_each_entry(domain, &master->domains, list) { |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
2014 |
ret = ec_domain_finish(domain, domain_offset); |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
2015 |
if (ret < 0) { |
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
2016 |
ec_mutex_unlock(&master->master_mutex); |
1921 | 2017 |
EC_MASTER_ERR(master, "Failed to finish domain 0x%p!\n", domain); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
2018 |
return ret; |
640
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2019 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2020 |
domain_offset += domain->data_size; |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2021 |
} |
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
|
2022 |
|
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
2023 |
ec_mutex_unlock(&master->master_mutex); |
640
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2024 |
|
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
2025 |
// restart EoE process and master thread with new locking |
1914
da7adbde2625
Fixed possible bug in EoE code: Only restart EoE process, when it was running
Florian Pose <fp@igh-essen.com>
parents:
1909
diff
changeset
|
2026 |
|
da7adbde2625
Fixed possible bug in EoE code: Only restart EoE process, when it was running
Florian Pose <fp@igh-essen.com>
parents:
1909
diff
changeset
|
2027 |
ec_master_thread_stop(master); |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
2028 |
|
1921 | 2029 |
EC_MASTER_DBG(master, 1, "FSM datagram is %p.\n", &master->fsm_datagram); |
640
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2030 |
|
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
2031 |
master->injection_seq_fsm = 0; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
2032 |
master->injection_seq_rt = 0; |
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
2033 |
|
2024
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
2034 |
master->fsm_queue_lock_cb = master->app_fsm_queue_lock_cb; |
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
2035 |
master->fsm_queue_unlock_cb = master->app_fsm_queue_unlock_cb; |
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
2036 |
master->fsm_queue_locking_data = master->app_fsm_queue_locking_data; |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
2037 |
|
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
2038 |
ret = ec_master_thread_start(master, ec_master_operation_thread, |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
2039 |
"EtherCAT-OP"); |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
2040 |
if (ret < 0) { |
1921 | 2041 |
EC_MASTER_ERR(master, "Failed to start master thread!\n"); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
2042 |
return ret; |
640
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2043 |
} |
902
ad703091a32b
Moved setting of the allow flags.
Florian Pose <fp@igh-essen.com>
parents:
901
diff
changeset
|
2044 |
|
2270
51d2b26a5d1c
Fixed reset of allow_scanning flag if ecrt_master_activate() was not called.
Florian Pose <fp@igh-essen.com>
parents:
2249
diff
changeset
|
2045 |
/* Allow scanning after a topology change. */ |
51d2b26a5d1c
Fixed reset of allow_scanning flag if ecrt_master_activate() was not called.
Florian Pose <fp@igh-essen.com>
parents:
2249
diff
changeset
|
2046 |
master->allow_scan = 1; |
51d2b26a5d1c
Fixed reset of allow_scanning flag if ecrt_master_activate() was not called.
Florian Pose <fp@igh-essen.com>
parents:
2249
diff
changeset
|
2047 |
|
1530
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2048 |
master->active = 1; |
1925
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
2049 |
|
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
2050 |
// notify state machine, that the configuration shall now be applied |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
2051 |
master->config_changed = 1; |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
2052 |
|
640
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2053 |
return 0; |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2054 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2055 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2056 |
/*****************************************************************************/ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2057 |
|
1530
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2058 |
void ecrt_master_deactivate(ec_master_t *master) |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2059 |
{ |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2060 |
ec_slave_t *slave; |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2061 |
#ifdef EC_EOE |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2062 |
ec_eoe_t *eoe; |
2036
7fbc7bb7b95a
properly deactivate slaves if there is no eoe slave
Matthias Luescher <ch1010472@ch10pc594>
parents:
2032
diff
changeset
|
2063 |
int is_eoe_slave; |
1530
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2064 |
#endif |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2065 |
|
1939
1ba48f78a0a5
Fixed bug that caused the configuration not to be cleared when reserved but
Florian Pose <fp@igh-essen.com>
parents:
1930
diff
changeset
|
2066 |
EC_MASTER_DBG(master, 1, "%s(master = 0x%p)\n", __func__, master); |
1530
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2067 |
|
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2068 |
if (!master->active) { |
1921 | 2069 |
EC_MASTER_WARN(master, "%s: Master not active.\n", __func__); |
1530
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2070 |
return; |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2071 |
} |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2072 |
|
1914
da7adbde2625
Fixed possible bug in EoE code: Only restart EoE process, when it was running
Florian Pose <fp@igh-essen.com>
parents:
1909
diff
changeset
|
2073 |
ec_master_thread_stop(master); |
1530
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2074 |
|
2024
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
2075 |
master->fsm_queue_lock_cb = NULL; |
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
2076 |
master->fsm_queue_unlock_cb= NULL; |
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
2077 |
master->fsm_queue_locking_data = NULL; |
1530
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2078 |
|
1939
1ba48f78a0a5
Fixed bug that caused the configuration not to be cleared when reserved but
Florian Pose <fp@igh-essen.com>
parents:
1930
diff
changeset
|
2079 |
ec_master_clear_config(master); |
1530
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2080 |
|
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2081 |
for (slave = master->slaves; |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2082 |
slave < master->slaves + master->slave_count; |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2083 |
slave++) { |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2084 |
|
2020
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
2085 |
// set state to PREOP for all but eoe slaves |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
2086 |
#ifdef EC_EOE |
2036
7fbc7bb7b95a
properly deactivate slaves if there is no eoe slave
Matthias Luescher <ch1010472@ch10pc594>
parents:
2032
diff
changeset
|
2087 |
is_eoe_slave = 0; |
2020
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
2088 |
// ... but leave EoE slaves in OP |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
2089 |
list_for_each_entry(eoe, &master->eoe_handlers, list) { |
2036
7fbc7bb7b95a
properly deactivate slaves if there is no eoe slave
Matthias Luescher <ch1010472@ch10pc594>
parents:
2032
diff
changeset
|
2090 |
if (slave == eoe->slave && ec_eoe_is_open(eoe)) |
7fbc7bb7b95a
properly deactivate slaves if there is no eoe slave
Matthias Luescher <ch1010472@ch10pc594>
parents:
2032
diff
changeset
|
2091 |
is_eoe_slave = 1; |
7fbc7bb7b95a
properly deactivate slaves if there is no eoe slave
Matthias Luescher <ch1010472@ch10pc594>
parents:
2032
diff
changeset
|
2092 |
} |
7fbc7bb7b95a
properly deactivate slaves if there is no eoe slave
Matthias Luescher <ch1010472@ch10pc594>
parents:
2032
diff
changeset
|
2093 |
if (!is_eoe_slave) { |
7fbc7bb7b95a
properly deactivate slaves if there is no eoe slave
Matthias Luescher <ch1010472@ch10pc594>
parents:
2032
diff
changeset
|
2094 |
ec_slave_request_state(slave, EC_SLAVE_STATE_PREOP); |
7fbc7bb7b95a
properly deactivate slaves if there is no eoe slave
Matthias Luescher <ch1010472@ch10pc594>
parents:
2032
diff
changeset
|
2095 |
// mark for reconfiguration, because the master could have no |
2107
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2096 |
// possibility for a reconfiguration between two sequential |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2097 |
// operation phases. |
2036
7fbc7bb7b95a
properly deactivate slaves if there is no eoe slave
Matthias Luescher <ch1010472@ch10pc594>
parents:
2032
diff
changeset
|
2098 |
slave->force_config = 1; |
2020
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
2099 |
} |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
2100 |
#else |
1530
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2101 |
ec_slave_request_state(slave, EC_SLAVE_STATE_PREOP); |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2102 |
// mark for reconfiguration, because the master could have no |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2103 |
// possibility for a reconfiguration between two sequential operation |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2104 |
// phases. |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2105 |
slave->force_config = 1; |
2020
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
2106 |
#endif |
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
2107 |
|
47db5df5c7b3
removed eoe thread: eoe processing now done by Idle/Operation thread
Martin Troxler <ch1010277@ch10pc446>
parents:
2019
diff
changeset
|
2108 |
} |
1530
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2109 |
|
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2110 |
master->app_time = 0ULL; |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2111 |
master->app_start_time = 0ULL; |
1925
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
2112 |
master->has_app_time = 0; |
1530
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2113 |
|
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2114 |
if (ec_master_thread_start(master, ec_master_idle_thread, |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2115 |
"EtherCAT-IDLE")) |
1921 | 2116 |
EC_MASTER_WARN(master, "Failed to restart master thread!\n"); |
1530
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2117 |
|
2270
51d2b26a5d1c
Fixed reset of allow_scanning flag if ecrt_master_activate() was not called.
Florian Pose <fp@igh-essen.com>
parents:
2249
diff
changeset
|
2118 |
/* Disallow scanning to get into the same state like after a master |
51d2b26a5d1c
Fixed reset of allow_scanning flag if ecrt_master_activate() was not called.
Florian Pose <fp@igh-essen.com>
parents:
2249
diff
changeset
|
2119 |
* request (after ec_master_enter_operation_phase() is called). */ |
51d2b26a5d1c
Fixed reset of allow_scanning flag if ecrt_master_activate() was not called.
Florian Pose <fp@igh-essen.com>
parents:
2249
diff
changeset
|
2120 |
master->allow_scan = 0; |
51d2b26a5d1c
Fixed reset of allow_scanning flag if ecrt_master_activate() was not called.
Florian Pose <fp@igh-essen.com>
parents:
2249
diff
changeset
|
2121 |
|
1530
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2122 |
master->active = 0; |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2123 |
} |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2124 |
|
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2125 |
/*****************************************************************************/ |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2126 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2127 |
void ecrt_master_send(ec_master_t *master) |
640
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2128 |
{ |
2039
629d3cf05180
Minor changes (consistent variable naming)
Martin Troxler <ch1010277@ch10pc446>
parents:
2038
diff
changeset
|
2129 |
ec_datagram_t *datagram, *next; |
640
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2130 |
|
2018
6c05411fee9b
replaced injection_seq mechanism with fsm datagram queue
Martin Troxler <ch1010277@ch10pc446>
parents:
2017
diff
changeset
|
2131 |
ec_master_inject_fsm_datagrams(master); |
640
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2132 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2133 |
if (unlikely(!master->main_device.link_state)) { |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2134 |
// link is down, no datagram can be sent |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
2135 |
list_for_each_entry_safe(datagram, next, &master->datagram_queue, |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2084
diff
changeset
|
2136 |
queue) { |
640
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2137 |
datagram->state = EC_DATAGRAM_ERROR; |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2138 |
list_del_init(&datagram->queue); |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2139 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2140 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2141 |
// query link state |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2142 |
ec_device_poll(&master->main_device); |
1856
10175d5f35ea
Fixed clearing frame statistics on link down.
Florian Pose <fp@igh-essen.com>
parents:
1848
diff
changeset
|
2143 |
|
10175d5f35ea
Fixed clearing frame statistics on link down.
Florian Pose <fp@igh-essen.com>
parents:
1848
diff
changeset
|
2144 |
// clear frame statistics |
10175d5f35ea
Fixed clearing frame statistics on link down.
Florian Pose <fp@igh-essen.com>
parents:
1848
diff
changeset
|
2145 |
ec_device_clear_stats(&master->main_device); |
640
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2146 |
return; |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2147 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2148 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2149 |
// send frames |
1804 | 2150 |
ec_master_send_datagrams(master); |
640
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2151 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2152 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2153 |
/*****************************************************************************/ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2154 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2155 |
void ecrt_master_receive(ec_master_t *master) |
640
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2156 |
{ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2157 |
ec_datagram_t *datagram, *next; |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2158 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2159 |
// receive datagrams |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2160 |
ec_device_poll(&master->main_device); |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2161 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2162 |
// dequeue all datagrams that timed out |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2163 |
list_for_each_entry_safe(datagram, next, &master->datagram_queue, queue) { |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2164 |
if (datagram->state != EC_DATAGRAM_SENT) continue; |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2165 |
|
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
2166 |
#ifdef EC_HAVE_CYCLES |
640
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2167 |
if (master->main_device.cycles_poll - datagram->cycles_sent |
1279
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
2168 |
> timeout_cycles) { |
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
2169 |
#else |
1279
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
2170 |
if (master->main_device.jiffies_poll - datagram->jiffies_sent |
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
2171 |
> timeout_jiffies) { |
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
2172 |
#endif |
640
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2173 |
list_del_init(&datagram->queue); |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2174 |
datagram->state = EC_DATAGRAM_TIMED_OUT; |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2175 |
master->stats.timeouts++; |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2176 |
ec_master_output_stats(master); |
684
bf991809dcf0
Added debugging output for unmatched frames and those that timed out.
Florian Pose <fp@igh-essen.com>
parents:
664
diff
changeset
|
2177 |
|
bf991809dcf0
Added debugging output for unmatched frames and those that timed out.
Florian Pose <fp@igh-essen.com>
parents:
664
diff
changeset
|
2178 |
if (unlikely(master->debug_level > 0)) { |
1237
33e8349b44bd
Avoided using #ifdef inside a macro.
Florian Pose <fp@igh-essen.com>
parents:
1209
diff
changeset
|
2179 |
unsigned int time_us; |
33e8349b44bd
Avoided using #ifdef inside a macro.
Florian Pose <fp@igh-essen.com>
parents:
1209
diff
changeset
|
2180 |
#ifdef EC_HAVE_CYCLES |
33e8349b44bd
Avoided using #ifdef inside a macro.
Florian Pose <fp@igh-essen.com>
parents:
1209
diff
changeset
|
2181 |
time_us = (unsigned int) (master->main_device.cycles_poll - |
33e8349b44bd
Avoided using #ifdef inside a macro.
Florian Pose <fp@igh-essen.com>
parents:
1209
diff
changeset
|
2182 |
datagram->cycles_sent) * 1000 / cpu_khz; |
33e8349b44bd
Avoided using #ifdef inside a macro.
Florian Pose <fp@igh-essen.com>
parents:
1209
diff
changeset
|
2183 |
#else |
1279
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
2184 |
time_us = (unsigned int) ((master->main_device.jiffies_poll - |
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
2185 |
datagram->jiffies_sent) * 1000000 / HZ); |
1237
33e8349b44bd
Avoided using #ifdef inside a macro.
Florian Pose <fp@igh-essen.com>
parents:
1209
diff
changeset
|
2186 |
#endif |
1921 | 2187 |
EC_MASTER_DBG(master, 0, "TIMED OUT datagram %p," |
2188 |
" index %02X waited %u us.\n", |
|
1543
373cd456dc26
Avoid warnings on x86_64 platform. Thanks to Thomas Elste.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2189 |
datagram, datagram->index, time_us); |
684
bf991809dcf0
Added debugging output for unmatched frames and those that timed out.
Florian Pose <fp@igh-essen.com>
parents:
664
diff
changeset
|
2190 |
} |
640
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2191 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2192 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2193 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2194 |
|
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
2195 |
|
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
2196 |
/*****************************************************************************/ |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
2197 |
|
1332
d62633fea8ed
merge -c1610 branches/stable-1.4: Added missing doxygen docs.
Florian Pose <fp@igh-essen.com>
parents:
1329
diff
changeset
|
2198 |
/** Same as ecrt_master_slave_config(), but with ERR_PTR() return value. |
d62633fea8ed
merge -c1610 branches/stable-1.4: Added missing doxygen docs.
Florian Pose <fp@igh-essen.com>
parents:
1329
diff
changeset
|
2199 |
*/ |
1312
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
2200 |
ec_slave_config_t *ecrt_master_slave_config_err(ec_master_t *master, |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2201 |
uint16_t alias, uint16_t position, uint32_t vendor_id, |
1010
6672b86e7b10
Reverted revision number checking from r1228.
Florian Pose <fp@igh-essen.com>
parents:
1009
diff
changeset
|
2202 |
uint32_t product_code) |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2203 |
{ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2204 |
ec_slave_config_t *sc; |
697
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
2205 |
unsigned int found = 0; |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
2206 |
|
1181
9e5954a2a46e
Added debugging for configuration function of the application interface.
Florian Pose <fp@igh-essen.com>
parents:
1178
diff
changeset
|
2207 |
|
1921 | 2208 |
EC_MASTER_DBG(master, 1, "ecrt_master_slave_config(master = 0x%p," |
2209 |
" alias = %u, position = %u, vendor_id = 0x%08x," |
|
2210 |
" product_code = 0x%08x)\n", |
|
2211 |
master, alias, position, vendor_id, product_code); |
|
1181
9e5954a2a46e
Added debugging for configuration function of the application interface.
Florian Pose <fp@igh-essen.com>
parents:
1178
diff
changeset
|
2212 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2213 |
list_for_each_entry(sc, &master->configs, list) { |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2214 |
if (sc->alias == alias && sc->position == position) { |
697
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
2215 |
found = 1; |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
2216 |
break; |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
2217 |
} |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
2218 |
} |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
2219 |
|
1024 | 2220 |
if (found) { // config with same alias/position already existing |
1010
6672b86e7b10
Reverted revision number checking from r1228.
Florian Pose <fp@igh-essen.com>
parents:
1009
diff
changeset
|
2221 |
if (sc->vendor_id != vendor_id || sc->product_code != product_code) { |
1921 | 2222 |
EC_MASTER_ERR(master, "Slave type mismatch. Slave was" |
2223 |
" configured as 0x%08X/0x%08X before. Now configuring" |
|
2224 |
" with 0x%08X/0x%08X.\n", sc->vendor_id, sc->product_code, |
|
1010
6672b86e7b10
Reverted revision number checking from r1228.
Florian Pose <fp@igh-essen.com>
parents:
1009
diff
changeset
|
2225 |
vendor_id, product_code); |
1312
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
2226 |
return ERR_PTR(-ENOENT); |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2227 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2228 |
} else { |
1921 | 2229 |
EC_MASTER_DBG(master, 1, "Creating slave configuration for %u:%u," |
2230 |
" 0x%08X/0x%08X.\n", |
|
2231 |
alias, position, vendor_id, product_code); |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2232 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2233 |
if (!(sc = (ec_slave_config_t *) kmalloc(sizeof(ec_slave_config_t), |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2234 |
GFP_KERNEL))) { |
1921 | 2235 |
EC_MASTER_ERR(master, "Failed to allocate memory" |
2236 |
" for slave configuration.\n"); |
|
1312
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
2237 |
return ERR_PTR(-ENOMEM); |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2238 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2239 |
|
995
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
994
diff
changeset
|
2240 |
ec_slave_config_init(sc, master, |
1010
6672b86e7b10
Reverted revision number checking from r1228.
Florian Pose <fp@igh-essen.com>
parents:
1009
diff
changeset
|
2241 |
alias, position, vendor_id, product_code); |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2242 |
|
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
2243 |
ec_mutex_lock(&master->master_mutex); |
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
|
2244 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2245 |
// try to find the addressed slave |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1047
diff
changeset
|
2246 |
ec_slave_config_attach(sc); |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1047
diff
changeset
|
2247 |
ec_slave_config_load_default_sync_config(sc); |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2248 |
list_add_tail(&sc->list, &master->configs); |
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
|
2249 |
|
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
2250 |
ec_mutex_unlock(&master->master_mutex); |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2251 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2252 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2253 |
return sc; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2254 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2255 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2256 |
/*****************************************************************************/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2257 |
|
1312
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
2258 |
ec_slave_config_t *ecrt_master_slave_config(ec_master_t *master, |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
2259 |
uint16_t alias, uint16_t position, uint32_t vendor_id, |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
2260 |
uint32_t product_code) |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
2261 |
{ |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
2262 |
ec_slave_config_t *sc = ecrt_master_slave_config_err(master, alias, |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
2263 |
position, vendor_id, product_code); |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
2264 |
return IS_ERR(sc) ? NULL : sc; |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
2265 |
} |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
2266 |
|
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
2267 |
/*****************************************************************************/ |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
2268 |
|
1594
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2269 |
int ecrt_master(ec_master_t *master, ec_master_info_t *master_info) |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2270 |
{ |
1921 | 2271 |
EC_MASTER_DBG(master, 1, "ecrt_master(master = 0x%p," |
2272 |
" master_info = 0x%p)\n", master, master_info); |
|
1594
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2273 |
|
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2274 |
master_info->slave_count = master->slave_count; |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2275 |
master_info->link_up = master->main_device.link_state; |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2276 |
master_info->scan_busy = master->scan_busy; |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2277 |
master_info->app_time = master->app_time; |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2278 |
return 0; |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2279 |
} |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2280 |
|
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2281 |
/*****************************************************************************/ |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2282 |
|
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2283 |
int ecrt_master_get_slave(ec_master_t *master, uint16_t slave_position, |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2284 |
ec_slave_info_t *slave_info) |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2285 |
{ |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2286 |
const ec_slave_t *slave; |
2249
6dbd7594dd1d
Copy missing slave_info data in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
2240
diff
changeset
|
2287 |
unsigned int i; |
1594
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2288 |
|
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
2289 |
if (ec_mutex_lock_interruptible(&master->master_mutex)) { |
1594
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2290 |
return -EINTR; |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2291 |
} |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2292 |
|
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2293 |
slave = ec_master_find_slave_const(master, 0, slave_position); |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2294 |
|
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2295 |
slave_info->position = slave->ring_position; |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2296 |
slave_info->vendor_id = slave->sii.vendor_id; |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2297 |
slave_info->product_code = slave->sii.product_code; |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2298 |
slave_info->revision_number = slave->sii.revision_number; |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2299 |
slave_info->serial_number = slave->sii.serial_number; |
1909
ea3eb4c74c1b
Introduced effective_alias variable to separate reg12 alias from SII alias.
Florian Pose <fp@igh-essen.com>
parents:
1906
diff
changeset
|
2300 |
slave_info->alias = slave->effective_alias; |
1594
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2301 |
slave_info->current_on_ebus = slave->sii.current_on_ebus; |
2249
6dbd7594dd1d
Copy missing slave_info data in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
2240
diff
changeset
|
2302 |
|
6dbd7594dd1d
Copy missing slave_info data in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
2240
diff
changeset
|
2303 |
for (i = 0; i < EC_MAX_PORTS; i++) { |
6dbd7594dd1d
Copy missing slave_info data in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
2240
diff
changeset
|
2304 |
slave_info->ports[i].desc = slave->ports[i].desc; |
6dbd7594dd1d
Copy missing slave_info data in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
2240
diff
changeset
|
2305 |
slave_info->ports[i].link.link_up = slave->ports[i].link.link_up; |
6dbd7594dd1d
Copy missing slave_info data in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
2240
diff
changeset
|
2306 |
slave_info->ports[i].link.loop_closed = |
6dbd7594dd1d
Copy missing slave_info data in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
2240
diff
changeset
|
2307 |
slave->ports[i].link.loop_closed; |
6dbd7594dd1d
Copy missing slave_info data in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
2240
diff
changeset
|
2308 |
slave_info->ports[i].link.signal_detected = |
6dbd7594dd1d
Copy missing slave_info data in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
2240
diff
changeset
|
2309 |
slave->ports[i].link.signal_detected; |
6dbd7594dd1d
Copy missing slave_info data in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
2240
diff
changeset
|
2310 |
slave_info->ports[i].receive_time = slave->ports[i].receive_time; |
6dbd7594dd1d
Copy missing slave_info data in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
2240
diff
changeset
|
2311 |
if (slave->ports[i].next_slave) { |
6dbd7594dd1d
Copy missing slave_info data in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
2240
diff
changeset
|
2312 |
slave_info->ports[i].next_slave = |
6dbd7594dd1d
Copy missing slave_info data in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
2240
diff
changeset
|
2313 |
slave->ports[i].next_slave->ring_position; |
6dbd7594dd1d
Copy missing slave_info data in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
2240
diff
changeset
|
2314 |
} else { |
6dbd7594dd1d
Copy missing slave_info data in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
2240
diff
changeset
|
2315 |
slave_info->ports[i].next_slave = 0xffff; |
6dbd7594dd1d
Copy missing slave_info data in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
2240
diff
changeset
|
2316 |
} |
6dbd7594dd1d
Copy missing slave_info data in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
2240
diff
changeset
|
2317 |
slave_info->ports[i].delay_to_next_dc = |
6dbd7594dd1d
Copy missing slave_info data in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
2240
diff
changeset
|
2318 |
slave->ports[i].delay_to_next_dc; |
6dbd7594dd1d
Copy missing slave_info data in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
2240
diff
changeset
|
2319 |
} |
6dbd7594dd1d
Copy missing slave_info data in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
2240
diff
changeset
|
2320 |
|
1594
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2321 |
slave_info->al_state = slave->current_state; |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2322 |
slave_info->error_flag = slave->error_flag; |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2323 |
slave_info->sync_count = slave->sii.sync_count; |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2324 |
slave_info->sdo_count = ec_slave_sdo_count(slave); |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2325 |
if (slave->sii.name) { |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2326 |
strncpy(slave_info->name, slave->sii.name, EC_MAX_STRING_LENGTH); |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2327 |
} else { |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2328 |
slave_info->name[0] = 0; |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2329 |
} |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2330 |
|
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
2331 |
ec_mutex_unlock(&master->master_mutex); |
1594
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2332 |
|
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2333 |
return 0; |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2334 |
} |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2335 |
|
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2336 |
/*****************************************************************************/ |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2337 |
|
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
2338 |
void ecrt_master_callbacks(ec_master_t *master, |
2024
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
2339 |
void (*lock_cb)(void *), void (*unlock_cb)(void *), |
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
2340 |
void *cb_data) |
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
2341 |
{ |
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
2342 |
EC_MASTER_DBG(master, 1,"ecrt_master_callbacks(master = %p, " |
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
2343 |
"lock_cb = %p, unlock_cb = %p, cb_data = %p)\n", |
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
2344 |
master, lock_cb, unlock_cb, cb_data); |
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
2345 |
|
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
2346 |
master->app_fsm_queue_lock_cb = lock_cb; |
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
2347 |
master->app_fsm_queue_unlock_cb = unlock_cb; |
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
2348 |
master->app_fsm_queue_locking_data = cb_data; |
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
2349 |
} |
96e2ae6cce95
ecrt_master_callbacks: replaced send/receive callback mechanism with locking mechanism; removed ecrt_master_send_ext
Martin Troxler <ch1010277@ch10pc446>
parents:
2022
diff
changeset
|
2350 |
|
204
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
2351 |
|
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
2352 |
/*****************************************************************************/ |
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
2353 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2354 |
void ecrt_master_state(const ec_master_t *master, ec_master_state_t *state) |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2355 |
{ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2356 |
state->slaves_responding = master->fsm.slaves_responding; |
1022
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
1018
diff
changeset
|
2357 |
state->al_states = master->fsm.slave_states; |
1018
e068da25639d
Completed master states.
Richard Hacker <ha@igh-essen.com>
parents:
1015
diff
changeset
|
2358 |
state->link_up = master->main_device.link_state; |
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
2359 |
} |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
2360 |
|
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
2361 |
/*****************************************************************************/ |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
2362 |
|
2107
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2363 |
void ecrt_master_configured_slaves_state( |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2364 |
const ec_master_t *master, |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2365 |
ec_master_state_t *state |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2366 |
) |
1978
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1856
diff
changeset
|
2367 |
{ |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1856
diff
changeset
|
2368 |
const ec_slave_config_t *sc; |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1856
diff
changeset
|
2369 |
ec_slave_config_state_t sc_state; |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1856
diff
changeset
|
2370 |
|
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1856
diff
changeset
|
2371 |
// collect al_states of all configured online slaves |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1856
diff
changeset
|
2372 |
state->al_states = 0; |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1856
diff
changeset
|
2373 |
list_for_each_entry(sc, &master->configs, list) { |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1856
diff
changeset
|
2374 |
ecrt_slave_config_state(sc,&sc_state); |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1856
diff
changeset
|
2375 |
if (sc_state.online) |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1856
diff
changeset
|
2376 |
state->al_states |= sc_state.al_state; |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1856
diff
changeset
|
2377 |
} |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1856
diff
changeset
|
2378 |
|
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1856
diff
changeset
|
2379 |
state->slaves_responding = master->fsm.slaves_responding; |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1856
diff
changeset
|
2380 |
state->link_up = master->main_device.link_state; |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1856
diff
changeset
|
2381 |
} |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1856
diff
changeset
|
2382 |
|
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1856
diff
changeset
|
2383 |
/*****************************************************************************/ |
d9b6e641eaeb
added API ecrt_master_configured_slaves_state
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1856
diff
changeset
|
2384 |
|
1434
4c6fe0ae37f1
Separated application time from synchronizing reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1426
diff
changeset
|
2385 |
void ecrt_master_application_time(ec_master_t *master, uint64_t app_time) |
1417
7c2d5d69134c
Replaced timeval by 64-bit EtherCAT time.
Florian Pose <fp@igh-essen.com>
parents:
1415
diff
changeset
|
2386 |
{ |
7c2d5d69134c
Replaced timeval by 64-bit EtherCAT time.
Florian Pose <fp@igh-essen.com>
parents:
1415
diff
changeset
|
2387 |
master->app_time = app_time; |
1436
08eaf72409bb
Use application start time as a common reference for cyclic generation
Florian Pose <fp@igh-essen.com>
parents:
1434
diff
changeset
|
2388 |
|
1925
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
2389 |
if (unlikely(!master->has_app_time)) { |
2107
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2390 |
EC_MASTER_DBG(master, 1, "Set application start time = %llu\n", |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2391 |
app_time); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2392 |
master->app_start_time = app_time; |
1999
5f1269a71588
use app_start_time for initial DC offset calculation because app_time might be overwritten while calculating the offsets.
Martin Troxler <ch1010277@ch10pc446>
parents:
1998
diff
changeset
|
2393 |
#ifdef EC_HAVE_CYCLES |
2107
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2394 |
master->dc_cycles_app_start_time = get_cycles(); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2395 |
#endif |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2396 |
master->dc_jiffies_app_start_time = jiffies; |
1925
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
2397 |
master->has_app_time = 1; |
1436
08eaf72409bb
Use application start time as a common reference for cyclic generation
Florian Pose <fp@igh-essen.com>
parents:
1434
diff
changeset
|
2398 |
} |
1434
4c6fe0ae37f1
Separated application time from synchronizing reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1426
diff
changeset
|
2399 |
} |
4c6fe0ae37f1
Separated application time from synchronizing reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1426
diff
changeset
|
2400 |
|
4c6fe0ae37f1
Separated application time from synchronizing reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1426
diff
changeset
|
2401 |
/*****************************************************************************/ |
4c6fe0ae37f1
Separated application time from synchronizing reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1426
diff
changeset
|
2402 |
|
4c6fe0ae37f1
Separated application time from synchronizing reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1426
diff
changeset
|
2403 |
void ecrt_master_sync_reference_clock(ec_master_t *master) |
4c6fe0ae37f1
Separated application time from synchronizing reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1426
diff
changeset
|
2404 |
{ |
1396
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1394
diff
changeset
|
2405 |
EC_WRITE_U32(master->ref_sync_datagram.data, master->app_time); |
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1394
diff
changeset
|
2406 |
ec_master_queue_datagram(master, &master->ref_sync_datagram); |
1410
fb6719008bf5
Separated sync_reference_clock() and sync_slave_clocks().
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
2407 |
} |
fb6719008bf5
Separated sync_reference_clock() and sync_slave_clocks().
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
2408 |
|
fb6719008bf5
Separated sync_reference_clock() and sync_slave_clocks().
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
2409 |
/*****************************************************************************/ |
fb6719008bf5
Separated sync_reference_clock() and sync_slave_clocks().
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
2410 |
|
fb6719008bf5
Separated sync_reference_clock() and sync_slave_clocks().
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
2411 |
void ecrt_master_sync_slave_clocks(ec_master_t *master) |
fb6719008bf5
Separated sync_reference_clock() and sync_slave_clocks().
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
2412 |
{ |
1394
e77728ddf0f9
Introduced ecrt_master_sync() for synchronizing slave clocks to reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
2413 |
ec_datagram_zero(&master->sync_datagram); |
e77728ddf0f9
Introduced ecrt_master_sync() for synchronizing slave clocks to reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
2414 |
ec_master_queue_datagram(master, &master->sync_datagram); |
e77728ddf0f9
Introduced ecrt_master_sync() for synchronizing slave clocks to reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
2415 |
} |
e77728ddf0f9
Introduced ecrt_master_sync() for synchronizing slave clocks to reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
2416 |
|
e77728ddf0f9
Introduced ecrt_master_sync() for synchronizing slave clocks to reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
2417 |
/*****************************************************************************/ |
e77728ddf0f9
Introduced ecrt_master_sync() for synchronizing slave clocks to reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
2418 |
|
1535
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2419 |
void ecrt_master_sync_monitor_queue(ec_master_t *master) |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2420 |
{ |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2421 |
ec_datagram_zero(&master->sync_mon_datagram); |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2422 |
ec_master_queue_datagram(master, &master->sync_mon_datagram); |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2423 |
} |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2424 |
|
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2425 |
/*****************************************************************************/ |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2426 |
|
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2427 |
uint32_t ecrt_master_sync_monitor_process(ec_master_t *master) |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2428 |
{ |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2429 |
if (master->sync_mon_datagram.state == EC_DATAGRAM_RECEIVED) { |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2430 |
return EC_READ_U32(master->sync_mon_datagram.data) & 0x7fffffff; |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2431 |
} else { |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2432 |
return 0xffffffff; |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2433 |
} |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2434 |
} |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2435 |
|
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2436 |
/*****************************************************************************/ |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2437 |
|
2107
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2438 |
int ecrt_master_sdo_download(ec_master_t *master, uint16_t slave_position, |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2439 |
uint16_t index, uint8_t subindex, uint8_t *data, |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2440 |
size_t data_size, uint32_t *abort_code) |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2441 |
{ |
2164
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2442 |
ec_master_sdo_request_t *request; |
2107
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2443 |
int retval; |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2444 |
|
2110
455126b35650
Fixed compiler error; added SDO debugging.
Florian Pose <fp@igh-essen.com>
parents:
2107
diff
changeset
|
2445 |
EC_MASTER_DBG(master, 1, "%s(master = 0x%p," |
455126b35650
Fixed compiler error; added SDO debugging.
Florian Pose <fp@igh-essen.com>
parents:
2107
diff
changeset
|
2446 |
" slave_position = %u, index = 0x%04X, subindex = 0x%02X," |
455126b35650
Fixed compiler error; added SDO debugging.
Florian Pose <fp@igh-essen.com>
parents:
2107
diff
changeset
|
2447 |
" data = 0x%p, data_size = %zu, abort_code = 0x%p)\n", |
455126b35650
Fixed compiler error; added SDO debugging.
Florian Pose <fp@igh-essen.com>
parents:
2107
diff
changeset
|
2448 |
__func__, master, slave_position, index, subindex, |
455126b35650
Fixed compiler error; added SDO debugging.
Florian Pose <fp@igh-essen.com>
parents:
2107
diff
changeset
|
2449 |
data, data_size, abort_code); |
455126b35650
Fixed compiler error; added SDO debugging.
Florian Pose <fp@igh-essen.com>
parents:
2107
diff
changeset
|
2450 |
|
2107
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2451 |
if (!data_size) { |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2452 |
EC_MASTER_ERR(master, "Zero data size!\n"); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2453 |
return -EINVAL; |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2454 |
} |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2455 |
|
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2456 |
request = kmalloc(sizeof(*request), GFP_KERNEL); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2457 |
if (!request) { |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2458 |
return -ENOMEM; |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2459 |
} |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2460 |
kref_init(&request->refcount); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2461 |
|
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2462 |
ec_sdo_request_init(&request->req); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2463 |
ec_sdo_request_address(&request->req, index, subindex); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2464 |
if (ec_sdo_request_alloc(&request->req, data_size)) { |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2465 |
kref_put(&request->refcount, ec_master_sdo_request_release); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2466 |
return -ENOMEM; |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2467 |
} |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2468 |
memcpy(request->req.data, data, data_size); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2469 |
request->req.data_size = data_size; |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2470 |
ecrt_sdo_request_write(&request->req); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2471 |
|
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2472 |
if (ec_mutex_lock_interruptible(&master->master_mutex)) { |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2473 |
kref_put(&request->refcount, ec_master_sdo_request_release); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2474 |
return -EINTR; |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2475 |
} |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2476 |
|
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2477 |
if (!(request->slave = ec_master_find_slave( |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2478 |
master, 0, slave_position))) { |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2479 |
ec_mutex_unlock(&master->master_mutex); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2480 |
EC_MASTER_ERR(master, "Slave %u does not exist!\n", slave_position); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2481 |
kref_put(&request->refcount, ec_master_sdo_request_release); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2482 |
return -EINVAL; |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2483 |
} |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2484 |
|
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2485 |
EC_SLAVE_DBG(request->slave, 1, "Schedule SDO download request %p.\n", |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2486 |
request); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2487 |
|
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2488 |
// schedule request |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2489 |
kref_get(&request->refcount); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2490 |
list_add_tail(&request->list, &request->slave->slave_sdo_requests); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2491 |
|
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2492 |
ec_mutex_unlock(&master->master_mutex); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2493 |
|
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2494 |
// wait for processing through FSM |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2495 |
if (wait_event_interruptible(request->slave->sdo_queue, |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2496 |
((request->req.state == EC_INT_REQUEST_SUCCESS) || |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2497 |
(request->req.state == EC_INT_REQUEST_FAILURE)))) { |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2498 |
// interrupted by signal |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2499 |
kref_put(&request->refcount, ec_master_sdo_request_release); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2500 |
return -EINTR; |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2501 |
} |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2502 |
|
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2503 |
EC_SLAVE_DBG(request->slave, 1, "Finished SDO download request %p.\n", |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2504 |
request); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2505 |
|
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2506 |
*abort_code = request->req.abort_code; |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2507 |
|
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2508 |
if (request->req.state == EC_INT_REQUEST_SUCCESS) { |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2509 |
retval = 0; |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2510 |
} else if (request->req.errno) { |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2511 |
retval = -request->req.errno; |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2512 |
} else { |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2513 |
retval = -EIO; |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2514 |
} |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2515 |
|
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2516 |
kref_put(&request->refcount, ec_master_sdo_request_release); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2517 |
return retval; |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2518 |
} |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2519 |
|
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2520 |
/*****************************************************************************/ |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2521 |
|
2150
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2522 |
int ecrt_master_sdo_download_complete(ec_master_t *master, |
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2523 |
uint16_t slave_position, uint16_t index, uint8_t *data, |
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2524 |
size_t data_size, uint32_t *abort_code) |
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2525 |
{ |
2164
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2526 |
ec_master_sdo_request_t *request; |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2527 |
int retval; |
2150
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2528 |
|
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2529 |
EC_MASTER_DBG(master, 1, "%s(master = 0x%p," |
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2530 |
" slave_position = %u, index = 0x%04X," |
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2531 |
" data = 0x%p, data_size = %zu, abort_code = 0x%p)\n", |
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2532 |
__func__, master, slave_position, index, data, data_size, |
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2533 |
abort_code); |
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2534 |
|
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2535 |
if (!data_size) { |
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2536 |
EC_MASTER_ERR(master, "Zero data size!\n"); |
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2537 |
return -EINVAL; |
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2538 |
} |
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2539 |
|
2164
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2540 |
request = kmalloc(sizeof(*request), GFP_KERNEL); |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2541 |
if (!request) { |
2150
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2542 |
return -ENOMEM; |
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2543 |
} |
2164
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2544 |
kref_init(&request->refcount); |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2545 |
|
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2546 |
ec_sdo_request_init(&request->req); |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2547 |
ec_sdo_request_address(&request->req, index, 0); |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2548 |
if (ec_sdo_request_alloc(&request->req, data_size)) { |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2549 |
kref_put(&request->refcount, ec_master_sdo_request_release); |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2550 |
return -ENOMEM; |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2551 |
} |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2552 |
|
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2553 |
request->req.complete_access = 1; |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2554 |
memcpy(request->req.data, data, data_size); |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2555 |
request->req.data_size = data_size; |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2556 |
ecrt_sdo_request_write(&request->req); |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2557 |
|
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2558 |
if (ec_mutex_lock_interruptible(&master->master_mutex)) { |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2559 |
kref_put(&request->refcount, ec_master_sdo_request_release); |
2150
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2560 |
return -EINTR; |
2164
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2561 |
} |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2562 |
|
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2563 |
if (!(request->slave = ec_master_find_slave( |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2564 |
master, 0, slave_position))) { |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2565 |
ec_mutex_unlock(&master->master_mutex); |
2150
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2566 |
EC_MASTER_ERR(master, "Slave %u does not exist!\n", slave_position); |
2164
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2567 |
kref_put(&request->refcount, ec_master_sdo_request_release); |
2150
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2568 |
return -EINVAL; |
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2569 |
} |
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2570 |
|
2164
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2571 |
EC_SLAVE_DBG(request->slave, 1, "Schedule SDO download request %p" |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2572 |
" (complete access).\n", request); |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2573 |
|
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2574 |
// schedule request |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2575 |
kref_get(&request->refcount); |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2576 |
list_add_tail(&request->list, &request->slave->slave_sdo_requests); |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2577 |
|
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2578 |
ec_mutex_unlock(&master->master_mutex); |
2150
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2579 |
|
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2580 |
// wait for processing through FSM |
2164
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2581 |
if (wait_event_interruptible(request->slave->sdo_queue, |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2582 |
((request->req.state == EC_INT_REQUEST_SUCCESS) || |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2583 |
(request->req.state == EC_INT_REQUEST_FAILURE)))) { |
2150
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2584 |
// interrupted by signal |
2164
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2585 |
kref_put(&request->refcount, ec_master_sdo_request_release); |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2586 |
return -EINTR; |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2587 |
} |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2588 |
|
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2589 |
EC_SLAVE_DBG(request->slave, 1, "Finished SDO download request %p" |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2590 |
" (complete access).\n", request); |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2591 |
|
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2592 |
*abort_code = request->req.abort_code; |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2593 |
|
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2594 |
if (request->req.state == EC_INT_REQUEST_SUCCESS) { |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2595 |
retval = 0; |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2596 |
} else if (request->req.errno) { |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2597 |
retval = -request->req.errno; |
2150
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2598 |
} else { |
2164
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2599 |
retval = -EIO; |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2600 |
} |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2601 |
|
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2602 |
kref_put(&request->refcount, ec_master_sdo_request_release); |
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2603 |
return retval; |
2150
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2604 |
} |
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2605 |
|
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2606 |
/*****************************************************************************/ |
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2607 |
|
2107
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2608 |
int ecrt_master_sdo_upload(ec_master_t *master, uint16_t slave_position, |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2609 |
uint16_t index, uint8_t subindex, uint8_t *target, |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2610 |
size_t target_size, size_t *result_size, uint32_t *abort_code) |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2611 |
{ |
2164
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2612 |
ec_master_sdo_request_t *request; |
2107
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2613 |
int retval; |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2614 |
|
2110
455126b35650
Fixed compiler error; added SDO debugging.
Florian Pose <fp@igh-essen.com>
parents:
2107
diff
changeset
|
2615 |
EC_MASTER_DBG(master, 1, "%s(master = 0x%p," |
455126b35650
Fixed compiler error; added SDO debugging.
Florian Pose <fp@igh-essen.com>
parents:
2107
diff
changeset
|
2616 |
" slave_position = %u, index = 0x%04X, subindex = 0x%02X," |
455126b35650
Fixed compiler error; added SDO debugging.
Florian Pose <fp@igh-essen.com>
parents:
2107
diff
changeset
|
2617 |
" target = 0x%p, target_size = %zu, result_size = 0x%p, " |
455126b35650
Fixed compiler error; added SDO debugging.
Florian Pose <fp@igh-essen.com>
parents:
2107
diff
changeset
|
2618 |
" abort_code = 0x%p)\n", |
455126b35650
Fixed compiler error; added SDO debugging.
Florian Pose <fp@igh-essen.com>
parents:
2107
diff
changeset
|
2619 |
__func__, master, slave_position, index, subindex, target, |
455126b35650
Fixed compiler error; added SDO debugging.
Florian Pose <fp@igh-essen.com>
parents:
2107
diff
changeset
|
2620 |
target_size, result_size, abort_code); |
455126b35650
Fixed compiler error; added SDO debugging.
Florian Pose <fp@igh-essen.com>
parents:
2107
diff
changeset
|
2621 |
|
2107
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2622 |
request = kmalloc(sizeof(*request), GFP_KERNEL); |
2164
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2623 |
if (!request) { |
2107
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2624 |
return -ENOMEM; |
2164
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2625 |
} |
2107
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2626 |
kref_init(&request->refcount); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2627 |
|
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2628 |
ec_sdo_request_init(&request->req); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2629 |
ec_sdo_request_address(&request->req, index, subindex); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2630 |
ecrt_sdo_request_read(&request->req); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2631 |
|
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2632 |
if (ec_mutex_lock_interruptible(&master->master_mutex)) { |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2633 |
kref_put(&request->refcount, ec_master_sdo_request_release); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2634 |
return -EINTR; |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2635 |
} |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2636 |
|
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2637 |
if (!(request->slave = ec_master_find_slave( |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2638 |
master, 0, slave_position))) { |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2639 |
ec_mutex_unlock(&master->master_mutex); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2640 |
EC_MASTER_ERR(master, "Slave %u does not exist!\n", slave_position); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2641 |
kref_put(&request->refcount, ec_master_sdo_request_release); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2642 |
return -EINVAL; |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2643 |
} |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2644 |
|
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2645 |
EC_SLAVE_DBG(request->slave, 1, "Schedule SDO upload request %p.\n", |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2646 |
request); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2647 |
|
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2648 |
// schedule request |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2649 |
kref_get(&request->refcount); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2650 |
list_add_tail(&request->list, &request->slave->slave_sdo_requests); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2651 |
|
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2652 |
ec_mutex_unlock(&master->master_mutex); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2653 |
|
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2654 |
// wait for processing through FSM |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2655 |
if (wait_event_interruptible(request->slave->sdo_queue, |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2656 |
((request->req.state == EC_INT_REQUEST_SUCCESS) || |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2657 |
(request->req.state == EC_INT_REQUEST_FAILURE)))) { |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2658 |
// interrupted by signal |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2659 |
kref_put(&request->refcount, ec_master_sdo_request_release); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2660 |
return -EINTR; |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2661 |
} |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2662 |
|
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2663 |
EC_SLAVE_DBG(request->slave, 1, "Finished SDO upload request %p.\n", |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2664 |
request); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2665 |
|
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2666 |
*abort_code = request->req.abort_code; |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2667 |
|
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2668 |
if (request->req.state != EC_INT_REQUEST_SUCCESS) { |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2669 |
*result_size = 0; |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2670 |
if (request->req.errno) { |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2671 |
retval = -request->req.errno; |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2672 |
} else { |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2673 |
retval = -EIO; |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2674 |
} |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2675 |
} else { |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2676 |
if (request->req.data_size > target_size) { |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2677 |
EC_MASTER_ERR(master, "Buffer too small.\n"); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2678 |
kref_put(&request->refcount, ec_master_sdo_request_release); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2679 |
return -EOVERFLOW; |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2680 |
} |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2681 |
memcpy(target, request->req.data, request->req.data_size); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2682 |
*result_size = request->req.data_size; |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2683 |
retval = 0; |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2684 |
} |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2685 |
|
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2686 |
kref_put(&request->refcount, ec_master_sdo_request_release); |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2687 |
return retval; |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2688 |
} |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2689 |
|
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2690 |
/*****************************************************************************/ |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2691 |
|
1947
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2692 |
int ecrt_master_write_idn(ec_master_t *master, uint16_t slave_position, |
1952
7d9fb723fc4b
Added drive_no parameter to SoE layer.
Florian Pose <fp@igh-essen.com>
parents:
1947
diff
changeset
|
2693 |
uint8_t drive_no, uint16_t idn, uint8_t *data, size_t data_size, |
7d9fb723fc4b
Added drive_no parameter to SoE layer.
Florian Pose <fp@igh-essen.com>
parents:
1947
diff
changeset
|
2694 |
uint16_t *error_code) |
1947
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2695 |
{ |
2164
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2696 |
ec_master_soe_request_t *request; |
1947
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2697 |
int retval; |
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2698 |
|
1952
7d9fb723fc4b
Added drive_no parameter to SoE layer.
Florian Pose <fp@igh-essen.com>
parents:
1947
diff
changeset
|
2699 |
if (drive_no > 7) { |
7d9fb723fc4b
Added drive_no parameter to SoE layer.
Florian Pose <fp@igh-essen.com>
parents:
1947
diff
changeset
|
2700 |
EC_MASTER_ERR(master, "Invalid drive number!\n"); |
7d9fb723fc4b
Added drive_no parameter to SoE layer.
Florian Pose <fp@igh-essen.com>
parents:
1947
diff
changeset
|
2701 |
return -EINVAL; |
7d9fb723fc4b
Added drive_no parameter to SoE layer.
Florian Pose <fp@igh-essen.com>
parents:
1947
diff
changeset
|
2702 |
} |
7d9fb723fc4b
Added drive_no parameter to SoE layer.
Florian Pose <fp@igh-essen.com>
parents:
1947
diff
changeset
|
2703 |
|
2032
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2704 |
request = kmalloc(sizeof(*request), GFP_KERNEL); |
2164
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2705 |
if (!request) { |
1947
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2706 |
return -ENOMEM; |
2164
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2707 |
} |
2032
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2708 |
kref_init(&request->refcount); |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2709 |
|
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2710 |
INIT_LIST_HEAD(&request->list); |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2711 |
ec_soe_request_init(&request->req); |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2712 |
ec_soe_request_set_drive_no(&request->req, drive_no); |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2713 |
ec_soe_request_set_idn(&request->req, idn); |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2714 |
|
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2715 |
if (ec_soe_request_alloc(&request->req, data_size)) { |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2716 |
ec_soe_request_clear(&request->req); |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2717 |
kref_put(&request->refcount,ec_master_soe_request_release); |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2718 |
return -ENOMEM; |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2719 |
} |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2720 |
|
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2721 |
memcpy(request->req.data, data, data_size); |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2722 |
request->req.data_size = data_size; |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2723 |
ec_soe_request_write(&request->req); |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2724 |
|
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2725 |
if (ec_mutex_lock_interruptible(&master->master_mutex)) { |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2726 |
kref_put(&request->refcount,ec_master_soe_request_release); |
1947
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2727 |
return -EINTR; |
2032
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2728 |
} |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2729 |
|
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2730 |
if (!(request->slave = ec_master_find_slave( |
1947
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2731 |
master, 0, slave_position))) { |
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
2732 |
ec_mutex_unlock(&master->master_mutex); |
1947
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2733 |
EC_MASTER_ERR(master, "Slave %u does not exist!\n", |
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2734 |
slave_position); |
2032
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2735 |
kref_put(&request->refcount,ec_master_soe_request_release); |
1947
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2736 |
return -EINVAL; |
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2737 |
} |
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2738 |
|
2107
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2739 |
EC_SLAVE_DBG(request->slave, 1, "Scheduled SoE write request %p.\n", |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2740 |
request); |
1947
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2741 |
|
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2742 |
// schedule SoE write request. |
2032
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2743 |
list_add_tail(&request->list, &request->slave->soe_requests); |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2744 |
kref_get(&request->refcount); |
1947
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2745 |
|
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
2746 |
ec_mutex_unlock(&master->master_mutex); |
1947
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2747 |
|
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2748 |
// wait for processing through FSM |
2032
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2749 |
if (wait_event_interruptible(request->slave->soe_queue, |
2107
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2750 |
((request->req.state == EC_INT_REQUEST_SUCCESS) || |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2751 |
(request->req.state == EC_INT_REQUEST_FAILURE)))) { |
2032
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2752 |
// interrupted by signal |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2753 |
kref_put(&request->refcount,ec_master_soe_request_release); |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2754 |
return -EINTR; |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2755 |
} |
1947
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2756 |
|
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2757 |
if (error_code) { |
2032
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2758 |
*error_code = request->req.error_code; |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2759 |
} |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2760 |
retval = request->req.state == EC_INT_REQUEST_SUCCESS ? 0 : -EIO; |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2761 |
kref_put(&request->refcount,ec_master_soe_request_release); |
1947
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2762 |
|
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2763 |
return retval; |
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2764 |
} |
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2765 |
|
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2766 |
/*****************************************************************************/ |
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2767 |
|
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2768 |
int ecrt_master_read_idn(ec_master_t *master, uint16_t slave_position, |
1952
7d9fb723fc4b
Added drive_no parameter to SoE layer.
Florian Pose <fp@igh-essen.com>
parents:
1947
diff
changeset
|
2769 |
uint8_t drive_no, uint16_t idn, uint8_t *target, size_t target_size, |
1947
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2770 |
size_t *result_size, uint16_t *error_code) |
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2771 |
{ |
2164
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2772 |
ec_master_soe_request_t *request; |
1947
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2773 |
|
1952
7d9fb723fc4b
Added drive_no parameter to SoE layer.
Florian Pose <fp@igh-essen.com>
parents:
1947
diff
changeset
|
2774 |
if (drive_no > 7) { |
7d9fb723fc4b
Added drive_no parameter to SoE layer.
Florian Pose <fp@igh-essen.com>
parents:
1947
diff
changeset
|
2775 |
EC_MASTER_ERR(master, "Invalid drive number!\n"); |
7d9fb723fc4b
Added drive_no parameter to SoE layer.
Florian Pose <fp@igh-essen.com>
parents:
1947
diff
changeset
|
2776 |
return -EINVAL; |
7d9fb723fc4b
Added drive_no parameter to SoE layer.
Florian Pose <fp@igh-essen.com>
parents:
1947
diff
changeset
|
2777 |
} |
7d9fb723fc4b
Added drive_no parameter to SoE layer.
Florian Pose <fp@igh-essen.com>
parents:
1947
diff
changeset
|
2778 |
|
2032
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2779 |
request = kmalloc(sizeof(*request), GFP_KERNEL); |
2164
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2780 |
if (!request) { |
2032
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2781 |
return -ENOMEM; |
2164
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2782 |
} |
2032
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2783 |
kref_init(&request->refcount); |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2784 |
|
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2785 |
INIT_LIST_HEAD(&request->list); |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2786 |
ec_soe_request_init(&request->req); |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2787 |
ec_soe_request_set_drive_no(&request->req, drive_no); |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2788 |
ec_soe_request_set_idn(&request->req, idn); |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2789 |
ec_soe_request_read(&request->req); |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2790 |
|
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2791 |
if (ec_mutex_lock_interruptible(&master->master_mutex)) { |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2792 |
kref_put(&request->refcount,ec_master_soe_request_release); |
1947
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2793 |
return -EINTR; |
2032
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2794 |
} |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2795 |
|
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2796 |
if (!(request->slave = ec_master_find_slave(master, 0, slave_position))) { |
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
2797 |
ec_mutex_unlock(&master->master_mutex); |
2032
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2798 |
kref_put(&request->refcount,ec_master_soe_request_release); |
1947
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2799 |
EC_MASTER_ERR(master, "Slave %u does not exist!\n", slave_position); |
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2800 |
return -EINVAL; |
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2801 |
} |
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2802 |
|
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2803 |
// schedule request. |
2032
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2804 |
list_add_tail(&request->list, &request->slave->soe_requests); |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2805 |
kref_get(&request->refcount); |
1947
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2806 |
|
2028
55854f070c4a
use rt_mutex instead of semaphore for mutual exclusion (use --enable-mutex)
Martin Troxler <ch1010277@ch10pc446>
parents:
2024
diff
changeset
|
2807 |
ec_mutex_unlock(&master->master_mutex); |
1947
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2808 |
|
2107
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2809 |
EC_SLAVE_DBG(request->slave, 1, "Scheduled SoE read request %p.\n", |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2810 |
request); |
1947
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2811 |
|
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2812 |
// wait for processing through FSM |
2032
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2813 |
if (wait_event_interruptible(request->slave->soe_queue, |
2107
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2814 |
((request->req.state == EC_INT_REQUEST_SUCCESS) || |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2815 |
(request->req.state == EC_INT_REQUEST_FAILURE)))) { |
2032
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2816 |
// interrupted by signal |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2817 |
kref_put(&request->refcount,ec_master_soe_request_release); |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2818 |
return -EINTR; |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2819 |
} |
1947
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2820 |
|
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2821 |
if (error_code) { |
2032
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2822 |
*error_code = request->req.error_code; |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2823 |
} |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2824 |
|
2107
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2825 |
EC_SLAVE_DBG(request->slave, 1, "SoE request %p read %zd bytes" |
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2826 |
" via SoE.\n", request, request->req.data_size); |
2032
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2827 |
|
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2828 |
if (request->req.state != EC_INT_REQUEST_SUCCESS) { |
1947
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2829 |
if (result_size) { |
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2830 |
*result_size = 0; |
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2831 |
} |
2032
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2832 |
kref_put(&request->refcount,ec_master_soe_request_release); |
1947
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2833 |
return -EIO; |
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2834 |
} else { |
2032
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2835 |
if (request->req.data_size > target_size) { |
1947
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2836 |
EC_MASTER_ERR(master, "Buffer too small.\n"); |
2032
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2837 |
kref_put(&request->refcount,ec_master_soe_request_release); |
1947
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2838 |
return -EOVERFLOW; |
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2839 |
} |
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2840 |
if (result_size) { |
2032
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2841 |
*result_size = request->req.data_size; |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2842 |
} |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2843 |
memcpy(target, request->req.data, request->req.data_size); |
57c618557912
SoE request wait_event() deadlock fixed: use wait_event_interruptible and refcount ec_master_soe_request_t objects with kref
Martin Troxler <ch1010277@ch10pc446>
parents:
2031
diff
changeset
|
2844 |
kref_put(&request->refcount,ec_master_soe_request_release); |
1947
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2845 |
return 0; |
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2846 |
} |
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2847 |
} |
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2848 |
|
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2849 |
/*****************************************************************************/ |
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2850 |
|
2009
b5391b329b5d
Added ecrt_master_reset() method.
Florian Pose <fp@igh-essen.com>
parents:
1952
diff
changeset
|
2851 |
void ecrt_master_reset(ec_master_t *master) |
b5391b329b5d
Added ecrt_master_reset() method.
Florian Pose <fp@igh-essen.com>
parents:
1952
diff
changeset
|
2852 |
{ |
b5391b329b5d
Added ecrt_master_reset() method.
Florian Pose <fp@igh-essen.com>
parents:
1952
diff
changeset
|
2853 |
ec_slave_config_t *sc; |
b5391b329b5d
Added ecrt_master_reset() method.
Florian Pose <fp@igh-essen.com>
parents:
1952
diff
changeset
|
2854 |
|
b5391b329b5d
Added ecrt_master_reset() method.
Florian Pose <fp@igh-essen.com>
parents:
1952
diff
changeset
|
2855 |
list_for_each_entry(sc, &master->configs, list) { |
b5391b329b5d
Added ecrt_master_reset() method.
Florian Pose <fp@igh-essen.com>
parents:
1952
diff
changeset
|
2856 |
if (sc->slave) { |
b5391b329b5d
Added ecrt_master_reset() method.
Florian Pose <fp@igh-essen.com>
parents:
1952
diff
changeset
|
2857 |
ec_slave_request_state(sc->slave, EC_SLAVE_STATE_OP); |
b5391b329b5d
Added ecrt_master_reset() method.
Florian Pose <fp@igh-essen.com>
parents:
1952
diff
changeset
|
2858 |
} |
b5391b329b5d
Added ecrt_master_reset() method.
Florian Pose <fp@igh-essen.com>
parents:
1952
diff
changeset
|
2859 |
} |
b5391b329b5d
Added ecrt_master_reset() method.
Florian Pose <fp@igh-essen.com>
parents:
1952
diff
changeset
|
2860 |
} |
b5391b329b5d
Added ecrt_master_reset() method.
Florian Pose <fp@igh-essen.com>
parents:
1952
diff
changeset
|
2861 |
|
b5391b329b5d
Added ecrt_master_reset() method.
Florian Pose <fp@igh-essen.com>
parents:
1952
diff
changeset
|
2862 |
/*****************************************************************************/ |
b5391b329b5d
Added ecrt_master_reset() method.
Florian Pose <fp@igh-essen.com>
parents:
1952
diff
changeset
|
2863 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
2864 |
/** \cond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
2865 |
|
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
2866 |
EXPORT_SYMBOL(ecrt_master_create_domain); |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
2867 |
EXPORT_SYMBOL(ecrt_master_activate); |
1530
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2868 |
EXPORT_SYMBOL(ecrt_master_deactivate); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
2869 |
EXPORT_SYMBOL(ecrt_master_send); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
2870 |
EXPORT_SYMBOL(ecrt_master_receive); |
206
60a10d85c20b
Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents:
204
diff
changeset
|
2871 |
EXPORT_SYMBOL(ecrt_master_callbacks); |
1594
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2872 |
EXPORT_SYMBOL(ecrt_master); |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2873 |
EXPORT_SYMBOL(ecrt_master_get_slave); |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2874 |
EXPORT_SYMBOL(ecrt_master_slave_config); |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2875 |
EXPORT_SYMBOL(ecrt_master_state); |
1434
4c6fe0ae37f1
Separated application time from synchronizing reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1426
diff
changeset
|
2876 |
EXPORT_SYMBOL(ecrt_master_application_time); |
1410
fb6719008bf5
Separated sync_reference_clock() and sync_slave_clocks().
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
2877 |
EXPORT_SYMBOL(ecrt_master_sync_reference_clock); |
fb6719008bf5
Separated sync_reference_clock() and sync_slave_clocks().
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
2878 |
EXPORT_SYMBOL(ecrt_master_sync_slave_clocks); |
1535
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2879 |
EXPORT_SYMBOL(ecrt_master_sync_monitor_queue); |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2880 |
EXPORT_SYMBOL(ecrt_master_sync_monitor_process); |
2107
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2881 |
EXPORT_SYMBOL(ecrt_master_sdo_download); |
2150
5144a4bc6184
Added ecrt_master_sdo_download_complete() for ad-hoc downloading SDOs (also
Florian Pose <fp@igh-essen.com>
parents:
2117
diff
changeset
|
2882 |
EXPORT_SYMBOL(ecrt_master_sdo_download_complete); |
2107
ebda087981e1
Implemented ecrt_master_sdo_upload() and ecrt_master_sdo_download() for kernel
Florian Pose <fp@igh-essen.com>
parents:
2103
diff
changeset
|
2883 |
EXPORT_SYMBOL(ecrt_master_sdo_upload); |
1947
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2884 |
EXPORT_SYMBOL(ecrt_master_write_idn); |
024a3c6aa3f7
Implemented ecrt_master_read_idn() and ecrt_master_write_idn() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1939
diff
changeset
|
2885 |
EXPORT_SYMBOL(ecrt_master_read_idn); |
2009
b5391b329b5d
Added ecrt_master_reset() method.
Florian Pose <fp@igh-essen.com>
parents:
1952
diff
changeset
|
2886 |
EXPORT_SYMBOL(ecrt_master_reset); |
2054
3417bbc4ad2f
First working RTDM Version,
Andreas Stewering-Bone <ab@igh-essen.com>
parents:
2009
diff
changeset
|
2887 |
EXPORT_SYMBOL(ecrt_master_find_domain); |
2164
cf4db3c282d2
Fixed compiler error in master.c; thanks to Jun Yuan.
Florian Pose <fp@igh-essen.com>
parents:
2150
diff
changeset
|
2888 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
2889 |
/** \endcond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
2890 |
|
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
2891 |
/*****************************************************************************/ |