author | Florian Pose <fp@igh-essen.com> |
Thu, 12 Jun 2008 13:03:50 +0000 | |
changeset 1005 | 5af7ab9a98b1 |
parent 1004 | 990b89d8ad03 |
child 1006 | 90db4c3de57b |
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 |
* |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
5 |
* Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
6 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
8 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
10 |
* and/or modify it under the terms of the GNU General Public License |
246
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
239
diff
changeset
|
11 |
* as published by the Free Software Foundation; either version 2 of the |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
239
diff
changeset
|
12 |
* License, or (at your option) any later version. |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
13 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
14 |
* The IgH EtherCAT Master is distributed in the hope that it will be |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
15 |
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
17 |
* GNU General Public License for more details. |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
18 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
19 |
* You should have received a copy of the GNU General Public License |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
20 |
* along with the IgH EtherCAT Master; if not, write to the Free Software |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
21 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
22 |
* |
246
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
239
diff
changeset
|
23 |
* The right to use EtherCAT Technology is granted and comes free of |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
239
diff
changeset
|
24 |
* charge under condition of compatibility of product made by |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
239
diff
changeset
|
25 |
* Licensee. People intending to distribute/sell products based on the |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
239
diff
changeset
|
26 |
* code, have to sign an agreement to guarantee that products using |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
239
diff
changeset
|
27 |
* software based on IgH EtherCAT master stay compatible with the actual |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
239
diff
changeset
|
28 |
* EtherCAT specification (which are released themselves as an open |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
239
diff
changeset
|
29 |
* standard) as the (only) precondition to have the right to use EtherCAT |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
239
diff
changeset
|
30 |
* Technology, IP and trade marks. |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
239
diff
changeset
|
31 |
* |
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
35
diff
changeset
|
32 |
*****************************************************************************/ |
0 | 33 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
34 |
/** |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
35 |
\file |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
36 |
EtherCAT master methods. |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
37 |
*/ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
38 |
|
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
39 |
/*****************************************************************************/ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
40 |
|
24
d417dd9bdc2f
Wilhelms ?nderungen ?bernommen.
Florian Pose <fp@igh-essen.com>
parents:
23
diff
changeset
|
41 |
#include <linux/module.h> |
0 | 42 |
#include <linux/kernel.h> |
43 |
#include <linux/string.h> |
|
44 |
#include <linux/slab.h> |
|
45 |
#include <linux/delay.h> |
|
46 |
||
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
47 |
#include "../include/ecrt.h" |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
48 |
#include "globals.h" |
55
059a9e712aa7
Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents:
54
diff
changeset
|
49 |
#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
|
50 |
#include "slave_config.h" |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
51 |
#include "device.h" |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
52 |
#include "datagram.h" |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
53 |
#ifdef EC_EOE |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
54 |
#include "ethernet.h" |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
55 |
#endif |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
56 |
#include "master.h" |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
57 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
58 |
/*****************************************************************************/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
59 |
|
995
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
994
diff
changeset
|
60 |
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
|
61 |
void ec_master_clear_domains(ec_master_t *); |
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
62 |
static int ec_master_idle_thread(ec_master_t *); |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
63 |
static int ec_master_operation_thread(ec_master_t *); |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
64 |
#ifdef EC_EOE |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
65 |
void ec_master_eoe_run(unsigned long); |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
66 |
#endif |
179
fb4c9dd11ca0
Sourced SysFS attribute show method prototypes out of headers.
Florian Pose <fp@igh-essen.com>
parents:
178
diff
changeset
|
67 |
|
fb4c9dd11ca0
Sourced SysFS attribute show method prototypes out of headers.
Florian Pose <fp@igh-essen.com>
parents:
178
diff
changeset
|
68 |
/*****************************************************************************/ |
fb4c9dd11ca0
Sourced SysFS attribute show method prototypes out of headers.
Florian Pose <fp@igh-essen.com>
parents:
178
diff
changeset
|
69 |
|
0 | 70 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
71 |
Master constructor. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
72 |
\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
|
73 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
74 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
75 |
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
|
76 |
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
|
77 |
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
|
78 |
const uint8_t *backup_mac, /**< MAC address of backup device */ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
902
diff
changeset
|
79 |
dev_t device_number /**< Character device number. */ |
576
158c5a3d0a2a
New module file /sys/ethercat, masters moved to /sys/ethercat/masterX.
Florian Pose <fp@igh-essen.com>
parents:
573
diff
changeset
|
80 |
) |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
81 |
{ |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
82 |
unsigned int i; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
83 |
|
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
84 |
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
|
85 |
master->reserved = 0; |
446 | 86 |
|
639
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
87 |
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
|
88 |
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
|
89 |
init_MUTEX(&master->device_sem); |
446 | 90 |
|
91 |
master->mode = EC_MASTER_MODE_ORPHANED; |
|
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
92 |
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
|
93 |
master->injection_seq_rt = 0; |
446 | 94 |
|
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
95 |
master->slaves = NULL; |
446 | 96 |
master->slave_count = 0; |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
97 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
98 |
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
|
99 |
|
900
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
100 |
master->scan_busy = 0; |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
101 |
master->allow_scan = 1; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
102 |
init_MUTEX(&master->scan_sem); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
103 |
init_waitqueue_head(&master->scan_queue); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
104 |
|
900
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
105 |
master->config_busy = 0; |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
106 |
master->allow_config = 1; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
107 |
init_MUTEX(&master->config_sem); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
108 |
init_waitqueue_head(&master->config_queue); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
109 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
110 |
INIT_LIST_HEAD(&master->datagram_queue); |
446 | 111 |
master->datagram_index = 0; |
112 |
||
95
0066de7a456d
Domains als Liste verwaltet.
Florian Pose <fp@igh-essen.com>
parents:
94
diff
changeset
|
113 |
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
|
114 |
|
446 | 115 |
master->debug_level = 0; |
116 |
master->stats.timeouts = 0; |
|
117 |
master->stats.corrupted = 0; |
|
118 |
master->stats.unmatched = 0; |
|
119 |
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
|
120 |
master->frames_timed_out = 0; |
446 | 121 |
|
122 |
for (i = 0; i < HZ; i++) { |
|
123 |
master->idle_cycle_times[i] = 0; |
|
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
124 |
#ifdef EC_EOE |
446 | 125 |
master->eoe_cycle_times[i] = 0; |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
126 |
#endif |
446 | 127 |
} |
128 |
master->idle_cycle_time_pos = 0; |
|
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
129 |
#ifdef EC_EOE |
446 | 130 |
master->eoe_cycle_time_pos = 0; |
131 |
||
226
07247920a7ba
EoE with workqueue; bugfix in ec_master_init()
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
132 |
init_timer(&master->eoe_timer); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
133 |
master->eoe_timer.function = ec_master_eoe_run; |
226
07247920a7ba
EoE with workqueue; bugfix in ec_master_init()
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
134 |
master->eoe_timer.data = (unsigned long) master; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
135 |
master->eoe_running = 0; |
446 | 136 |
INIT_LIST_HEAD(&master->eoe_handlers); |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
137 |
#endif |
446 | 138 |
|
139 |
master->internal_lock = SPIN_LOCK_UNLOCKED; |
|
140 |
master->request_cb = NULL; |
|
141 |
master->release_cb = NULL; |
|
142 |
master->cb_data = NULL; |
|
143 |
||
872 | 144 |
INIT_LIST_HEAD(&master->sii_requests); |
145 |
init_MUTEX(&master->sii_sem); |
|
146 |
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
|
147 |
|
849
4b712ec8929d
Removed slave pointer from ec_sdo_request_t class.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
148 |
INIT_LIST_HEAD(&master->slave_sdo_requests); |
441
ffa13db95e10
SDO uploading via Sysfs without master FSM calling wake_up().
Florian Pose <fp@igh-essen.com>
parents:
435
diff
changeset
|
149 |
init_MUTEX(&master->sdo_sem); |
646
fbbd4e54e031
Implemented SDO reading with wait queues.
Florian Pose <fp@igh-essen.com>
parents:
643
diff
changeset
|
150 |
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
|
151 |
|
579
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
578
diff
changeset
|
152 |
// init devices |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
578
diff
changeset
|
153 |
if (ec_device_init(&master->main_device, master)) |
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
154 |
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
|
155 |
|
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
578
diff
changeset
|
156 |
if (ec_device_init(&master->backup_device, master)) |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
578
diff
changeset
|
157 |
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
|
158 |
|
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
|
159 |
// 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
|
160 |
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
|
161 |
snprintf(master->fsm_datagram.name, EC_DATAGRAM_NAME_SIZE, "master-fsm"); |
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
|
162 |
if (ec_datagram_prealloc(&master->fsm_datagram, EC_MAX_DATA_SIZE)) { |
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
|
163 |
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
|
164 |
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
|
165 |
} |
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
|
166 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
167 |
// 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
|
168 |
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
|
169 |
|
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
170 |
// init character device |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
171 |
if (ec_cdev_init(&master->cdev, master, device_number)) |
659
d7c5a958bad0
Removed unecessary clearing of EoE handlers in master init function;
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
172 |
goto out_clear_fsm; |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
140
diff
changeset
|
173 |
|
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
174 |
return 0; |
226
07247920a7ba
EoE with workqueue; bugfix in ec_master_init()
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
175 |
|
659
d7c5a958bad0
Removed unecessary clearing of EoE handlers in master init function;
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
176 |
out_clear_fsm: |
d7c5a958bad0
Removed unecessary clearing of EoE handlers in master init function;
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
177 |
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
|
178 |
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
|
179 |
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
|
180 |
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
|
181 |
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
|
182 |
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
|
183 |
out_return: |
226
07247920a7ba
EoE with workqueue; bugfix in ec_master_init()
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
184 |
return -1; |
0 | 185 |
} |
186 |
||
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
35
diff
changeset
|
187 |
/*****************************************************************************/ |
0 | 188 |
|
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
189 |
/** Destructor. |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
190 |
*/ |
639
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
191 |
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
|
192 |
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
|
193 |
) |
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
194 |
{ |
995
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
994
diff
changeset
|
195 |
ec_cdev_clear(&master->cdev); |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
196 |
#ifdef EC_EOE |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
197 |
ec_master_clear_eoe_handlers(master); |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
198 |
#endif |
994
e29edcced328
Clear domains before slave configs, because domain references the FMMU
Florian Pose <fp@igh-essen.com>
parents:
993
diff
changeset
|
199 |
ec_master_clear_domains(master); |
995
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
994
diff
changeset
|
200 |
ec_master_clear_slave_configs(master); |
992
50a44cbd30af
Removed kobjects from sdo and slave.
Florian Pose <fp@igh-essen.com>
parents:
990
diff
changeset
|
201 |
ec_master_clear_slaves(master); |
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
|
202 |
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
|
203 |
ec_datagram_clear(&master->fsm_datagram); |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
204 |
ec_device_clear(&master->backup_device); |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
205 |
ec_device_clear(&master->main_device); |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
206 |
} |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
207 |
|
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
208 |
/*****************************************************************************/ |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
209 |
|
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
210 |
#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
|
211 |
/** Clear and free all EoE handlers. |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
212 |
*/ |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
213 |
void ec_master_clear_eoe_handlers( |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
214 |
ec_master_t *master /**< EtherCAT master */ |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
215 |
) |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
216 |
{ |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
217 |
ec_eoe_t *eoe, *next; |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
218 |
|
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
219 |
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
|
220 |
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
|
221 |
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
|
222 |
kfree(eoe); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
223 |
} |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
224 |
} |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
225 |
#endif |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
226 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
227 |
/*****************************************************************************/ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
228 |
|
995
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
994
diff
changeset
|
229 |
/** 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
|
230 |
*/ |
995
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
994
diff
changeset
|
231 |
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
|
232 |
{ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
233 |
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
|
234 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
235 |
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
|
236 |
list_del(&sc->list); |
995
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
994
diff
changeset
|
237 |
ec_slave_config_clear(sc); |
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
994
diff
changeset
|
238 |
kfree(sc); |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
239 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
240 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
241 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
242 |
/*****************************************************************************/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
243 |
|
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
244 |
/** 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
|
245 |
*/ |
992
50a44cbd30af
Removed kobjects from sdo and slave.
Florian Pose <fp@igh-essen.com>
parents:
990
diff
changeset
|
246 |
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
|
247 |
{ |
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
248 |
ec_slave_t *slave; |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
249 |
|
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
250 |
for (slave = master->slaves; |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
251 |
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
|
252 |
slave++) { |
992
50a44cbd30af
Removed kobjects from sdo and slave.
Florian Pose <fp@igh-essen.com>
parents:
990
diff
changeset
|
253 |
ec_slave_clear(slave); |
1004
990b89d8ad03
Fixed duplicate kfree() bug.
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
254 |
} |
990b89d8ad03
Fixed duplicate kfree() bug.
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
255 |
|
990b89d8ad03
Fixed duplicate kfree() bug.
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
256 |
if (master->slaves) { |
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
257 |
kfree(master->slaves); |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
258 |
master->slaves = NULL; |
1004
990b89d8ad03
Fixed duplicate kfree() bug.
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
259 |
} |
990b89d8ad03
Fixed duplicate kfree() bug.
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
260 |
|
990b89d8ad03
Fixed duplicate kfree() bug.
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
261 |
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
|
262 |
} |
9bf603942791
Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
263 |
|
9bf603942791
Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
264 |
/*****************************************************************************/ |
9bf603942791
Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
265 |
|
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
266 |
/** Clear all domains. |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
267 |
*/ |
993
8c32564252fd
Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents:
992
diff
changeset
|
268 |
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
|
269 |
{ |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
270 |
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
|
271 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
272 |
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
|
273 |
list_del(&domain->list); |
993
8c32564252fd
Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents:
992
diff
changeset
|
274 |
ec_domain_clear(domain); |
8c32564252fd
Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents:
992
diff
changeset
|
275 |
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
|
276 |
} |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
277 |
} |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
278 |
|
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
279 |
/*****************************************************************************/ |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
280 |
|
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
281 |
/** Internal locking callback. |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
282 |
*/ |
515
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
283 |
int ec_master_request_cb(void *master /**< callback data */) |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
284 |
{ |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
285 |
spin_lock(&((ec_master_t *) master)->internal_lock); |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
286 |
return 0; |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
287 |
} |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
288 |
|
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
289 |
/*****************************************************************************/ |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
290 |
|
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
291 |
/** Internal unlocking callback. |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
292 |
*/ |
515
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
293 |
void ec_master_release_cb(void *master /**< callback data */) |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
294 |
{ |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
295 |
spin_unlock(&((ec_master_t *) master)->internal_lock); |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
296 |
} |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
297 |
|
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
298 |
/*****************************************************************************/ |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
299 |
|
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
300 |
/** Starts the master thread. |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
301 |
*/ |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
302 |
int ec_master_thread_start( |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
303 |
ec_master_t *master, /**< EtherCAT master */ |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
304 |
int (*thread_func)(ec_master_t *) /**< thread function to start */ |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
305 |
) |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
306 |
{ |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
307 |
init_completion(&master->thread_exit); |
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
308 |
|
540
a729667dea1e
Minor changes in master thread messages.
Florian Pose <fp@igh-essen.com>
parents:
533
diff
changeset
|
309 |
EC_INFO("Starting master thread.\n"); |
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
310 |
if (!(master->thread_id = kernel_thread((int (*)(void *)) thread_func, |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
311 |
master, CLONE_KERNEL))) |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
312 |
return -1; |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
313 |
|
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
314 |
return 0; |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
315 |
} |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
316 |
|
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
317 |
/*****************************************************************************/ |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
318 |
|
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
319 |
/** Stops the master thread. |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
320 |
*/ |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
321 |
void ec_master_thread_stop(ec_master_t *master /**< EtherCAT master */) |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
322 |
{ |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
323 |
if (!master->thread_id) { |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
324 |
EC_WARN("ec_master_thread_stop: Already finished!\n"); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
325 |
return; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
326 |
} |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
327 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
328 |
kill_proc(master->thread_id, SIGTERM, 1); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
329 |
wait_for_completion(&master->thread_exit); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
330 |
EC_INFO("Master thread exited.\n"); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
331 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
332 |
if (master->fsm_datagram.state != EC_DATAGRAM_SENT) return; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
333 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
334 |
// wait for FSM datagram |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
335 |
while (get_cycles() - master->fsm_datagram.cycles_sent |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
336 |
< (cycles_t) EC_IO_TIMEOUT /* us */ * (cpu_khz / 1000)) |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
337 |
schedule(); |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
338 |
} |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
339 |
|
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
340 |
/*****************************************************************************/ |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
341 |
|
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
342 |
/** Transition function from ORPHANED to IDLE mode. |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
343 |
*/ |
446 | 344 |
int ec_master_enter_idle_mode(ec_master_t *master /**< EtherCAT master */) |
345 |
{ |
|
515
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
346 |
master->request_cb = ec_master_request_cb; |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
347 |
master->release_cb = ec_master_release_cb; |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
348 |
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
|
349 |
|
446 | 350 |
master->mode = EC_MASTER_MODE_IDLE; |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
351 |
if (ec_master_thread_start(master, ec_master_idle_thread)) { |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
352 |
master->mode = EC_MASTER_MODE_ORPHANED; |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
353 |
return -1; |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
354 |
} |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
355 |
|
446 | 356 |
return 0; |
357 |
} |
|
358 |
||
359 |
/*****************************************************************************/ |
|
360 |
||
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
361 |
/** Transition function from IDLE to ORPHANED mode. |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
362 |
*/ |
446 | 363 |
void ec_master_leave_idle_mode(ec_master_t *master /**< EtherCAT master */) |
364 |
{ |
|
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
365 |
master->mode = EC_MASTER_MODE_ORPHANED; |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
366 |
|
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
367 |
#ifdef EC_EOE |
446 | 368 |
ec_master_eoe_stop(master); |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
369 |
#endif |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
370 |
ec_master_thread_stop(master); |
992
50a44cbd30af
Removed kobjects from sdo and slave.
Florian Pose <fp@igh-essen.com>
parents:
990
diff
changeset
|
371 |
ec_master_clear_slaves(master); |
446 | 372 |
} |
373 |
||
374 |
/*****************************************************************************/ |
|
375 |
||
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
376 |
/** Transition function from IDLE to OPERATION mode. |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
377 |
*/ |
446 | 378 |
int ec_master_enter_operation_mode(ec_master_t *master /**< EtherCAT master */) |
379 |
{ |
|
380 |
ec_slave_t *slave; |
|
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
381 |
#ifdef EC_EOE |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
382 |
ec_eoe_t *eoe; |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
383 |
#endif |
446 | 384 |
|
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
385 |
down(&master->config_sem); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
386 |
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
|
387 |
if (master->config_busy) { |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
388 |
up(&master->config_sem); |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
389 |
|
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
390 |
// wait for slave configuration to complete |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
391 |
if (wait_event_interruptible(master->config_queue, |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
392 |
!master->config_busy)) { |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
393 |
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
|
394 |
goto out_allow; |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
395 |
} |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
396 |
|
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
397 |
if (master->debug_level) |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
398 |
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
|
399 |
} else { |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
400 |
up(&master->config_sem); |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
401 |
} |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
402 |
|
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
403 |
down(&master->scan_sem); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
404 |
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
|
405 |
if (!master->scan_busy) { |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
406 |
up(&master->scan_sem); |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
407 |
} else { |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
408 |
up(&master->scan_sem); |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
409 |
|
794
684dea874956
Allow bus configuration when link is down.
Florian Pose <fp@igh-essen.com>
parents:
792
diff
changeset
|
410 |
// wait for slave scan to complete |
900
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
411 |
if (wait_event_interruptible(master->scan_queue, !master->scan_busy)) { |
794
684dea874956
Allow bus configuration when link is down.
Florian Pose <fp@igh-essen.com>
parents:
792
diff
changeset
|
412 |
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
|
413 |
goto out_allow; |
684dea874956
Allow bus configuration when link is down.
Florian Pose <fp@igh-essen.com>
parents:
792
diff
changeset
|
414 |
} |
900
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
415 |
|
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
416 |
if (master->debug_level) |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
417 |
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
|
418 |
} |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
419 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
420 |
// 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
|
421 |
for (slave = master->slaves; |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
422 |
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
|
423 |
slave++) { |
643
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
424 |
ec_slave_request_state(slave, EC_SLAVE_STATE_PREOP); |
446 | 425 |
} |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
426 |
#ifdef EC_EOE |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
427 |
// ... but set EoE slaves to OP |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
428 |
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
|
429 |
if (ec_eoe_is_open(eoe)) |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
430 |
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
|
431 |
} |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
432 |
#endif |
446 | 433 |
|
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
434 |
if (master->debug_level) |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
435 |
EC_DBG("Switching to operation mode.\n"); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
436 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
437 |
master->mode = EC_MASTER_MODE_OPERATION; |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
438 |
master->ext_request_cb = NULL; |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
439 |
master->ext_release_cb = NULL; |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
440 |
master->ext_cb_data = NULL; |
446 | 441 |
return 0; |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
442 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
443 |
out_allow: |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
444 |
master->allow_scan = 1; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
445 |
master->allow_config = 1; |
446 | 446 |
return -1; |
447 |
} |
|
448 |
||
449 |
/*****************************************************************************/ |
|
450 |
||
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
451 |
/** Transition function from OPERATION to IDLE mode. |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
452 |
*/ |
446 | 453 |
void ec_master_leave_operation_mode(ec_master_t *master |
454 |
/**< EtherCAT master */) |
|
455 |
{ |
|
456 |
ec_slave_t *slave; |
|
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
457 |
#ifdef EC_EOE |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
458 |
ec_eoe_t *eoe; |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
459 |
#endif |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
460 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
461 |
master->mode = EC_MASTER_MODE_IDLE; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
462 |
|
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
463 |
#ifdef EC_EOE |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
464 |
ec_master_eoe_stop(master); |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
465 |
#endif |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
466 |
ec_master_thread_stop(master); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
467 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
468 |
master->request_cb = ec_master_request_cb; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
469 |
master->release_cb = ec_master_release_cb; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
470 |
master->cb_data = master; |
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
|
471 |
|
993
8c32564252fd
Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents:
992
diff
changeset
|
472 |
ec_master_clear_domains(master); |
995
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
994
diff
changeset
|
473 |
ec_master_clear_slave_configs(master); |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
474 |
|
449
3caf8ff4d8a2
Moved functionality of ecrt_master_deactivate() (now deprecated) to ecrt_master_release().
Florian Pose <fp@igh-essen.com>
parents:
448
diff
changeset
|
475 |
// 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
|
476 |
for (slave = master->slaves; |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
477 |
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
|
478 |
slave++) { |
449
3caf8ff4d8a2
Moved functionality of ecrt_master_deactivate() (now deprecated) to ecrt_master_release().
Florian Pose <fp@igh-essen.com>
parents:
448
diff
changeset
|
479 |
ec_slave_request_state(slave, EC_SLAVE_STATE_PREOP); |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
480 |
} |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
481 |
#ifdef EC_EOE |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
482 |
// ... but leave EoE slaves in OP |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
483 |
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
|
484 |
if (ec_eoe_is_open(eoe)) |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
485 |
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
|
486 |
} |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
487 |
#endif |
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
|
488 |
|
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
489 |
if (ec_master_thread_start(master, ec_master_idle_thread)) |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
490 |
EC_WARN("Failed to restart master thread!\n"); |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
491 |
#ifdef EC_EOE |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
492 |
ec_master_eoe_start(master); |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
493 |
#endif |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
494 |
|
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
495 |
master->allow_scan = 1; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
496 |
master->allow_config = 1; |
446 | 497 |
} |
498 |
||
499 |
/*****************************************************************************/ |
|
500 |
||
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
501 |
/** 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
|
502 |
*/ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
503 |
void ec_master_queue_datagram(ec_master_t *master, /**< EtherCAT master */ |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
504 |
ec_datagram_t *datagram /**< datagram */ |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
505 |
) |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
506 |
{ |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
507 |
ec_datagram_t *queued_datagram; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
508 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
509 |
// check, if the datagram is already queued |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
510 |
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
|
511 |
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
|
512 |
datagram->skip_count++; |
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
513 |
if (master->debug_level) |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
514 |
EC_DBG("skipping datagram %x.\n", (unsigned int) datagram); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
515 |
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
|
516 |
return; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
517 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
518 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
519 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
520 |
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
|
521 |
datagram->state = EC_DATAGRAM_QUEUED; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
522 |
} |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
523 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
524 |
/*****************************************************************************/ |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
525 |
|
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
526 |
/** 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
|
527 |
* |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
528 |
* \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
|
529 |
*/ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
530 |
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
|
531 |
{ |
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
532 |
ec_datagram_t *datagram, *next; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
533 |
size_t datagram_size; |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
534 |
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
|
535 |
void *follows_word; |
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
536 |
cycles_t cycles_start, cycles_sent, cycles_end; |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
537 |
unsigned long jiffies_sent; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
538 |
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
|
539 |
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
|
540 |
|
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
541 |
cycles_start = get_cycles(); |
176 | 542 |
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
|
543 |
INIT_LIST_HEAD(&sent_datagrams); |
208
b7797f8a813d
command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents:
206
diff
changeset
|
544 |
|
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
545 |
if (unlikely(master->debug_level > 1)) |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
546 |
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
|
547 |
|
176 | 548 |
do { |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
549 |
// 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
|
550 |
frame_data = ec_device_tx_data(&master->main_device); |
176 | 551 |
cur_data = frame_data + EC_FRAME_HEADER_SIZE; |
552 |
follows_word = NULL; |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
553 |
more_datagrams_waiting = 0; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
554 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
555 |
// fill current frame with datagrams |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
556 |
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
|
557 |
if (datagram->state != EC_DATAGRAM_QUEUED) continue; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
558 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
559 |
// does the current datagram fit in the frame? |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
560 |
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
|
561 |
+ EC_DATAGRAM_FOOTER_SIZE; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
562 |
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
|
563 |
more_datagrams_waiting = 1; |
176 | 564 |
break; |
565 |
} |
|
566 |
||
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
567 |
list_add_tail(&datagram->sent, &sent_datagrams); |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
568 |
datagram->index = master->datagram_index++; |
176 | 569 |
|
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
570 |
if (unlikely(master->debug_level > 1)) |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
571 |
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
|
572 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
573 |
// set "datagram following" flag in previous frame |
176 | 574 |
if (follows_word) |
575 |
EC_WRITE_U16(follows_word, EC_READ_U16(follows_word) | 0x8000); |
|
576 |
||
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
577 |
// EtherCAT datagram header |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
578 |
EC_WRITE_U8 (cur_data, datagram->type); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
579 |
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
|
580 |
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
|
581 |
EC_WRITE_U16(cur_data + 6, datagram->data_size & 0x7FF); |
176 | 582 |
EC_WRITE_U16(cur_data + 8, 0x0000); |
583 |
follows_word = cur_data + 6; |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
584 |
cur_data += EC_DATAGRAM_HEADER_SIZE; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
585 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
586 |
// EtherCAT datagram data |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
587 |
memcpy(cur_data, datagram->data, datagram->data_size); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
588 |
cur_data += datagram->data_size; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
589 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
590 |
// EtherCAT datagram footer |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
591 |
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
|
592 |
cur_data += EC_DATAGRAM_FOOTER_SIZE; |
176 | 593 |
} |
594 |
||
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
595 |
if (list_empty(&sent_datagrams)) { |
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
596 |
if (unlikely(master->debug_level > 1)) |
176 | 597 |
EC_DBG("nothing to send.\n"); |
598 |
break; |
|
599 |
} |
|
600 |
||
601 |
// EtherCAT frame header |
|
602 |
EC_WRITE_U16(frame_data, ((cur_data - frame_data |
|
603 |
- EC_FRAME_HEADER_SIZE) & 0x7FF) | 0x1000); |
|
604 |
||
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
605 |
// pad frame |
211
c684b6b7adaf
Using kernel Ethernet constants.
Florian Pose <fp@igh-essen.com>
parents:
208
diff
changeset
|
606 |
while (cur_data - frame_data < ETH_ZLEN - ETH_HLEN) |
176 | 607 |
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
|
608 |
|
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
609 |
if (unlikely(master->debug_level > 1)) |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
958
diff
changeset
|
610 |
EC_DBG("frame size: %u\n", cur_data - frame_data); |
176 | 611 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
612 |
// 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
|
613 |
ec_device_send(&master->main_device, cur_data - frame_data); |
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
614 |
cycles_sent = get_cycles(); |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
615 |
jiffies_sent = jiffies; |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
616 |
|
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
617 |
// 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
|
618 |
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
|
619 |
datagram->state = EC_DATAGRAM_SENT; |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
620 |
datagram->cycles_sent = cycles_sent; |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
621 |
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
|
622 |
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
|
623 |
} |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
624 |
|
176 | 625 |
frame_count++; |
626 |
} |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
627 |
while (more_datagrams_waiting); |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
628 |
|
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
629 |
if (unlikely(master->debug_level > 1)) { |
344
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
630 |
cycles_end = get_cycles(); |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
958
diff
changeset
|
631 |
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
|
632 |
frame_count, |
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
633 |
(unsigned int) (cycles_end - cycles_start) * 1000 / cpu_khz); |
176 | 634 |
} |
635 |
} |
|
636 |
||
637 |
/*****************************************************************************/ |
|
638 |
||
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
639 |
/** Processes a received frame. |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
640 |
* |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
641 |
* 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
|
642 |
* |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
643 |
* \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
|
644 |
*/ |
331
17f58fe99511
Renamed ec_master_receive() to ec_master_receive_datagrams().
Florian Pose <fp@igh-essen.com>
parents:
330
diff
changeset
|
645 |
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
|
646 |
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
|
647 |
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
|
648 |
) |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
649 |
{ |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
650 |
size_t frame_size, data_size; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
651 |
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
|
652 |
unsigned int cmd_follows, matched; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
653 |
const uint8_t *cur_data; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
654 |
ec_datagram_t *datagram; |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
655 |
|
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
656 |
if (unlikely(size < EC_FRAME_HEADER_SIZE)) { |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
657 |
master->stats.corrupted++; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
658 |
ec_master_output_stats(master); |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
659 |
return; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
660 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
661 |
|
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
662 |
cur_data = frame_data; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
663 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
664 |
// 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
|
665 |
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
|
666 |
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
|
667 |
|
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
668 |
if (unlikely(frame_size > size)) { |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
669 |
master->stats.corrupted++; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
670 |
ec_master_output_stats(master); |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
671 |
return; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
672 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
673 |
|
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
674 |
cmd_follows = 1; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
675 |
while (cmd_follows) { |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
676 |
// process datagram header |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
677 |
datagram_type = EC_READ_U8 (cur_data); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
678 |
datagram_index = EC_READ_U8 (cur_data + 1); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
679 |
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
|
680 |
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
|
681 |
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
|
682 |
|
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
683 |
if (unlikely(cur_data - frame_data |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
684 |
+ data_size + EC_DATAGRAM_FOOTER_SIZE > size)) { |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
685 |
master->stats.corrupted++; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
686 |
ec_master_output_stats(master); |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
687 |
return; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
688 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
689 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
690 |
// 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
|
691 |
matched = 0; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
692 |
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
|
693 |
if (datagram->index == datagram_index |
5e231f6a3d2e
Re-ordered criteria for datagram matching.
Florian Pose <fp@igh-essen.com>
parents:
688
diff
changeset
|
694 |
&& datagram->state == EC_DATAGRAM_SENT |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
695 |
&& datagram->type == datagram_type |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
696 |
&& 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
|
697 |
matched = 1; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
698 |
break; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
699 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
700 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
701 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
702 |
// 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
|
703 |
if (!matched) { |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
704 |
master->stats.unmatched++; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
705 |
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
|
706 |
|
bf991809dcf0
Added debugging output for unmatched frames and those that timed out.
Florian Pose <fp@igh-essen.com>
parents:
664
diff
changeset
|
707 |
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
|
708 |
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
|
709 |
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
|
710 |
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
|
711 |
+ 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
|
712 |
#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
|
713 |
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
|
714 |
#endif |
684
bf991809dcf0
Added debugging output for unmatched frames and those that timed out.
Florian Pose <fp@igh-essen.com>
parents:
664
diff
changeset
|
715 |
} |
bf991809dcf0
Added debugging output for unmatched frames and those that timed out.
Florian Pose <fp@igh-essen.com>
parents:
664
diff
changeset
|
716 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
717 |
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
|
718 |
continue; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
719 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
720 |
|
345
beb0a77d73c0
Improved datagram reception in sync_io and frame dequeuing.
Florian Pose <fp@igh-essen.com>
parents:
344
diff
changeset
|
721 |
// copy received data into the datagram memory |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
722 |
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
|
723 |
cur_data += data_size; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
724 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
725 |
// set the datagram's working counter |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
726 |
datagram->working_counter = EC_READ_U16(cur_data); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
727 |
cur_data += EC_DATAGRAM_FOOTER_SIZE; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
728 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
729 |
// 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
|
730 |
datagram->state = EC_DATAGRAM_RECEIVED; |
579
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
578
diff
changeset
|
731 |
datagram->cycles_received = master->main_device.cycles_poll; |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
578
diff
changeset
|
732 |
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
|
733 |
list_del_init(&datagram->queue); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
734 |
} |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
735 |
} |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
736 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
737 |
/*****************************************************************************/ |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
738 |
|
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
739 |
/** Output statistics in cyclic mode. |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
740 |
* |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
741 |
* 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
|
742 |
* 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
|
743 |
*/ |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
744 |
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
|
745 |
{ |
344
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
746 |
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
|
747 |
master->stats.output_jiffies = jiffies; |
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
748 |
|
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
749 |
if (master->stats.timeouts) { |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
958
diff
changeset
|
750 |
EC_WARN("%u datagram%s TIMED OUT!\n", master->stats.timeouts, |
396 | 751 |
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
|
752 |
master->stats.timeouts = 0; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
753 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
754 |
if (master->stats.corrupted) { |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
958
diff
changeset
|
755 |
EC_WARN("%u frame%s CORRUPTED!\n", master->stats.corrupted, |
396 | 756 |
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
|
757 |
master->stats.corrupted = 0; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
758 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
759 |
if (master->stats.unmatched) { |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
958
diff
changeset
|
760 |
EC_WARN("%u datagram%s UNMATCHED!\n", master->stats.unmatched, |
396 | 761 |
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
|
762 |
master->stats.unmatched = 0; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
763 |
} |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
764 |
} |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
765 |
} |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
766 |
|
68
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
66
diff
changeset
|
767 |
/*****************************************************************************/ |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
66
diff
changeset
|
768 |
|
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
769 |
/** Master kernel thread function for IDLE mode. |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
770 |
*/ |
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
771 |
static int ec_master_idle_thread(ec_master_t *master) |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
772 |
{ |
344
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
773 |
cycles_t cycles_start, cycles_end; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
774 |
|
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
775 |
daemonize("EtherCAT-IDLE"); |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
776 |
allow_signal(SIGTERM); |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
777 |
|
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
778 |
while (!signal_pending(current)) { |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
779 |
cycles_start = get_cycles(); |
719
03d5b96632fb
Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents:
715
diff
changeset
|
780 |
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
|
781 |
|
691
77b79a29e0e7
Included datagram queuing in critical section in idle task; added some
Florian Pose <fp@igh-essen.com>
parents:
690
diff
changeset
|
782 |
if (ec_fsm_master_running(&master->fsm)) { // datagram on the way |
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
783 |
// receive |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
784 |
spin_lock_bh(&master->internal_lock); |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
785 |
ecrt_master_receive(master); |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
786 |
spin_unlock_bh(&master->internal_lock); |
691
77b79a29e0e7
Included datagram queuing in critical section in idle task; added some
Florian Pose <fp@igh-essen.com>
parents:
690
diff
changeset
|
787 |
|
77b79a29e0e7
Included datagram queuing in critical section in idle task; added some
Florian Pose <fp@igh-essen.com>
parents:
690
diff
changeset
|
788 |
if (master->fsm_datagram.state == EC_DATAGRAM_SENT) |
77b79a29e0e7
Included datagram queuing in critical section in idle task; added some
Florian Pose <fp@igh-essen.com>
parents:
690
diff
changeset
|
789 |
goto schedule; |
77b79a29e0e7
Included datagram queuing in critical section in idle task; added some
Florian Pose <fp@igh-essen.com>
parents:
690
diff
changeset
|
790 |
} |
651
8c11399cc911
Fixed skipped datagrams when not in FSM idle phase.
Florian Pose <fp@igh-essen.com>
parents:
650
diff
changeset
|
791 |
|
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
792 |
// execute master state machine |
691
77b79a29e0e7
Included datagram queuing in critical section in idle task; added some
Florian Pose <fp@igh-essen.com>
parents:
690
diff
changeset
|
793 |
if (ec_fsm_master_exec(&master->fsm)) { // datagram ready for sending |
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
794 |
// queue and send |
691
77b79a29e0e7
Included datagram queuing in critical section in idle task; added some
Florian Pose <fp@igh-essen.com>
parents:
690
diff
changeset
|
795 |
spin_lock_bh(&master->internal_lock); |
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
796 |
ec_master_queue_datagram(master, &master->fsm_datagram); |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
797 |
ecrt_master_send(master); |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
798 |
spin_unlock_bh(&master->internal_lock); |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
799 |
} |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
800 |
|
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
801 |
cycles_end = get_cycles(); |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
802 |
master->idle_cycle_times[master->idle_cycle_time_pos] |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
803 |
= (u32) (cycles_end - cycles_start) * 1000 / cpu_khz; |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
804 |
master->idle_cycle_time_pos++; |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
805 |
master->idle_cycle_time_pos %= HZ; |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
806 |
|
651
8c11399cc911
Fixed skipped datagrams when not in FSM idle phase.
Florian Pose <fp@igh-essen.com>
parents:
650
diff
changeset
|
807 |
schedule: |
650
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
648
diff
changeset
|
808 |
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
|
809 |
set_current_state(TASK_INTERRUPTIBLE); |
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
648
diff
changeset
|
810 |
schedule_timeout(1); |
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
648
diff
changeset
|
811 |
} |
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
648
diff
changeset
|
812 |
else { |
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
648
diff
changeset
|
813 |
schedule(); |
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
648
diff
changeset
|
814 |
} |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
815 |
} |
518
b6a1426ba724
Fixed race: Stop EoE processing when entering or leaving operation mode.
Florian Pose <fp@igh-essen.com>
parents:
517
diff
changeset
|
816 |
|
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
817 |
master->thread_id = 0; |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
818 |
if (master->debug_level) |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
819 |
EC_DBG("Master IDLE thread exiting...\n"); |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
820 |
complete_and_exit(&master->thread_exit, 0); |
191 | 821 |
} |
822 |
||
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
823 |
/*****************************************************************************/ |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
824 |
|
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
825 |
/** Master kernel thread function for IDLE mode. |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
826 |
*/ |
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
827 |
static int ec_master_operation_thread(ec_master_t *master) |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
828 |
{ |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
829 |
cycles_t cycles_start, cycles_end; |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
830 |
|
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
831 |
daemonize("EtherCAT-OP"); |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
832 |
allow_signal(SIGTERM); |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
833 |
|
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
834 |
while (!signal_pending(current)) { |
719
03d5b96632fb
Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents:
715
diff
changeset
|
835 |
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
|
836 |
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
|
837 |
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
|
838 |
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
|
839 |
goto schedule; |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
840 |
|
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
841 |
cycles_start = get_cycles(); |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
842 |
|
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
843 |
// output statistics |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
844 |
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
|
845 |
|
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
846 |
// execute master state machine |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
847 |
if (ec_fsm_master_exec(&master->fsm)) { |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
848 |
// inject datagram |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
849 |
master->injection_seq_fsm++; |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
850 |
} |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
851 |
|
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
852 |
cycles_end = get_cycles(); |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
853 |
master->idle_cycle_times[master->idle_cycle_time_pos] |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
854 |
= (u32) (cycles_end - cycles_start) * 1000 / cpu_khz; |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
855 |
master->idle_cycle_time_pos++; |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
856 |
master->idle_cycle_time_pos %= HZ; |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
857 |
|
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
858 |
schedule: |
650
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
648
diff
changeset
|
859 |
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
|
860 |
set_current_state(TASK_INTERRUPTIBLE); |
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
648
diff
changeset
|
861 |
schedule_timeout(1); |
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
648
diff
changeset
|
862 |
} |
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
648
diff
changeset
|
863 |
else { |
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
648
diff
changeset
|
864 |
schedule(); |
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
648
diff
changeset
|
865 |
} |
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
866 |
} |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
867 |
|
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
868 |
master->thread_id = 0; |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
869 |
if (master->debug_level) |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
870 |
EC_DBG("Master OP thread exiting...\n"); |
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
871 |
complete_and_exit(&master->thread_exit, 0); |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
872 |
} |
578
f402b4bd2f4d
Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents:
576
diff
changeset
|
873 |
|
f402b4bd2f4d
Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents:
576
diff
changeset
|
874 |
/*****************************************************************************/ |
f402b4bd2f4d
Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents:
576
diff
changeset
|
875 |
|
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
876 |
#ifdef EC_EOE |
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
877 |
/** Starts Ethernet-over-EtherCAT processing on demand. |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
878 |
*/ |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
879 |
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
|
880 |
{ |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
881 |
if (master->eoe_running) { |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
882 |
EC_WARN("EoE already running!\n"); |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
883 |
return; |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
884 |
} |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
885 |
|
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
886 |
if (list_empty(&master->eoe_handlers)) |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
887 |
return; |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
888 |
|
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
889 |
if (!master->request_cb || !master->release_cb) { |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
890 |
EC_WARN("No EoE processing because of missing locking callbacks!\n"); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
891 |
return; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
892 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
893 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
894 |
EC_INFO("Starting EoE processing.\n"); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
895 |
master->eoe_running = 1; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
896 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
897 |
// start EoE processing |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
898 |
master->eoe_timer.expires = jiffies + 10; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
899 |
add_timer(&master->eoe_timer); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
900 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
901 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
902 |
/*****************************************************************************/ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
903 |
|
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
904 |
/** Stops the Ethernet-over-EtherCAT processing. |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
905 |
*/ |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
906 |
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
|
907 |
{ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
908 |
if (!master->eoe_running) return; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
909 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
910 |
EC_INFO("Stopping EoE processing.\n"); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
911 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
912 |
del_timer_sync(&master->eoe_timer); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
913 |
master->eoe_running = 0; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
914 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
915 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
916 |
/*****************************************************************************/ |
441
ffa13db95e10
SDO uploading via Sysfs without master FSM calling wake_up().
Florian Pose <fp@igh-essen.com>
parents:
435
diff
changeset
|
917 |
|
997
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
918 |
/** Does the Ethernet-over-EtherCAT processing. |
652180478e95
Removed kobject from master and module. Sysfs is gone!
Florian Pose <fp@igh-essen.com>
parents:
995
diff
changeset
|
919 |
*/ |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
920 |
void ec_master_eoe_run(unsigned long data /**< master pointer */) |
206
60a10d85c20b
Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents:
204
diff
changeset
|
921 |
{ |
60a10d85c20b
Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents:
204
diff
changeset
|
922 |
ec_master_t *master = (ec_master_t *) data; |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
923 |
ec_eoe_t *eoe; |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
924 |
unsigned int none_open = 1; |
344
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
925 |
cycles_t cycles_start, cycles_end; |
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
926 |
unsigned long restart_jiffies; |
235
f973808540a6
No master locking, if no EoE devices are "up".
Florian Pose <fp@igh-essen.com>
parents:
228
diff
changeset
|
927 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
928 |
list_for_each_entry(eoe, &master->eoe_handlers, list) { |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
929 |
if (ec_eoe_is_open(eoe)) { |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
930 |
none_open = 0; |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
931 |
break; |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
932 |
} |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
933 |
} |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
934 |
if (none_open) |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
935 |
goto queue_timer; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
936 |
|
721
ebc2fd3e09e5
Improved EoE handling: Avoided skipping of datagrams and release lock
Florian Pose <fp@igh-essen.com>
parents:
720
diff
changeset
|
937 |
// receive datagrams |
663
38d9c37664d9
Completely lock master while an EoE cycle is executing.
Florian Pose <fp@igh-essen.com>
parents:
661
diff
changeset
|
938 |
if (master->request_cb(master->cb_data)) goto queue_timer; |
344
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
939 |
cycles_start = get_cycles(); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
940 |
ecrt_master_receive(master); |
721
ebc2fd3e09e5
Improved EoE handling: Avoided skipping of datagrams and release lock
Florian Pose <fp@igh-essen.com>
parents:
720
diff
changeset
|
941 |
master->release_cb(master->cb_data); |
515
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
942 |
|
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
943 |
// actual EoE processing |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
944 |
list_for_each_entry(eoe, &master->eoe_handlers, list) { |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
945 |
ec_eoe_run(eoe); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
946 |
} |
334
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
947 |
|
515
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
948 |
// send datagrams |
721
ebc2fd3e09e5
Improved EoE handling: Avoided skipping of datagrams and release lock
Florian Pose <fp@igh-essen.com>
parents:
720
diff
changeset
|
949 |
if (master->request_cb(master->cb_data)) { |
ebc2fd3e09e5
Improved EoE handling: Avoided skipping of datagrams and release lock
Florian Pose <fp@igh-essen.com>
parents:
720
diff
changeset
|
950 |
goto queue_timer; |
ebc2fd3e09e5
Improved EoE handling: Avoided skipping of datagrams and release lock
Florian Pose <fp@igh-essen.com>
parents:
720
diff
changeset
|
951 |
} |
ebc2fd3e09e5
Improved EoE handling: Avoided skipping of datagrams and release lock
Florian Pose <fp@igh-essen.com>
parents:
720
diff
changeset
|
952 |
list_for_each_entry(eoe, &master->eoe_handlers, list) { |
ebc2fd3e09e5
Improved EoE handling: Avoided skipping of datagrams and release lock
Florian Pose <fp@igh-essen.com>
parents:
720
diff
changeset
|
953 |
ec_eoe_queue(eoe); |
ebc2fd3e09e5
Improved EoE handling: Avoided skipping of datagrams and release lock
Florian Pose <fp@igh-essen.com>
parents:
720
diff
changeset
|
954 |
} |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
955 |
ecrt_master_send(master); |
721
ebc2fd3e09e5
Improved EoE handling: Avoided skipping of datagrams and release lock
Florian Pose <fp@igh-essen.com>
parents:
720
diff
changeset
|
956 |
master->release_cb(master->cb_data); |
344
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
957 |
cycles_end = get_cycles(); |
663
38d9c37664d9
Completely lock master while an EoE cycle is executing.
Florian Pose <fp@igh-essen.com>
parents:
661
diff
changeset
|
958 |
|
335
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
959 |
master->eoe_cycle_times[master->eoe_cycle_time_pos] |
344
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
960 |
= (u32) (cycles_end - cycles_start) * 1000 / cpu_khz; |
335
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
961 |
master->eoe_cycle_time_pos++; |
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
962 |
master->eoe_cycle_time_pos %= HZ; |
334
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
963 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
964 |
queue_timer: |
344
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
965 |
restart_jiffies = HZ / EC_EOE_FREQUENCY; |
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
966 |
if (!restart_jiffies) restart_jiffies = 1; |
721
ebc2fd3e09e5
Improved EoE handling: Avoided skipping of datagrams and release lock
Florian Pose <fp@igh-essen.com>
parents:
720
diff
changeset
|
967 |
master->eoe_timer.expires = jiffies + restart_jiffies; |
208
b7797f8a813d
command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents:
206
diff
changeset
|
968 |
add_timer(&master->eoe_timer); |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
969 |
} |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
970 |
#endif |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
971 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
972 |
/*****************************************************************************/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
973 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
974 |
/** 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
|
975 |
*/ |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
976 |
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
|
977 |
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
|
978 |
) |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
979 |
{ |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
980 |
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
|
981 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
982 |
if (!master->configs_attached) |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
983 |
return; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
984 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
985 |
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
|
986 |
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
|
987 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
988 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
989 |
master->configs_attached = 0; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
990 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
991 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
992 |
/*****************************************************************************/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
993 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
994 |
/** 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
|
995 |
*/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
996 |
int ec_master_attach_slave_configs( |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
997 |
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
|
998 |
) |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
999 |
{ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1000 |
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
|
1001 |
unsigned int errors = 0; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1002 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1003 |
if (master->configs_attached) |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1004 |
return 0; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1005 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1006 |
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
|
1007 |
if (ec_slave_config_attach(sc)) |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1008 |
errors = 1; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1009 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1010 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1011 |
master->configs_attached = !errors; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1012 |
return errors ? -1 : 0; |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1013 |
} |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1014 |
|
927
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1015 |
/*****************************************************************************/ |
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1016 |
|
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1017 |
/** 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
|
1018 |
*/ |
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1019 |
ec_slave_t *ec_master_find_slave( |
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1020 |
ec_master_t *master, /**< EtherCAT master. */ |
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1021 |
uint16_t alias, /**< Slave alias. */ |
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1022 |
uint16_t position /**< Slave position. */ |
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1023 |
) |
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1024 |
{ |
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
1025 |
ec_slave_t *slave = master->slaves; |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
1026 |
|
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
1027 |
if (alias) { |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
1028 |
// find slave with the given alias |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
1029 |
for (; 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
|
1030 |
slave++) { |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
1031 |
if (slave->sii.alias != alias) |
927
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1032 |
continue; |
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1033 |
} |
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
1034 |
if (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
|
1035 |
return NULL; |
927
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1036 |
} |
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1037 |
|
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
1038 |
slave += position; |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
1039 |
if (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
|
1040 |
return slave; |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
1041 |
} else { |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
1042 |
return NULL; |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
997
diff
changeset
|
1043 |
} |
927
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1044 |
} |
ffb7d1876ce0
Introduced ec_master_find_slave().
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
1045 |
|
946
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1046 |
/*****************************************************************************/ |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1047 |
|
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1048 |
unsigned int ec_master_config_count( |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1049 |
const ec_master_t *master /**< EtherCAT master. */ |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1050 |
) |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1051 |
{ |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1052 |
const ec_slave_config_t *sc; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1053 |
unsigned int count = 0; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1054 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1055 |
list_for_each_entry(sc, &master->configs, list) { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1056 |
count++; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1057 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1058 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1059 |
return count; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1060 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1061 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1062 |
/*****************************************************************************/ |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1063 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1064 |
const ec_slave_config_t *ec_master_get_config_const( |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1065 |
const ec_master_t *master, /**< EtherCAT master. */ |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1066 |
unsigned int index /**< List position. */ |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1067 |
) |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1068 |
{ |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1069 |
const ec_slave_config_t *sc; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1070 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1071 |
list_for_each_entry(sc, &master->configs, list) { |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1072 |
if (index--) |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1073 |
continue; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1074 |
return sc; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1075 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1076 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1077 |
return NULL; |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1078 |
} |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1079 |
|
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1080 |
/*****************************************************************************/ |
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
1081 |
|
946
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1082 |
unsigned int ec_master_domain_count( |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1083 |
const ec_master_t *master /**< EtherCAT master. */ |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1084 |
) |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1085 |
{ |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1086 |
const ec_domain_t *domain; |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1087 |
unsigned int count = 0; |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1088 |
|
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1089 |
list_for_each_entry(domain, &master->domains, list) { |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1090 |
count++; |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1091 |
} |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1092 |
|
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1093 |
return count; |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1094 |
} |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1095 |
|
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1096 |
/*****************************************************************************/ |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1097 |
|
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1098 |
ec_domain_t *ec_master_find_domain( |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1099 |
ec_master_t *master, /**< EtherCAT master. */ |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1100 |
unsigned int index /**< Domain index. */ |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1101 |
) |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1102 |
{ |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1103 |
ec_domain_t *domain; |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1104 |
|
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1105 |
list_for_each_entry(domain, &master->domains, list) { |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1106 |
if (index--) |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1107 |
continue; |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1108 |
return domain; |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1109 |
} |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1110 |
|
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1111 |
return NULL; |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1112 |
} |
6ef20c5de875
Introduced ec_master_domain_count() and ec_master_find_domain().
Florian Pose <fp@igh-essen.com>
parents:
927
diff
changeset
|
1113 |
|
956
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1114 |
/*****************************************************************************/ |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1115 |
|
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1116 |
int ec_master_debug_level( |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1117 |
ec_master_t *master, |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1118 |
int level |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1119 |
) |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1120 |
{ |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1121 |
if (level < 0 || level > 2) { |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1122 |
EC_ERR("Invalid debug level %i!\n", level); |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1123 |
return -1; |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1124 |
} |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1125 |
|
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1126 |
if (level != master->debug_level) { |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1127 |
master->debug_level = level; |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1128 |
EC_INFO("Master debug level set to %i.\n", master->debug_level); |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1129 |
} |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1130 |
|
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1131 |
return 0; |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1132 |
} |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
946
diff
changeset
|
1133 |
|
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
|
1134 |
/****************************************************************************** |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1135 |
* Realtime interface |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1136 |
*****************************************************************************/ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1137 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1138 |
ec_domain_t *ecrt_master_create_domain(ec_master_t *master /**< 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
|
1139 |
{ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1140 |
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
|
1141 |
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
|
1142 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1143 |
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
|
1144 |
EC_ERR("Error allocating domain memory!\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
|
1145 |
return NULL; |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1146 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1147 |
|
993
8c32564252fd
Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents:
992
diff
changeset
|
1148 |
if (list_empty(&master->domains)) { |
8c32564252fd
Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents:
992
diff
changeset
|
1149 |
index = 0; |
8c32564252fd
Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents:
992
diff
changeset
|
1150 |
} 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
|
1151 |
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
|
1152 |
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
|
1153 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1154 |
|
993
8c32564252fd
Removed kobject from domain.
Florian Pose <fp@igh-essen.com>
parents:
992
diff
changeset
|
1155 |
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
|
1156 |
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
|
1157 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1158 |
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
|
1159 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1160 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1161 |
/*****************************************************************************/ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1162 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1163 |
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
|
1164 |
{ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1165 |
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
|
1166 |
ec_domain_t *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
|
1167 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1168 |
// 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
|
1169 |
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
|
1170 |
list_for_each_entry(domain, &master->domains, list) { |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1171 |
if (ec_domain_finish(domain, domain_offset)) { |
926
6bb33c6ec770
Output subindices with %02X.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
1172 |
EC_ERR("Failed to finish domain 0x%08X!\n", (u32) domain); |
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
|
1173 |
return -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
|
1174 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1175 |
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
|
1176 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1177 |
|
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1178 |
// 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
|
1179 |
#ifdef EC_EOE |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1180 |
ec_master_eoe_stop(master); |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
1181 |
#endif |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1182 |
ec_master_thread_stop(master); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1183 |
|
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
|
1184 |
if (master->debug_level) |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1185 |
EC_DBG("FSM datagram is %x.\n", (unsigned int) &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
|
1186 |
|
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1187 |
master->injection_seq_fsm = 0; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1188 |
master->injection_seq_rt = 0; |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1189 |
master->request_cb = master->ext_request_cb; |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1190 |
master->release_cb = master->ext_release_cb; |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1191 |
master->cb_data = master->ext_cb_data; |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1192 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1193 |
if (ec_master_thread_start(master, ec_master_operation_thread)) { |
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
|
1194 |
EC_ERR("Failed to start master thread!\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
|
1195 |
return -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
|
1196 |
} |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
1197 |
#ifdef EC_EOE |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1198 |
ec_master_eoe_start(master); |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
714
diff
changeset
|
1199 |
#endif |
902
ad703091a32b
Moved setting of the allow flags.
Florian Pose <fp@igh-essen.com>
parents:
901
diff
changeset
|
1200 |
|
ad703091a32b
Moved setting of the allow flags.
Florian Pose <fp@igh-essen.com>
parents:
901
diff
changeset
|
1201 |
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
|
1202 |
master->allow_scan = 1; // allow re-scanning on topology change |
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
|
1203 |
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
|
1204 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1205 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1206 |
/*****************************************************************************/ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1207 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1208 |
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
|
1209 |
{ |
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 |
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
|
1211 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1212 |
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
|
1213 |
// 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
|
1214 |
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
|
1215 |
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
|
1216 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1217 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1218 |
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
|
1219 |
// 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
|
1220 |
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
|
1221 |
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
|
1222 |
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
|
1223 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1224 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1225 |
// 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
|
1226 |
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
|
1227 |
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
|
1228 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1229 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1230 |
// 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
|
1231 |
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
|
1232 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1233 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1234 |
/*****************************************************************************/ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1235 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1236 |
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
|
1237 |
{ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1238 |
ec_datagram_t *datagram, *next; |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1239 |
cycles_t cycles_timeout; |
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
|
1240 |
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
|
1241 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1242 |
// 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
|
1243 |
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
|
1244 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1245 |
cycles_timeout = (cycles_t) EC_IO_TIMEOUT /* us */ * (cpu_khz / 1000); |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1246 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1247 |
// 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
|
1248 |
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
|
1249 |
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
|
1250 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1251 |
if (master->main_device.cycles_poll - datagram->cycles_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
|
1252 |
> cycles_timeout) { |
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
|
1253 |
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
|
1254 |
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
|
1255 |
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
|
1256 |
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
|
1257 |
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
|
1258 |
|
bf991809dcf0
Added debugging output for unmatched frames and those that timed out.
Florian Pose <fp@igh-essen.com>
parents:
664
diff
changeset
|
1259 |
if (unlikely(master->debug_level > 0)) { |
691
77b79a29e0e7
Included datagram queuing in critical section in idle task; added some
Florian Pose <fp@igh-essen.com>
parents:
690
diff
changeset
|
1260 |
EC_DBG("TIMED OUT datagram %08x, index %02X waited %u us.\n", |
77b79a29e0e7
Included datagram queuing in critical section in idle task; added some
Florian Pose <fp@igh-essen.com>
parents:
690
diff
changeset
|
1261 |
(unsigned int) datagram, datagram->index, |
684
bf991809dcf0
Added debugging output for unmatched frames and those that timed out.
Florian Pose <fp@igh-essen.com>
parents:
664
diff
changeset
|
1262 |
(unsigned int) (master->main_device.cycles_poll |
bf991809dcf0
Added debugging output for unmatched frames and those that timed out.
Florian Pose <fp@igh-essen.com>
parents:
664
diff
changeset
|
1263 |
- datagram->cycles_sent) * 1000 / cpu_khz); |
bf991809dcf0
Added debugging output for unmatched frames and those that timed out.
Florian Pose <fp@igh-essen.com>
parents:
664
diff
changeset
|
1264 |
} |
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
|
1265 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1266 |
} |
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
|
1267 |
|
18c48cb7de06
Introduced frames_timed_out flag to notice bus failure when link down is
Florian Pose <fp@igh-essen.com>
parents:
663
diff
changeset
|
1268 |
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
|
1269 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1270 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1271 |
/*****************************************************************************/ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1272 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1273 |
ec_slave_config_t *ecrt_master_slave_config(ec_master_t *master, |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1274 |
uint16_t alias, uint16_t position, uint32_t vendor_id, |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1275 |
uint32_t product_code) |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1276 |
{ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1277 |
ec_slave_config_t *sc; |
697
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1278 |
unsigned int found = 0; |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1279 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1280 |
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
|
1281 |
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
|
1282 |
found = 1; |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1283 |
break; |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1284 |
} |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1285 |
} |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1286 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1287 |
if (found) { |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1288 |
if (master->debug_level) { |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1289 |
EC_INFO("Using existing slave configuration for %u:%u\n", |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1290 |
alias, position); |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1291 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1292 |
if (sc->vendor_id != vendor_id || sc->product_code != product_code) { |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1293 |
EC_ERR("Slave type mismatch. Slave was configured as" |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1294 |
" 0x%08X/0x%08X before. Now configuring with" |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1295 |
" 0x%08X/0x%08X.\n", sc->vendor_id, sc->product_code, |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1296 |
vendor_id, product_code); |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1297 |
return NULL; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1298 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1299 |
} else { |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1300 |
if (master->debug_level) { |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1301 |
EC_INFO("Creating slave configuration for %u:%u," |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1302 |
" 0x%08X/0x%08X.\n", alias, position, vendor_id, |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1303 |
product_code); |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1304 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1305 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1306 |
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
|
1307 |
GFP_KERNEL))) { |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1308 |
EC_ERR("Failed to allocate memory for slave configuration.\n"); |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1309 |
return NULL; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1310 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1311 |
|
995
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
994
diff
changeset
|
1312 |
ec_slave_config_init(sc, master, |
54149a703c47
Removed kobject from slave_config.
Florian Pose <fp@igh-essen.com>
parents:
994
diff
changeset
|
1313 |
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
|
1314 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1315 |
// try to find the addressed slave |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1316 |
ec_slave_config_attach(sc); |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
872
diff
changeset
|
1317 |
ec_slave_config_load_default_assignment(sc); |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1318 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1319 |
list_add_tail(&sc->list, &master->configs); |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1320 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1321 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1322 |
return sc; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1323 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1324 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1325 |
/*****************************************************************************/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1326 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1327 |
void ecrt_master_callbacks(ec_master_t *master, int (*request_cb)(void *), |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1328 |
void (*release_cb)(void *), void *cb_data) |
204
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1329 |
{ |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1330 |
master->ext_request_cb = request_cb; |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1331 |
master->ext_release_cb = release_cb; |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1332 |
master->ext_cb_data = cb_data; |
204
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1333 |
} |
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1334 |
|
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1335 |
/*****************************************************************************/ |
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1336 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1337 |
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
|
1338 |
{ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
1339 |
state->slaves_responding = master->fsm.slaves_responding; |
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
1340 |
} |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
1341 |
|
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
1342 |
/*****************************************************************************/ |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
1343 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1344 |
/** \cond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1345 |
|
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1346 |
EXPORT_SYMBOL(ecrt_master_create_domain); |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1347 |
EXPORT_SYMBOL(ecrt_master_activate); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
1348 |
EXPORT_SYMBOL(ecrt_master_send); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
1349 |
EXPORT_SYMBOL(ecrt_master_receive); |
206
60a10d85c20b
Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents:
204
diff
changeset
|
1350 |
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
|
1351 |
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
|
1352 |
EXPORT_SYMBOL(ecrt_master_state); |
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
39
diff
changeset
|
1353 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1354 |
/** \endcond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1355 |
|
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1356 |
/*****************************************************************************/ |