author | Florian Pose <fp@igh-essen.com> |
Fri, 05 Mar 2010 17:48:50 +0100 | |
changeset 1842 | 6d3190b9d464 |
parent 1831 | 1875b9fea0ba |
child 1848 | 1fe21e740efd |
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 |
* |
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
35
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 |
* |
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
35
diff
changeset
|
28 |
*****************************************************************************/ |
0 | 29 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
30 |
/** |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
31 |
\file |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
32 |
EtherCAT master methods. |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
33 |
*/ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
34 |
|
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
35 |
/*****************************************************************************/ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
36 |
|
24
d417dd9bdc2f
Wilhelms ?nderungen ?bernommen.
Florian Pose <fp@igh-essen.com>
parents:
23
diff
changeset
|
37 |
#include <linux/module.h> |
0 | 38 |
#include <linux/kernel.h> |
39 |
#include <linux/string.h> |
|
40 |
#include <linux/slab.h> |
|
41 |
#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
|
42 |
#include <linux/device.h> |
24efac66a647
Added support for different versions of class_device_create().
Florian Pose <fp@igh-essen.com>
parents:
1013
diff
changeset
|
43 |
#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
|
44 |
#include <linux/hrtimer.h> |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
45 |
#include "globals.h" |
55
059a9e712aa7
Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents:
54
diff
changeset
|
46 |
#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
|
47 |
#include "slave_config.h" |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
48 |
#include "device.h" |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
49 |
#include "datagram.h" |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
50 |
#ifdef EC_EOE |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
51 |
#include "ethernet.h" |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
52 |
#endif |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
53 |
#include "master.h" |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
54 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
55 |
/*****************************************************************************/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
56 |
|
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
57 |
/** Set to 1 to enable external datagram injection debugging. |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
58 |
*/ |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
59 |
#define DEBUG_INJECT 0 |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
60 |
|
1279
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
61 |
#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
|
62 |
|
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
63 |
/** 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
|
64 |
*/ |
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
65 |
static cycles_t timeout_cycles; |
1585
1f640e321ee4
ecrt_master_set_max_cycle_size: limit SDO traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
66 |
static cycles_t sdo_injection_timeout_cycles; |
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 |
#else |
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 jiffies. |
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 unsigned long timeout_jiffies; |
1585
1f640e321ee4
ecrt_master_set_max_cycle_size: limit SDO traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
72 |
static unsigned long sdo_injection_timeout_jiffies; |
1f640e321ee4
ecrt_master_set_max_cycle_size: limit SDO traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
73 |
|
1279
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
74 |
#endif |
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
75 |
|
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
76 |
/*****************************************************************************/ |
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
77 |
|
995
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
994
diff
changeset
|
78 |
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
|
79 |
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
|
80 |
static int ec_master_idle_thread(void *); |
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
81 |
static int ec_master_operation_thread(void *); |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
82 |
#ifdef EC_EOE |
1489
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
83 |
static int ec_master_eoe_thread(void *); |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
84 |
#endif |
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
85 |
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
|
86 |
|
fb4c9dd11ca0
Sourced SysFS attribute show method prototypes out of headers.
Florian Pose <fp@igh-essen.com>
parents:
178
diff
changeset
|
87 |
/*****************************************************************************/ |
fb4c9dd11ca0
Sourced SysFS attribute show method prototypes out of headers.
Florian Pose <fp@igh-essen.com>
parents:
178
diff
changeset
|
88 |
|
1279
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
89 |
/** 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
|
90 |
*/ |
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
91 |
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
|
92 |
{ |
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
93 |
#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
|
94 |
timeout_cycles = (cycles_t) EC_IO_TIMEOUT /* us */ * (cpu_khz / 1000); |
1585
1f640e321ee4
ecrt_master_set_max_cycle_size: limit SDO traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
95 |
sdo_injection_timeout_cycles = (cycles_t) EC_SDO_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
|
96 |
#else |
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
97 |
// 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
|
98 |
timeout_jiffies = max(EC_IO_TIMEOUT * HZ / 1000000, 1); |
1585
1f640e321ee4
ecrt_master_set_max_cycle_size: limit SDO traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
99 |
sdo_injection_timeout_jiffies = max(EC_SDO_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
|
100 |
#endif |
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
101 |
} |
6911450535b7
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
Florian Pose <fp@igh-essen.com>
parents:
1252
diff
changeset
|
102 |
|
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 |
|
0 | 105 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
106 |
Master constructor. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
107 |
\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
|
108 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
109 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
110 |
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
|
111 |
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
|
112 |
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
|
113 |
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
|
114 |
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
|
115 |
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
|
116 |
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
|
117 |
) |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
118 |
{ |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
119 |
int ret; |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
120 |
|
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
121 |
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
|
122 |
master->reserved = 0; |
446 | 123 |
|
1579
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1507
diff
changeset
|
124 |
sema_init(&master->master_sem, 1); |
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
|
125 |
|
639
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
126 |
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
|
127 |
master->backup_mac = backup_mac; |
1579
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1507
diff
changeset
|
128 |
|
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1507
diff
changeset
|
129 |
sema_init(&master->device_sem, 1); |
446 | 130 |
|
1029
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
131 |
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
|
132 |
master->active = 0; |
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
133 |
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
|
134 |
master->injection_seq_rt = 0; |
446 | 135 |
|
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
136 |
master->slaves = NULL; |
446 | 137 |
master->slave_count = 0; |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
138 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
139 |
INIT_LIST_HEAD(&master->configs); |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
140 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
141 |
master->app_time = 0ULL; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
142 |
master->app_start_time = 0ULL; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
143 |
master->has_start_time = 0; |
1408 | 144 |
|
900
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
145 |
master->scan_busy = 0; |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
146 |
master->allow_scan = 1; |
1579
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1507
diff
changeset
|
147 |
sema_init(&master->scan_sem, 1); |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
148 |
init_waitqueue_head(&master->scan_queue); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
149 |
|
900
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
150 |
master->config_busy = 0; |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
151 |
master->allow_config = 1; |
1579
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1507
diff
changeset
|
152 |
sema_init(&master->config_sem, 1); |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
153 |
init_waitqueue_head(&master->config_queue); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
154 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
155 |
INIT_LIST_HEAD(&master->datagram_queue); |
446 | 156 |
master->datagram_index = 0; |
157 |
||
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
158 |
INIT_LIST_HEAD(&master->ext_datagram_queue); |
1579
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1507
diff
changeset
|
159 |
sema_init(&master->ext_queue_sem, 1); |
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
160 |
|
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
161 |
INIT_LIST_HEAD(&master->external_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
|
162 |
|
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
|
163 |
// 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
|
164 |
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
|
165 |
|
95
0066de7a456d
Domains als Liste verwaltet.
Florian Pose <fp@igh-essen.com>
parents:
94
diff
changeset
|
166 |
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
|
167 |
|
1399
f79d4bb5b23a
Added debug_level module parameter. debug_level is now unsigned int.
Florian Pose <fp@igh-essen.com>
parents:
1396
diff
changeset
|
168 |
master->debug_level = debug_level; |
446 | 169 |
master->stats.timeouts = 0; |
170 |
master->stats.corrupted = 0; |
|
171 |
master->stats.unmatched = 0; |
|
172 |
master->stats.output_jiffies = 0; |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
173 |
master->frames_timed_out = 0; |
446 | 174 |
|
1241
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
175 |
master->thread = NULL; |
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
176 |
|
1041
42c9ac58d9ce
Removed state machine cycle time measuring.
Florian Pose <fp@igh-essen.com>
parents:
1040
diff
changeset
|
177 |
#ifdef EC_EOE |
1489
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
178 |
master->eoe_thread = NULL; |
446 | 179 |
INIT_LIST_HEAD(&master->eoe_handlers); |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
180 |
#endif |
446 | 181 |
|
1579
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1507
diff
changeset
|
182 |
sema_init(&master->io_sem, 1); |
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
183 |
master->send_cb = NULL; |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
184 |
master->receive_cb = NULL; |
1513
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
185 |
master->cb_data = NULL; |
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
186 |
master->app_send_cb = NULL; |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
187 |
master->app_receive_cb = NULL; |
1513
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
188 |
master->app_cb_data = NULL; |
446 | 189 |
|
872 | 190 |
INIT_LIST_HEAD(&master->sii_requests); |
191 |
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
|
192 |
|
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1369
diff
changeset
|
193 |
INIT_LIST_HEAD(&master->reg_requests); |
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1369
diff
changeset
|
194 |
init_waitqueue_head(&master->reg_queue); |
1200 | 195 |
|
579
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
578
diff
changeset
|
196 |
// init devices |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
197 |
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
|
198 |
if (ret < 0) |
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
199 |
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
|
200 |
|
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
201 |
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
|
202 |
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
|
203 |
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
|
204 |
|
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
|
205 |
// 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
|
206 |
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
|
207 |
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
|
208 |
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
|
209 |
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
|
210 |
ec_datagram_clear(&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
|
211 |
EC_ERR("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
|
212 |
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
|
213 |
} |
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
|
214 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
215 |
// create state machine object |
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
|
216 |
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
|
217 |
|
1396
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1394
diff
changeset
|
218 |
// init reference sync datagram |
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1394
diff
changeset
|
219 |
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
|
220 |
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
|
221 |
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
|
222 |
if (ret < 0) { |
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1394
diff
changeset
|
223 |
ec_datagram_clear(&master->ref_sync_datagram); |
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1394
diff
changeset
|
224 |
EC_ERR("Failed to allocate reference synchronisation datagram.\n"); |
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1394
diff
changeset
|
225 |
goto out_clear_fsm; |
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1394
diff
changeset
|
226 |
} |
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1394
diff
changeset
|
227 |
|
1394
e77728ddf0f9
Introduced ecrt_master_sync() for synchronizing slave clocks to reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
228 |
// 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
|
229 |
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
|
230 |
snprintf(master->sync_datagram.name, EC_DATAGRAM_NAME_SIZE, "sync"); |
1408 | 231 |
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
|
232 |
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
|
233 |
ec_datagram_clear(&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
|
234 |
EC_ERR("Failed to allocate synchronisation datagram.\n"); |
1396
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1394
diff
changeset
|
235 |
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
|
236 |
} |
1535
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
237 |
|
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
238 |
// init sync monitor datagram |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
239 |
ec_datagram_init(&master->sync_mon_datagram); |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
240 |
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
|
241 |
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
|
242 |
if (ret < 0) { |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
243 |
ec_datagram_clear(&master->sync_mon_datagram); |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
244 |
EC_ERR("Failed to allocate sync monitoring datagram.\n"); |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
245 |
goto out_clear_sync; |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
246 |
} |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
247 |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
248 |
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
|
249 |
|
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
250 |
// init character device |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
251 |
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
|
252 |
if (ret) |
1535
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
253 |
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
|
254 |
|
1369
61793d845ad6
Preparations to compile against 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
255 |
#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
|
256 |
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
|
257 |
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
|
258 |
"EtherCAT%u", master->index); |
61793d845ad6
Preparations to compile against 2.6.27.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
259 |
#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
|
260 |
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
|
261 |
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
|
262 |
"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
|
263 |
#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
|
264 |
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
|
265 |
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
|
266 |
"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
|
267 |
#else |
1250
642048176899
Applied patch by Mario Witkowski to support the new class/device
Florian Pose <fp@igh-essen.com>
parents:
1245
diff
changeset
|
268 |
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
|
269 |
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
|
270 |
"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
|
271 |
#endif |
1013
52256b75f975
Create class device with device_number information in sysfs.
Florian Pose <fp@igh-essen.com>
parents:
1010
diff
changeset
|
272 |
if (IS_ERR(master->class_device)) { |
52256b75f975
Create class device with device_number information in sysfs.
Florian Pose <fp@igh-essen.com>
parents:
1010
diff
changeset
|
273 |
EC_ERR("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
|
274 |
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
|
275 |
goto out_clear_cdev; |
52256b75f975
Create class device with device_number information in sysfs.
Florian Pose <fp@igh-essen.com>
parents:
1010
diff
changeset
|
276 |
} |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
140
diff
changeset
|
277 |
|
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
278 |
return 0; |
226
07247920a7ba
EoE with workqueue; bugfix in ec_master_init()
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
279 |
|
1013
52256b75f975
Create class device with device_number information in sysfs.
Florian Pose <fp@igh-essen.com>
parents:
1010
diff
changeset
|
280 |
out_clear_cdev: |
52256b75f975
Create class device with device_number information in sysfs.
Florian Pose <fp@igh-essen.com>
parents:
1010
diff
changeset
|
281 |
ec_cdev_clear(&master->cdev); |
1535
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
282 |
out_clear_sync_mon: |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
283 |
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
|
284 |
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
|
285 |
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
|
286 |
out_clear_ref_sync: |
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1394
diff
changeset
|
287 |
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
|
288 |
out_clear_fsm: |
d7c5a958bad0
Removed unecessary clearing of EoE handlers in master init function;
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
289 |
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
|
290 |
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
|
291 |
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
|
292 |
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
|
293 |
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
|
294 |
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
|
295 |
out_return: |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
296 |
return ret; |
0 | 297 |
} |
298 |
||
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
35
diff
changeset
|
299 |
/*****************************************************************************/ |
0 | 300 |
|
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
301 |
/** Destructor. |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
302 |
*/ |
639
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
303 |
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
|
304 |
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
|
305 |
) |
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
306 |
{ |
1250
642048176899
Applied patch by Mario Witkowski to support the new class/device
Florian Pose <fp@igh-essen.com>
parents:
1245
diff
changeset
|
307 |
#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
|
308 |
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
|
309 |
#else |
1013
52256b75f975
Create class device with device_number information in sysfs.
Florian Pose <fp@igh-essen.com>
parents:
1010
diff
changeset
|
310 |
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
|
311 |
#endif |
1394
e77728ddf0f9
Introduced ecrt_master_sync() for synchronizing slave clocks to reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
312 |
|
995
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
994
diff
changeset
|
313 |
ec_cdev_clear(&master->cdev); |
1394
e77728ddf0f9
Introduced ecrt_master_sync() for synchronizing slave clocks to reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
314 |
|
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
315 |
#ifdef EC_EOE |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
316 |
ec_master_clear_eoe_handlers(master); |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
317 |
#endif |
994
e29edcced328
Clear domains before slave configs, because domain references the FMMU
Florian Pose <fp@igh-essen.com>
parents:
993
diff
changeset
|
318 |
ec_master_clear_domains(master); |
995
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
994
diff
changeset
|
319 |
ec_master_clear_slave_configs(master); |
992
50a44cbd30af
Removed kobjects from sdo and slave.
Florian Pose <fp@igh-essen.com>
parents:
990
diff
changeset
|
320 |
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
|
321 |
|
1535
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
322 |
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
|
323 |
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
|
324 |
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
|
325 |
ec_fsm_master_clear(&master->fsm); |
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
|
326 |
ec_datagram_clear(&master->fsm_datagram); |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
327 |
ec_device_clear(&master->backup_device); |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
328 |
ec_device_clear(&master->main_device); |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
329 |
} |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
330 |
|
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
331 |
/*****************************************************************************/ |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
332 |
|
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
333 |
#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
|
334 |
/** Clear and free all EoE handlers. |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
335 |
*/ |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
336 |
void ec_master_clear_eoe_handlers( |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
337 |
ec_master_t *master /**< EtherCAT master */ |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
338 |
) |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
339 |
{ |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
340 |
ec_eoe_t *eoe, *next; |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
341 |
|
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
342 |
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
|
343 |
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
|
344 |
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
|
345 |
kfree(eoe); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
346 |
} |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
347 |
} |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
348 |
#endif |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
349 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
350 |
/*****************************************************************************/ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
351 |
|
995
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
994
diff
changeset
|
352 |
/** 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
|
353 |
*/ |
995
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
994
diff
changeset
|
354 |
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
|
355 |
{ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
356 |
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
|
357 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
358 |
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
|
359 |
list_del(&sc->list); |
995
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
994
diff
changeset
|
360 |
ec_slave_config_clear(sc); |
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
994
diff
changeset
|
361 |
kfree(sc); |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
362 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
363 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
364 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
365 |
/*****************************************************************************/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
366 |
|
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
367 |
/** 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
|
368 |
*/ |
992
50a44cbd30af
Removed kobjects from sdo and slave.
Florian Pose <fp@igh-essen.com>
parents:
990
diff
changeset
|
369 |
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
|
370 |
{ |
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
371 |
ec_slave_t *slave; |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
372 |
|
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
373 |
master->dc_ref_clock = NULL; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
374 |
|
1538
cf2fa3be6add
Fixed clearing slaves: Also clear external requests before. Thanks to Martin
Florian Pose <fp@igh-essen.com>
parents:
1535
diff
changeset
|
375 |
// 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
|
376 |
// them from the list |
cf2fa3be6add
Fixed clearing slaves: Also clear external requests before. Thanks to Martin
Florian Pose <fp@igh-essen.com>
parents:
1535
diff
changeset
|
377 |
// |
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
|
378 |
// SII requests |
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
|
379 |
while (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
|
380 |
ec_sii_write_request_t *request; |
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
|
381 |
if (list_empty(&master->sii_requests)) |
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
|
382 |
break; |
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
|
383 |
// get first request |
1538
cf2fa3be6add
Fixed clearing slaves: Also clear external requests before. Thanks to Martin
Florian Pose <fp@igh-essen.com>
parents:
1535
diff
changeset
|
384 |
request = list_entry(master->sii_requests.next, |
cf2fa3be6add
Fixed clearing slaves: Also clear external requests before. Thanks to Martin
Florian Pose <fp@igh-essen.com>
parents:
1535
diff
changeset
|
385 |
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
|
386 |
list_del_init(&request->list); // dequeue |
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
|
387 |
EC_INFO("Discarding SII request, slave %u does not exist anymore.\n", |
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
|
388 |
request->slave->ring_position); |
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
|
389 |
request->state = EC_INT_REQUEST_FAILURE; |
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
|
390 |
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
|
391 |
} |
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
|
392 |
|
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
|
393 |
// Register requests |
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
|
394 |
while (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
|
395 |
ec_reg_request_t *request; |
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
|
396 |
if (list_empty(&master->reg_requests)) |
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
|
397 |
break; |
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
|
398 |
// get first request |
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
|
399 |
request = list_entry(master->reg_requests.next, |
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 |
ec_reg_request_t, list); |
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
|
401 |
list_del_init(&request->list); // dequeue |
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
|
402 |
EC_INFO("Discarding Reg request, slave %u does not exist anymore.\n", |
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->slave->ring_position); |
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
|
404 |
request->state = EC_INT_REQUEST_FAILURE; |
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->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
|
406 |
} |
1538
cf2fa3be6add
Fixed clearing slaves: Also clear external requests before. Thanks to Martin
Florian Pose <fp@igh-essen.com>
parents:
1535
diff
changeset
|
407 |
|
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
408 |
for (slave = master->slaves; |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
409 |
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
|
410 |
slave++) { |
1596
ea8d2b4ee742
Moved sdo request queue to slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1585
diff
changeset
|
411 |
// SDO requests |
ea8d2b4ee742
Moved sdo request queue to slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1585
diff
changeset
|
412 |
while (1) { |
ea8d2b4ee742
Moved sdo request queue to slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1585
diff
changeset
|
413 |
ec_master_sdo_request_t *request; |
ea8d2b4ee742
Moved sdo request queue to slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1585
diff
changeset
|
414 |
if (list_empty(&slave->slave_sdo_requests)) |
ea8d2b4ee742
Moved sdo request queue to slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1585
diff
changeset
|
415 |
break; |
ea8d2b4ee742
Moved sdo request queue to slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1585
diff
changeset
|
416 |
// get first request |
ea8d2b4ee742
Moved sdo request queue to slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1585
diff
changeset
|
417 |
request = list_entry(slave->slave_sdo_requests.next, |
ea8d2b4ee742
Moved sdo request queue to slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1585
diff
changeset
|
418 |
ec_master_sdo_request_t, list); |
ea8d2b4ee742
Moved sdo request queue to slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1585
diff
changeset
|
419 |
list_del_init(&request->list); // dequeue |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
420 |
EC_INFO("Discarding SDO request," |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
421 |
" slave %u does not exist anymore.\n", |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
422 |
slave->ring_position); |
1596
ea8d2b4ee742
Moved sdo request queue to slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1585
diff
changeset
|
423 |
request->req.state = EC_INT_REQUEST_FAILURE; |
ea8d2b4ee742
Moved sdo request queue to slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1585
diff
changeset
|
424 |
wake_up(&slave->sdo_queue); |
ea8d2b4ee742
Moved sdo request queue to slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1585
diff
changeset
|
425 |
} |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
426 |
// FoE requests |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
427 |
while (1) { |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
428 |
ec_master_foe_request_t *request; |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
429 |
if (list_empty(&slave->foe_requests)) |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
430 |
break; |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
431 |
// get first request |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
432 |
request = list_entry(slave->foe_requests.next, |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
433 |
ec_master_foe_request_t, list); |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
434 |
list_del_init(&request->list); // dequeue |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
435 |
EC_INFO("Discarding FoE request," |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
436 |
" slave %u does not exist anymore.\n", |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
437 |
slave->ring_position); |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
438 |
request->req.state = EC_INT_REQUEST_FAILURE; |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
439 |
wake_up(&slave->foe_queue); |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
440 |
} |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
441 |
// SoE requests |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
442 |
while (1) { |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
443 |
ec_master_soe_request_t *request; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
444 |
if (list_empty(&slave->soe_requests)) |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
445 |
break; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
446 |
// get first request |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
447 |
request = list_entry(slave->soe_requests.next, |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
448 |
ec_master_soe_request_t, list); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
449 |
list_del_init(&request->list); // dequeue |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
450 |
EC_INFO("Discarding SoE request," |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
451 |
" slave %u does not exist anymore.\n", |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
452 |
slave->ring_position); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
453 |
request->req.state = EC_INT_REQUEST_FAILURE; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
454 |
wake_up(&slave->soe_queue); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
455 |
} |
992
50a44cbd30af
Removed kobjects from sdo and slave.
Florian Pose <fp@igh-essen.com>
parents:
990
diff
changeset
|
456 |
ec_slave_clear(slave); |
1004
990b89d8ad03
Fixed duplicate kfree() bug.
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
457 |
} |
990b89d8ad03
Fixed duplicate kfree() bug.
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
458 |
|
990b89d8ad03
Fixed duplicate kfree() bug.
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
459 |
if (master->slaves) { |
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
460 |
kfree(master->slaves); |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
461 |
master->slaves = NULL; |
1004
990b89d8ad03
Fixed duplicate kfree() bug.
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
462 |
} |
990b89d8ad03
Fixed duplicate kfree() bug.
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
463 |
|
990b89d8ad03
Fixed duplicate kfree() bug.
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
464 |
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
|
465 |
} |
9bf603942791
Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
466 |
|
9bf603942791
Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
467 |
/*****************************************************************************/ |
9bf603942791
Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
468 |
|
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
469 |
/** Clear all domains. |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
470 |
*/ |
993
8c32564252fd
Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents:
992
diff
changeset
|
471 |
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
|
472 |
{ |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
473 |
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
|
474 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
475 |
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
|
476 |
list_del(&domain->list); |
993
8c32564252fd
Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents:
992
diff
changeset
|
477 |
ec_domain_clear(domain); |
8c32564252fd
Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents:
992
diff
changeset
|
478 |
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
|
479 |
} |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
480 |
} |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
481 |
|
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
482 |
/*****************************************************************************/ |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
483 |
|
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
484 |
/** Internal sending callback. |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
485 |
*/ |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
486 |
void ec_master_internal_send_cb( |
1513
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
487 |
void *cb_data /**< Callback data. */ |
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
488 |
) |
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
489 |
{ |
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
490 |
ec_master_t *master = (ec_master_t *) cb_data; |
1489
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
491 |
down(&master->io_sem); |
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
492 |
ecrt_master_send_ext(master); |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
493 |
up(&master->io_sem); |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
494 |
} |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
495 |
|
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
496 |
/*****************************************************************************/ |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
497 |
|
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
498 |
/** Internal receiving callback. |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
499 |
*/ |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
500 |
void ec_master_internal_receive_cb( |
1513
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
501 |
void *cb_data /**< Callback data. */ |
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
502 |
) |
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
503 |
{ |
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
504 |
ec_master_t *master = (ec_master_t *) cb_data; |
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
505 |
down(&master->io_sem); |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
506 |
ecrt_master_receive(master); |
1489
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
507 |
up(&master->io_sem); |
515
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
508 |
} |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
509 |
|
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
510 |
/*****************************************************************************/ |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
511 |
|
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
512 |
/** Starts the master thread. |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
513 |
* |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
514 |
* \retval 0 Success. |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
515 |
* \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
|
516 |
*/ |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
517 |
int ec_master_thread_start( |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
518 |
ec_master_t *master, /**< EtherCAT master */ |
1241
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
519 |
int (*thread_func)(void *), /**< thread function to start */ |
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
520 |
const char *name /**< Thread name. */ |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
521 |
) |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
522 |
{ |
1241
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
523 |
EC_INFO("Starting %s thread.\n", name); |
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
524 |
master->thread = kthread_run(thread_func, master, name); |
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
525 |
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
|
526 |
int err = (int) PTR_ERR(master->thread); |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
527 |
EC_ERR("Failed to start master thread (error %i)!\n", err); |
1241
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
528 |
master->thread = NULL; |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
529 |
return err; |
1241
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
530 |
} |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
531 |
|
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
532 |
return 0; |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
533 |
} |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
534 |
|
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
535 |
/*****************************************************************************/ |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
536 |
|
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
537 |
/** Stops the master thread. |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
538 |
*/ |
1029
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
539 |
void ec_master_thread_stop( |
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
540 |
ec_master_t *master /**< EtherCAT master */ |
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
541 |
) |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
542 |
{ |
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
543 |
unsigned long sleep_jiffies; |
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
544 |
|
1241
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
545 |
if (!master->thread) { |
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
546 |
EC_WARN("ec_master_thread_stop(): Already finished!\n"); |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
547 |
return; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
548 |
} |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
549 |
|
1006
90db4c3de57b
Added a few debugging messages.
Florian Pose <fp@igh-essen.com>
parents:
1004
diff
changeset
|
550 |
if (master->debug_level) |
90db4c3de57b
Added a few debugging messages.
Florian Pose <fp@igh-essen.com>
parents:
1004
diff
changeset
|
551 |
EC_DBG("Stopping master thread.\n"); |
90db4c3de57b
Added a few debugging messages.
Florian Pose <fp@igh-essen.com>
parents:
1004
diff
changeset
|
552 |
|
1241
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
553 |
kthread_stop(master->thread); |
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
554 |
master->thread = NULL; |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
555 |
EC_INFO("Master thread exited.\n"); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
556 |
|
1198
be606e9caba4
Fixed race concerning thread signaling when master thread had no
Florian Pose <fp@igh-essen.com>
parents:
1197
diff
changeset
|
557 |
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
|
558 |
return; |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
559 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
560 |
// wait for FSM datagram |
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
561 |
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
|
562 |
schedule_timeout(sleep_jiffies); |
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 |
|
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
565 |
/*****************************************************************************/ |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
566 |
|
1029
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
567 |
/** Transition function from ORPHANED to IDLE phase. |
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
568 |
*/ |
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
569 |
int ec_master_enter_idle_phase( |
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
570 |
ec_master_t *master /**< EtherCAT master */ |
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
571 |
) |
446 | 572 |
{ |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
573 |
int ret; |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
574 |
|
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
|
575 |
if (master->debug_level) |
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
|
576 |
EC_DBG("ORPHANED -> IDLE.\n"); |
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
|
577 |
|
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
578 |
master->send_cb = ec_master_internal_send_cb; |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
579 |
master->receive_cb = ec_master_internal_receive_cb; |
1513
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
580 |
master->cb_data = master; |
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
581 |
|
1029
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
582 |
master->phase = EC_IDLE; |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
583 |
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
|
584 |
"EtherCAT-IDLE"); |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
585 |
if (ret) |
1029
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
586 |
master->phase = EC_ORPHANED; |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
587 |
|
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
588 |
return ret; |
446 | 589 |
} |
590 |
||
591 |
/*****************************************************************************/ |
|
592 |
||
1029
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
593 |
/** Transition function from IDLE to ORPHANED phase. |
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
594 |
*/ |
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
595 |
void ec_master_leave_idle_phase(ec_master_t *master /**< EtherCAT master */) |
446 | 596 |
{ |
1006
90db4c3de57b
Added a few debugging messages.
Florian Pose <fp@igh-essen.com>
parents:
1004
diff
changeset
|
597 |
if (master->debug_level) |
90db4c3de57b
Added a few debugging messages.
Florian Pose <fp@igh-essen.com>
parents:
1004
diff
changeset
|
598 |
EC_DBG("IDLE -> ORPHANED.\n"); |
90db4c3de57b
Added a few debugging messages.
Florian Pose <fp@igh-essen.com>
parents:
1004
diff
changeset
|
599 |
|
1029
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
600 |
master->phase = EC_ORPHANED; |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
601 |
|
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
602 |
#ifdef EC_EOE |
446 | 603 |
ec_master_eoe_stop(master); |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
604 |
#endif |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
605 |
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
|
606 |
|
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
|
607 |
down(&master->master_sem); |
992
50a44cbd30af
Removed kobjects from sdo and slave.
Florian Pose <fp@igh-essen.com>
parents:
990
diff
changeset
|
608 |
ec_master_clear_slaves(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
|
609 |
up(&master->master_sem); |
446 | 610 |
} |
611 |
||
612 |
/*****************************************************************************/ |
|
613 |
||
1029
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
614 |
/** Transition function from IDLE to OPERATION phase. |
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
615 |
*/ |
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
616 |
int ec_master_enter_operation_phase(ec_master_t *master /**< EtherCAT master */) |
446 | 617 |
{ |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
618 |
int ret = 0; |
446 | 619 |
ec_slave_t *slave; |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
620 |
#ifdef EC_EOE |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
621 |
ec_eoe_t *eoe; |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
622 |
#endif |
446 | 623 |
|
1006
90db4c3de57b
Added a few debugging messages.
Florian Pose <fp@igh-essen.com>
parents:
1004
diff
changeset
|
624 |
if (master->debug_level) |
90db4c3de57b
Added a few debugging messages.
Florian Pose <fp@igh-essen.com>
parents:
1004
diff
changeset
|
625 |
EC_DBG("IDLE -> OPERATION.\n"); |
90db4c3de57b
Added a few debugging messages.
Florian Pose <fp@igh-essen.com>
parents:
1004
diff
changeset
|
626 |
|
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
627 |
down(&master->config_sem); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
628 |
master->allow_config = 0; // temporarily disable slave configuration |
900
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
629 |
if (master->config_busy) { |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
630 |
up(&master->config_sem); |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
631 |
|
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
632 |
// 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
|
633 |
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
|
634 |
!master->config_busy); |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
635 |
if (ret) { |
900
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
636 |
EC_INFO("Finishing slave configuration interrupted by signal.\n"); |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
637 |
goto out_allow; |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
638 |
} |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
639 |
|
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
640 |
if (master->debug_level) |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
641 |
EC_DBG("Waiting for pending slave configuration returned.\n"); |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
642 |
} else { |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
643 |
up(&master->config_sem); |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
644 |
} |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
645 |
|
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
646 |
down(&master->scan_sem); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
647 |
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
|
648 |
if (!master->scan_busy) { |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
649 |
up(&master->scan_sem); |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
650 |
} else { |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
651 |
up(&master->scan_sem); |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
652 |
|
794
684dea874956
Allow bus configuration when link is down.
Florian Pose <fp@igh-essen.com>
parents:
792
diff
changeset
|
653 |
// 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
|
654 |
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
|
655 |
if (ret) { |
794
684dea874956
Allow bus configuration when link is down.
Florian Pose <fp@igh-essen.com>
parents:
792
diff
changeset
|
656 |
EC_INFO("Waiting for slave scan interrupted by signal.\n"); |
684dea874956
Allow bus configuration when link is down.
Florian Pose <fp@igh-essen.com>
parents:
792
diff
changeset
|
657 |
goto out_allow; |
684dea874956
Allow bus configuration when link is down.
Florian Pose <fp@igh-essen.com>
parents:
792
diff
changeset
|
658 |
} |
900
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
659 |
|
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
660 |
if (master->debug_level) |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
661 |
EC_DBG("Waiting for pending slave scan returned.\n"); |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
662 |
} |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
663 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
664 |
// 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
|
665 |
for (slave = master->slaves; |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
666 |
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
|
667 |
slave++) { |
643
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
668 |
ec_slave_request_state(slave, EC_SLAVE_STATE_PREOP); |
446 | 669 |
} |
1451
78fbafbf08ba
Always set DC reference clock to OP.
Florian Pose <fp@igh-essen.com>
parents:
1436
diff
changeset
|
670 |
|
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
671 |
#ifdef EC_EOE |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
672 |
// ... but set EoE slaves to OP |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
673 |
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
|
674 |
if (ec_eoe_is_open(eoe)) |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
675 |
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
|
676 |
} |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
677 |
#endif |
446 | 678 |
|
1029
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
679 |
master->phase = EC_OPERATION; |
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
680 |
master->app_send_cb = NULL; |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
681 |
master->app_receive_cb = NULL; |
1513
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
682 |
master->app_cb_data = NULL; |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
683 |
return ret; |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
684 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
685 |
out_allow: |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
686 |
master->allow_scan = 1; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
687 |
master->allow_config = 1; |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
688 |
return ret; |
446 | 689 |
} |
690 |
||
691 |
/*****************************************************************************/ |
|
692 |
||
1029
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
693 |
/** Transition function from OPERATION to IDLE phase. |
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
694 |
*/ |
1530
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
695 |
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
|
696 |
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
|
697 |
) |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
698 |
{ |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
699 |
if (master->active) |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
700 |
ecrt_master_deactivate(master); |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
701 |
|
1006
90db4c3de57b
Added a few debugging messages.
Florian Pose <fp@igh-essen.com>
parents:
1004
diff
changeset
|
702 |
if (master->debug_level) |
90db4c3de57b
Added a few debugging messages.
Florian Pose <fp@igh-essen.com>
parents:
1004
diff
changeset
|
703 |
EC_DBG("OPERATION -> IDLE.\n"); |
90db4c3de57b
Added a few debugging messages.
Florian Pose <fp@igh-essen.com>
parents:
1004
diff
changeset
|
704 |
|
1029
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
705 |
master->phase = EC_IDLE; |
446 | 706 |
} |
707 |
||
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
|
708 |
|
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
|
709 |
/*****************************************************************************/ |
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
|
710 |
|
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
711 |
/** Injects external datagrams that fit into the datagram queue. |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
712 |
*/ |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
713 |
void ec_master_inject_external_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
|
714 |
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
|
715 |
) |
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
|
716 |
{ |
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 |
ec_datagram_t *datagram, *n; |
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
|
718 |
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
|
719 |
|
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
|
720 |
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
|
721 |
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
|
722 |
} |
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
723 |
|
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
724 |
list_for_each_entry_safe(datagram, n, &master->external_datagram_queue, |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
725 |
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
|
726 |
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
|
727 |
if (queue_size <= master->max_queue_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
|
728 |
list_del_init(&datagram->queue); |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
729 |
#if DEBUG_INJECT |
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
|
730 |
if (master->debug_level) { |
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
|
731 |
EC_DBG("Injecting external datagram %08x size=%u," |
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
|
732 |
" queue_size=%u\n", (unsigned int) datagram, |
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
|
733 |
datagram->data_size, queue_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
|
734 |
} |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
735 |
#endif |
1585
1f640e321ee4
ecrt_master_set_max_cycle_size: limit SDO traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
736 |
#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
|
737 |
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
|
738 |
#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
|
739 |
datagram->jiffies_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
|
740 |
ec_master_queue_datagram(master, datagram); |
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
|
741 |
} |
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
|
742 |
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
|
743 |
if (datagram->data_size > master->max_queue_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
|
744 |
list_del_init(&datagram->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
|
745 |
datagram->state = EC_DATAGRAM_ERROR; |
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
746 |
EC_ERR("External datagram %p is too large," |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
747 |
" size=%u, max_queue_size=%u\n", |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
748 |
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
|
749 |
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
|
750 |
} else { |
1585
1f640e321ee4
ecrt_master_set_max_cycle_size: limit SDO traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
751 |
#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
|
752 |
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
|
753 |
|
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
|
754 |
if (cycles_now - datagram->cycles_sent |
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
755 |
> sdo_injection_timeout_cycles) |
1585
1f640e321ee4
ecrt_master_set_max_cycle_size: limit SDO traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
756 |
#else |
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
757 |
if (jiffies - datagram->jiffies_sent |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
758 |
> sdo_injection_timeout_jiffies) |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
759 |
#endif |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
760 |
{ |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
761 |
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
|
762 |
|
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
763 |
list_del_init(&datagram->queue); |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
764 |
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
|
765 |
#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
|
766 |
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
|
767 |
((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
|
768 |
/ cpu_khz; |
1585
1f640e321ee4
ecrt_master_set_max_cycle_size: limit SDO traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
769 |
#else |
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
770 |
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
|
771 |
((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
|
772 |
#endif |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
773 |
EC_ERR("Timeout %u us: injecting external datagram %p" |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
774 |
" size=%u, max_queue_size=%u\n", |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
775 |
time_us, datagram, |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
776 |
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
|
777 |
} |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
778 |
#if DEBUG_INJECT |
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
779 |
else if (master->debug_level) { |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
780 |
EC_DBG("Deferred injecting of external datagram %p" |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
781 |
" size=%u, queue_size=%u\n", |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
782 |
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
|
783 |
} |
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
784 |
#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
|
785 |
} |
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
|
786 |
} |
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
|
787 |
} |
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
788 |
} |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
789 |
|
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
790 |
/*****************************************************************************/ |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
791 |
|
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
792 |
/** 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
|
793 |
* 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
|
794 |
*/ |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
795 |
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
|
796 |
ec_master_t *master, /**< EtherCAT master */ |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
797 |
size_t 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
|
798 |
) |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
799 |
{ |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
800 |
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
|
801 |
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
|
802 |
(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
|
803 |
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
|
804 |
} |
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
|
805 |
|
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
|
806 |
/*****************************************************************************/ |
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
|
807 |
|
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
808 |
/** Places an external datagram in the sdo datagram queue. |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
809 |
*/ |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
810 |
void ec_master_queue_external_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
|
811 |
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
|
812 |
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
|
813 |
) |
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
|
814 |
{ |
1804 | 815 |
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
|
816 |
|
e36c92cf58a9
use given send interval to limit SDO/FOE traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
817 |
down(&master->io_sem); |
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
818 |
|
1804 | 819 |
// check, if the datagram is already queued |
820 |
list_for_each_entry(queued_datagram, &master->external_datagram_queue, |
|
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
821 |
queue) { |
1804 | 822 |
if (queued_datagram == datagram) { |
823 |
datagram->state = EC_DATAGRAM_QUEUED; |
|
824 |
return; |
|
825 |
} |
|
826 |
} |
|
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
827 |
|
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
828 |
#if DEBUG_INJECT |
1804 | 829 |
if (master->debug_level) { |
830 |
EC_DBG("Requesting external datagram %p size=%u\n", |
|
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
831 |
datagram, datagram->data_size); |
1804 | 832 |
} |
833 |
#endif |
|
834 |
||
835 |
list_add_tail(&datagram->queue, &master->external_datagram_queue); |
|
836 |
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
|
837 |
#ifdef EC_HAVE_CYCLES |
1804 | 838 |
datagram->cycles_sent = get_cycles(); |
839 |
#endif |
|
840 |
datagram->jiffies_sent = jiffies; |
|
841 |
||
842 |
master->fsm.idle = 0; |
|
843 |
up(&master->io_sem); |
|
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 |
{ |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
855 |
ec_datagram_t *queued_datagram; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
856 |
|
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
|
857 |
if (datagram->state == EC_DATAGRAM_SENT) |
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
|
858 |
return; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
859 |
// check, if the datagram is already queued |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
860 |
list_for_each_entry(queued_datagram, &master->datagram_queue, queue) { |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
861 |
if (queued_datagram == datagram) { |
719
03d5b96632fb
Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents:
715
diff
changeset
|
862 |
datagram->skip_count++; |
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
863 |
if (master->debug_level) |
1543
373cd456dc26
Avoid warnings on x86_64 platform. Thanks to Thomas Elste.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
864 |
EC_DBG("skipping datagram %p.\n", datagram); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
865 |
datagram->state = EC_DATAGRAM_QUEUED; |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
866 |
return; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
867 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
868 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
869 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
870 |
list_add_tail(&datagram->queue, &master->datagram_queue); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
871 |
datagram->state = EC_DATAGRAM_QUEUED; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
872 |
} |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
873 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
874 |
/*****************************************************************************/ |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
875 |
|
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
876 |
/** Places a datagram in the non-application datagram queue. |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
877 |
*/ |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
878 |
void ec_master_queue_datagram_ext( |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
879 |
ec_master_t *master, /**< EtherCAT master */ |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
880 |
ec_datagram_t *datagram /**< datagram */ |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
881 |
) |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
882 |
{ |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
883 |
down(&master->ext_queue_sem); |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
884 |
list_add_tail(&datagram->queue, &master->ext_datagram_queue); |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
885 |
up(&master->ext_queue_sem); |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
886 |
} |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
887 |
|
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
888 |
/*****************************************************************************/ |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
889 |
|
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
890 |
/** 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
|
891 |
* |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
892 |
*/ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
893 |
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
|
894 |
{ |
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
895 |
ec_datagram_t *datagram, *next; |
1804 | 896 |
size_t datagram_size; |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
897 |
uint8_t *frame_data, *cur_data; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
898 |
void *follows_word; |
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_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
|
901 |
#endif |
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
902 |
unsigned long jiffies_sent; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
903 |
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
|
904 |
struct list_head sent_datagrams; |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
905 |
|
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
906 |
#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
|
907 |
cycles_start = get_cycles(); |
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
908 |
#endif |
176 | 909 |
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
|
910 |
INIT_LIST_HEAD(&sent_datagrams); |
208
b7797f8a813d
command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents:
206
diff
changeset
|
911 |
|
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
912 |
if (unlikely(master->debug_level > 1)) |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
913 |
EC_DBG("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
|
914 |
|
176 | 915 |
do { |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
916 |
// 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
|
917 |
frame_data = ec_device_tx_data(&master->main_device); |
176 | 918 |
cur_data = frame_data + EC_FRAME_HEADER_SIZE; |
919 |
follows_word = NULL; |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
920 |
more_datagrams_waiting = 0; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
921 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
922 |
// fill current frame with datagrams |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
923 |
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
|
924 |
if (datagram->state != EC_DATAGRAM_QUEUED) continue; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
925 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
926 |
// does the current datagram fit in the frame? |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
927 |
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
|
928 |
+ EC_DATAGRAM_FOOTER_SIZE; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
929 |
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
|
930 |
more_datagrams_waiting = 1; |
176 | 931 |
break; |
932 |
} |
|
933 |
||
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
934 |
list_add_tail(&datagram->sent, &sent_datagrams); |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
935 |
datagram->index = master->datagram_index++; |
176 | 936 |
|
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
937 |
if (unlikely(master->debug_level > 1)) |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
938 |
EC_DBG("adding datagram 0x%02X\n", datagram->index); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
939 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
940 |
// set "datagram following" flag in previous frame |
176 | 941 |
if (follows_word) |
942 |
EC_WRITE_U16(follows_word, EC_READ_U16(follows_word) | 0x8000); |
|
943 |
||
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
944 |
// EtherCAT datagram header |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
945 |
EC_WRITE_U8 (cur_data, datagram->type); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
946 |
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
|
947 |
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
|
948 |
EC_WRITE_U16(cur_data + 6, datagram->data_size & 0x7FF); |
176 | 949 |
EC_WRITE_U16(cur_data + 8, 0x0000); |
950 |
follows_word = cur_data + 6; |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
951 |
cur_data += EC_DATAGRAM_HEADER_SIZE; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
952 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
953 |
// EtherCAT datagram data |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
954 |
memcpy(cur_data, datagram->data, datagram->data_size); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
955 |
cur_data += datagram->data_size; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
956 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
957 |
// EtherCAT datagram footer |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
958 |
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
|
959 |
cur_data += EC_DATAGRAM_FOOTER_SIZE; |
176 | 960 |
} |
961 |
||
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
962 |
if (list_empty(&sent_datagrams)) { |
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
963 |
if (unlikely(master->debug_level > 1)) |
176 | 964 |
EC_DBG("nothing to send.\n"); |
965 |
break; |
|
966 |
} |
|
967 |
||
968 |
// EtherCAT frame header |
|
969 |
EC_WRITE_U16(frame_data, ((cur_data - frame_data |
|
970 |
- EC_FRAME_HEADER_SIZE) & 0x7FF) | 0x1000); |
|
971 |
||
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
972 |
// pad frame |
211
c684b6b7adaf
Using kernel Ethernet constants.
Florian Pose <fp@igh-essen.com>
parents:
208
diff
changeset
|
973 |
while (cur_data - frame_data < ETH_ZLEN - ETH_HLEN) |
176 | 974 |
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
|
975 |
|
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
976 |
if (unlikely(master->debug_level > 1)) |
1543
373cd456dc26
Avoid warnings on x86_64 platform. Thanks to Thomas Elste.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
977 |
EC_DBG("frame size: %zu\n", cur_data - frame_data); |
176 | 978 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
979 |
// 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
|
980 |
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
|
981 |
#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
|
982 |
cycles_sent = get_cycles(); |
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
983 |
#endif |
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
984 |
jiffies_sent = jiffies; |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
985 |
|
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
986 |
// 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
|
987 |
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
|
988 |
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
|
989 |
#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
|
990 |
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
|
991 |
#endif |
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
992 |
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
|
993 |
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
|
994 |
} |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
995 |
|
176 | 996 |
frame_count++; |
997 |
} |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
998 |
while (more_datagrams_waiting); |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
999 |
|
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
1000 |
#ifdef EC_HAVE_CYCLES |
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
1001 |
if (unlikely(master->debug_level > 1)) { |
344
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
1002 |
cycles_end = get_cycles(); |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
958
diff
changeset
|
1003 |
EC_DBG("ec_master_send_datagrams sent %u frames in %uus.\n", |
344
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
1004 |
frame_count, |
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
1005 |
(unsigned int) (cycles_end - cycles_start) * 1000 / cpu_khz); |
176 | 1006 |
} |
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
1007 |
#endif |
176 | 1008 |
} |
1009 |
||
1010 |
/*****************************************************************************/ |
|
1011 |
||
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
1012 |
/** Processes a received frame. |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
1013 |
* |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
1014 |
* 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
|
1015 |
* |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
1016 |
* \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
|
1017 |
*/ |
331
17f58fe99511
Renamed ec_master_receive() to ec_master_receive_datagrams().
Florian Pose <fp@igh-essen.com>
parents:
330
diff
changeset
|
1018 |
void ec_master_receive_datagrams(ec_master_t *master, /**< EtherCAT master */ |
17f58fe99511
Renamed ec_master_receive() to ec_master_receive_datagrams().
Florian Pose <fp@igh-essen.com>
parents:
330
diff
changeset
|
1019 |
const uint8_t *frame_data, /**< frame data */ |
17f58fe99511
Renamed ec_master_receive() to ec_master_receive_datagrams().
Florian Pose <fp@igh-essen.com>
parents:
330
diff
changeset
|
1020 |
size_t size /**< size of the received data */ |
17f58fe99511
Renamed ec_master_receive() to ec_master_receive_datagrams().
Florian Pose <fp@igh-essen.com>
parents:
330
diff
changeset
|
1021 |
) |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1022 |
{ |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1023 |
size_t frame_size, data_size; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1024 |
uint8_t datagram_type, datagram_index; |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1025 |
unsigned int cmd_follows, matched; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1026 |
const uint8_t *cur_data; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1027 |
ec_datagram_t *datagram; |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1028 |
|
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1029 |
if (unlikely(size < EC_FRAME_HEADER_SIZE)) { |
1303
448f2e9fa483
Output corrupted frame reasons.
Florian Pose <fp@igh-essen.com>
parents:
1279
diff
changeset
|
1030 |
if (master->debug_level) { |
1543
373cd456dc26
Avoid warnings on x86_64 platform. Thanks to Thomas Elste.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
1031 |
EC_DBG("Corrupted frame received (size %zu < %u byte):\n", |
1303
448f2e9fa483
Output corrupted frame reasons.
Florian Pose <fp@igh-essen.com>
parents:
1279
diff
changeset
|
1032 |
size, EC_FRAME_HEADER_SIZE); |
448f2e9fa483
Output corrupted frame reasons.
Florian Pose <fp@igh-essen.com>
parents:
1279
diff
changeset
|
1033 |
ec_print_data(frame_data, size); |
448f2e9fa483
Output corrupted frame reasons.
Florian Pose <fp@igh-essen.com>
parents:
1279
diff
changeset
|
1034 |
} |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1035 |
master->stats.corrupted++; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1036 |
ec_master_output_stats(master); |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1037 |
return; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1038 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1039 |
|
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1040 |
cur_data = frame_data; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1041 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1042 |
// 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
|
1043 |
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
|
1044 |
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
|
1045 |
|
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1046 |
if (unlikely(frame_size > size)) { |
1303
448f2e9fa483
Output corrupted frame reasons.
Florian Pose <fp@igh-essen.com>
parents:
1279
diff
changeset
|
1047 |
if (master->debug_level) { |
1543
373cd456dc26
Avoid warnings on x86_64 platform. Thanks to Thomas Elste.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
1048 |
EC_DBG("Corrupted frame received (invalid frame size %zu for " |
373cd456dc26
Avoid warnings on x86_64 platform. Thanks to Thomas Elste.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
1049 |
"received size %zu):\n", frame_size, size); |
1303
448f2e9fa483
Output corrupted frame reasons.
Florian Pose <fp@igh-essen.com>
parents:
1279
diff
changeset
|
1050 |
ec_print_data(frame_data, size); |
448f2e9fa483
Output corrupted frame reasons.
Florian Pose <fp@igh-essen.com>
parents:
1279
diff
changeset
|
1051 |
} |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1052 |
master->stats.corrupted++; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1053 |
ec_master_output_stats(master); |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1054 |
return; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1055 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1056 |
|
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1057 |
cmd_follows = 1; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1058 |
while (cmd_follows) { |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1059 |
// process datagram header |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1060 |
datagram_type = EC_READ_U8 (cur_data); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1061 |
datagram_index = EC_READ_U8 (cur_data + 1); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1062 |
data_size = EC_READ_U16(cur_data + 6) & 0x07FF; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1063 |
cmd_follows = EC_READ_U16(cur_data + 6) & 0x8000; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1064 |
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
|
1065 |
|
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1066 |
if (unlikely(cur_data - frame_data |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1067 |
+ data_size + EC_DATAGRAM_FOOTER_SIZE > size)) { |
1303
448f2e9fa483
Output corrupted frame reasons.
Florian Pose <fp@igh-essen.com>
parents:
1279
diff
changeset
|
1068 |
if (master->debug_level) { |
1543
373cd456dc26
Avoid warnings on x86_64 platform. Thanks to Thomas Elste.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
1069 |
EC_DBG("Corrupted frame received (invalid data size %zu):\n", |
1303
448f2e9fa483
Output corrupted frame reasons.
Florian Pose <fp@igh-essen.com>
parents:
1279
diff
changeset
|
1070 |
data_size); |
448f2e9fa483
Output corrupted frame reasons.
Florian Pose <fp@igh-essen.com>
parents:
1279
diff
changeset
|
1071 |
ec_print_data(frame_data, size); |
448f2e9fa483
Output corrupted frame reasons.
Florian Pose <fp@igh-essen.com>
parents:
1279
diff
changeset
|
1072 |
} |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1073 |
master->stats.corrupted++; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1074 |
ec_master_output_stats(master); |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1075 |
return; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1076 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1077 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1078 |
// 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
|
1079 |
matched = 0; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1080 |
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
|
1081 |
if (datagram->index == datagram_index |
5e231f6a3d2e
Re-ordered criteria for datagram matching.
Florian Pose <fp@igh-essen.com>
parents:
688
diff
changeset
|
1082 |
&& datagram->state == EC_DATAGRAM_SENT |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1083 |
&& datagram->type == datagram_type |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1084 |
&& 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
|
1085 |
matched = 1; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1086 |
break; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1087 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1088 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1089 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1090 |
// 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
|
1091 |
if (!matched) { |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1092 |
master->stats.unmatched++; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1093 |
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
|
1094 |
|
bf991809dcf0
Added debugging output for unmatched frames and those that timed out.
Florian Pose <fp@igh-essen.com>
parents:
664
diff
changeset
|
1095 |
if (unlikely(master->debug_level > 0)) { |
bf991809dcf0
Added debugging output for unmatched frames and those that timed out.
Florian Pose <fp@igh-essen.com>
parents:
664
diff
changeset
|
1096 |
EC_DBG("UNMATCHED datagram:\n"); |
bf991809dcf0
Added debugging output for unmatched frames and those that timed out.
Florian Pose <fp@igh-essen.com>
parents:
664
diff
changeset
|
1097 |
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
|
1098 |
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
|
1099 |
+ 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
|
1100 |
#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
|
1101 |
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
|
1102 |
#endif |
684
bf991809dcf0
Added debugging output for unmatched frames and those that timed out.
Florian Pose <fp@igh-essen.com>
parents:
664
diff
changeset
|
1103 |
} |
bf991809dcf0
Added debugging output for unmatched frames and those that timed out.
Florian Pose <fp@igh-essen.com>
parents:
664
diff
changeset
|
1104 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1105 |
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
|
1106 |
continue; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1107 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1108 |
|
345
beb0a77d73c0
Improved datagram reception in sync_io and frame dequeuing.
Florian Pose <fp@igh-essen.com>
parents:
344
diff
changeset
|
1109 |
// copy received data into the datagram memory |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1110 |
memcpy(datagram->data, cur_data, data_size); |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1111 |
cur_data += data_size; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1112 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1113 |
// set the datagram's working counter |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1114 |
datagram->working_counter = EC_READ_U16(cur_data); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1115 |
cur_data += EC_DATAGRAM_FOOTER_SIZE; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1116 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1117 |
// 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
|
1118 |
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
|
1119 |
#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
|
1120 |
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
|
1121 |
#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
|
1122 |
datagram->jiffies_received = master->main_device.jiffies_poll; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1123 |
list_del_init(&datagram->queue); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1124 |
} |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1125 |
} |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1126 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1127 |
/*****************************************************************************/ |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1128 |
|
1029
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
1129 |
/** Output master statistics. |
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
1130 |
* |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
1131 |
* 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
|
1132 |
* 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
|
1133 |
*/ |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1134 |
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
|
1135 |
{ |
344
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
1136 |
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
|
1137 |
master->stats.output_jiffies = jiffies; |
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
1138 |
|
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1139 |
if (master->stats.timeouts) { |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
958
diff
changeset
|
1140 |
EC_WARN("%u datagram%s TIMED OUT!\n", master->stats.timeouts, |
396 | 1141 |
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
|
1142 |
master->stats.timeouts = 0; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1143 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1144 |
if (master->stats.corrupted) { |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
958
diff
changeset
|
1145 |
EC_WARN("%u frame%s CORRUPTED!\n", master->stats.corrupted, |
396 | 1146 |
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
|
1147 |
master->stats.corrupted = 0; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1148 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1149 |
if (master->stats.unmatched) { |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
958
diff
changeset
|
1150 |
EC_WARN("%u datagram%s UNMATCHED!\n", master->stats.unmatched, |
396 | 1151 |
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
|
1152 |
master->stats.unmatched = 0; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
1153 |
} |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
1154 |
} |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
1155 |
} |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
1156 |
|
1600
e36c92cf58a9
use given send interval to limit SDO/FOE traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
1157 |
|
e36c92cf58a9
use given send interval to limit SDO/FOE traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
1158 |
/*****************************************************************************/ |
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
|
1159 |
|
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
|
1160 |
#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
|
1161 |
|
1600
e36c92cf58a9
use given send interval to limit SDO/FOE traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
1162 |
/* |
e36c92cf58a9
use given send interval to limit SDO/FOE traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
1163 |
* Sleep related functions: |
e36c92cf58a9
use given send interval to limit SDO/FOE traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
1164 |
*/ |
e36c92cf58a9
use given send interval to limit SDO/FOE traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
1165 |
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
|
1166 |
{ |
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
|
1167 |
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
|
1168 |
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
|
1169 |
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
|
1170 |
|
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
|
1171 |
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
|
1172 |
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
|
1173 |
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
|
1174 |
|
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
|
1175 |
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
|
1176 |
} |
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
|
1177 |
|
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
|
1178 |
/*****************************************************************************/ |
1600
e36c92cf58a9
use given send interval to limit SDO/FOE traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
1179 |
|
1603
8e528f806dc5
fix build for recent kernel versions (tested with 2.6.31)
Matthias Luescher <ch1010472@ch10lt140>
parents:
1600
diff
changeset
|
1180 |
#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
|
1181 |
|
1603
8e528f806dc5
fix build for recent kernel versions (tested with 2.6.31)
Matthias Luescher <ch1010472@ch10lt140>
parents:
1600
diff
changeset
|
1182 |
/* 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
|
1183 |
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
|
1184 |
{ |
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
|
1185 |
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
|
1186 |
} |
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
|
1187 |
|
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
|
1188 |
/*****************************************************************************/ |
1603
8e528f806dc5
fix build for recent kernel versions (tested with 2.6.31)
Matthias Luescher <ch1010472@ch10lt140>
parents:
1600
diff
changeset
|
1189 |
|
8e528f806dc5
fix build for recent kernel versions (tested with 2.6.31)
Matthias Luescher <ch1010472@ch10lt140>
parents:
1600
diff
changeset
|
1190 |
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
|
1191 |
{ |
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
|
1192 |
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
|
1193 |
} |
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
|
1194 |
|
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
|
1195 |
#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
|
1196 |
|
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
|
1197 |
/*****************************************************************************/ |
1603
8e528f806dc5
fix build for recent kernel versions (tested with 2.6.31)
Matthias Luescher <ch1010472@ch10lt140>
parents:
1600
diff
changeset
|
1198 |
|
1600
e36c92cf58a9
use given send interval to limit SDO/FOE traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
1199 |
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
|
1200 |
{ |
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
|
1201 |
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
|
1202 |
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
|
1203 |
|
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
|
1204 |
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
|
1205 |
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
|
1206 |
t.task = current; |
1600
e36c92cf58a9
use given send interval to limit SDO/FOE traffic
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
1207 |
#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
|
1208 |
#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
|
1209 |
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
|
1210 |
#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
|
1211 |
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
|
1212 |
#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
|
1213 |
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
|
1214 |
#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
|
1215 |
#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
|
1216 |
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
|
1217 |
|
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
|
1218 |
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
|
1219 |
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
|
1220 |
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
|
1221 |
|
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
|
1222 |
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
|
1223 |
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
|
1224 |
|
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
|
1225 |
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
|
1226 |
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
|
1227 |
|
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
|
1228 |
} 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
|
1229 |
} |
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
|
1230 |
|
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
|
1231 |
#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
|
1232 |
|
68
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
66
diff
changeset
|
1233 |
/*****************************************************************************/ |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
66
diff
changeset
|
1234 |
|
1029
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
1235 |
/** 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
|
1236 |
*/ |
1241
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
1237 |
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
|
1238 |
{ |
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
1239 |
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
|
1240 |
ec_slave_t *slave = NULL; |
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
|
1241 |
int fsm_exec; |
1804 | 1242 |
size_t sent_bytes; |
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
1243 |
|
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
1244 |
// send interval in IDLE phase |
1804 | 1245 |
ec_master_set_send_interval(master, 1000000 / HZ); |
1246 |
||
1247 |
if (master->debug_level) |
|
1248 |
EC_DBG("Idle thread running with send interval = %d us," |
|
1774
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
1249 |
" max data size=%d\n", master->send_interval, |
a9143f82c7c5
Fixed name of byte transmission time define; changed coding style.
Florian Pose <fp@igh-essen.com>
parents:
1773
diff
changeset
|
1250 |
master->max_queue_size); |
1241
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
1251 |
|
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
1252 |
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
|
1253 |
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
|
1254 |
|
1031
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
1255 |
// receive |
1489
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1256 |
down(&master->io_sem); |
1031
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
1257 |
ecrt_master_receive(master); |
1489
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1258 |
up(&master->io_sem); |
1031
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
1259 |
|
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
|
1260 |
fsm_exec = 0; |
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
|
1261 |
// execute master & slave state machines |
1241
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
1262 |
if (down_interruptible(&master->master_sem)) |
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
1263 |
break; |
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
|
1264 |
fsm_exec = ec_fsm_master_exec(&master->fsm); |
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
|
1265 |
for (slave = master->slaves; |
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
|
1266 |
slave < master->slaves + master->slave_count; |
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
|
1267 |
slave++) { |
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
|
1268 |
ec_fsm_slave_exec(&slave->fsm); |
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
|
1269 |
} |
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
|
1270 |
up(&master->master_sem); |
1031
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
1271 |
|
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
1272 |
// queue and send |
1489
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1273 |
down(&master->io_sem); |
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
|
1274 |
if (fsm_exec) { |
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
|
1275 |
ec_master_queue_datagram(master, &master->fsm_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
|
1276 |
} |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
1277 |
ec_master_inject_external_datagrams(master); |
1031
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
1278 |
ecrt_master_send(master); |
1804 | 1279 |
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
|
1280 |
master->main_device.tx_ring_index]->len; |
1489
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1281 |
up(&master->io_sem); |
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
|
1282 |
|
1804 | 1283 |
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
|
1284 |
#ifdef EC_USE_HRTIMER |
1804 | 1285 |
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
|
1286 |
#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
|
1287 |
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
|
1288 |
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
|
1289 |
#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
|
1290 |
} 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
|
1291 |
#ifdef EC_USE_HRTIMER |
1804 | 1292 |
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
|
1293 |
#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
|
1294 |
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
|
1295 |
#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
|
1296 |
} |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
1297 |
} |
518
b6a1426ba724
Fixed race: Stop EoE processing when entering or leaving operation mode.
Florian Pose <fp@igh-essen.com>
parents:
517
diff
changeset
|
1298 |
|
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1299 |
if (master->debug_level) |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1300 |
EC_DBG("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
|
1301 |
|
1241
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
1302 |
return 0; |
191 | 1303 |
} |
1304 |
||
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
1305 |
/*****************************************************************************/ |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
1306 |
|
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
|
1307 |
/** 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
|
1308 |
*/ |
1241
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
1309 |
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
|
1310 |
{ |
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
1311 |
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
|
1312 |
ec_slave_t *slave = NULL; |
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
|
1313 |
int fsm_exec; |
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
|
1314 |
|
1241
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
1315 |
if (master->debug_level) |
1804 | 1316 |
EC_DBG("Operation thread running with fsm interval = %d us," |
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
|
1317 |
" max data size=%d\n", |
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
|
1318 |
master->send_interval, |
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
|
1319 |
master->max_queue_size); |
1241
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 |
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
|
1322 |
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
|
1323 |
|
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
|
1324 |
if (master->injection_seq_rt == master->injection_seq_fsm) { |
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
|
1325 |
// output statistics |
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
|
1326 |
ec_master_output_stats(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
|
1327 |
|
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
|
1328 |
fsm_exec = 0; |
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
|
1329 |
// execute master & slave state machines |
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
|
1330 |
if (down_interruptible(&master->master_sem)) |
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
|
1331 |
break; |
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
|
1332 |
fsm_exec += ec_fsm_master_exec(&master->fsm); |
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
|
1333 |
for (slave = master->slaves; |
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
|
1334 |
slave < master->slaves + master->slave_count; |
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
|
1335 |
slave++) { |
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
|
1336 |
ec_fsm_slave_exec(&slave->fsm); |
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
|
1337 |
} |
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
|
1338 |
up(&master->master_sem); |
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
|
1339 |
|
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
|
1340 |
// inject datagrams (let the rt thread queue them, see ecrt_master_send) |
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
|
1341 |
if (fsm_exec) |
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
|
1342 |
master->injection_seq_fsm++; |
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
|
1343 |
} |
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
|
1344 |
|
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
|
1345 |
#ifdef EC_USE_HRTIMER |
1804 | 1346 |
// the op thread should not work faster than the sending RT thread |
1347 |
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
|
1348 |
#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
|
1349 |
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
|
1350 |
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
|
1351 |
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
|
1352 |
} |
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
|
1353 |
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
|
1354 |
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
|
1355 |
} |
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
|
1356 |
#endif |
1804 | 1357 |
} |
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
1358 |
|
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1359 |
if (master->debug_level) |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1360 |
EC_DBG("Master OP thread exiting...\n"); |
1241
794cbccdcd00
Moved threads to kthread interface.
Florian Pose <fp@igh-essen.com>
parents:
1237
diff
changeset
|
1361 |
return 0; |
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
1362 |
} |
578
f402b4bd2f4d
Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents:
576
diff
changeset
|
1363 |
|
f402b4bd2f4d
Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents:
576
diff
changeset
|
1364 |
/*****************************************************************************/ |
f402b4bd2f4d
Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents:
576
diff
changeset
|
1365 |
|
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
1366 |
#ifdef EC_EOE |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
1367 |
/** Starts Ethernet over EtherCAT processing on demand. |
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
1368 |
*/ |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1369 |
void ec_master_eoe_start(ec_master_t *master /**< EtherCAT master */) |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1370 |
{ |
1489
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1371 |
struct sched_param param = { .sched_priority = 0 }; |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1372 |
|
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1373 |
if (master->eoe_thread) { |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1374 |
EC_WARN("EoE already running!\n"); |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1375 |
return; |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1376 |
} |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1377 |
|
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1378 |
if (list_empty(&master->eoe_handlers)) |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1379 |
return; |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1380 |
|
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
1381 |
if (!master->send_cb || !master->receive_cb) { |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
1382 |
EC_WARN("No EoE processing because of missing callbacks!\n"); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1383 |
return; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1384 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1385 |
|
1489
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1386 |
EC_INFO("Starting EoE thread.\n"); |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1387 |
master->eoe_thread = kthread_run(ec_master_eoe_thread, master, |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1388 |
"EtherCAT-EoE"); |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1389 |
if (IS_ERR(master->eoe_thread)) { |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1390 |
int err = (int) PTR_ERR(master->eoe_thread); |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1391 |
EC_ERR("Failed to start EoE thread (error %i)!\n", err); |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1392 |
master->eoe_thread = NULL; |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1393 |
return; |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1394 |
} |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1395 |
|
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1396 |
sched_setscheduler(master->eoe_thread, SCHED_NORMAL, ¶m); |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1397 |
set_user_nice(master->eoe_thread, 0); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1398 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1399 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1400 |
/*****************************************************************************/ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1401 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
1402 |
/** Stops 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
|
1403 |
*/ |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1404 |
void ec_master_eoe_stop(ec_master_t *master /**< EtherCAT master */) |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1405 |
{ |
1489
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1406 |
if (master->eoe_thread) { |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1407 |
EC_INFO("Stopping EoE thread.\n"); |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1408 |
|
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1409 |
kthread_stop(master->eoe_thread); |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1410 |
master->eoe_thread = NULL; |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1411 |
EC_INFO("EoE thread exited.\n"); |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1412 |
} |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1413 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1414 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1415 |
/*****************************************************************************/ |
441
ffa13db95e10
SDO uploading via Sysfs without master FSM calling wake_up().
Florian Pose <fp@igh-essen.com>
parents:
435
diff
changeset
|
1416 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
1417 |
/** 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
|
1418 |
*/ |
1489
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1419 |
static int ec_master_eoe_thread(void *priv_data) |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1420 |
{ |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1421 |
ec_master_t *master = (ec_master_t *) priv_data; |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1422 |
ec_eoe_t *eoe; |
1489
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1423 |
unsigned int none_open, sth_to_send, all_idle; |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1424 |
|
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1425 |
if (master->debug_level) |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1426 |
EC_DBG("EoE thread running.\n"); |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1427 |
|
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1428 |
while (!kthread_should_stop()) { |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1429 |
none_open = 1; |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1430 |
all_idle = 1; |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1431 |
|
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1432 |
list_for_each_entry(eoe, &master->eoe_handlers, list) { |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1433 |
if (ec_eoe_is_open(eoe)) { |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1434 |
none_open = 0; |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1435 |
break; |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1436 |
} |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1437 |
} |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1438 |
if (none_open) |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1439 |
goto schedule; |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1440 |
|
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1441 |
// receive datagrams |
1513
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1442 |
master->receive_cb(master->cb_data); |
1489
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1443 |
|
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1444 |
// actual EoE processing |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1445 |
sth_to_send = 0; |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1446 |
list_for_each_entry(eoe, &master->eoe_handlers, list) { |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1447 |
ec_eoe_run(eoe); |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1448 |
if (eoe->queue_datagram) { |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1449 |
sth_to_send = 1; |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1450 |
} |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1451 |
if (!ec_eoe_is_idle(eoe)) { |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1452 |
all_idle = 0; |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1453 |
} |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1454 |
} |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1455 |
|
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1456 |
if (sth_to_send) { |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1457 |
list_for_each_entry(eoe, &master->eoe_handlers, list) { |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1458 |
ec_eoe_queue(eoe); |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1459 |
} |
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
1460 |
// (try to) send datagrams |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
1461 |
down(&master->ext_queue_sem); |
1513
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1462 |
master->send_cb(master->cb_data); |
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
1463 |
up(&master->ext_queue_sem); |
1489
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1464 |
} |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1465 |
|
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1466 |
schedule: |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1467 |
if (all_idle) { |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1468 |
set_current_state(TASK_INTERRUPTIBLE); |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1469 |
schedule_timeout(1); |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1470 |
} else { |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1471 |
schedule(); |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1472 |
} |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1473 |
} |
1041
42c9ac58d9ce
Removed state machine cycle time measuring.
Florian Pose <fp@igh-essen.com>
parents:
1040
diff
changeset
|
1474 |
|
1489
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1475 |
if (master->debug_level) |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1476 |
EC_DBG("EoE thread exiting...\n"); |
f77a1182b6f4
EoE processing with kthread.
Florian Pose <fp@igh-essen.com>
parents:
1485
diff
changeset
|
1477 |
return 0; |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1478 |
} |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
1479 |
#endif |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1480 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
1481 |
/*****************************************************************************/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
1482 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1483 |
/** 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
|
1484 |
*/ |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1485 |
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
|
1486 |
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
|
1487 |
) |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1488 |
{ |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1489 |
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
|
1490 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1491 |
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
|
1492 |
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
|
1493 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1494 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1495 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1496 |
/*****************************************************************************/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1497 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1498 |
/** 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
|
1499 |
*/ |
1028
afdd4bdbb7ec
Removed configs_attached flag; changed return value of
Florian Pose <fp@igh-essen.com>
parents:
1024
diff
changeset
|
1500 |
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
|
1501 |
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
|
1502 |
) |
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 |
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
|
1505 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1506 |
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
|
1507 |
ec_slave_config_attach(sc); |
afdd4bdbb7ec
Removed configs_attached flag; changed return value of
Florian Pose <fp@igh-essen.com>
parents:
1024
diff
changeset
|
1508 |
} |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1509 |
} |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1510 |
|
927
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1511 |
/*****************************************************************************/ |
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1512 |
|
1077
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1513 |
/** Common implementation for ec_master_find_slave() |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1514 |
* and ec_master_find_slave_const(). |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1515 |
*/ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1516 |
#define EC_FIND_SLAVE \ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1517 |
do { \ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1518 |
if (alias) { \ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1519 |
for (; slave < master->slaves + master->slave_count; \ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1520 |
slave++) { \ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1521 |
if (slave->sii.alias == alias) \ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1522 |
break; \ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1523 |
} \ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1524 |
if (slave == master->slaves + master->slave_count) \ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1525 |
return NULL; \ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1526 |
} \ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1527 |
\ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1528 |
slave += position; \ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1529 |
if (slave < master->slaves + master->slave_count) { \ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1530 |
return slave; \ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1531 |
} else { \ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1532 |
return NULL; \ |
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 |
} while (0) |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1535 |
|
927
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1536 |
/** 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
|
1537 |
*/ |
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1538 |
ec_slave_t *ec_master_find_slave( |
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1539 |
ec_master_t *master, /**< EtherCAT master. */ |
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1540 |
uint16_t alias, /**< Slave alias. */ |
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1541 |
uint16_t position /**< Slave position. */ |
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1542 |
) |
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1543 |
{ |
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
1544 |
ec_slave_t *slave = master->slaves; |
1077
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1545 |
EC_FIND_SLAVE; |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1546 |
} |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1547 |
|
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1548 |
/** 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
|
1549 |
* |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1550 |
* Const version. |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1551 |
*/ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1552 |
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
|
1553 |
const ec_master_t *master, /**< EtherCAT master. */ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1554 |
uint16_t alias, /**< Slave alias. */ |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1555 |
uint16_t position /**< Slave position. */ |
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 |
const ec_slave_t *slave = master->slaves; |
c95cd717b852
Added ec_master_find_slave_const().
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1559 |
EC_FIND_SLAVE; |
927
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1560 |
} |
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1561 |
|
946
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1562 |
/*****************************************************************************/ |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1563 |
|
1092 | 1564 |
/** Get the number of slave configurations provided by the application. |
1565 |
* |
|
1566 |
* \return Number of configurations. |
|
1567 |
*/ |
|
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1568 |
unsigned int ec_master_config_count( |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1569 |
const ec_master_t *master /**< EtherCAT master. */ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1570 |
) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1571 |
{ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1572 |
const ec_slave_config_t *sc; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1573 |
unsigned int count = 0; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1574 |
|
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1575 |
list_for_each_entry(sc, &master->configs, list) { |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1576 |
count++; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1577 |
} |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1578 |
|
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1579 |
return count; |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1580 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1581 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1582 |
/*****************************************************************************/ |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1583 |
|
1252
0b411da5fd24
Added ec_master_get_config().
Florian Pose <fp@igh-essen.com>
parents:
1250
diff
changeset
|
1584 |
/** Common implementation for ec_master_get_config() |
0b411da5fd24
Added ec_master_get_config().
Florian Pose <fp@igh-essen.com>
parents:
1250
diff
changeset
|
1585 |
* and ec_master_get_config_const(). |
0b411da5fd24
Added ec_master_get_config().
Florian Pose <fp@igh-essen.com>
parents:
1250
diff
changeset
|
1586 |
*/ |
0b411da5fd24
Added ec_master_get_config().
Florian Pose <fp@igh-essen.com>
parents:
1250
diff
changeset
|
1587 |
#define EC_FIND_CONFIG \ |
0b411da5fd24
Added ec_master_get_config().
Florian Pose <fp@igh-essen.com>
parents:
1250
diff
changeset
|
1588 |
do { \ |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1589 |
list_for_each_entry(sc, &master->configs, list) { \ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1590 |
if (pos--) \ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1591 |
continue; \ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1592 |
return sc; \ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1593 |
} \ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1594 |
return NULL; \ |
1252
0b411da5fd24
Added ec_master_get_config().
Florian Pose <fp@igh-essen.com>
parents:
1250
diff
changeset
|
1595 |
} while (0) |
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 |
/** 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
|
1598 |
* |
0b411da5fd24
Added ec_master_get_config().
Florian Pose <fp@igh-essen.com>
parents:
1250
diff
changeset
|
1599 |
* \return Slave configuration or \a NULL. |
0b411da5fd24
Added ec_master_get_config().
Florian Pose <fp@igh-essen.com>
parents:
1250
diff
changeset
|
1600 |
*/ |
0b411da5fd24
Added ec_master_get_config().
Florian Pose <fp@igh-essen.com>
parents:
1250
diff
changeset
|
1601 |
ec_slave_config_t *ec_master_get_config( |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1602 |
const ec_master_t *master, /**< EtherCAT master. */ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1603 |
unsigned int pos /**< List position. */ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1604 |
) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1605 |
{ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1606 |
ec_slave_config_t *sc; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1607 |
EC_FIND_CONFIG; |
1252
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 |
|
1092 | 1610 |
/** Get a slave configuration via its position in the list. |
1611 |
* |
|
1612 |
* Const version. |
|
1613 |
* |
|
1614 |
* \return Slave configuration or \a NULL. |
|
1615 |
*/ |
|
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1616 |
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
|
1617 |
const ec_master_t *master, /**< EtherCAT master. */ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1618 |
unsigned int pos /**< List position. */ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1619 |
) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1620 |
{ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1621 |
const ec_slave_config_t *sc; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1622 |
EC_FIND_CONFIG; |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1623 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1624 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1625 |
/*****************************************************************************/ |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1626 |
|
1092 | 1627 |
/** Get the number of domains. |
1628 |
* |
|
1629 |
* \return Number of domains. |
|
1630 |
*/ |
|
946
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1631 |
unsigned int ec_master_domain_count( |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1632 |
const ec_master_t *master /**< EtherCAT master. */ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1633 |
) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1634 |
{ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1635 |
const ec_domain_t *domain; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1636 |
unsigned int count = 0; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1637 |
|
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1638 |
list_for_each_entry(domain, &master->domains, list) { |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1639 |
count++; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1640 |
} |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1641 |
|
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1642 |
return count; |
946
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1643 |
} |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1644 |
|
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1645 |
/*****************************************************************************/ |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1646 |
|
1082
ff06c58e269c
Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
1647 |
/** 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
|
1648 |
* 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
|
1649 |
*/ |
1078
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1650 |
#define EC_FIND_DOMAIN \ |
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1651 |
do { \ |
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1652 |
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
|
1653 |
if (index--) \ |
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1654 |
continue; \ |
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1655 |
return domain; \ |
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1656 |
} \ |
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1657 |
\ |
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1658 |
return NULL; \ |
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1659 |
} while (0) |
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1660 |
|
1092 | 1661 |
/** Get a domain via its position in the list. |
1662 |
* |
|
1663 |
* \return Domain pointer, or \a NULL if not found. |
|
1664 |
*/ |
|
946
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1665 |
ec_domain_t *ec_master_find_domain( |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1666 |
ec_master_t *master, /**< EtherCAT master. */ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1667 |
unsigned int index /**< Domain index. */ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1668 |
) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1669 |
{ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1670 |
ec_domain_t *domain; |
1078
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1671 |
EC_FIND_DOMAIN; |
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1672 |
} |
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1673 |
|
1092 | 1674 |
/** Get a domain via its position in the list. |
1675 |
* |
|
1676 |
* Const version. |
|
1677 |
* |
|
1678 |
* \return Domain pointer, or \a NULL if not found. |
|
1679 |
*/ |
|
1078
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1680 |
const ec_domain_t *ec_master_find_domain_const( |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1681 |
const ec_master_t *master, /**< EtherCAT master. */ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1682 |
unsigned int index /**< Domain index. */ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1683 |
) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1684 |
{ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1685 |
const ec_domain_t *domain; |
1078
fce58ba8a912
Added ec_master_find_domain_const().
Florian Pose <fp@igh-essen.com>
parents:
1077
diff
changeset
|
1686 |
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
|
1687 |
} |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1688 |
|
956
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1689 |
/*****************************************************************************/ |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1690 |
|
1516
e3b09f847512
Fixed compiler error on --disable-eoe.
Florian Pose <fp@igh-essen.com>
parents:
1513
diff
changeset
|
1691 |
#ifdef EC_EOE |
e3b09f847512
Fixed compiler error on --disable-eoe.
Florian Pose <fp@igh-essen.com>
parents:
1513
diff
changeset
|
1692 |
|
1485 | 1693 |
/** Get the number of EoE handlers. |
1694 |
* |
|
1695 |
* \return Number of EoE handlers. |
|
1696 |
*/ |
|
1697 |
uint16_t ec_master_eoe_handler_count( |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1698 |
const ec_master_t *master /**< EtherCAT master. */ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1699 |
) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1700 |
{ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1701 |
const ec_eoe_t *eoe; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1702 |
unsigned int count = 0; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1703 |
|
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1704 |
list_for_each_entry(eoe, &master->eoe_handlers, list) { |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1705 |
count++; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1706 |
} |
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 |
return count; |
1485 | 1709 |
} |
1710 |
||
1711 |
/*****************************************************************************/ |
|
1712 |
||
1713 |
/** Get an EoE handler via its position in the list. |
|
1714 |
* |
|
1715 |
* Const version. |
|
1716 |
* |
|
1717 |
* \return EoE handler pointer, or \a NULL if not found. |
|
1718 |
*/ |
|
1719 |
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
|
1720 |
const ec_master_t *master, /**< EtherCAT master. */ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1721 |
uint16_t index /**< EoE handler index. */ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1722 |
) |
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 |
const ec_eoe_t *eoe; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1725 |
|
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1726 |
list_for_each_entry(eoe, &master->eoe_handlers, list) { |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1727 |
if (index--) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1728 |
continue; |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1729 |
return eoe; |
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 NULL; |
1485 | 1733 |
} |
1734 |
||
1516
e3b09f847512
Fixed compiler error on --disable-eoe.
Florian Pose <fp@igh-essen.com>
parents:
1513
diff
changeset
|
1735 |
#endif |
e3b09f847512
Fixed compiler error on --disable-eoe.
Florian Pose <fp@igh-essen.com>
parents:
1513
diff
changeset
|
1736 |
|
1485 | 1737 |
/*****************************************************************************/ |
1738 |
||
1092 | 1739 |
/** Set the debug level. |
1740 |
* |
|
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
1741 |
* \retval 0 Success. |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
1742 |
* \retval -EINVAL Invalid debug level. |
1092 | 1743 |
*/ |
956
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1744 |
int ec_master_debug_level( |
1092 | 1745 |
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
|
1746 |
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
|
1747 |
) |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1748 |
{ |
1399
f79d4bb5b23a
Added debug_level module parameter. debug_level is now unsigned int.
Florian Pose <fp@igh-essen.com>
parents:
1396
diff
changeset
|
1749 |
if (level > 2) { |
f79d4bb5b23a
Added debug_level module parameter. debug_level is now unsigned int.
Florian Pose <fp@igh-essen.com>
parents:
1396
diff
changeset
|
1750 |
EC_ERR("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
|
1751 |
return -EINVAL; |
956
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1752 |
} |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1753 |
|
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1754 |
if (level != master->debug_level) { |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1755 |
master->debug_level = level; |
1399
f79d4bb5b23a
Added debug_level module parameter. debug_level is now unsigned int.
Florian Pose <fp@igh-essen.com>
parents:
1396
diff
changeset
|
1756 |
EC_INFO("Master debug level set to %u.\n", master->debug_level); |
956
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1757 |
} |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1758 |
|
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1759 |
return 0; |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1760 |
} |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1761 |
|
1408 | 1762 |
/*****************************************************************************/ |
1763 |
||
1764 |
/** Finds the DC reference clock. |
|
1765 |
*/ |
|
1766 |
void ec_master_find_dc_ref_clock( |
|
1767 |
ec_master_t *master /**< EtherCAT master. */ |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1768 |
) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1769 |
{ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1770 |
ec_slave_t *slave, *ref = NULL; |
1408 | 1771 |
|
1772 |
for (slave = master->slaves; |
|
1773 |
slave < master->slaves + master->slave_count; |
|
1774 |
slave++) { |
|
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1775 |
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
|
1776 |
ref = slave; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1777 |
break; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1778 |
} |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1779 |
} |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1780 |
|
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1781 |
master->dc_ref_clock = ref; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1782 |
|
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1783 |
// 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
|
1784 |
ec_datagram_frmw(&master->sync_datagram, |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1785 |
ref ? ref->station_address : 0xffff, 0x0910, 4); |
1408 | 1786 |
} |
1787 |
||
1421 | 1788 |
/*****************************************************************************/ |
1789 |
||
1790 |
/** Calculates the bus topology; recursion function. |
|
1791 |
*/ |
|
1792 |
int ec_master_calc_topology_rec( |
|
1793 |
ec_master_t *master, /**< EtherCAT master. */ |
|
1794 |
ec_slave_t *port0_slave, /**< Slave at port 0. */ |
|
1795 |
unsigned int *slave_position /**< Slave position. */ |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1796 |
) |
1421 | 1797 |
{ |
1798 |
ec_slave_t *slave = master->slaves + *slave_position; |
|
1799 |
unsigned int i; |
|
1800 |
int ret; |
|
1801 |
||
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1802 |
slave->ports[0].next_slave = port0_slave; |
1421 | 1803 |
|
1804 |
for (i = 1; i < EC_MAX_PORTS; i++) { |
|
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1805 |
if (!slave->ports[i].link.loop_closed) { |
1421 | 1806 |
*slave_position = *slave_position + 1; |
1807 |
if (*slave_position < master->slave_count) { |
|
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1808 |
slave->ports[i].next_slave = master->slaves + *slave_position; |
1421 | 1809 |
ret = ec_master_calc_topology_rec(master, |
1810 |
slave, slave_position); |
|
1811 |
if (ret) |
|
1812 |
return ret; |
|
1813 |
} else { |
|
1814 |
return -1; |
|
1815 |
} |
|
1816 |
} |
|
1817 |
} |
|
1818 |
||
1819 |
return 0; |
|
1820 |
} |
|
1821 |
||
1822 |
/*****************************************************************************/ |
|
1823 |
||
1824 |
/** Calculates the bus topology. |
|
1825 |
*/ |
|
1826 |
void ec_master_calc_topology( |
|
1827 |
ec_master_t *master /**< EtherCAT master. */ |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1828 |
) |
1421 | 1829 |
{ |
1830 |
unsigned int slave_position = 0; |
|
1831 |
||
1832 |
if (master->slave_count == 0) |
|
1833 |
return; |
|
1834 |
||
1835 |
if (ec_master_calc_topology_rec(master, NULL, &slave_position)) |
|
1836 |
EC_ERR("Failed to calculate bus topology.\n"); |
|
1837 |
} |
|
1838 |
||
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1839 |
/*****************************************************************************/ |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1840 |
|
1426 | 1841 |
/** Calculates the bus transmission delays. |
1842 |
*/ |
|
1843 |
void ec_master_calc_transmission_delays( |
|
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1844 |
ec_master_t *master /**< EtherCAT master. */ |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1845 |
) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1846 |
{ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1847 |
ec_slave_t *slave; |
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1848 |
|
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1849 |
for (slave = master->slaves; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1850 |
slave < master->slaves + master->slave_count; |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1851 |
slave++) { |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1852 |
ec_slave_calc_port_delays(slave); |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1853 |
} |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1854 |
|
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1855 |
if (master->dc_ref_clock) { |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1856 |
uint32_t delay = 0; |
1426 | 1857 |
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
|
1858 |
} |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1859 |
} |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1860 |
|
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1861 |
/*****************************************************************************/ |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1862 |
|
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1863 |
/** Distributed-clocks calculations. |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1864 |
*/ |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1865 |
void ec_master_calc_dc( |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1866 |
ec_master_t *master /**< EtherCAT master. */ |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1867 |
) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1868 |
{ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1869 |
// find DC reference clock |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
1870 |
ec_master_find_dc_ref_clock(master); |
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1871 |
|
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1872 |
// calculate bus topology |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1873 |
ec_master_calc_topology(master); |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1874 |
|
1426 | 1875 |
ec_master_calc_transmission_delays(master); |
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1876 |
} |
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
1877 |
|
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
|
1878 |
/****************************************************************************** |
1394
e77728ddf0f9
Introduced ecrt_master_sync() for synchronizing slave clocks to reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
1879 |
* 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
|
1880 |
*****************************************************************************/ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1881 |
|
1332
d62633fea8ed
merge -c1610 branches/stable-1.4: Added missing doxygen docs.
Florian Pose <fp@igh-essen.com>
parents:
1329
diff
changeset
|
1882 |
/** 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
|
1883 |
*/ |
1312
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
1884 |
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
|
1885 |
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
|
1886 |
) |
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
|
1887 |
{ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1888 |
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
|
1889 |
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
|
1890 |
|
1181
9e5954a2a46e
Added debugging for configuration function of the application interface.
Florian Pose <fp@igh-essen.com>
parents:
1178
diff
changeset
|
1891 |
if (master->debug_level) |
1543
373cd456dc26
Avoid warnings on x86_64 platform. Thanks to Thomas Elste.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
1892 |
EC_DBG("ecrt_master_create_domain(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
|
1893 |
|
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
|
1894 |
if (!(domain = (ec_domain_t *) kmalloc(sizeof(ec_domain_t), GFP_KERNEL))) { |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1895 |
EC_ERR("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
|
1896 |
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
|
1897 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1898 |
|
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
|
1899 |
down(&master->master_sem); |
94c6e36e0f8d
Implemented master semaphore to secure concurrent access from ioctls, state machine and realtime interface.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1900 |
|
993
8c32564252fd
Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents:
992
diff
changeset
|
1901 |
if (list_empty(&master->domains)) { |
8c32564252fd
Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents:
992
diff
changeset
|
1902 |
index = 0; |
8c32564252fd
Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents:
992
diff
changeset
|
1903 |
} 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
|
1904 |
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
|
1905 |
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
|
1906 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1907 |
|
993
8c32564252fd
Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents:
992
diff
changeset
|
1908 |
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
|
1909 |
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
|
1910 |
|
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
|
1911 |
up(&master->master_sem); |
94c6e36e0f8d
Implemented master semaphore to secure concurrent access from ioctls, state machine and realtime interface.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1912 |
|
1181
9e5954a2a46e
Added debugging for configuration function of the application interface.
Florian Pose <fp@igh-essen.com>
parents:
1178
diff
changeset
|
1913 |
if (master->debug_level) |
9e5954a2a46e
Added debugging for configuration function of the application interface.
Florian Pose <fp@igh-essen.com>
parents:
1178
diff
changeset
|
1914 |
EC_DBG("Created domain %u.\n", domain->index); |
9e5954a2a46e
Added debugging for configuration function of the application interface.
Florian Pose <fp@igh-essen.com>
parents:
1178
diff
changeset
|
1915 |
|
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
|
1916 |
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
|
1917 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1918 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1919 |
/*****************************************************************************/ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1920 |
|
1312
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
1921 |
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
|
1922 |
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
|
1923 |
) |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
1924 |
{ |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
1925 |
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
|
1926 |
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
|
1927 |
} |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
1928 |
|
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
1929 |
/*****************************************************************************/ |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
1930 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1931 |
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
|
1932 |
{ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1933 |
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
|
1934 |
ec_domain_t *domain; |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
1935 |
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
|
1936 |
|
1181
9e5954a2a46e
Added debugging for configuration function of the application interface.
Florian Pose <fp@igh-essen.com>
parents:
1178
diff
changeset
|
1937 |
if (master->debug_level) |
1543
373cd456dc26
Avoid warnings on x86_64 platform. Thanks to Thomas Elste.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
1938 |
EC_DBG("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
|
1939 |
|
1530
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
1940 |
if (master->active) { |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
1941 |
EC_WARN("%s: Master already active!\n", __func__); |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
1942 |
return 0; |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
1943 |
} |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
1944 |
|
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
|
1945 |
down(&master->master_sem); |
94c6e36e0f8d
Implemented master semaphore to secure concurrent access from ioctls, state machine and realtime interface.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1946 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1947 |
// 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
|
1948 |
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
|
1949 |
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
|
1950 |
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
|
1951 |
if (ret < 0) { |
1197 | 1952 |
up(&master->master_sem); |
1543
373cd456dc26
Avoid warnings on x86_64 platform. Thanks to Thomas Elste.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
1953 |
EC_ERR("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
|
1954 |
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
|
1955 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1956 |
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
|
1957 |
} |
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
|
1958 |
|
1451
78fbafbf08ba
Always set DC reference clock to OP.
Florian Pose <fp@igh-essen.com>
parents:
1436
diff
changeset
|
1959 |
// always set DC reference clock to OP |
78fbafbf08ba
Always set DC reference clock to OP.
Florian Pose <fp@igh-essen.com>
parents:
1436
diff
changeset
|
1960 |
if (master->dc_ref_clock) { |
78fbafbf08ba
Always set DC reference clock to OP.
Florian Pose <fp@igh-essen.com>
parents:
1436
diff
changeset
|
1961 |
ec_slave_request_state(master->dc_ref_clock, EC_SLAVE_STATE_OP); |
78fbafbf08ba
Always set DC reference clock to OP.
Florian Pose <fp@igh-essen.com>
parents:
1436
diff
changeset
|
1962 |
} |
78fbafbf08ba
Always set DC reference clock to OP.
Florian Pose <fp@igh-essen.com>
parents:
1436
diff
changeset
|
1963 |
|
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
|
1964 |
up(&master->master_sem); |
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
|
1965 |
|
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1966 |
// restart EoE process and master thread with new locking |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
1967 |
#ifdef EC_EOE |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1968 |
ec_master_eoe_stop(master); |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
1969 |
#endif |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1970 |
ec_master_thread_stop(master); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1971 |
|
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
|
1972 |
if (master->debug_level) |
1543
373cd456dc26
Avoid warnings on x86_64 platform. Thanks to Thomas Elste.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
1973 |
EC_DBG("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
|
1974 |
|
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1975 |
master->injection_seq_fsm = 0; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1976 |
master->injection_seq_rt = 0; |
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
1977 |
|
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
1978 |
master->send_cb = master->app_send_cb; |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
1979 |
master->receive_cb = master->app_receive_cb; |
1513
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1980 |
master->cb_data = master->app_cb_data; |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1981 |
|
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
1982 |
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
|
1983 |
"EtherCAT-OP"); |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
1984 |
if (ret < 0) { |
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
|
1985 |
EC_ERR("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
|
1986 |
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
|
1987 |
} |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
1988 |
#ifdef EC_EOE |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1989 |
ec_master_eoe_start(master); |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
1990 |
#endif |
902
ad703091a32b
Moved setting of the allow flags.
Florian Pose <fp@igh-essen.com>
parents:
901
diff
changeset
|
1991 |
|
ad703091a32b
Moved setting of the allow flags.
Florian Pose <fp@igh-essen.com>
parents:
901
diff
changeset
|
1992 |
master->allow_config = 1; // request the current configuration |
ad703091a32b
Moved setting of the allow flags.
Florian Pose <fp@igh-essen.com>
parents:
901
diff
changeset
|
1993 |
master->allow_scan = 1; // allow re-scanning on topology change |
1530
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
1994 |
master->active = 1; |
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
|
1995 |
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
|
1996 |
} |
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 |
/*****************************************************************************/ |
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 |
|
1530
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2000 |
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
|
2001 |
{ |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2002 |
ec_slave_t *slave; |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2003 |
#ifdef EC_EOE |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2004 |
ec_eoe_t *eoe; |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2005 |
#endif |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2006 |
|
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2007 |
if (master->debug_level) |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2008 |
EC_DBG("ecrt_master_deactivate(master = 0x%x)\n", (u32) master); |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2009 |
|
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2010 |
if (!master->active) { |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2011 |
EC_WARN("%s: Master not active.\n", __func__); |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2012 |
return; |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2013 |
} |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2014 |
|
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2015 |
#ifdef EC_EOE |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2016 |
ec_master_eoe_stop(master); |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2017 |
#endif |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2018 |
ec_master_thread_stop(master); |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2019 |
|
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2020 |
master->send_cb = ec_master_internal_send_cb; |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2021 |
master->receive_cb = ec_master_internal_receive_cb; |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2022 |
master->cb_data = master; |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2023 |
|
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2024 |
down(&master->master_sem); |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2025 |
ec_master_clear_domains(master); |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2026 |
ec_master_clear_slave_configs(master); |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2027 |
up(&master->master_sem); |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2028 |
|
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2029 |
for (slave = master->slaves; |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2030 |
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
|
2031 |
slave++) { |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2032 |
|
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2033 |
// set states for all slaves |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2034 |
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
|
2035 |
|
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2036 |
// 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
|
2037 |
// 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
|
2038 |
// phases. |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2039 |
slave->force_config = 1; |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2040 |
} |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2041 |
|
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2042 |
#ifdef EC_EOE |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2043 |
// ... but leave EoE slaves in OP |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2044 |
list_for_each_entry(eoe, &master->eoe_handlers, list) { |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2045 |
if (ec_eoe_is_open(eoe)) |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2046 |
ec_slave_request_state(eoe->slave, EC_SLAVE_STATE_OP); |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2047 |
} |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2048 |
#endif |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2049 |
|
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2050 |
master->app_time = 0ULL; |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2051 |
master->app_start_time = 0ULL; |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2052 |
master->has_start_time = 0; |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2053 |
|
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2054 |
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
|
2055 |
"EtherCAT-IDLE")) |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2056 |
EC_WARN("Failed to restart master thread!\n"); |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2057 |
#ifdef EC_EOE |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2058 |
ec_master_eoe_start(master); |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2059 |
#endif |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2060 |
|
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2061 |
master->allow_scan = 1; |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2062 |
master->allow_config = 1; |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2063 |
master->active = 0; |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2064 |
} |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2065 |
|
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2066 |
/*****************************************************************************/ |
96629de2202b
Added ecrt_master_deactivate() to remove the bus configuration.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2067 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2068 |
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
|
2069 |
{ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2070 |
ec_datagram_t *datagram, *n; |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2071 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2072 |
if (master->injection_seq_rt != master->injection_seq_fsm) { |
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
|
2073 |
// inject datagrams produced by master & slave FSMs |
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
|
2074 |
ec_master_queue_datagram(master, &master->fsm_datagram); |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2075 |
master->injection_seq_rt = master->injection_seq_fsm; |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2076 |
} |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
2077 |
ec_master_inject_external_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
|
2078 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2079 |
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
|
2080 |
// link is down, no datagram can be sent |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2081 |
list_for_each_entry_safe(datagram, n, &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
|
2082 |
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
|
2083 |
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
|
2084 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2085 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2086 |
// 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
|
2087 |
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
|
2088 |
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
|
2089 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2090 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2091 |
// send frames |
1804 | 2092 |
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
|
2093 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2094 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2095 |
/*****************************************************************************/ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2096 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2097 |
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
|
2098 |
{ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2099 |
ec_datagram_t *datagram, *next; |
664
18c48cb7de06
Introduced frames_timed_out flag to notice bus failure when link down is
Florian Pose <fp@igh-essen.com>
parents:
663
diff
changeset
|
2100 |
unsigned int frames_timed_out = 0; |
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
|
2101 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2102 |
// 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
|
2103 |
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
|
2104 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2105 |
// 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
|
2106 |
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
|
2107 |
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
|
2108 |
|
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
2109 |
#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
|
2110 |
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
|
2111 |
> timeout_cycles) { |
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
2112 |
#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
|
2113 |
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
|
2114 |
> timeout_jiffies) { |
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
2115 |
#endif |
664
18c48cb7de06
Introduced frames_timed_out flag to notice bus failure when link down is
Florian Pose <fp@igh-essen.com>
parents:
663
diff
changeset
|
2116 |
frames_timed_out = 1; |
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
|
2117 |
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
|
2118 |
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
|
2119 |
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
|
2120 |
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
|
2121 |
|
bf991809dcf0
Added debugging output for unmatched frames and those that timed out.
Florian Pose <fp@igh-essen.com>
parents:
664
diff
changeset
|
2122 |
if (unlikely(master->debug_level > 0)) { |
1237
33e8349b44bd
Avoided using #ifdef inside a macro.
Florian Pose <fp@igh-essen.com>
parents:
1209
diff
changeset
|
2123 |
unsigned int time_us; |
33e8349b44bd
Avoided using #ifdef inside a macro.
Florian Pose <fp@igh-essen.com>
parents:
1209
diff
changeset
|
2124 |
#ifdef EC_HAVE_CYCLES |
33e8349b44bd
Avoided using #ifdef inside a macro.
Florian Pose <fp@igh-essen.com>
parents:
1209
diff
changeset
|
2125 |
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
|
2126 |
datagram->cycles_sent) * 1000 / cpu_khz; |
33e8349b44bd
Avoided using #ifdef inside a macro.
Florian Pose <fp@igh-essen.com>
parents:
1209
diff
changeset
|
2127 |
#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
|
2128 |
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
|
2129 |
datagram->jiffies_sent) * 1000000 / HZ); |
1237
33e8349b44bd
Avoided using #ifdef inside a macro.
Florian Pose <fp@igh-essen.com>
parents:
1209
diff
changeset
|
2130 |
#endif |
1543
373cd456dc26
Avoid warnings on x86_64 platform. Thanks to Thomas Elste.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2131 |
EC_DBG("TIMED OUT datagram %p, index %02X waited %u us.\n", |
373cd456dc26
Avoid warnings on x86_64 platform. Thanks to Thomas Elste.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2132 |
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
|
2133 |
} |
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
|
2134 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
2135 |
} |
664
18c48cb7de06
Introduced frames_timed_out flag to notice bus failure when link down is
Florian Pose <fp@igh-essen.com>
parents:
663
diff
changeset
|
2136 |
|
18c48cb7de06
Introduced frames_timed_out flag to notice bus failure when link down is
Florian Pose <fp@igh-essen.com>
parents:
663
diff
changeset
|
2137 |
master->frames_timed_out = frames_timed_out; |
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
|
2138 |
} |
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 |
|
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
2142 |
void ecrt_master_send_ext(ec_master_t *master) |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
2143 |
{ |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
2144 |
ec_datagram_t *datagram, *next; |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
2145 |
|
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
2146 |
list_for_each_entry_safe(datagram, next, &master->ext_datagram_queue, |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
2147 |
queue) { |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
2148 |
list_del(&datagram->queue); |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
2149 |
ec_master_queue_datagram(master, datagram); |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
2150 |
} |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
2151 |
|
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
2152 |
ecrt_master_send(master); |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
2153 |
} |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
2154 |
|
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
2155 |
/*****************************************************************************/ |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
2156 |
|
1332
d62633fea8ed
merge -c1610 branches/stable-1.4: Added missing doxygen docs.
Florian Pose <fp@igh-essen.com>
parents:
1329
diff
changeset
|
2157 |
/** 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
|
2158 |
*/ |
1312
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
2159 |
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
|
2160 |
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
|
2161 |
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
|
2162 |
{ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2163 |
ec_slave_config_t *sc; |
697
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
2164 |
unsigned int found = 0; |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
2165 |
|
1181
9e5954a2a46e
Added debugging for configuration function of the application interface.
Florian Pose <fp@igh-essen.com>
parents:
1178
diff
changeset
|
2166 |
|
9e5954a2a46e
Added debugging for configuration function of the application interface.
Florian Pose <fp@igh-essen.com>
parents:
1178
diff
changeset
|
2167 |
if (master->debug_level) |
1543
373cd456dc26
Avoid warnings on x86_64 platform. Thanks to Thomas Elste.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2168 |
EC_DBG("ecrt_master_slave_config(master = 0x%p, alias = %u, " |
1483
43adf48aa157
Minor: vendor/product with 8 hex digits.
Florian Pose <fp@igh-essen.com>
parents:
1451
diff
changeset
|
2169 |
"position = %u, vendor_id = 0x%08x, product_code = 0x%08x)\n", |
1543
373cd456dc26
Avoid warnings on x86_64 platform. Thanks to Thomas Elste.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2170 |
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
|
2171 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2172 |
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
|
2173 |
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
|
2174 |
found = 1; |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
2175 |
break; |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
2176 |
} |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
2177 |
} |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
2178 |
|
1024 | 2179 |
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
|
2180 |
if (sc->vendor_id != vendor_id || sc->product_code != product_code) { |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2181 |
EC_ERR("Slave type mismatch. Slave was configured as" |
1010
6672b86e7b10
Reverted revision number checking from r1228.
Florian Pose <fp@igh-essen.com>
parents:
1009
diff
changeset
|
2182 |
" 0x%08X/0x%08X before. Now configuring with" |
6672b86e7b10
Reverted revision number checking from r1228.
Florian Pose <fp@igh-essen.com>
parents:
1009
diff
changeset
|
2183 |
" 0x%08X/0x%08X.\n", sc->vendor_id, sc->product_code, |
6672b86e7b10
Reverted revision number checking from r1228.
Florian Pose <fp@igh-essen.com>
parents:
1009
diff
changeset
|
2184 |
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
|
2185 |
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
|
2186 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2187 |
} else { |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1047
diff
changeset
|
2188 |
if (master->debug_level) |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1047
diff
changeset
|
2189 |
EC_DBG("Creating slave configuration for %u:%u, 0x%08X/0x%08X.\n", |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1047
diff
changeset
|
2190 |
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
|
2191 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2192 |
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
|
2193 |
GFP_KERNEL))) { |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2194 |
EC_ERR("Failed to allocate memory 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
|
2195 |
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
|
2196 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2197 |
|
995
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
994
diff
changeset
|
2198 |
ec_slave_config_init(sc, master, |
1010
6672b86e7b10
Reverted revision number checking from r1228.
Florian Pose <fp@igh-essen.com>
parents:
1009
diff
changeset
|
2199 |
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
|
2200 |
|
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
|
2201 |
down(&master->master_sem); |
94c6e36e0f8d
Implemented master semaphore to secure concurrent access from ioctls, state machine and realtime interface.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
2202 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2203 |
// 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
|
2204 |
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
|
2205 |
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
|
2206 |
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
|
2207 |
|
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
|
2208 |
up(&master->master_sem); |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2209 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2210 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2211 |
return sc; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2212 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2213 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2214 |
/*****************************************************************************/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2215 |
|
1312
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
2216 |
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
|
2217 |
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
|
2218 |
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
|
2219 |
{ |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
2220 |
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
|
2221 |
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
|
2222 |
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
|
2223 |
} |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
2224 |
|
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
2225 |
/*****************************************************************************/ |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1303
diff
changeset
|
2226 |
|
1594
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2227 |
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
|
2228 |
{ |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2229 |
if (master->debug_level) |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2230 |
EC_DBG("ecrt_master(master = 0x%p, master_info = 0x%p)\n", |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2231 |
master, master_info); |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2232 |
|
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2233 |
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
|
2234 |
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
|
2235 |
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
|
2236 |
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
|
2237 |
return 0; |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2238 |
} |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2239 |
|
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2240 |
/*****************************************************************************/ |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2241 |
|
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2242 |
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
|
2243 |
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
|
2244 |
{ |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2245 |
const ec_slave_t *slave; |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2246 |
|
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2247 |
if (down_interruptible(&master->master_sem)) { |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2248 |
return -EINTR; |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2249 |
} |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2250 |
|
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2251 |
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
|
2252 |
|
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2253 |
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
|
2254 |
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
|
2255 |
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
|
2256 |
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
|
2257 |
slave_info->serial_number = slave->sii.serial_number; |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2258 |
slave_info->alias = slave->sii.alias; |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2259 |
slave_info->current_on_ebus = slave->sii.current_on_ebus; |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2260 |
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
|
2261 |
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
|
2262 |
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
|
2263 |
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
|
2264 |
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
|
2265 |
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
|
2266 |
} else { |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2267 |
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
|
2268 |
} |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2269 |
|
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2270 |
up(&master->master_sem); |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2271 |
|
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2272 |
return 0; |
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 |
|
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2275 |
/*****************************************************************************/ |
2019bec460ad
Implemented ecrt_master() and ecrt_master_get_slave() in kernel space.
Florian Pose <fp@igh-essen.com>
parents:
1586
diff
changeset
|
2276 |
|
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
2277 |
void ecrt_master_callbacks(ec_master_t *master, |
1513
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2278 |
void (*send_cb)(void *), void (*receive_cb)(void *), void *cb_data) |
204
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
2279 |
{ |
1181
9e5954a2a46e
Added debugging for configuration function of the application interface.
Florian Pose <fp@igh-essen.com>
parents:
1178
diff
changeset
|
2280 |
if (master->debug_level) |
1543
373cd456dc26
Avoid warnings on x86_64 platform. Thanks to Thomas Elste.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2281 |
EC_DBG("ecrt_master_callbacks(master = 0x%p, send_cb = 0x%p, " |
373cd456dc26
Avoid warnings on x86_64 platform. Thanks to Thomas Elste.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2282 |
" receive_cb = 0x%p, cb_data = 0x%p)\n", master, |
373cd456dc26
Avoid warnings on x86_64 platform. Thanks to Thomas Elste.
Florian Pose <fp@igh-essen.com>
parents:
1516
diff
changeset
|
2283 |
send_cb, receive_cb, cb_data); |
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
2284 |
|
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
2285 |
master->app_send_cb = send_cb; |
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
2286 |
master->app_receive_cb = receive_cb; |
1513
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
2287 |
master->app_cb_data = cb_data; |
204
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
2288 |
} |
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
2289 |
|
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
2290 |
/*****************************************************************************/ |
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
2291 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2292 |
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
|
2293 |
{ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
2294 |
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
|
2295 |
state->al_states = master->fsm.slave_states; |
1018
e068da25639d
Completed master states.
Richard Hacker <ha@igh-essen.com>
parents:
1015
diff
changeset
|
2296 |
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
|
2297 |
} |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
2298 |
|
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
2299 |
/*****************************************************************************/ |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
2300 |
|
1434
4c6fe0ae37f1
Separated application time from synchronizing reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1426
diff
changeset
|
2301 |
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
|
2302 |
{ |
7c2d5d69134c
Replaced timeval by 64-bit EtherCAT time.
Florian Pose <fp@igh-essen.com>
parents:
1415
diff
changeset
|
2303 |
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
|
2304 |
|
08eaf72409bb
Use application start time as a common reference for cyclic generation
Florian Pose <fp@igh-essen.com>
parents:
1434
diff
changeset
|
2305 |
if (unlikely(!master->has_start_time)) { |
08eaf72409bb
Use application start time as a common reference for cyclic generation
Florian Pose <fp@igh-essen.com>
parents:
1434
diff
changeset
|
2306 |
master->app_start_time = app_time; |
08eaf72409bb
Use application start time as a common reference for cyclic generation
Florian Pose <fp@igh-essen.com>
parents:
1434
diff
changeset
|
2307 |
master->has_start_time = 1; |
08eaf72409bb
Use application start time as a common reference for cyclic generation
Florian Pose <fp@igh-essen.com>
parents:
1434
diff
changeset
|
2308 |
} |
1434
4c6fe0ae37f1
Separated application time from synchronizing reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1426
diff
changeset
|
2309 |
} |
4c6fe0ae37f1
Separated application time from synchronizing reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1426
diff
changeset
|
2310 |
|
4c6fe0ae37f1
Separated application time from synchronizing reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1426
diff
changeset
|
2311 |
/*****************************************************************************/ |
4c6fe0ae37f1
Separated application time from synchronizing reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1426
diff
changeset
|
2312 |
|
4c6fe0ae37f1
Separated application time from synchronizing reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1426
diff
changeset
|
2313 |
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
|
2314 |
{ |
1396
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1394
diff
changeset
|
2315 |
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
|
2316 |
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
|
2317 |
} |
fb6719008bf5
Separated sync_reference_clock() and sync_slave_clocks().
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
2318 |
|
fb6719008bf5
Separated sync_reference_clock() and sync_slave_clocks().
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
2319 |
/*****************************************************************************/ |
fb6719008bf5
Separated sync_reference_clock() and sync_slave_clocks().
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
2320 |
|
fb6719008bf5
Separated sync_reference_clock() and sync_slave_clocks().
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
2321 |
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
|
2322 |
{ |
1394
e77728ddf0f9
Introduced ecrt_master_sync() for synchronizing slave clocks to reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
2323 |
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
|
2324 |
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
|
2325 |
} |
e77728ddf0f9
Introduced ecrt_master_sync() for synchronizing slave clocks to reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
2326 |
|
e77728ddf0f9
Introduced ecrt_master_sync() for synchronizing slave clocks to reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
2327 |
/*****************************************************************************/ |
e77728ddf0f9
Introduced ecrt_master_sync() for synchronizing slave clocks to reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
2328 |
|
1535
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2329 |
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
|
2330 |
{ |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2331 |
ec_datagram_zero(&master->sync_mon_datagram); |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2332 |
ec_master_queue_datagram(master, &master->sync_mon_datagram); |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2333 |
} |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2334 |
|
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2335 |
/*****************************************************************************/ |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2336 |
|
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2337 |
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
|
2338 |
{ |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2339 |
if (master->sync_mon_datagram.state == EC_DATAGRAM_RECEIVED) { |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2340 |
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
|
2341 |
} else { |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2342 |
return 0xffffffff; |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2343 |
} |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2344 |
} |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2345 |
|
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2346 |
/*****************************************************************************/ |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2347 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
2348 |
/** \cond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
2349 |
|
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
2350 |
EXPORT_SYMBOL(ecrt_master_create_domain); |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
2351 |
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
|
2352 |
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
|
2353 |
EXPORT_SYMBOL(ecrt_master_send); |
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1489
diff
changeset
|
2354 |
EXPORT_SYMBOL(ecrt_master_send_ext); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
2355 |
EXPORT_SYMBOL(ecrt_master_receive); |
206
60a10d85c20b
Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents:
204
diff
changeset
|
2356 |
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
|
2357 |
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
|
2358 |
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
|
2359 |
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
|
2360 |
EXPORT_SYMBOL(ecrt_master_state); |
1434
4c6fe0ae37f1
Separated application time from synchronizing reference clock.
Florian Pose <fp@igh-essen.com>
parents:
1426
diff
changeset
|
2361 |
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
|
2362 |
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
|
2363 |
EXPORT_SYMBOL(ecrt_master_sync_slave_clocks); |
1535
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2364 |
EXPORT_SYMBOL(ecrt_master_sync_monitor_queue); |
0c484ee12d89
DC synchrony monitoring methods.
Florian Pose <fp@igh-essen.com>
parents:
1530
diff
changeset
|
2365 |
EXPORT_SYMBOL(ecrt_master_sync_monitor_process); |
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
39
diff
changeset
|
2366 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
2367 |
/** \endcond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
2368 |
|
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
2369 |
/*****************************************************************************/ |