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