author | Florian Pose <fp@igh-essen.com> |
Thu, 06 Sep 2007 09:23:56 +0000 | |
changeset 707 | 9ae68af8e17a |
parent 697 | 6f658c2082fd |
child 708 | 90bdb315f560 |
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" |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
49 |
#include "master.h" |
55
059a9e712aa7
Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents:
54
diff
changeset
|
50 |
#include "slave.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" |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
53 |
#include "ethernet.h" |
0 | 54 |
|
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
35
diff
changeset
|
55 |
/*****************************************************************************/ |
0 | 56 |
|
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
|
57 |
void ec_master_destroy_domains(ec_master_t *); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
58 |
void ec_master_sync_io(ec_master_t *); |
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
59 |
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
|
60 |
static int ec_master_operation_thread(ec_master_t *); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
61 |
void ec_master_eoe_run(unsigned long); |
441
ffa13db95e10
SDO uploading via Sysfs without master FSM calling wake_up().
Florian Pose <fp@igh-essen.com>
parents:
435
diff
changeset
|
62 |
void ec_master_check_sdo(unsigned long); |
446 | 63 |
int ec_master_measure_bus_time(ec_master_t *); |
179
fb4c9dd11ca0
Sourced SysFS attribute show method prototypes out of headers.
Florian Pose <fp@igh-essen.com>
parents:
178
diff
changeset
|
64 |
ssize_t ec_show_master_attribute(struct kobject *, struct attribute *, char *); |
268
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
65 |
ssize_t ec_store_master_attribute(struct kobject *, struct attribute *, |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
66 |
const char *, size_t); |
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 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
70 |
/** \cond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
71 |
|
334
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
72 |
EC_SYSFS_READ_ATTR(info); |
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
73 |
EC_SYSFS_READ_WRITE_ATTR(debug_level); |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
74 |
|
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
75 |
static struct attribute *ec_def_attrs[] = { |
334
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
76 |
&attr_info, |
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
77 |
&attr_debug_level, |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
78 |
NULL, |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
79 |
}; |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
80 |
|
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
81 |
static struct sysfs_ops ec_sysfs_ops = { |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
82 |
.show = &ec_show_master_attribute, |
268
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
83 |
.store = ec_store_master_attribute |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
84 |
}; |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
85 |
|
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
86 |
static struct kobj_type ktype_ec_master = { |
639
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
87 |
.release = NULL, |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
88 |
.sysfs_ops = &ec_sysfs_ops, |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
89 |
.default_attrs = ec_def_attrs |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
90 |
}; |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
91 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
92 |
/** \endcond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
93 |
|
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
94 |
/*****************************************************************************/ |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
95 |
|
0 | 96 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
97 |
Master constructor. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
98 |
\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
|
99 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
100 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
101 |
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
|
102 |
struct kobject *module_kobj, /**< kobject of the master module */ |
158c5a3d0a2a
New module file /sys/ethercat, masters moved to /sys/ethercat/masterX.
Florian Pose <fp@igh-essen.com>
parents:
573
diff
changeset
|
103 |
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
|
104 |
const uint8_t *main_mac, /**< MAC address of main device */ |
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
105 |
const uint8_t *backup_mac /**< MAC address of backup device */ |
576
158c5a3d0a2a
New module file /sys/ethercat, masters moved to /sys/ethercat/masterX.
Florian Pose <fp@igh-essen.com>
parents:
573
diff
changeset
|
106 |
) |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
107 |
{ |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
108 |
unsigned int i; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
109 |
|
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
110 |
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
|
111 |
master->reserved = 0; |
446 | 112 |
|
639
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
113 |
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
|
114 |
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
|
115 |
init_MUTEX(&master->device_sem); |
446 | 116 |
|
117 |
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
|
118 |
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
|
119 |
master->injection_seq_rt = 0; |
446 | 120 |
|
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
179
diff
changeset
|
121 |
INIT_LIST_HEAD(&master->slaves); |
446 | 122 |
master->slave_count = 0; |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
123 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
124 |
master->scan_state = EC_REQUEST_IN_PROGRESS; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
125 |
master->allow_scan = 1; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
126 |
init_MUTEX(&master->scan_sem); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
127 |
init_waitqueue_head(&master->scan_queue); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
128 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
129 |
master->config_state = EC_REQUEST_COMPLETE; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
130 |
master->allow_config = 1; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
131 |
init_MUTEX(&master->config_sem); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
132 |
init_waitqueue_head(&master->config_queue); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
133 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
134 |
INIT_LIST_HEAD(&master->datagram_queue); |
446 | 135 |
master->datagram_index = 0; |
136 |
||
95
0066de7a456d
Domains als Liste verwaltet.
Florian Pose <fp@igh-essen.com>
parents:
94
diff
changeset
|
137 |
INIT_LIST_HEAD(&master->domains); |
446 | 138 |
master->debug_level = 0; |
139 |
||
140 |
master->stats.timeouts = 0; |
|
141 |
master->stats.corrupted = 0; |
|
142 |
master->stats.skipped = 0; |
|
143 |
master->stats.unmatched = 0; |
|
144 |
master->stats.output_jiffies = 0; |
|
145 |
||
146 |
for (i = 0; i < HZ; i++) { |
|
147 |
master->idle_cycle_times[i] = 0; |
|
148 |
master->eoe_cycle_times[i] = 0; |
|
149 |
} |
|
150 |
master->idle_cycle_time_pos = 0; |
|
151 |
master->eoe_cycle_time_pos = 0; |
|
152 |
||
226
07247920a7ba
EoE with workqueue; bugfix in ec_master_init()
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
153 |
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
|
154 |
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
|
155 |
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
|
156 |
master->eoe_running = 0; |
446 | 157 |
INIT_LIST_HEAD(&master->eoe_handlers); |
158 |
||
159 |
master->internal_lock = SPIN_LOCK_UNLOCKED; |
|
160 |
master->request_cb = NULL; |
|
161 |
master->release_cb = NULL; |
|
162 |
master->cb_data = NULL; |
|
163 |
||
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
597
diff
changeset
|
164 |
INIT_LIST_HEAD(&master->eeprom_requests); |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
597
diff
changeset
|
165 |
init_MUTEX(&master->eeprom_sem); |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
597
diff
changeset
|
166 |
init_waitqueue_head(&master->eeprom_queue); |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
597
diff
changeset
|
167 |
|
646
fbbd4e54e031
Implemented SDO reading with wait queues.
Florian Pose <fp@igh-essen.com>
parents:
643
diff
changeset
|
168 |
INIT_LIST_HEAD(&master->sdo_requests); |
441
ffa13db95e10
SDO uploading via Sysfs without master FSM calling wake_up().
Florian Pose <fp@igh-essen.com>
parents:
435
diff
changeset
|
169 |
init_MUTEX(&master->sdo_sem); |
646
fbbd4e54e031
Implemented SDO reading with wait queues.
Florian Pose <fp@igh-essen.com>
parents:
643
diff
changeset
|
170 |
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
|
171 |
|
579
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
578
diff
changeset
|
172 |
// 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
|
173 |
if (ec_device_init(&master->main_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
|
174 |
goto out_return; |
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
578
diff
changeset
|
175 |
|
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
578
diff
changeset
|
176 |
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
|
177 |
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
|
178 |
|
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
|
179 |
// 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
|
180 |
ec_datagram_init(&master->fsm_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
|
181 |
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
|
182 |
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
|
183 |
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
|
184 |
} |
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
|
185 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
186 |
// 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
|
187 |
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
|
188 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
189 |
// init kobject and add it to the hierarchy |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
190 |
memset(&master->kobj, 0x00, sizeof(struct kobject)); |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
191 |
kobject_init(&master->kobj); |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
192 |
master->kobj.ktype = &ktype_ec_master; |
576
158c5a3d0a2a
New module file /sys/ethercat, masters moved to /sys/ethercat/masterX.
Florian Pose <fp@igh-essen.com>
parents:
573
diff
changeset
|
193 |
master->kobj.parent = module_kobj; |
158c5a3d0a2a
New module file /sys/ethercat, masters moved to /sys/ethercat/masterX.
Florian Pose <fp@igh-essen.com>
parents:
573
diff
changeset
|
194 |
|
158c5a3d0a2a
New module file /sys/ethercat, masters moved to /sys/ethercat/masterX.
Florian Pose <fp@igh-essen.com>
parents:
573
diff
changeset
|
195 |
if (kobject_set_name(&master->kobj, "master%i", index)) { |
158c5a3d0a2a
New module file /sys/ethercat, masters moved to /sys/ethercat/masterX.
Florian Pose <fp@igh-essen.com>
parents:
573
diff
changeset
|
196 |
EC_ERR("Failed to set master kobject name.\n"); |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
197 |
kobject_put(&master->kobj); |
659
d7c5a958bad0
Removed unecessary clearing of EoE handlers in master init function;
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
198 |
goto out_clear_fsm; |
226
07247920a7ba
EoE with workqueue; bugfix in ec_master_init()
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
199 |
} |
576
158c5a3d0a2a
New module file /sys/ethercat, masters moved to /sys/ethercat/masterX.
Florian Pose <fp@igh-essen.com>
parents:
573
diff
changeset
|
200 |
|
484
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
483
diff
changeset
|
201 |
if (kobject_add(&master->kobj)) { |
576
158c5a3d0a2a
New module file /sys/ethercat, masters moved to /sys/ethercat/masterX.
Florian Pose <fp@igh-essen.com>
parents:
573
diff
changeset
|
202 |
EC_ERR("Failed to add master kobject.\n"); |
484
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
483
diff
changeset
|
203 |
kobject_put(&master->kobj); |
659
d7c5a958bad0
Removed unecessary clearing of EoE handlers in master init function;
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
204 |
goto out_clear_fsm; |
484
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
483
diff
changeset
|
205 |
} |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
140
diff
changeset
|
206 |
|
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
207 |
return 0; |
226
07247920a7ba
EoE with workqueue; bugfix in ec_master_init()
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
208 |
|
659
d7c5a958bad0
Removed unecessary clearing of EoE handlers in master init function;
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
209 |
out_clear_fsm: |
d7c5a958bad0
Removed unecessary clearing of EoE handlers in master init function;
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
210 |
ec_fsm_master_clear(&master->fsm); |
d7c5a958bad0
Removed unecessary clearing of EoE handlers in master init function;
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
211 |
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
|
212 |
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
|
213 |
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
|
214 |
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
|
215 |
out_return: |
226
07247920a7ba
EoE with workqueue; bugfix in ec_master_init()
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
216 |
return -1; |
0 | 217 |
} |
218 |
||
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
35
diff
changeset
|
219 |
/*****************************************************************************/ |
0 | 220 |
|
221 |
/** |
|
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
|
222 |
Clear and free master. |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
223 |
This method is called by the kobject, |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
224 |
once there are no more references to it. |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
225 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
226 |
|
639
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
227 |
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
|
228 |
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
|
229 |
) |
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
230 |
{ |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
231 |
ec_master_clear_eoe_handlers(master); |
639
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
232 |
ec_master_destroy_slaves(master); |
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
233 |
ec_master_destroy_domains(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
|
234 |
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
|
235 |
ec_datagram_clear(&master->fsm_datagram); |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
236 |
ec_device_clear(&master->backup_device); |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
237 |
ec_device_clear(&master->main_device); |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
238 |
|
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
239 |
// destroy self |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
240 |
kobject_del(&master->kobj); |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
241 |
kobject_put(&master->kobj); |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
242 |
} |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
243 |
|
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
244 |
/*****************************************************************************/ |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
245 |
|
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
246 |
/** |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
247 |
* Clear and free all EoE handlers. |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
248 |
*/ |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
249 |
|
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
250 |
void ec_master_clear_eoe_handlers( |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
251 |
ec_master_t *master /**< EtherCAT master */ |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
252 |
) |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
253 |
{ |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
254 |
ec_eoe_t *eoe, *next; |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
255 |
|
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
256 |
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
|
257 |
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
|
258 |
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
|
259 |
kfree(eoe); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
260 |
} |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
261 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
262 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
263 |
/*****************************************************************************/ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
264 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
265 |
/** |
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
|
266 |
Destroy all slaves. |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
267 |
*/ |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
268 |
|
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 |
void ec_master_destroy_slaves(ec_master_t *master) |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
270 |
{ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
271 |
ec_slave_t *slave, *next_slave; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
272 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
273 |
list_for_each_entry_safe(slave, next_slave, &master->slaves, list) { |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
274 |
list_del(&slave->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
|
275 |
ec_slave_destroy(slave); |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
276 |
} |
446 | 277 |
|
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
236
diff
changeset
|
278 |
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
|
279 |
} |
9bf603942791
Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
280 |
|
9bf603942791
Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
281 |
/*****************************************************************************/ |
9bf603942791
Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
282 |
|
9bf603942791
Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents:
73
diff
changeset
|
283 |
/** |
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
|
284 |
Destroy all domains. |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
285 |
*/ |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
286 |
|
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
287 |
void ec_master_destroy_domains(ec_master_t *master) |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
288 |
{ |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
289 |
ec_domain_t *domain, *next_d; |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
290 |
|
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
291 |
list_for_each_entry_safe(domain, next_d, &master->domains, list) { |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
292 |
list_del(&domain->list); |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
293 |
ec_domain_destroy(domain); |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
294 |
} |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
295 |
} |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
296 |
|
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
297 |
/*****************************************************************************/ |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
298 |
|
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
299 |
/** |
515
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
300 |
Internal locking callback. |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
301 |
*/ |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
302 |
|
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
303 |
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
|
304 |
{ |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
305 |
spin_lock(&((ec_master_t *) master)->internal_lock); |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
306 |
return 0; |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
307 |
} |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
308 |
|
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
309 |
/*****************************************************************************/ |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
310 |
|
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
311 |
/** |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
312 |
Internal unlocking callback. |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
313 |
*/ |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
314 |
|
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
315 |
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
|
316 |
{ |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
317 |
spin_unlock(&((ec_master_t *) master)->internal_lock); |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
318 |
} |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
319 |
|
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
320 |
/*****************************************************************************/ |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
321 |
|
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
322 |
/** |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
323 |
* Starts the master thread. |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
324 |
*/ |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
325 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
326 |
int ec_master_thread_start( |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
327 |
ec_master_t *master, /**< EtherCAT master */ |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
328 |
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
|
329 |
) |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
330 |
{ |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
331 |
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
|
332 |
|
540
a729667dea1e
Minor changes in master thread messages.
Florian Pose <fp@igh-essen.com>
parents:
533
diff
changeset
|
333 |
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
|
334 |
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
|
335 |
master, CLONE_KERNEL))) |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
336 |
return -1; |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
337 |
|
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
338 |
return 0; |
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 |
/*****************************************************************************/ |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
342 |
|
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
343 |
/** |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
344 |
* Stops the master thread. |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
345 |
*/ |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
346 |
|
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
347 |
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
|
348 |
{ |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
349 |
if (!master->thread_id) { |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
350 |
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
|
351 |
return; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
352 |
} |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
353 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
354 |
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
|
355 |
wait_for_completion(&master->thread_exit); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
356 |
EC_INFO("Master thread exited.\n"); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
357 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
358 |
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
|
359 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
360 |
// wait for FSM datagram |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
361 |
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
|
362 |
< (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
|
363 |
schedule(); |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
364 |
} |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
365 |
|
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
366 |
/*****************************************************************************/ |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
367 |
|
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
368 |
/** |
527 | 369 |
* Transition function from ORPHANED to IDLE mode. |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
370 |
*/ |
446 | 371 |
|
372 |
int ec_master_enter_idle_mode(ec_master_t *master /**< EtherCAT master */) |
|
373 |
{ |
|
515
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
374 |
master->request_cb = ec_master_request_cb; |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
375 |
master->release_cb = ec_master_release_cb; |
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
376 |
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
|
377 |
|
446 | 378 |
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
|
379 |
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
|
380 |
master->mode = EC_MASTER_MODE_ORPHANED; |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
381 |
return -1; |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
382 |
} |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
383 |
|
446 | 384 |
return 0; |
385 |
} |
|
386 |
||
387 |
/*****************************************************************************/ |
|
388 |
||
389 |
/** |
|
527 | 390 |
* Transition function from IDLE to ORPHANED mode. |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
391 |
*/ |
446 | 392 |
|
393 |
void ec_master_leave_idle_mode(ec_master_t *master /**< EtherCAT master */) |
|
394 |
{ |
|
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
395 |
master->mode = EC_MASTER_MODE_ORPHANED; |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
396 |
|
446 | 397 |
ec_master_eoe_stop(master); |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
398 |
ec_master_thread_stop(master); |
589
492148a329e7
Destroy slaves when leaving idle mode.
Florian Pose <fp@igh-essen.com>
parents:
579
diff
changeset
|
399 |
ec_master_destroy_slaves(master); |
446 | 400 |
} |
401 |
||
402 |
/*****************************************************************************/ |
|
403 |
||
404 |
/** |
|
527 | 405 |
* Transition function from IDLE to OPERATION mode. |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
406 |
*/ |
446 | 407 |
|
408 |
int ec_master_enter_operation_mode(ec_master_t *master /**< EtherCAT master */) |
|
409 |
{ |
|
410 |
ec_slave_t *slave; |
|
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
411 |
ec_eoe_t *eoe; |
446 | 412 |
|
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
413 |
down(&master->config_sem); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
414 |
master->allow_config = 0; // temporarily disable slave configuration |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
415 |
up(&master->config_sem); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
416 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
417 |
// wait for slave configuration to complete |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
418 |
if (wait_event_interruptible(master->config_queue, |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
419 |
master->config_state != EC_REQUEST_IN_PROGRESS)) { |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
420 |
EC_INFO("Finishing slave configuration interrupted by signal.\n"); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
421 |
goto out_allow; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
422 |
} |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
423 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
424 |
if (master->debug_level) |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
425 |
EC_DBG("Waiting for pending slave configuration returned.\n"); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
426 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
427 |
down(&master->scan_sem); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
428 |
master->allow_scan = 0; // 'lock' the slave list |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
429 |
up(&master->scan_sem); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
430 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
431 |
// wait for slave scan to complete |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
432 |
if (wait_event_interruptible(master->scan_queue, |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
433 |
master->scan_state != EC_REQUEST_IN_PROGRESS)) { |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
434 |
EC_INFO("Waiting for slave scan interrupted by signal.\n"); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
435 |
goto out_allow; |
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 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
438 |
if (master->debug_level) |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
439 |
EC_DBG("Waiting for pending slave scan returned.\n"); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
440 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
441 |
// set states for all slaves |
446 | 442 |
list_for_each_entry(slave, &master->slaves, list) { |
643
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
443 |
ec_slave_request_state(slave, EC_SLAVE_STATE_PREOP); |
446 | 444 |
} |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
445 |
// ... but set EoE slaves to OP |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
446 |
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
|
447 |
if (ec_eoe_is_open(eoe)) |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
448 |
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
|
449 |
} |
446 | 450 |
|
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
451 |
if (master->debug_level) |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
452 |
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
|
453 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
454 |
master->mode = EC_MASTER_MODE_OPERATION; |
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
455 |
master->pdo_slaves_offline = 0; // assume all PDO slaves online |
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
|
456 |
master->frames_timed_out = 0; |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
457 |
master->ext_request_cb = NULL; |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
458 |
master->ext_release_cb = NULL; |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
459 |
master->ext_cb_data = NULL; |
446 | 460 |
return 0; |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
461 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
462 |
out_allow: |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
463 |
master->allow_scan = 1; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
464 |
master->allow_config = 1; |
446 | 465 |
return -1; |
466 |
} |
|
467 |
||
468 |
/*****************************************************************************/ |
|
469 |
||
470 |
/** |
|
527 | 471 |
* Transition function from OPERATION to IDLE mode. |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
472 |
*/ |
446 | 473 |
|
474 |
void ec_master_leave_operation_mode(ec_master_t *master |
|
475 |
/**< EtherCAT master */) |
|
476 |
{ |
|
477 |
ec_slave_t *slave; |
|
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
478 |
ec_eoe_t *eoe; |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
479 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
480 |
master->mode = EC_MASTER_MODE_IDLE; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
481 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
482 |
ec_master_eoe_stop(master); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
483 |
ec_master_thread_stop(master); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
484 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
485 |
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
|
486 |
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
|
487 |
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
|
488 |
|
449
3caf8ff4d8a2
Moved functionality of ecrt_master_deactivate() (now deprecated) to ecrt_master_release().
Florian Pose <fp@igh-essen.com>
parents:
448
diff
changeset
|
489 |
// set states for all slaves |
3caf8ff4d8a2
Moved functionality of ecrt_master_deactivate() (now deprecated) to ecrt_master_release().
Florian Pose <fp@igh-essen.com>
parents:
448
diff
changeset
|
490 |
list_for_each_entry(slave, &master->slaves, list) { |
467
2274de57ca84
Remove estimated sync manager sizes when leaving operation mode.
Florian Pose <fp@igh-essen.com>
parents:
462
diff
changeset
|
491 |
ec_slave_reset(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
|
492 |
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
|
493 |
} |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
494 |
// ... but leave EoE slaves in OP |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
495 |
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
|
496 |
if (ec_eoe_is_open(eoe)) |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
497 |
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
|
498 |
} |
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
|
499 |
|
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
500 |
ec_master_destroy_domains(master); |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
501 |
|
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
502 |
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
|
503 |
EC_WARN("Failed to restart master thread!\n"); |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
504 |
ec_master_eoe_start(master); |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
505 |
|
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
506 |
master->allow_scan = 1; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
507 |
master->allow_config = 1; |
446 | 508 |
} |
509 |
||
510 |
/*****************************************************************************/ |
|
511 |
||
512 |
/** |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
513 |
Places a datagram in the datagram queue. |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
514 |
*/ |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
515 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
516 |
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
|
517 |
ec_datagram_t *datagram /**< datagram */ |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
518 |
) |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
519 |
{ |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
520 |
ec_datagram_t *queued_datagram; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
521 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
522 |
// check, if the datagram is already queued |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
523 |
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
|
524 |
if (queued_datagram == datagram) { |
332
e16093374dfd
New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents:
331
diff
changeset
|
525 |
master->stats.skipped++; |
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
526 |
if (master->debug_level) |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
527 |
EC_DBG("skipping datagram %x.\n", (unsigned int) datagram); |
332
e16093374dfd
New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents:
331
diff
changeset
|
528 |
ec_master_output_stats(master); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
529 |
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
|
530 |
return; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
531 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
532 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
533 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
534 |
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
|
535 |
datagram->state = EC_DATAGRAM_QUEUED; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
536 |
} |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
537 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
538 |
/*****************************************************************************/ |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
539 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
540 |
/** |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
541 |
Sends the datagrams in the queue. |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
542 |
\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
|
543 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
544 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
545 |
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
|
546 |
{ |
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
547 |
ec_datagram_t *datagram, *next; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
548 |
size_t datagram_size; |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
549 |
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
|
550 |
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
|
551 |
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
|
552 |
unsigned long jiffies_sent; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
553 |
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
|
554 |
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
|
555 |
|
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
556 |
cycles_start = get_cycles(); |
176 | 557 |
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
|
558 |
INIT_LIST_HEAD(&sent_datagrams); |
208
b7797f8a813d
command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents:
206
diff
changeset
|
559 |
|
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
560 |
if (unlikely(master->debug_level > 1)) |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
561 |
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
|
562 |
|
176 | 563 |
do { |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
564 |
// 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
|
565 |
frame_data = ec_device_tx_data(&master->main_device); |
176 | 566 |
cur_data = frame_data + EC_FRAME_HEADER_SIZE; |
567 |
follows_word = NULL; |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
568 |
more_datagrams_waiting = 0; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
569 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
570 |
// fill current frame with datagrams |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
571 |
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
|
572 |
if (datagram->state != EC_DATAGRAM_QUEUED) continue; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
573 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
574 |
// does the current datagram fit in the frame? |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
575 |
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
|
576 |
+ EC_DATAGRAM_FOOTER_SIZE; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
577 |
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
|
578 |
more_datagrams_waiting = 1; |
176 | 579 |
break; |
580 |
} |
|
581 |
||
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
582 |
list_add_tail(&datagram->sent, &sent_datagrams); |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
583 |
datagram->index = master->datagram_index++; |
176 | 584 |
|
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
585 |
if (unlikely(master->debug_level > 1)) |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
586 |
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
|
587 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
588 |
// set "datagram following" flag in previous frame |
176 | 589 |
if (follows_word) |
590 |
EC_WRITE_U16(follows_word, EC_READ_U16(follows_word) | 0x8000); |
|
591 |
||
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
592 |
// EtherCAT datagram header |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
593 |
EC_WRITE_U8 (cur_data, datagram->type); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
594 |
EC_WRITE_U8 (cur_data + 1, datagram->index); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
595 |
EC_WRITE_U32(cur_data + 2, datagram->address.logical); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
596 |
EC_WRITE_U16(cur_data + 6, datagram->data_size & 0x7FF); |
176 | 597 |
EC_WRITE_U16(cur_data + 8, 0x0000); |
598 |
follows_word = cur_data + 6; |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
599 |
cur_data += EC_DATAGRAM_HEADER_SIZE; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
600 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
601 |
// EtherCAT datagram data |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
602 |
memcpy(cur_data, datagram->data, datagram->data_size); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
603 |
cur_data += datagram->data_size; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
604 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
605 |
// EtherCAT datagram footer |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
606 |
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
|
607 |
cur_data += EC_DATAGRAM_FOOTER_SIZE; |
176 | 608 |
} |
609 |
||
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
610 |
if (list_empty(&sent_datagrams)) { |
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
611 |
if (unlikely(master->debug_level > 1)) |
176 | 612 |
EC_DBG("nothing to send.\n"); |
613 |
break; |
|
614 |
} |
|
615 |
||
616 |
// EtherCAT frame header |
|
617 |
EC_WRITE_U16(frame_data, ((cur_data - frame_data |
|
618 |
- EC_FRAME_HEADER_SIZE) & 0x7FF) | 0x1000); |
|
619 |
||
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
620 |
// pad frame |
211
c684b6b7adaf
Using kernel Ethernet constants.
Florian Pose <fp@igh-essen.com>
parents:
208
diff
changeset
|
621 |
while (cur_data - frame_data < ETH_ZLEN - ETH_HLEN) |
176 | 622 |
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
|
623 |
|
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
624 |
if (unlikely(master->debug_level > 1)) |
176 | 625 |
EC_DBG("frame size: %i\n", cur_data - frame_data); |
626 |
||
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
627 |
// 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
|
628 |
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
|
629 |
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
|
630 |
jiffies_sent = jiffies; |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
631 |
|
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
632 |
// 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
|
633 |
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
|
634 |
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
|
635 |
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
|
636 |
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
|
637 |
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
|
638 |
} |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
639 |
|
176 | 640 |
frame_count++; |
641 |
} |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
642 |
while (more_datagrams_waiting); |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
643 |
|
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
644 |
if (unlikely(master->debug_level > 1)) { |
344
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
645 |
cycles_end = get_cycles(); |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
646 |
EC_DBG("ec_master_send_datagrams sent %i frames in %ius.\n", |
344
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
647 |
frame_count, |
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
648 |
(unsigned int) (cycles_end - cycles_start) * 1000 / cpu_khz); |
176 | 649 |
} |
650 |
} |
|
651 |
||
652 |
/*****************************************************************************/ |
|
653 |
||
654 |
/** |
|
655 |
Processes a received frame. |
|
656 |
This function is called by the network driver for every received frame. |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
657 |
\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
|
658 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
659 |
|
331
17f58fe99511
Renamed ec_master_receive() to ec_master_receive_datagrams().
Florian Pose <fp@igh-essen.com>
parents:
330
diff
changeset
|
660 |
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
|
661 |
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
|
662 |
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
|
663 |
) |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
664 |
{ |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
665 |
size_t frame_size, data_size; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
666 |
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
|
667 |
unsigned int cmd_follows, matched; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
668 |
const uint8_t *cur_data; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
669 |
ec_datagram_t *datagram; |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
670 |
|
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
671 |
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
|
672 |
master->stats.corrupted++; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
673 |
ec_master_output_stats(master); |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
674 |
return; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
675 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
676 |
|
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
677 |
cur_data = frame_data; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
678 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
679 |
// 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
|
680 |
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
|
681 |
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
|
682 |
|
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
683 |
if (unlikely(frame_size > size)) { |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
684 |
master->stats.corrupted++; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
685 |
ec_master_output_stats(master); |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
686 |
return; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
687 |
} |
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 |
cmd_follows = 1; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
690 |
while (cmd_follows) { |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
691 |
// process datagram header |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
692 |
datagram_type = EC_READ_U8 (cur_data); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
693 |
datagram_index = EC_READ_U8 (cur_data + 1); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
694 |
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
|
695 |
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
|
696 |
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
|
697 |
|
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
698 |
if (unlikely(cur_data - frame_data |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
699 |
+ 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
|
700 |
master->stats.corrupted++; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
701 |
ec_master_output_stats(master); |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
702 |
return; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
703 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
704 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
705 |
// 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
|
706 |
matched = 0; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
707 |
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
|
708 |
if (datagram->index == datagram_index |
5e231f6a3d2e
Re-ordered criteria for datagram matching.
Florian Pose <fp@igh-essen.com>
parents:
688
diff
changeset
|
709 |
&& datagram->state == EC_DATAGRAM_SENT |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
710 |
&& datagram->type == datagram_type |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
711 |
&& 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
|
712 |
matched = 1; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
713 |
break; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
714 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
715 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
716 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
717 |
// 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
|
718 |
if (!matched) { |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
719 |
master->stats.unmatched++; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
720 |
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
|
721 |
|
bf991809dcf0
Added debugging output for unmatched frames and those that timed out.
Florian Pose <fp@igh-essen.com>
parents:
664
diff
changeset
|
722 |
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
|
723 |
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
|
724 |
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
|
725 |
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
|
726 |
+ 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
|
727 |
#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
|
728 |
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
|
729 |
#endif |
684
bf991809dcf0
Added debugging output for unmatched frames and those that timed out.
Florian Pose <fp@igh-essen.com>
parents:
664
diff
changeset
|
730 |
} |
bf991809dcf0
Added debugging output for unmatched frames and those that timed out.
Florian Pose <fp@igh-essen.com>
parents:
664
diff
changeset
|
731 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
732 |
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
|
733 |
continue; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
734 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
735 |
|
345
beb0a77d73c0
Improved datagram reception in sync_io and frame dequeuing.
Florian Pose <fp@igh-essen.com>
parents:
344
diff
changeset
|
736 |
// copy received data into the datagram memory |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
737 |
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
|
738 |
cur_data += data_size; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
739 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
740 |
// set the datagram's working counter |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
741 |
datagram->working_counter = EC_READ_U16(cur_data); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
742 |
cur_data += EC_DATAGRAM_FOOTER_SIZE; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
743 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
744 |
// 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
|
745 |
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
|
746 |
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
|
747 |
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
|
748 |
list_del_init(&datagram->queue); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
749 |
} |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
750 |
} |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
751 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
752 |
/*****************************************************************************/ |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
753 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
754 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
755 |
Output statistics in cyclic mode. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
756 |
This function outputs statistical data on demand, but not more often than |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
757 |
necessary. The output happens at most once a second. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
758 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
759 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
760 |
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
|
761 |
{ |
344
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
762 |
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
|
763 |
master->stats.output_jiffies = jiffies; |
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
764 |
|
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
765 |
if (master->stats.timeouts) { |
396 | 766 |
EC_WARN("%i datagram%s TIMED OUT!\n", master->stats.timeouts, |
767 |
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
|
768 |
master->stats.timeouts = 0; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
769 |
} |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
770 |
if (master->stats.corrupted) { |
396 | 771 |
EC_WARN("%i frame%s CORRUPTED!\n", master->stats.corrupted, |
772 |
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
|
773 |
master->stats.corrupted = 0; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
774 |
} |
332
e16093374dfd
New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents:
331
diff
changeset
|
775 |
if (master->stats.skipped) { |
396 | 776 |
EC_WARN("%i datagram%s SKIPPED!\n", master->stats.skipped, |
777 |
master->stats.skipped == 1 ? "" : "s"); |
|
332
e16093374dfd
New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents:
331
diff
changeset
|
778 |
master->stats.skipped = 0; |
e16093374dfd
New statistic outputs to avoid blasting the logs.
Florian Pose <fp@igh-essen.com>
parents:
331
diff
changeset
|
779 |
} |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
780 |
if (master->stats.unmatched) { |
396 | 781 |
EC_WARN("%i datagram%s UNMATCHED!\n", master->stats.unmatched, |
782 |
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
|
783 |
master->stats.unmatched = 0; |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
95
diff
changeset
|
784 |
} |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
68
diff
changeset
|
785 |
} |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
786 |
} |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
787 |
|
68
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
66
diff
changeset
|
788 |
/*****************************************************************************/ |
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
66
diff
changeset
|
789 |
|
a452700db994
Neue ASCII-Adressierung und Code-Dokumantation.
Florian Pose <fp@igh-essen.com>
parents:
66
diff
changeset
|
790 |
/** |
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
791 |
* Master kernel thread function for IDLE mode. |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
792 |
*/ |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
793 |
|
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
794 |
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
|
795 |
{ |
344
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
796 |
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
|
797 |
|
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
798 |
daemonize("EtherCAT-IDLE"); |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
799 |
allow_signal(SIGTERM); |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
800 |
|
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
801 |
while (!signal_pending(current)) { |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
802 |
cycles_start = get_cycles(); |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
803 |
|
691
77b79a29e0e7
Included datagram queuing in critical section in idle task; added some
Florian Pose <fp@igh-essen.com>
parents:
690
diff
changeset
|
804 |
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
|
805 |
// receive |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
806 |
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
|
807 |
ecrt_master_receive(master); |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
808 |
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
|
809 |
|
77b79a29e0e7
Included datagram queuing in critical section in idle task; added some
Florian Pose <fp@igh-essen.com>
parents:
690
diff
changeset
|
810 |
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
|
811 |
goto schedule; |
77b79a29e0e7
Included datagram queuing in critical section in idle task; added some
Florian Pose <fp@igh-essen.com>
parents:
690
diff
changeset
|
812 |
} |
651
8c11399cc911
Fixed skipped datagrams when not in FSM idle phase.
Florian Pose <fp@igh-essen.com>
parents:
650
diff
changeset
|
813 |
|
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
814 |
// 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
|
815 |
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
|
816 |
// 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
|
817 |
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
|
818 |
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
|
819 |
ecrt_master_send(master); |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
820 |
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
|
821 |
} |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
822 |
|
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
823 |
cycles_end = get_cycles(); |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
824 |
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
|
825 |
= (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
|
826 |
master->idle_cycle_time_pos++; |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
827 |
master->idle_cycle_time_pos %= HZ; |
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
828 |
|
651
8c11399cc911
Fixed skipped datagrams when not in FSM idle phase.
Florian Pose <fp@igh-essen.com>
parents:
650
diff
changeset
|
829 |
schedule: |
650
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
648
diff
changeset
|
830 |
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
|
831 |
set_current_state(TASK_INTERRUPTIBLE); |
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
648
diff
changeset
|
832 |
schedule_timeout(1); |
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
648
diff
changeset
|
833 |
} |
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
648
diff
changeset
|
834 |
else { |
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
648
diff
changeset
|
835 |
schedule(); |
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
648
diff
changeset
|
836 |
} |
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
837 |
} |
518
b6a1426ba724
Fixed race: Stop EoE processing when entering or leaving operation mode.
Florian Pose <fp@igh-essen.com>
parents:
517
diff
changeset
|
838 |
|
525
8b20781bd1e0
Master workqueue replaced with kernel thread.
Florian Pose <fp@igh-essen.com>
parents:
524
diff
changeset
|
839 |
master->thread_id = 0; |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
840 |
if (master->debug_level) |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
841 |
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
|
842 |
complete_and_exit(&master->thread_exit, 0); |
191 | 843 |
} |
844 |
||
637
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 |
|
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
847 |
/** |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
848 |
* Master kernel thread function for IDLE mode. |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
849 |
*/ |
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 |
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
|
852 |
{ |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
853 |
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
|
854 |
|
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
855 |
daemonize("EtherCAT-OP"); |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
856 |
allow_signal(SIGTERM); |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
857 |
|
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
858 |
while (!signal_pending(current)) { |
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
859 |
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
|
860 |
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
|
861 |
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
|
862 |
goto schedule; |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
863 |
|
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
864 |
cycles_start = get_cycles(); |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
865 |
|
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
866 |
// output statistics |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
867 |
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
|
868 |
|
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
869 |
// execute master state machine |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
870 |
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
|
871 |
// inject datagram |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
872 |
master->injection_seq_fsm++; |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
873 |
} |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
874 |
|
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
875 |
cycles_end = get_cycles(); |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
876 |
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
|
877 |
= (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
|
878 |
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
|
879 |
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
|
880 |
|
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
881 |
schedule: |
650
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
648
diff
changeset
|
882 |
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
|
883 |
set_current_state(TASK_INTERRUPTIBLE); |
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
648
diff
changeset
|
884 |
schedule_timeout(1); |
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
648
diff
changeset
|
885 |
} |
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
648
diff
changeset
|
886 |
else { |
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
648
diff
changeset
|
887 |
schedule(); |
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
648
diff
changeset
|
888 |
} |
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
889 |
} |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
890 |
|
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
891 |
master->thread_id = 0; |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
892 |
if (master->debug_level) |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
893 |
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
|
894 |
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
|
895 |
} |
578
f402b4bd2f4d
Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents:
576
diff
changeset
|
896 |
|
f402b4bd2f4d
Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents:
576
diff
changeset
|
897 |
/*****************************************************************************/ |
f402b4bd2f4d
Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents:
576
diff
changeset
|
898 |
|
639
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
899 |
ssize_t ec_master_device_info( |
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
900 |
const ec_device_t *device, |
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
901 |
const uint8_t *mac, |
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
902 |
char *buffer |
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
903 |
) |
578
f402b4bd2f4d
Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents:
576
diff
changeset
|
904 |
{ |
f402b4bd2f4d
Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents:
576
diff
changeset
|
905 |
unsigned int frames_lost; |
f402b4bd2f4d
Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents:
576
diff
changeset
|
906 |
off_t off = 0; |
f402b4bd2f4d
Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents:
576
diff
changeset
|
907 |
|
639
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
908 |
if (ec_mac_is_zero(mac)) { |
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
909 |
off += sprintf(buffer + off, "none.\n"); |
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
910 |
} |
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
911 |
else { |
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
912 |
off += ec_mac_print(mac, buffer + off); |
578
f402b4bd2f4d
Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents:
576
diff
changeset
|
913 |
|
639
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
914 |
if (device->dev) { |
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
915 |
off += sprintf(buffer + off, " (connected).\n"); |
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
916 |
off += sprintf(buffer + off, " Frames sent: %u\n", |
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
917 |
device->tx_count); |
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
918 |
off += sprintf(buffer + off, " Frames received: %u\n", |
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
919 |
device->rx_count); |
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
920 |
frames_lost = device->tx_count - device->rx_count; |
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
921 |
if (frames_lost) frames_lost--; |
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
922 |
off += sprintf(buffer + off, " Frames lost: %u\n", frames_lost); |
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
923 |
} |
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
924 |
else { |
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
925 |
off += sprintf(buffer + off, " (WAITING).\n"); |
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
926 |
} |
578
f402b4bd2f4d
Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents:
576
diff
changeset
|
927 |
} |
f402b4bd2f4d
Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents:
576
diff
changeset
|
928 |
|
f402b4bd2f4d
Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents:
576
diff
changeset
|
929 |
return off; |
f402b4bd2f4d
Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents:
576
diff
changeset
|
930 |
} |
f402b4bd2f4d
Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents:
576
diff
changeset
|
931 |
|
191 | 932 |
/*****************************************************************************/ |
933 |
||
934 |
/** |
|
334
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
935 |
Formats master information for SysFS read access. |
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
936 |
\return number of bytes written |
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
937 |
*/ |
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
938 |
|
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
939 |
ssize_t ec_master_info(ec_master_t *master, /**< EtherCAT master */ |
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
940 |
char *buffer /**< memory to store data */ |
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
941 |
) |
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
942 |
{ |
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
943 |
off_t off = 0; |
336 | 944 |
ec_eoe_t *eoe; |
335
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
945 |
uint32_t cur, sum, min, max, pos, i; |
578
f402b4bd2f4d
Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents:
576
diff
changeset
|
946 |
|
334
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
947 |
off += sprintf(buffer + off, "\nMode: "); |
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
948 |
switch (master->mode) { |
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
949 |
case EC_MASTER_MODE_ORPHANED: |
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
950 |
off += sprintf(buffer + off, "ORPHANED"); |
335
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
951 |
break; |
334
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
952 |
case EC_MASTER_MODE_IDLE: |
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
953 |
off += sprintf(buffer + off, "IDLE"); |
335
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
954 |
break; |
334
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
955 |
case EC_MASTER_MODE_OPERATION: |
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
956 |
off += sprintf(buffer + off, "OPERATION"); |
335
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
957 |
break; |
334
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
958 |
} |
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
959 |
|
339 | 960 |
off += sprintf(buffer + off, "\nSlaves: %i\n", |
334
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
961 |
master->slave_count); |
578
f402b4bd2f4d
Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents:
576
diff
changeset
|
962 |
|
f402b4bd2f4d
Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents:
576
diff
changeset
|
963 |
off += sprintf(buffer + off, "\nDevices:\n"); |
f402b4bd2f4d
Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents:
576
diff
changeset
|
964 |
|
648
0a6d38ec463f
Made waiting for device semaphore uninterruptible.
Florian Pose <fp@igh-essen.com>
parents:
647
diff
changeset
|
965 |
down(&master->device_sem); |
578
f402b4bd2f4d
Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents:
576
diff
changeset
|
966 |
off += sprintf(buffer + off, " Main: "); |
579
17c6fd3b076e
Made master devices persistent; added ec_device_attach() and ec_device_detach().
Florian Pose <fp@igh-essen.com>
parents:
578
diff
changeset
|
967 |
off += ec_master_device_info(&master->main_device, |
639
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
968 |
master->main_mac, buffer + off); |
578
f402b4bd2f4d
Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents:
576
diff
changeset
|
969 |
off += sprintf(buffer + off, " 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
|
970 |
off += ec_master_device_info(&master->backup_device, |
639
aa23c48dca2d
Allow only MAC addresses as device identifiers; replaced master list by
Florian Pose <fp@igh-essen.com>
parents:
637
diff
changeset
|
971 |
master->backup_mac, buffer + off); |
578
f402b4bd2f4d
Removed ktype for module kobject; added backup device for master; device
Florian Pose <fp@igh-essen.com>
parents:
576
diff
changeset
|
972 |
up(&master->device_sem); |
334
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
973 |
|
335
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
974 |
off += sprintf(buffer + off, "\nTiming (min/avg/max) [us]:\n"); |
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
975 |
|
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
976 |
sum = 0; |
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
977 |
min = 0xFFFFFFFF; |
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
978 |
max = 0; |
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
979 |
pos = master->idle_cycle_time_pos; |
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
980 |
for (i = 0; i < HZ; i++) { |
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
981 |
cur = master->idle_cycle_times[(i + pos) % HZ]; |
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
982 |
sum += cur; |
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
983 |
if (cur < min) min = cur; |
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
984 |
if (cur > max) max = cur; |
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
985 |
} |
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
986 |
off += sprintf(buffer + off, " Idle cycle: %u / %u.%u / %u\n", |
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
987 |
min, sum / HZ, (sum * 100 / HZ) % 100, max); |
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
988 |
|
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
989 |
sum = 0; |
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
990 |
min = 0xFFFFFFFF; |
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
991 |
max = 0; |
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
992 |
pos = master->eoe_cycle_time_pos; |
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
993 |
for (i = 0; i < HZ; i++) { |
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
994 |
cur = master->eoe_cycle_times[(i + pos) % HZ]; |
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
995 |
sum += cur; |
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
996 |
if (cur < min) min = cur; |
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
997 |
if (cur > max) max = cur; |
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
998 |
} |
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
999 |
off += sprintf(buffer + off, " EoE cycle: %u / %u.%u / %u\n", |
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
1000 |
min, sum / HZ, (sum * 100 / HZ) % 100, max); |
334
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
1001 |
|
336 | 1002 |
if (!list_empty(&master->eoe_handlers)) |
339 | 1003 |
off += sprintf(buffer + off, "\nEoE statistics (RX/TX) [bps]:\n"); |
336 | 1004 |
list_for_each_entry(eoe, &master->eoe_handlers, list) { |
341
f8aa65e05ff4
Added EoE rate in KB/s to master info.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
1005 |
off += sprintf(buffer + off, " %s: %u / %u (%u KB/s)\n", |
f8aa65e05ff4
Added EoE rate in KB/s to master info.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
1006 |
eoe->dev->name, eoe->rx_rate, eoe->tx_rate, |
f8aa65e05ff4
Added EoE rate in KB/s to master info.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
1007 |
((eoe->rx_rate + eoe->tx_rate) / 8 + 512) / 1024); |
336 | 1008 |
} |
1009 |
||
334
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
1010 |
off += sprintf(buffer + off, "\n"); |
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
1011 |
|
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
1012 |
return off; |
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
1013 |
} |
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
1014 |
|
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
1015 |
/*****************************************************************************/ |
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
1016 |
|
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
1017 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1018 |
Formats attribute data for SysFS read access. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1019 |
\return number of bytes to read |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1020 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1021 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1022 |
ssize_t ec_show_master_attribute(struct kobject *kobj, /**< kobject */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1023 |
struct attribute *attr, /**< attribute */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
1024 |
char *buffer /**< memory to store data */ |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1025 |
) |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1026 |
{ |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1027 |
ec_master_t *master = container_of(kobj, ec_master_t, kobj); |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1028 |
|
334
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
1029 |
if (attr == &attr_info) { |
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
1030 |
return ec_master_info(master, buffer); |
191 | 1031 |
} |
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
1032 |
else if (attr == &attr_debug_level) { |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
1033 |
return sprintf(buffer, "%i\n", master->debug_level); |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
1034 |
} |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1035 |
|
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1036 |
return 0; |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1037 |
} |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1038 |
|
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1039 |
/*****************************************************************************/ |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1040 |
|
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
176
diff
changeset
|
1041 |
/** |
268
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
1042 |
Formats attribute data for SysFS write access. |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
1043 |
\return number of bytes processed, or negative error code |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
1044 |
*/ |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
1045 |
|
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
1046 |
ssize_t ec_store_master_attribute(struct kobject *kobj, /**< slave's kobject */ |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
1047 |
struct attribute *attr, /**< attribute */ |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
1048 |
const char *buffer, /**< memory with data */ |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
1049 |
size_t size /**< size of data to store */ |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
1050 |
) |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
1051 |
{ |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
1052 |
ec_master_t *master = container_of(kobj, ec_master_t, kobj); |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
1053 |
|
597
3a2c2d6ca5e9
Removed eeprom_write_enable file.
Florian Pose <fp@igh-essen.com>
parents:
589
diff
changeset
|
1054 |
if (attr == &attr_debug_level) { |
303
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
1055 |
if (!strcmp(buffer, "0\n")) { |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
1056 |
master->debug_level = 0; |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
1057 |
} |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
1058 |
else if (!strcmp(buffer, "1\n")) { |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
1059 |
master->debug_level = 1; |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
1060 |
} |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
1061 |
else if (!strcmp(buffer, "2\n")) { |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
1062 |
master->debug_level = 2; |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
1063 |
} |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
1064 |
else { |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
1065 |
EC_ERR("Invalid debug level value!\n"); |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
1066 |
return -EINVAL; |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
1067 |
} |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
1068 |
|
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
1069 |
EC_INFO("Master debug level set to %i.\n", master->debug_level); |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
1070 |
return size; |
03fd45bc13ef
SysFS entry for debug level.
Florian Pose <fp@igh-essen.com>
parents:
298
diff
changeset
|
1071 |
} |
268
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
1072 |
|
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
1073 |
return -EINVAL; |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
1074 |
} |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
1075 |
|
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
1076 |
/*****************************************************************************/ |
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
1077 |
|
4f9c149fb71f
EEPROM write enable SysFS entry.
Florian Pose <fp@igh-essen.com>
parents:
261
diff
changeset
|
1078 |
/** |
326
ddb48b173680
Fixed bug with ec_master_eoe_start() does new coupling all the time.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1079 |
Starts Ethernet-over-EtherCAT processing on demand. |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1080 |
*/ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1081 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1082 |
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
|
1083 |
{ |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1084 |
if (master->eoe_running) { |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1085 |
EC_WARN("EoE already running!\n"); |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1086 |
return; |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1087 |
} |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1088 |
|
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1089 |
if (list_empty(&master->eoe_handlers)) |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1090 |
return; |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1091 |
|
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1092 |
if (!master->request_cb || !master->release_cb) { |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1093 |
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
|
1094 |
return; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1095 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1096 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1097 |
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
|
1098 |
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
|
1099 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1100 |
// start EoE processing |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1101 |
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
|
1102 |
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
|
1103 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1104 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1105 |
/*****************************************************************************/ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1106 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1107 |
/** |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1108 |
Stops the Ethernet-over-EtherCAT processing. |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1109 |
*/ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1110 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1111 |
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
|
1112 |
{ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1113 |
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
|
1114 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1115 |
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
|
1116 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1117 |
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
|
1118 |
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
|
1119 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1120 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1121 |
/*****************************************************************************/ |
441
ffa13db95e10
SDO uploading via Sysfs without master FSM calling wake_up().
Florian Pose <fp@igh-essen.com>
parents:
435
diff
changeset
|
1122 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1123 |
/** |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1124 |
Does the Ethernet-over-EtherCAT processing. |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1125 |
*/ |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1126 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1127 |
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
|
1128 |
{ |
60a10d85c20b
Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents:
204
diff
changeset
|
1129 |
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
|
1130 |
ec_eoe_t *eoe; |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1131 |
unsigned int none_open = 1; |
344
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
1132 |
cycles_t cycles_start, cycles_end; |
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
1133 |
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
|
1134 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1135 |
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
|
1136 |
if (ec_eoe_is_open(eoe)) { |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1137 |
none_open = 0; |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1138 |
break; |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1139 |
} |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1140 |
} |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1141 |
if (none_open) |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1142 |
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
|
1143 |
|
663
38d9c37664d9
Completely lock master while an EoE cycle is executing.
Florian Pose <fp@igh-essen.com>
parents:
661
diff
changeset
|
1144 |
if (master->request_cb(master->cb_data)) goto queue_timer; |
38d9c37664d9
Completely lock master while an EoE cycle is executing.
Florian Pose <fp@igh-essen.com>
parents:
661
diff
changeset
|
1145 |
|
515
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
1146 |
// receive datagrams |
344
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
1147 |
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
|
1148 |
ecrt_master_receive(master); |
515
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
1149 |
|
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
1150 |
// 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
|
1151 |
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
|
1152 |
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
|
1153 |
} |
334
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
1154 |
|
515
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
1155 |
// send datagrams |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
1156 |
ecrt_master_send(master); |
344
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
1157 |
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
|
1158 |
|
515
37aa1bfa0dee
Internal locking callbacks, improved locking.
Florian Pose <fp@igh-essen.com>
parents:
511
diff
changeset
|
1159 |
master->release_cb(master->cb_data); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1160 |
|
335
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
1161 |
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
|
1162 |
= (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
|
1163 |
master->eoe_cycle_time_pos++; |
1e37c856b74e
Better EoE and Idle timing measurement.
Florian Pose <fp@igh-essen.com>
parents:
334
diff
changeset
|
1164 |
master->eoe_cycle_time_pos %= HZ; |
334
2be97e069602
Master information, timing.
Florian Pose <fp@igh-essen.com>
parents:
332
diff
changeset
|
1165 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1166 |
queue_timer: |
344
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
1167 |
restart_jiffies = HZ / EC_EOE_FREQUENCY; |
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
1168 |
if (!restart_jiffies) restart_jiffies = 1; |
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
341
diff
changeset
|
1169 |
master->eoe_timer.expires += restart_jiffies; |
208
b7797f8a813d
command timeout, EoE processing with kernel timer.
Florian Pose <fp@igh-essen.com>
parents:
206
diff
changeset
|
1170 |
add_timer(&master->eoe_timer); |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1171 |
} |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1172 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
1173 |
/*****************************************************************************/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
1174 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
321
diff
changeset
|
1175 |
/** |
330 | 1176 |
Measures the time, a frame is on the bus. |
377
ecac8252f114
Changes in ecrt_request_master(); minor output changes.
Florian Pose <fp@igh-essen.com>
parents:
361
diff
changeset
|
1177 |
\return 0 in case of success, else < 0 |
ecac8252f114
Changes in ecrt_request_master(); minor output changes.
Florian Pose <fp@igh-essen.com>
parents:
361
diff
changeset
|
1178 |
*/ |
ecac8252f114
Changes in ecrt_request_master(); minor output changes.
Florian Pose <fp@igh-essen.com>
parents:
361
diff
changeset
|
1179 |
|
ecac8252f114
Changes in ecrt_request_master(); minor output changes.
Florian Pose <fp@igh-essen.com>
parents:
361
diff
changeset
|
1180 |
int ec_master_measure_bus_time(ec_master_t *master) |
330 | 1181 |
{ |
1182 |
ec_datagram_t datagram; |
|
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1183 |
uint32_t cur, sum, min, max, i; |
330 | 1184 |
|
1185 |
ec_datagram_init(&datagram); |
|
1186 |
||
688 | 1187 |
if (ec_datagram_brd(&datagram, 0x0130, 2)) { |
330 | 1188 |
EC_ERR("Failed to allocate datagram for bus time measuring.\n"); |
1189 |
ec_datagram_clear(&datagram); |
|
377
ecac8252f114
Changes in ecrt_request_master(); minor output changes.
Florian Pose <fp@igh-essen.com>
parents:
361
diff
changeset
|
1190 |
return -1; |
330 | 1191 |
} |
1192 |
||
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1193 |
ecrt_master_receive(master); |
330 | 1194 |
|
1195 |
sum = 0; |
|
1196 |
min = 0xFFFFFFFF; |
|
1197 |
max = 0; |
|
1198 |
||
1199 |
for (i = 0; i < 100; i++) { |
|
1200 |
ec_master_queue_datagram(master, &datagram); |
|
1201 |
ecrt_master_send(master); |
|
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1202 |
|
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1203 |
while (1) { |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1204 |
ecrt_master_receive(master); |
330 | 1205 |
|
1206 |
if (datagram.state == EC_DATAGRAM_RECEIVED) { |
|
1207 |
break; |
|
1208 |
} |
|
1209 |
else if (datagram.state == EC_DATAGRAM_ERROR) { |
|
1210 |
EC_WARN("Failed to measure bus time.\n"); |
|
1211 |
goto error; |
|
1212 |
} |
|
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1213 |
else if (datagram.state == EC_DATAGRAM_TIMED_OUT) { |
330 | 1214 |
EC_WARN("Timeout while measuring bus time.\n"); |
1215 |
goto error; |
|
1216 |
} |
|
1217 |
} |
|
1218 |
||
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1219 |
cur = (unsigned int) (datagram.cycles_received |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1220 |
- datagram.cycles_sent) * 1000 / cpu_khz; |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1221 |
sum += cur; |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1222 |
if (cur > max) max = cur; |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1223 |
if (cur < min) min = cur; |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1224 |
} |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1225 |
|
459
f0da52cf6b5b
Print certain logs only at debug_level.
Florian Pose <fp@igh-essen.com>
parents:
456
diff
changeset
|
1226 |
EC_DBG("Bus time is (min/avg/max) %u / %u.%u / %u us.\n", |
f0da52cf6b5b
Print certain logs only at debug_level.
Florian Pose <fp@igh-essen.com>
parents:
456
diff
changeset
|
1227 |
min, sum / 100, sum % 100, max); |
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1228 |
ec_datagram_clear(&datagram); |
377
ecac8252f114
Changes in ecrt_request_master(); minor output changes.
Florian Pose <fp@igh-essen.com>
parents:
361
diff
changeset
|
1229 |
return 0; |
330 | 1230 |
|
1231 |
error: |
|
1232 |
ec_datagram_clear(&datagram); |
|
377
ecac8252f114
Changes in ecrt_request_master(); minor output changes.
Florian Pose <fp@igh-essen.com>
parents:
361
diff
changeset
|
1233 |
return -1; |
330 | 1234 |
} |
1235 |
||
495
88c597598bbc
Interface changes for version 1.2, see NEWS file.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
1236 |
/*****************************************************************************/ |
88c597598bbc
Interface changes for version 1.2, see NEWS file.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
1237 |
|
88c597598bbc
Interface changes for version 1.2, see NEWS file.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
1238 |
/** |
88c597598bbc
Interface changes for version 1.2, see NEWS file.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
1239 |
Prepares synchronous IO. |
88c597598bbc
Interface changes for version 1.2, see NEWS file.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
1240 |
Queues all domain datagrams and sends them. Then waits a certain time, so |
88c597598bbc
Interface changes for version 1.2, see NEWS file.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
1241 |
that ecrt_master_receive() can be called securely. |
88c597598bbc
Interface changes for version 1.2, see NEWS file.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
1242 |
*/ |
88c597598bbc
Interface changes for version 1.2, see NEWS file.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
1243 |
|
88c597598bbc
Interface changes for version 1.2, see NEWS file.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
1244 |
void ec_master_prepare(ec_master_t *master /**< EtherCAT master */) |
88c597598bbc
Interface changes for version 1.2, see NEWS file.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
1245 |
{ |
88c597598bbc
Interface changes for version 1.2, see NEWS file.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
1246 |
ec_domain_t *domain; |
88c597598bbc
Interface changes for version 1.2, see NEWS file.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
1247 |
cycles_t cycles_start, cycles_end, cycles_timeout; |
88c597598bbc
Interface changes for version 1.2, see NEWS file.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
1248 |
|
88c597598bbc
Interface changes for version 1.2, see NEWS file.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
1249 |
// queue datagrams of all domains |
88c597598bbc
Interface changes for version 1.2, see NEWS file.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
1250 |
list_for_each_entry(domain, &master->domains, list) |
88c597598bbc
Interface changes for version 1.2, see NEWS file.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
1251 |
ecrt_domain_queue(domain); |
88c597598bbc
Interface changes for version 1.2, see NEWS file.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
1252 |
|
88c597598bbc
Interface changes for version 1.2, see NEWS file.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
1253 |
ecrt_master_send(master); |
88c597598bbc
Interface changes for version 1.2, see NEWS file.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
1254 |
|
88c597598bbc
Interface changes for version 1.2, see NEWS file.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
1255 |
cycles_start = get_cycles(); |
88c597598bbc
Interface changes for version 1.2, see NEWS file.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
1256 |
cycles_timeout = (cycles_t) EC_IO_TIMEOUT /* us */ * (cpu_khz / 1000); |
88c597598bbc
Interface changes for version 1.2, see NEWS file.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
1257 |
|
88c597598bbc
Interface changes for version 1.2, see NEWS file.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
1258 |
// active waiting |
88c597598bbc
Interface changes for version 1.2, see NEWS file.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
1259 |
while (1) { |
88c597598bbc
Interface changes for version 1.2, see NEWS file.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
1260 |
udelay(100); |
88c597598bbc
Interface changes for version 1.2, see NEWS file.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
1261 |
cycles_end = get_cycles(); |
88c597598bbc
Interface changes for version 1.2, see NEWS file.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
1262 |
if (cycles_end - cycles_start >= cycles_timeout) break; |
88c597598bbc
Interface changes for version 1.2, see NEWS file.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
1263 |
} |
88c597598bbc
Interface changes for version 1.2, see NEWS file.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
1264 |
} |
88c597598bbc
Interface changes for version 1.2, see NEWS file.
Florian Pose <fp@igh-essen.com>
parents:
493
diff
changeset
|
1265 |
|
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
|
1266 |
/*****************************************************************************/ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1267 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1268 |
/** |
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 |
* Translates an ASCII coded bus-address to a slave pointer. |
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 |
* These are the valid addressing schemes: |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1271 |
* - \a "X" = the Xth slave on the bus (ring position), |
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
|
1272 |
* - \a "#X" = the slave with alias X, |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1273 |
* - \a "#X:Y" = the Yth slave after the slave with alias X. |
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
|
1274 |
* X and Y are zero-based indices and may be provided in hexadecimal or octal |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1275 |
* notation (with appropriate prefix). |
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
|
1276 |
* \return pointer to the slave on success, else 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
|
1277 |
*/ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1278 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1279 |
ec_slave_t *ec_master_parse_slave_address( |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1280 |
const ec_master_t *master, /**< EtherCAT 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
|
1281 |
const char *address /**< address string */ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1282 |
) |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1283 |
{ |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1284 |
unsigned long first, second; |
502
5f4a2fd3b180
Fixed warnings in master.c.
Florian Pose <fp@igh-essen.com>
parents:
500
diff
changeset
|
1285 |
char *remainder, *remainder2; |
5f4a2fd3b180
Fixed warnings in master.c.
Florian Pose <fp@igh-essen.com>
parents:
500
diff
changeset
|
1286 |
const char *original; |
643
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1287 |
unsigned int alias_requested = 0, alias_not_found = 1; |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1288 |
ec_slave_t *alias_slave = NULL, *slave; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1289 |
|
500
f9e6d119463f
Corrected error messages in get_slave().
Florian Pose <fp@igh-essen.com>
parents:
496
diff
changeset
|
1290 |
original = address; |
f9e6d119463f
Corrected error messages in get_slave().
Florian Pose <fp@igh-essen.com>
parents:
496
diff
changeset
|
1291 |
|
643
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1292 |
if (!address[0]) |
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1293 |
goto out_invalid; |
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1294 |
|
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1295 |
if (address[0] == '#') { |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1296 |
alias_requested = 1; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1297 |
address++; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1298 |
} |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1299 |
|
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1300 |
first = simple_strtoul(address, &remainder, 0); |
643
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1301 |
if (remainder == address) |
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1302 |
goto out_invalid; |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1303 |
|
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1304 |
if (alias_requested) { |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1305 |
list_for_each_entry(alias_slave, &master->slaves, list) { |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1306 |
if (alias_slave->sii_alias == first) { |
643
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1307 |
alias_not_found = 0; |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1308 |
break; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1309 |
} |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1310 |
} |
643
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1311 |
if (alias_not_found) { |
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1312 |
EC_ERR("Alias not found!\n"); |
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1313 |
goto out_invalid; |
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1314 |
} |
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1315 |
} |
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1316 |
|
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1317 |
if (!remainder[0]) { |
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1318 |
if (alias_requested) { // alias addressing |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1319 |
return alias_slave; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1320 |
} |
643
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1321 |
else { // position addressing |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1322 |
list_for_each_entry(slave, &master->slaves, list) { |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1323 |
if (slave->ring_position == first) return slave; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1324 |
} |
643
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1325 |
EC_ERR("Slave index out of range!\n"); |
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1326 |
goto out_invalid; |
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1327 |
} |
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1328 |
} |
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1329 |
else if (alias_requested && remainder[0] == ':') { // field addressing |
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1330 |
struct list_head *list; |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1331 |
remainder++; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1332 |
second = simple_strtoul(remainder, &remainder2, 0); |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1333 |
|
643
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1334 |
if (remainder2 == remainder || remainder2[0]) |
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1335 |
goto out_invalid; |
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1336 |
|
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1337 |
list = &alias_slave->list; |
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1338 |
while (second--) { |
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1339 |
list = list->next; |
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1340 |
if (list == &master->slaves) { // last slave exceeded |
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1341 |
EC_ERR("Slave index out of range!\n"); |
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1342 |
goto out_invalid; |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1343 |
} |
643
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1344 |
} |
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1345 |
return list_entry(list, ec_slave_t, list); |
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1346 |
} |
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1347 |
|
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1348 |
out_invalid: |
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
640
diff
changeset
|
1349 |
EC_ERR("Invalid slave address string \"%s\"!\n", original); |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1350 |
return NULL; |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1351 |
} |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1352 |
|
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
|
1353 |
/****************************************************************************** |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1354 |
* 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
|
1355 |
*****************************************************************************/ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1356 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1357 |
/** |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1358 |
Creates a 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
|
1359 |
\return pointer to new domain on success, else 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
|
1360 |
\ingroup RealtimeInterface |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1361 |
*/ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1362 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1363 |
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
|
1364 |
{ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1365 |
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
|
1366 |
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
|
1367 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1368 |
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
|
1369 |
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
|
1370 |
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
|
1371 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1372 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1373 |
if (list_empty(&master->domains)) index = 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
|
1374 |
else { |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1375 |
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
|
1376 |
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
|
1377 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1378 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1379 |
if (ec_domain_init(domain, master, 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
|
1380 |
EC_ERR("Failed to init domain.\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
|
1381 |
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
|
1382 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1383 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1384 |
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
|
1385 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1386 |
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
|
1387 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1388 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1389 |
/*****************************************************************************/ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1390 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1391 |
/** |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1392 |
Configures all slaves and leads them to the OP 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
|
1393 |
Does the complete configuration and activation for all slaves. Sets sync |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1394 |
managers and FMMUs, and does the appropriate transitions, until the slave |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1395 |
is operational. |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1396 |
\return 0 in case of success, else < 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
|
1397 |
\ingroup RealtimeInterface |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1398 |
*/ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1399 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1400 |
int ecrt_master_activate(ec_master_t *master /**< EtherCAT 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
|
1401 |
{ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1402 |
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
|
1403 |
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
|
1404 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1405 |
// allocate all 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
|
1406 |
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
|
1407 |
list_for_each_entry(domain, &master->domains, 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
|
1408 |
if (ec_domain_alloc(domain, 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
|
1409 |
EC_ERR("Failed to allocate domain %X!\n", (u32) 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
|
1410 |
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
|
1411 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1412 |
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
|
1413 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1414 |
|
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1415 |
// request slave configuration |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1416 |
down(&master->config_sem); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1417 |
master->allow_config = 1; // request the current configuration |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1418 |
master->config_state = EC_REQUEST_IN_PROGRESS; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1419 |
up(&master->config_sem); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1420 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1421 |
// wait for configuration to complete |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1422 |
if (wait_event_interruptible(master->config_queue, |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1423 |
master->config_state != EC_REQUEST_IN_PROGRESS)) { |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1424 |
EC_INFO("Waiting for configuration interrupted by signal.\n"); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1425 |
return -1; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1426 |
} |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1427 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1428 |
if (master->config_state != EC_REQUEST_COMPLETE) { |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1429 |
EC_ERR("Failed to configure slaves.\n"); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1430 |
return -1; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1431 |
} |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1432 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1433 |
// restart EoE process and master thread with new locking |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1434 |
ec_master_eoe_stop(master); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1435 |
ec_master_thread_stop(master); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1436 |
|
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
|
1437 |
ec_master_prepare(master); // prepare asynchronous IO |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1438 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1439 |
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
|
1440 |
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
|
1441 |
|
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1442 |
master->injection_seq_fsm = 0; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1443 |
master->injection_seq_rt = 0; |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1444 |
master->request_cb = master->ext_request_cb; |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1445 |
master->release_cb = master->ext_release_cb; |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1446 |
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
|
1447 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
651
diff
changeset
|
1448 |
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
|
1449 |
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
|
1450 |
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
|
1451 |
} |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1452 |
ec_master_eoe_start(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
|
1453 |
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
|
1454 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1455 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1456 |
/*****************************************************************************/ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1457 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1458 |
/** |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1459 |
Asynchronous sending of 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
|
1460 |
\ingroup RealtimeInterface |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1461 |
*/ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1462 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1463 |
void ecrt_master_send(ec_master_t *master /**< EtherCAT 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
|
1464 |
{ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1465 |
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
|
1466 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1467 |
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
|
1468 |
// 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
|
1469 |
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
|
1470 |
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
|
1471 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1472 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1473 |
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
|
1474 |
// 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
|
1475 |
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
|
1476 |
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
|
1477 |
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
|
1478 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1479 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1480 |
// 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
|
1481 |
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
|
1482 |
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
|
1483 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1484 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1485 |
// 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
|
1486 |
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
|
1487 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1488 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1489 |
/*****************************************************************************/ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1490 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1491 |
/** |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1492 |
Asynchronous receiving of 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
|
1493 |
\ingroup RealtimeInterface |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1494 |
*/ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1495 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1496 |
void ecrt_master_receive(ec_master_t *master /**< EtherCAT 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
|
1497 |
{ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1498 |
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
|
1499 |
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
|
1500 |
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
|
1501 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1502 |
// 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
|
1503 |
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
|
1504 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1505 |
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
|
1506 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1507 |
// 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
|
1508 |
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
|
1509 |
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
|
1510 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1511 |
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
|
1512 |
> 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
|
1513 |
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
|
1514 |
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
|
1515 |
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
|
1516 |
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
|
1517 |
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
|
1518 |
|
bf991809dcf0
Added debugging output for unmatched frames and those that timed out.
Florian Pose <fp@igh-essen.com>
parents:
664
diff
changeset
|
1519 |
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
|
1520 |
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
|
1521 |
(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
|
1522 |
(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
|
1523 |
- 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
|
1524 |
} |
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
|
1525 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1526 |
} |
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
|
1527 |
|
18c48cb7de06
Introduced frames_timed_out flag to notice bus failure when link down is
Florian Pose <fp@igh-essen.com>
parents:
663
diff
changeset
|
1528 |
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
|
1529 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1530 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1531 |
/*****************************************************************************/ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1532 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1533 |
/** |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1534 |
* Obtains a slave pointer by its bus address. |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1535 |
* A valid slave pointer is only returned, if vendor ID and product code are |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1536 |
* matching. |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1537 |
* \return pointer to the slave on success, else 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
|
1538 |
* \ingroup RealtimeInterface |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1539 |
*/ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1540 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1541 |
ec_slave_t *ecrt_master_get_slave( |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1542 |
const ec_master_t *master, /**< EtherCAT 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
|
1543 |
const char *address, /**< address string |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1544 |
\see ec_master_parse_slave_address() */ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1545 |
uint32_t vendor_id, /**< vendor ID */ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1546 |
uint32_t product_code /**< product code */ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1547 |
) |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1548 |
{ |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1549 |
ec_slave_t *slave = ec_master_parse_slave_address(master, address); |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1550 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1551 |
if (!slave) |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1552 |
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
|
1553 |
|
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1554 |
return ec_slave_validate(slave, vendor_id, product_code) ? NULL : slave; |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1555 |
} |
16e9ad7d8e12
Added parameters for vendor ID and product code to ecrt_get_slave(); PDO
Florian Pose <fp@igh-essen.com>
parents:
639
diff
changeset
|
1556 |
|
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1557 |
/*****************************************************************************/ |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1558 |
|
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
1559 |
/** |
697
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1560 |
* Obtains a slave pointer by its ring position. |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1561 |
* A valid slave pointer is only returned, if vendor ID and product code are |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1562 |
* matching. |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1563 |
* \return pointer to the slave on success, else NULL |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1564 |
* \ingroup RealtimeInterface |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1565 |
*/ |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1566 |
|
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1567 |
ec_slave_t *ecrt_master_get_slave_by_pos( |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1568 |
const ec_master_t *master, /**< EtherCAT master */ |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1569 |
uint16_t ring_position, /**< ring position */ |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1570 |
uint32_t vendor_id, /**< vendor ID */ |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1571 |
uint32_t product_code /**< product code */ |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1572 |
) |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1573 |
{ |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1574 |
ec_slave_t *slave; |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1575 |
unsigned int found = 0; |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1576 |
|
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1577 |
list_for_each_entry(slave, &master->slaves, list) { |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1578 |
if (slave->ring_position == ring_position) { |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1579 |
found = 1; |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1580 |
break; |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1581 |
} |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1582 |
} |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1583 |
|
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1584 |
if (!found) { |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1585 |
EC_ERR("Slave index out of range!\n"); |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1586 |
return NULL; |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1587 |
} |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1588 |
|
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1589 |
return ec_slave_validate(slave, vendor_id, product_code) ? NULL : slave; |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1590 |
} |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1591 |
|
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1592 |
/*****************************************************************************/ |
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1593 |
|
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1594 |
/** |
204
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1595 |
Sets the locking callbacks. |
226
07247920a7ba
EoE with workqueue; bugfix in ec_master_init()
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
1596 |
The request_cb function must return zero, to allow another instance |
07247920a7ba
EoE with workqueue; bugfix in ec_master_init()
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
1597 |
(the EoE process for example) to access the master. Non-zero means, |
07247920a7ba
EoE with workqueue; bugfix in ec_master_init()
Florian Pose <fp@igh-essen.com>
parents:
214
diff
changeset
|
1598 |
that access is forbidden at this time. |
204
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1599 |
\ingroup RealtimeInterface |
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1600 |
*/ |
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1601 |
|
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1602 |
void ecrt_master_callbacks(ec_master_t *master, /**< EtherCAT master */ |
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1603 |
int (*request_cb)(void *), /**< request lock CB */ |
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1604 |
void (*release_cb)(void *), /**< release lock CB */ |
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1605 |
void *cb_data /**< data parameter */ |
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1606 |
) |
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1607 |
{ |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1608 |
master->ext_request_cb = request_cb; |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1609 |
master->ext_release_cb = release_cb; |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
659
diff
changeset
|
1610 |
master->ext_cb_data = cb_data; |
204
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1611 |
} |
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1612 |
|
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1613 |
/*****************************************************************************/ |
5ab50514d9b2
Locking callback interface.
Florian Pose <fp@igh-essen.com>
parents:
203
diff
changeset
|
1614 |
|
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
1615 |
/** |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
1616 |
* Reads the current master status. |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
1617 |
*/ |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
1618 |
|
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
1619 |
void ecrt_master_get_status(const ec_master_t *master, /**< EtherCAT master */ |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
1620 |
ec_master_status_t *status /**< target status object */ |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
1621 |
) |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
1622 |
{ |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
1623 |
status->bus_status = |
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
|
1624 |
(master->pdo_slaves_offline || master->frames_timed_out) |
18c48cb7de06
Introduced frames_timed_out flag to notice bus failure when link down is
Florian Pose <fp@igh-essen.com>
parents:
663
diff
changeset
|
1625 |
? EC_BUS_FAILURE : EC_BUS_OK; |
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
1626 |
status->bus_tainted = master->fsm.tainted; |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
1627 |
status->slaves_responding = master->fsm.slaves_responding; |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
1628 |
} |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
1629 |
|
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
1630 |
/*****************************************************************************/ |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
1631 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1632 |
/** \cond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1633 |
|
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1634 |
EXPORT_SYMBOL(ecrt_master_create_domain); |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
1635 |
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
|
1636 |
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
|
1637 |
EXPORT_SYMBOL(ecrt_master_receive); |
206
60a10d85c20b
Prepared EoE processing with workqueue.
Florian Pose <fp@igh-essen.com>
parents:
204
diff
changeset
|
1638 |
EXPORT_SYMBOL(ecrt_master_callbacks); |
138
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
136
diff
changeset
|
1639 |
EXPORT_SYMBOL(ecrt_master_get_slave); |
697
6f658c2082fd
Added ecrt_master_get_slave_by_pos().
Florian Pose <fp@igh-essen.com>
parents:
692
diff
changeset
|
1640 |
EXPORT_SYMBOL(ecrt_master_get_slave_by_pos); |
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
1641 |
EXPORT_SYMBOL(ecrt_master_get_status); |
42
a22a202d0f42
Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents:
39
diff
changeset
|
1642 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1643 |
/** \endcond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1644 |
|
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1645 |
/*****************************************************************************/ |