author | Florian Pose <fp@igh-essen.com> |
Wed, 30 Jan 2008 13:44:00 +0000 | |
changeset 774 | 40e9190072a6 |
parent 772 | 6c29e74d6763 |
child 784 | 0a0994fdafb8 |
permissions | -rw-r--r-- |
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
26
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:
26
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:
238
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:
238
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:
238
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:
238
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:
238
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:
238
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:
238
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:
238
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:
238
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:
238
diff
changeset
|
30 |
* Technology, IP and trade marks. |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
31 |
* |
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
26
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 slave 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> |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
42 |
#include <linux/delay.h> |
0 | 43 |
|
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
44 |
#include "globals.h" |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
45 |
#include "slave.h" |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
46 |
#include "datagram.h" |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
91
diff
changeset
|
47 |
#include "master.h" |
0 | 48 |
|
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
26
diff
changeset
|
49 |
/*****************************************************************************/ |
0 | 50 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
51 |
extern const ec_code_msg_t al_status_messages[]; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
52 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
53 |
/*****************************************************************************/ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
54 |
|
404
7f7f429e13c7
Removed clear functions from headers of kobject-classes.
Florian Pose <fp@igh-essen.com>
parents:
403
diff
changeset
|
55 |
void ec_slave_clear(struct kobject *); |
482
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
56 |
void ec_slave_sdos_clear(struct kobject *); |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
57 |
ssize_t ec_show_slave_attribute(struct kobject *, struct attribute *, char *); |
256
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
58 |
ssize_t ec_store_slave_attribute(struct kobject *, struct attribute *, |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
59 |
const char *, size_t); |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
60 |
char *ec_slave_sii_string(ec_slave_t *, unsigned int); |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
61 |
|
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
62 |
/*****************************************************************************/ |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
63 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
64 |
/** \cond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
65 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
66 |
EC_SYSFS_READ_ATTR(info); |
256
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
67 |
EC_SYSFS_READ_WRITE_ATTR(state); |
269 | 68 |
EC_SYSFS_READ_WRITE_ATTR(eeprom); |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
69 |
EC_SYSFS_READ_WRITE_ATTR(alias); |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
70 |
|
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
71 |
static struct attribute *def_attrs[] = { |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
72 |
&attr_info, |
256
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
73 |
&attr_state, |
266
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
74 |
&attr_eeprom, |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
75 |
&attr_alias, |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
76 |
NULL, |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
77 |
}; |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
78 |
|
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
79 |
static struct sysfs_ops sysfs_ops = { |
256
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
80 |
.show = ec_show_slave_attribute, |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
81 |
.store = ec_store_slave_attribute |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
82 |
}; |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
83 |
|
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
84 |
static struct kobj_type ktype_ec_slave = { |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
85 |
.release = ec_slave_clear, |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
86 |
.sysfs_ops = &sysfs_ops, |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
87 |
.default_attrs = def_attrs |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
88 |
}; |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
89 |
|
482
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
90 |
static struct kobj_type ktype_ec_slave_sdos = { |
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
91 |
.release = ec_slave_sdos_clear |
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
92 |
}; |
419
cf724fc82a00
Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents:
418
diff
changeset
|
93 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
94 |
/** \endcond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
95 |
|
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
96 |
/*****************************************************************************/ |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
97 |
|
0 | 98 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
99 |
Slave constructor. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
100 |
\return 0 in case of success, else < 0 |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
101 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
102 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
103 |
int ec_slave_init(ec_slave_t *slave, /**< EtherCAT slave */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
104 |
ec_master_t *master, /**< EtherCAT master */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
105 |
uint16_t ring_position, /**< ring position */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
106 |
uint16_t station_address /**< station address to configure */ |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
107 |
) |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
108 |
{ |
142 | 109 |
unsigned int i; |
110 |
||
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
111 |
slave->ring_position = ring_position; |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
112 |
slave->station_address = station_address; |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
113 |
|
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
114 |
slave->master = master; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
115 |
|
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
649
diff
changeset
|
116 |
slave->requested_state = EC_SLAVE_STATE_PREOP; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
117 |
slave->current_state = EC_SLAVE_STATE_UNKNOWN; |
523
584a4f60b067
Re-added slave.configured flag as slave.self_configured.
Florian Pose <fp@igh-essen.com>
parents:
520
diff
changeset
|
118 |
slave->self_configured = 0; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
119 |
slave->error_flag = 0; |
610
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
120 |
slave->online_state = EC_SLAVE_ONLINE; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
121 |
slave->fmmu_count = 0; |
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
122 |
slave->pdos_registered = 0; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
123 |
|
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
124 |
slave->base_type = 0; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
125 |
slave->base_revision = 0; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
126 |
slave->base_build = 0; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
127 |
slave->base_fmmu_count = 0; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
128 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
129 |
slave->eeprom_data = NULL; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
130 |
slave->eeprom_size = 0; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
131 |
|
114 | 132 |
slave->sii_alias = 0; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
133 |
slave->sii_vendor_id = 0; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
134 |
slave->sii_product_code = 0; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
135 |
slave->sii_revision_number = 0; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
136 |
slave->sii_serial_number = 0; |
136
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
137 |
slave->sii_rx_mailbox_offset = 0; |
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
138 |
slave->sii_rx_mailbox_size = 0; |
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
139 |
slave->sii_tx_mailbox_offset = 0; |
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
140 |
slave->sii_tx_mailbox_size = 0; |
133
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
132
diff
changeset
|
141 |
slave->sii_mailbox_protocols = 0; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
142 |
slave->sii_group = NULL; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
143 |
slave->sii_image = NULL; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
144 |
slave->sii_order = NULL; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
145 |
slave->sii_name = NULL; |
499
fb005e975181
Current consumption in sysfs; "lsec -c" shows current consumption and remaining current.
Florian Pose <fp@igh-essen.com>
parents:
484
diff
changeset
|
146 |
slave->sii_current_on_ebus = 0; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
147 |
|
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
148 |
slave->sii_strings = NULL; |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
149 |
slave->sii_string_count = 0; |
618
e4b89c862c43
SII sync managers as array instead of list, removed sync manager
Florian Pose <fp@igh-essen.com>
parents:
613
diff
changeset
|
150 |
slave->sii_syncs = NULL; |
e4b89c862c43
SII sync managers as array instead of list, removed sync manager
Florian Pose <fp@igh-essen.com>
parents:
613
diff
changeset
|
151 |
slave->sii_sync_count = 0; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
152 |
INIT_LIST_HEAD(&slave->sii_pdos); |
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
133
diff
changeset
|
153 |
INIT_LIST_HEAD(&slave->sdo_dictionary); |
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
154 |
INIT_LIST_HEAD(&slave->sdo_confs); |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
155 |
|
419
cf724fc82a00
Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents:
418
diff
changeset
|
156 |
slave->sdo_dictionary_fetched = 0; |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
740
diff
changeset
|
157 |
slave->pdo_mapping_fetched = 0; |
419
cf724fc82a00
Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents:
418
diff
changeset
|
158 |
slave->jiffies_preop = 0; |
cf724fc82a00
Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents:
418
diff
changeset
|
159 |
|
183
8ae1e011e96c
More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents:
182
diff
changeset
|
160 |
for (i = 0; i < 4; i++) { |
8ae1e011e96c
More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents:
182
diff
changeset
|
161 |
slave->dl_link[i] = 0; |
8ae1e011e96c
More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents:
182
diff
changeset
|
162 |
slave->dl_loop[i] = 0; |
8ae1e011e96c
More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents:
182
diff
changeset
|
163 |
slave->dl_signal[i] = 0; |
190
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
164 |
slave->sii_physical_layer[i] = 0xFF; |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
165 |
} |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
166 |
|
484
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
167 |
// init kobject and add it to the hierarchy |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
168 |
memset(&slave->kobj, 0x00, sizeof(struct kobject)); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
169 |
kobject_init(&slave->kobj); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
170 |
slave->kobj.ktype = &ktype_ec_slave; |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
171 |
slave->kobj.parent = &master->kobj; |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
172 |
if (kobject_set_name(&slave->kobj, "slave%03i", slave->ring_position)) { |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
173 |
EC_ERR("Failed to set kobject name.\n"); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
174 |
goto out_slave_put; |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
175 |
} |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
176 |
if (kobject_add(&slave->kobj)) { |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
177 |
EC_ERR("Failed to add slave's kobject.\n"); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
178 |
goto out_slave_put; |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
179 |
} |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
180 |
|
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
181 |
// init SDO kobject and add it to the hierarchy |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
182 |
memset(&slave->sdo_kobj, 0x00, sizeof(struct kobject)); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
183 |
kobject_init(&slave->sdo_kobj); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
184 |
slave->sdo_kobj.ktype = &ktype_ec_slave_sdos; |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
185 |
slave->sdo_kobj.parent = &slave->kobj; |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
186 |
if (kobject_set_name(&slave->sdo_kobj, "sdos")) { |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
187 |
EC_ERR("Failed to set kobject name.\n"); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
188 |
goto out_sdo_put; |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
189 |
} |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
190 |
if (kobject_add(&slave->sdo_kobj)) { |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
191 |
EC_ERR("Failed to add SDOs kobject.\n"); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
192 |
goto out_sdo_put; |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
193 |
} |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
194 |
|
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
195 |
return 0; |
484
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
196 |
|
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
197 |
out_sdo_put: |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
198 |
kobject_put(&slave->sdo_kobj); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
199 |
kobject_del(&slave->kobj); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
200 |
out_slave_put: |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
201 |
kobject_put(&slave->kobj); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
202 |
return -1; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
203 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
204 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
205 |
/*****************************************************************************/ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
206 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
207 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
208 |
Slave destructor. |
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
|
209 |
Clears and frees a slave object. |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
210 |
*/ |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
211 |
|
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
212 |
void ec_slave_destroy(ec_slave_t *slave /**< EtherCAT slave */) |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
213 |
{ |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
214 |
ec_sdo_t *sdo, *next_sdo; |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
215 |
|
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
216 |
// free all SDOs |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
217 |
list_for_each_entry_safe(sdo, next_sdo, &slave->sdo_dictionary, 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
|
218 |
list_del(&sdo->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
|
219 |
ec_sdo_destroy(sdo); |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
220 |
} |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
221 |
|
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 |
// free SDO kobject |
484
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
223 |
kobject_del(&slave->sdo_kobj); |
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
|
224 |
kobject_put(&slave->sdo_kobj); |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
225 |
|
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
226 |
// destroy self |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
227 |
kobject_del(&slave->kobj); |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
228 |
kobject_put(&slave->kobj); |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
229 |
} |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
230 |
|
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
231 |
/*****************************************************************************/ |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
232 |
|
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
233 |
/** |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
234 |
Clear and free slave. |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
235 |
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
|
236 |
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:
190
diff
changeset
|
237 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
238 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
239 |
void ec_slave_clear(struct kobject *kobj /**< kobject of the slave */) |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
240 |
{ |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
241 |
ec_slave_t *slave; |
625
ec69acbbd156
Renamed ec_sii_pdo_t and ec_sii_pdo_entry_t to ec_pdo_t and
Florian Pose <fp@igh-essen.com>
parents:
624
diff
changeset
|
242 |
ec_pdo_t *pdo, *next_pdo; |
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
243 |
ec_sdo_data_t *sdodata, *next_sdodata; |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
244 |
unsigned int i; |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
245 |
|
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
246 |
slave = container_of(kobj, ec_slave_t, kobj); |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
247 |
|
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
248 |
// free all strings |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
249 |
if (slave->sii_strings) { |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
250 |
for (i = 0; i < slave->sii_string_count; i++) |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
251 |
kfree(slave->sii_strings[i]); |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
252 |
kfree(slave->sii_strings); |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
253 |
} |
121
1cd6f7a47b72
Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents:
119
diff
changeset
|
254 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
255 |
// free all sync managers |
628
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
256 |
if (slave->sii_syncs) { |
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
257 |
for (i = 0; i < slave->sii_sync_count; i++) { |
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
258 |
ec_sync_clear(&slave->sii_syncs[i]); |
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
259 |
} |
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
260 |
kfree(slave->sii_syncs); |
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
261 |
} |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
262 |
|
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
263 |
// free all SII PDOs |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
264 |
list_for_each_entry_safe(pdo, next_pdo, &slave->sii_pdos, list) { |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
265 |
list_del(&pdo->list); |
627
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
626
diff
changeset
|
266 |
ec_pdo_clear(pdo); |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
267 |
kfree(pdo); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
268 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
269 |
|
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
270 |
// free all SDO configurations |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
271 |
list_for_each_entry_safe(sdodata, next_sdodata, &slave->sdo_confs, list) { |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
272 |
list_del(&sdodata->list); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
273 |
kfree(sdodata->data); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
274 |
kfree(sdodata); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
275 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
276 |
|
266
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
277 |
if (slave->eeprom_data) kfree(slave->eeprom_data); |
418
7a43437bc48b
Fixed memory leak in master and slave destructors.
Florian Pose <fp@igh-essen.com>
parents:
416
diff
changeset
|
278 |
|
7a43437bc48b
Fixed memory leak in master and slave destructors.
Florian Pose <fp@igh-essen.com>
parents:
416
diff
changeset
|
279 |
kfree(slave); |
121
1cd6f7a47b72
Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents:
119
diff
changeset
|
280 |
} |
1cd6f7a47b72
Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents:
119
diff
changeset
|
281 |
|
1cd6f7a47b72
Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents:
119
diff
changeset
|
282 |
/*****************************************************************************/ |
1cd6f7a47b72
Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents:
119
diff
changeset
|
283 |
|
1cd6f7a47b72
Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents:
119
diff
changeset
|
284 |
/** |
758
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
285 |
* SDO kobject clear method. |
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
286 |
*/ |
482
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
287 |
|
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
288 |
void ec_slave_sdos_clear(struct kobject *kobj /**< kobject for SDOs */) |
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
289 |
{ |
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
290 |
} |
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
291 |
|
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
292 |
/*****************************************************************************/ |
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
293 |
|
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
294 |
/** |
446 | 295 |
Reset slave from operation mode. |
296 |
*/ |
|
297 |
||
298 |
void ec_slave_reset(ec_slave_t *slave /**< EtherCAT slave */) |
|
299 |
{ |
|
465
3779b60a7c9b
BUGFIX: Remove SDO configurations when leaving OPERATION mode.
Florian Pose <fp@igh-essen.com>
parents:
464
diff
changeset
|
300 |
ec_sdo_data_t *sdodata, *next_sdodata; |
618
e4b89c862c43
SII sync managers as array instead of list, removed sync manager
Florian Pose <fp@igh-essen.com>
parents:
613
diff
changeset
|
301 |
unsigned int i; |
465
3779b60a7c9b
BUGFIX: Remove SDO configurations when leaving OPERATION mode.
Florian Pose <fp@igh-essen.com>
parents:
464
diff
changeset
|
302 |
|
446 | 303 |
slave->fmmu_count = 0; |
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
304 |
slave->pdos_registered = 0; |
465
3779b60a7c9b
BUGFIX: Remove SDO configurations when leaving OPERATION mode.
Florian Pose <fp@igh-essen.com>
parents:
464
diff
changeset
|
305 |
|
3779b60a7c9b
BUGFIX: Remove SDO configurations when leaving OPERATION mode.
Florian Pose <fp@igh-essen.com>
parents:
464
diff
changeset
|
306 |
// free all SDO configurations |
3779b60a7c9b
BUGFIX: Remove SDO configurations when leaving OPERATION mode.
Florian Pose <fp@igh-essen.com>
parents:
464
diff
changeset
|
307 |
list_for_each_entry_safe(sdodata, next_sdodata, &slave->sdo_confs, list) { |
3779b60a7c9b
BUGFIX: Remove SDO configurations when leaving OPERATION mode.
Florian Pose <fp@igh-essen.com>
parents:
464
diff
changeset
|
308 |
list_del(&sdodata->list); |
3779b60a7c9b
BUGFIX: Remove SDO configurations when leaving OPERATION mode.
Florian Pose <fp@igh-essen.com>
parents:
464
diff
changeset
|
309 |
kfree(sdodata->data); |
3779b60a7c9b
BUGFIX: Remove SDO configurations when leaving OPERATION mode.
Florian Pose <fp@igh-essen.com>
parents:
464
diff
changeset
|
310 |
kfree(sdodata); |
3779b60a7c9b
BUGFIX: Remove SDO configurations when leaving OPERATION mode.
Florian Pose <fp@igh-essen.com>
parents:
464
diff
changeset
|
311 |
} |
467
2274de57ca84
Remove estimated sync manager sizes when leaving operation mode.
Florian Pose <fp@igh-essen.com>
parents:
465
diff
changeset
|
312 |
|
2274de57ca84
Remove estimated sync manager sizes when leaving operation mode.
Florian Pose <fp@igh-essen.com>
parents:
465
diff
changeset
|
313 |
// remove estimated sync manager sizes |
618
e4b89c862c43
SII sync managers as array instead of list, removed sync manager
Florian Pose <fp@igh-essen.com>
parents:
613
diff
changeset
|
314 |
for (i = 0; i < slave->sii_sync_count; i++) { |
e4b89c862c43
SII sync managers as array instead of list, removed sync manager
Florian Pose <fp@igh-essen.com>
parents:
613
diff
changeset
|
315 |
slave->sii_syncs[i].est_length = 0; |
467
2274de57ca84
Remove estimated sync manager sizes when leaving operation mode.
Florian Pose <fp@igh-essen.com>
parents:
465
diff
changeset
|
316 |
} |
446 | 317 |
} |
318 |
||
319 |
/*****************************************************************************/ |
|
320 |
||
321 |
/** |
|
610
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
322 |
* Sets the application state of a slave. |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
323 |
*/ |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
324 |
|
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
325 |
void ec_slave_set_state(ec_slave_t *slave, /**< EtherCAT slave */ |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
326 |
ec_slave_state_t new_state /**< new application state */ |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
327 |
) |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
328 |
{ |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
329 |
if (new_state != slave->current_state) { |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
330 |
if (slave->master->debug_level) { |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
331 |
char old_state[EC_STATE_STRING_SIZE], |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
332 |
cur_state[EC_STATE_STRING_SIZE]; |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
333 |
ec_state_string(slave->current_state, old_state); |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
334 |
ec_state_string(new_state, cur_state); |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
335 |
EC_DBG("Slave %i: %s -> %s.\n", |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
336 |
slave->ring_position, old_state, cur_state); |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
337 |
} |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
338 |
slave->current_state = new_state; |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
339 |
} |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
340 |
} |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
341 |
|
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
342 |
/*****************************************************************************/ |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
343 |
|
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
344 |
/** |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
345 |
* Sets the online state of a slave. |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
346 |
*/ |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
347 |
|
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
348 |
void ec_slave_set_online_state(ec_slave_t *slave, /**< EtherCAT slave */ |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
349 |
ec_slave_online_state_t new_state /**< new online state */ |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
350 |
) |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
351 |
{ |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
352 |
if (new_state == EC_SLAVE_OFFLINE && |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
353 |
slave->online_state == EC_SLAVE_ONLINE) { |
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
354 |
if (slave->pdos_registered) |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
355 |
slave->master->pdo_slaves_offline++; |
610
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
356 |
if (slave->master->debug_level) |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
357 |
EC_DBG("Slave %i: offline.\n", slave->ring_position); |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
358 |
} |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
359 |
else if (new_state == EC_SLAVE_ONLINE && |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
360 |
slave->online_state == EC_SLAVE_OFFLINE) { |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
361 |
slave->error_flag = 0; // clear error flag |
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
362 |
if (slave->pdos_registered) |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
363 |
slave->master->pdo_slaves_offline--; |
610
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
364 |
if (slave->master->debug_level) { |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
365 |
char cur_state[EC_STATE_STRING_SIZE]; |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
366 |
ec_state_string(slave->current_state, cur_state); |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
367 |
EC_DBG("Slave %i: online (%s).\n", |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
368 |
slave->ring_position, cur_state); |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
369 |
} |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
370 |
} |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
371 |
|
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
372 |
slave->online_state = new_state; |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
373 |
} |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
374 |
|
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
375 |
/*****************************************************************************/ |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
376 |
|
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
377 |
/** |
758
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
378 |
* Request a slave state and resets the error flag. |
446 | 379 |
*/ |
380 |
||
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
381 |
void ec_slave_request_state(ec_slave_t *slave, /**< EtherCAT slave */ |
446 | 382 |
ec_slave_state_t state /**< new state */ |
383 |
) |
|
384 |
{ |
|
385 |
slave->requested_state = state; |
|
386 |
slave->error_flag = 0; |
|
387 |
} |
|
388 |
||
389 |
/*****************************************************************************/ |
|
390 |
||
391 |
/** |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
392 |
Fetches data from a STRING category. |
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
393 |
\todo range checking |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
394 |
\return 0 in case of success, else < 0 |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
395 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
396 |
|
620
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
397 |
int ec_slave_fetch_sii_strings( |
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
398 |
ec_slave_t *slave, /**< EtherCAT slave */ |
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
399 |
const uint8_t *data, /**< category data */ |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
400 |
size_t data_size /**< number of bytes */ |
620
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
401 |
) |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
402 |
{ |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
403 |
int i; |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
404 |
size_t size; |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
405 |
off_t offset; |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
406 |
|
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
407 |
slave->sii_string_count = data[0]; |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
408 |
|
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
409 |
if (!slave->sii_string_count) |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
410 |
return 0; |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
411 |
|
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
412 |
if (!(slave->sii_strings = |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
413 |
kmalloc(sizeof(char *) * slave->sii_string_count, |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
414 |
GFP_KERNEL))) { |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
415 |
EC_ERR("Failed to allocate string array memory.\n"); |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
416 |
goto out_zero; |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
417 |
} |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
418 |
|
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
419 |
offset = 1; |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
420 |
for (i = 0; i < slave->sii_string_count; i++) { |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
421 |
size = data[offset]; |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
422 |
// allocate memory for string structure and data at a single blow |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
423 |
if (!(slave->sii_strings[i] = |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
424 |
kmalloc(sizeof(char) * size + 1, GFP_KERNEL))) { |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
425 |
EC_ERR("Failed to allocate string memory.\n"); |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
426 |
goto out_free; |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
427 |
} |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
428 |
memcpy(slave->sii_strings[i], data + offset + 1, size); |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
429 |
slave->sii_strings[i][size] = 0x00; // append binary zero |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
430 |
offset += 1 + size; |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
431 |
} |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
432 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
433 |
return 0; |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
434 |
|
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
435 |
out_free: |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
436 |
for (i--; i >= 0; i--) kfree(slave->sii_strings[i]); |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
437 |
kfree(slave->sii_strings); |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
438 |
slave->sii_strings = NULL; |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
439 |
out_zero: |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
440 |
slave->sii_string_count = 0; |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
441 |
return -1; |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
442 |
} |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
443 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
444 |
/*****************************************************************************/ |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
445 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
446 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
447 |
Fetches data from a GENERAL category. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
448 |
\return 0 in case of success, else < 0 |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
449 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
450 |
|
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
451 |
int ec_slave_fetch_sii_general( |
620
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
452 |
ec_slave_t *slave, /**< EtherCAT slave */ |
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
453 |
const uint8_t *data, /**< category data */ |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
454 |
size_t data_size /**< size in bytes */ |
620
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
455 |
) |
123 | 456 |
{ |
190
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
457 |
unsigned int i; |
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
458 |
|
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
459 |
if (data_size != 32) { |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
460 |
EC_ERR("Wrong size of general category (%u/32) in slave %u.\n", |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
461 |
data_size, slave->ring_position); |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
462 |
return -1; |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
463 |
} |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
464 |
|
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
465 |
slave->sii_group = ec_slave_sii_string(slave, data[0]); |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
466 |
slave->sii_image = ec_slave_sii_string(slave, data[1]); |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
467 |
slave->sii_order = ec_slave_sii_string(slave, data[2]); |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
468 |
slave->sii_name = ec_slave_sii_string(slave, data[3]); |
123 | 469 |
|
190
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
470 |
for (i = 0; i < 4; i++) |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
471 |
slave->sii_physical_layer[i] = |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
472 |
(data[4] & (0x03 << (i * 2))) >> (i * 2); |
499
fb005e975181
Current consumption in sysfs; "lsec -c" shows current consumption and remaining current.
Florian Pose <fp@igh-essen.com>
parents:
484
diff
changeset
|
473 |
|
fb005e975181
Current consumption in sysfs; "lsec -c" shows current consumption and remaining current.
Florian Pose <fp@igh-essen.com>
parents:
484
diff
changeset
|
474 |
slave->sii_current_on_ebus = EC_READ_S16(data + 0x0C); |
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
475 |
|
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
476 |
return 0; |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
477 |
} |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
478 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
479 |
/*****************************************************************************/ |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
480 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
481 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
482 |
Fetches data from a SYNC MANAGER category. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
483 |
\return 0 in case of success, else < 0 |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
484 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
485 |
|
620
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
486 |
int ec_slave_fetch_sii_syncs( |
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
487 |
ec_slave_t *slave, /**< EtherCAT slave */ |
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
488 |
const uint8_t *data, /**< category data */ |
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
489 |
size_t data_size /**< number of bytes */ |
620
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
490 |
) |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
491 |
{ |
618
e4b89c862c43
SII sync managers as array instead of list, removed sync manager
Florian Pose <fp@igh-essen.com>
parents:
613
diff
changeset
|
492 |
unsigned int i; |
626
a5e838c30733
Renamed ec_sii_sync_t to ec_sync_t.
Florian Pose <fp@igh-essen.com>
parents:
625
diff
changeset
|
493 |
ec_sync_t *sync; |
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
494 |
size_t memsize; |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
495 |
|
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
496 |
// one sync manager struct is 4 words long |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
497 |
if (data_size % 8) { |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
498 |
EC_ERR("Invalid SII sync manager size %u in slave %u.\n", |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
499 |
data_size, slave->ring_position); |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
500 |
return -1; |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
501 |
} |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
502 |
|
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
503 |
slave->sii_sync_count = data_size / 8; |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
504 |
|
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
505 |
memsize = sizeof(ec_sync_t) * slave->sii_sync_count; |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
506 |
if (!(slave->sii_syncs = kmalloc(memsize, GFP_KERNEL))) { |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
507 |
EC_ERR("Failed to allocate %u bytes for sync managers.\n", |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
508 |
memsize); |
628
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
509 |
slave->sii_sync_count = 0; |
618
e4b89c862c43
SII sync managers as array instead of list, removed sync manager
Florian Pose <fp@igh-essen.com>
parents:
613
diff
changeset
|
510 |
return -1; |
e4b89c862c43
SII sync managers as array instead of list, removed sync manager
Florian Pose <fp@igh-essen.com>
parents:
613
diff
changeset
|
511 |
} |
e4b89c862c43
SII sync managers as array instead of list, removed sync manager
Florian Pose <fp@igh-essen.com>
parents:
613
diff
changeset
|
512 |
|
e4b89c862c43
SII sync managers as array instead of list, removed sync manager
Florian Pose <fp@igh-essen.com>
parents:
613
diff
changeset
|
513 |
for (i = 0; i < slave->sii_sync_count; i++, data += 8) { |
e4b89c862c43
SII sync managers as array instead of list, removed sync manager
Florian Pose <fp@igh-essen.com>
parents:
613
diff
changeset
|
514 |
sync = &slave->sii_syncs[i]; |
e4b89c862c43
SII sync managers as array instead of list, removed sync manager
Florian Pose <fp@igh-essen.com>
parents:
613
diff
changeset
|
515 |
|
628
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
516 |
ec_sync_init(sync, slave, i); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
517 |
sync->physical_start_address = EC_READ_U16(data); |
628
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
518 |
sync->length = EC_READ_U16(data + 2); |
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
519 |
sync->control_register = EC_READ_U8 (data + 4); |
e94a16bc52ce
Layed out sync manager structures and methods into own files.
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
520 |
sync->enable = EC_READ_U8 (data + 6); |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
521 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
522 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
523 |
return 0; |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
524 |
} |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
525 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
526 |
/*****************************************************************************/ |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
527 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
528 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
529 |
Fetches data from a [RT]XPDO category. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
530 |
\return 0 in case of success, else < 0 |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
531 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
532 |
|
620
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
533 |
int ec_slave_fetch_sii_pdos( |
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
534 |
ec_slave_t *slave, /**< EtherCAT slave */ |
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
535 |
const uint8_t *data, /**< category data */ |
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
536 |
size_t data_size, /**< number of bytes */ |
625
ec69acbbd156
Renamed ec_sii_pdo_t and ec_sii_pdo_entry_t to ec_pdo_t and
Florian Pose <fp@igh-essen.com>
parents:
624
diff
changeset
|
537 |
ec_pdo_type_t pdo_type /**< PDO type */ |
620
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
538 |
) |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
539 |
{ |
625
ec69acbbd156
Renamed ec_sii_pdo_t and ec_sii_pdo_entry_t to ec_pdo_t and
Florian Pose <fp@igh-essen.com>
parents:
624
diff
changeset
|
540 |
ec_pdo_t *pdo; |
ec69acbbd156
Renamed ec_sii_pdo_t and ec_sii_pdo_entry_t to ec_pdo_t and
Florian Pose <fp@igh-essen.com>
parents:
624
diff
changeset
|
541 |
ec_pdo_entry_t *entry; |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
542 |
unsigned int entry_count, i; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
543 |
|
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
544 |
while (data_size >= 8) { |
625
ec69acbbd156
Renamed ec_sii_pdo_t and ec_sii_pdo_entry_t to ec_pdo_t and
Florian Pose <fp@igh-essen.com>
parents:
624
diff
changeset
|
545 |
if (!(pdo = kmalloc(sizeof(ec_pdo_t), GFP_KERNEL))) { |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
546 |
EC_ERR("Failed to allocate PDO memory.\n"); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
547 |
return -1; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
548 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
549 |
|
627
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
626
diff
changeset
|
550 |
ec_pdo_init(pdo); |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
551 |
pdo->type = pdo_type; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
552 |
pdo->index = EC_READ_U16(data); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
553 |
entry_count = EC_READ_U8(data + 2); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
554 |
pdo->sync_index = EC_READ_U8(data + 3); |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
555 |
pdo->name = ec_slave_sii_string(slave, EC_READ_U8(data + 5)); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
556 |
list_add_tail(&pdo->list, &slave->sii_pdos); |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
557 |
|
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
558 |
data_size -= 8; |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
559 |
data += 8; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
560 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
561 |
for (i = 0; i < entry_count; i++) { |
625
ec69acbbd156
Renamed ec_sii_pdo_t and ec_sii_pdo_entry_t to ec_pdo_t and
Florian Pose <fp@igh-essen.com>
parents:
624
diff
changeset
|
562 |
if (!(entry = kmalloc(sizeof(ec_pdo_entry_t), GFP_KERNEL))) { |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
563 |
EC_ERR("Failed to allocate PDO entry memory.\n"); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
564 |
return -1; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
565 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
566 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
567 |
entry->index = EC_READ_U16(data); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
568 |
entry->subindex = EC_READ_U8(data + 2); |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
569 |
entry->name = ec_slave_sii_string(slave, EC_READ_U8(data + 3)); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
570 |
entry->bit_length = EC_READ_U8(data + 5); |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
571 |
list_add_tail(&entry->list, &pdo->entries); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
572 |
|
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
573 |
data_size -= 8; |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
574 |
data += 8; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
575 |
} |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
576 |
|
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
577 |
// if sync manager index is positive, the PDO is mapped by default |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
578 |
if (pdo->sync_index >= 0) { |
762
15214036c72a
Store PDO mapping source in sync manager.
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
579 |
ec_sync_t *sync; |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
580 |
ec_pdo_t *mapped_pdo; |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
581 |
|
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
582 |
if (pdo->sync_index >= slave->sii_sync_count) { |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
583 |
EC_ERR("Invalid SM index %i for PDO 0x%04X in slave %u.", |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
584 |
pdo->sync_index, pdo->index, slave->ring_position); |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
585 |
return -1; |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
586 |
} |
762
15214036c72a
Store PDO mapping source in sync manager.
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
587 |
sync = &slave->sii_syncs[pdo->sync_index]; |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
588 |
|
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
589 |
if (!(mapped_pdo = kmalloc(sizeof(ec_pdo_t), GFP_KERNEL))) { |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
590 |
EC_ERR("Failed to allocate PDO memory.\n"); |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
591 |
return -1; |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
592 |
} |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
593 |
|
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
594 |
if (ec_pdo_copy(mapped_pdo, pdo)) { |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
595 |
EC_ERR("Failed to copy PDO.\n"); |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
596 |
kfree(mapped_pdo); |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
597 |
return -1; |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
598 |
} |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
599 |
|
762
15214036c72a
Store PDO mapping source in sync manager.
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
600 |
list_add_tail(&mapped_pdo->list, &sync->pdos); |
15214036c72a
Store PDO mapping source in sync manager.
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
601 |
sync->mapping_source = EC_SYNC_MAPPING_SII; |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
602 |
} |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
603 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
604 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
605 |
return 0; |
114 | 606 |
} |
607 |
||
608 |
/*****************************************************************************/ |
|
609 |
||
610 |
/** |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
611 |
Searches the string list for an index and allocates a new string. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
612 |
\return 0 in case of success, else < 0 |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
613 |
\todo documentation |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
614 |
*/ |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
615 |
|
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
616 |
char *ec_slave_sii_string( |
620
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
617 |
ec_slave_t *slave, /**< EtherCAT slave */ |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
618 |
unsigned int index /**< string index */ |
620
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
619 |
) |
123 | 620 |
{ |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
621 |
if (!index--) |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
622 |
return NULL; |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
623 |
|
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
624 |
if (index >= slave->sii_string_count) { |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
625 |
if (slave->master->debug_level) |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
626 |
EC_WARN("String %i not found in slave %i.\n", |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
627 |
index, slave->ring_position); |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
628 |
return NULL; |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
629 |
} |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
630 |
|
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
631 |
return slave->sii_strings[index]; |
123 | 632 |
} |
633 |
||
634 |
/*****************************************************************************/ |
|
635 |
||
636 |
/** |
|
630
1b755b7342eb
Layed out FMMU structure and methods to own files.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
637 |
* Prepares an FMMU configuration. |
1b755b7342eb
Layed out FMMU structure and methods to own files.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
638 |
* Configuration data for the FMMU is saved in the slave structure and is |
1b755b7342eb
Layed out FMMU structure and methods to own files.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
639 |
* written to the slave in ecrt_master_activate(). |
1b755b7342eb
Layed out FMMU structure and methods to own files.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
640 |
* The FMMU configuration is done in a way, that the complete data range |
1b755b7342eb
Layed out FMMU structure and methods to own files.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
641 |
* of the corresponding sync manager is covered. Seperate FMMUs are configured |
1b755b7342eb
Layed out FMMU structure and methods to own files.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
642 |
* for each domain. |
1b755b7342eb
Layed out FMMU structure and methods to own files.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
643 |
* If the FMMU configuration is already prepared, the function returns with |
1b755b7342eb
Layed out FMMU structure and methods to own files.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
644 |
* success. |
1b755b7342eb
Layed out FMMU structure and methods to own files.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
645 |
* \return 0 in case of success, else < 0 |
1b755b7342eb
Layed out FMMU structure and methods to own files.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
646 |
*/ |
1b755b7342eb
Layed out FMMU structure and methods to own files.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
647 |
|
1b755b7342eb
Layed out FMMU structure and methods to own files.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
648 |
int ec_slave_prepare_fmmu( |
1b755b7342eb
Layed out FMMU structure and methods to own files.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
649 |
ec_slave_t *slave, /**< EtherCAT slave */ |
1b755b7342eb
Layed out FMMU structure and methods to own files.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
650 |
const ec_domain_t *domain, /**< domain */ |
1b755b7342eb
Layed out FMMU structure and methods to own files.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
651 |
const ec_sync_t *sync /**< sync manager */ |
1b755b7342eb
Layed out FMMU structure and methods to own files.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
652 |
) |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
653 |
{ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
654 |
unsigned int i; |
412 | 655 |
ec_fmmu_t *fmmu; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
656 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
657 |
// FMMU configuration already prepared? |
412 | 658 |
for (i = 0; i < slave->fmmu_count; i++) { |
659 |
fmmu = &slave->fmmus[i]; |
|
660 |
if (fmmu->domain == domain && fmmu->sync == sync) |
|
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
661 |
return 0; |
412 | 662 |
} |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
663 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
664 |
// reserve new FMMU... |
91
0120d6214948
Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents:
89
diff
changeset
|
665 |
|
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
666 |
if (slave->fmmu_count >= slave->base_fmmu_count) { |
84
b4ae98855cea
printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents:
77
diff
changeset
|
667 |
EC_ERR("Slave %i FMMU limit reached!\n", slave->ring_position); |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
668 |
return -1; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
669 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
670 |
|
412 | 671 |
fmmu = &slave->fmmus[slave->fmmu_count]; |
672 |
||
630
1b755b7342eb
Layed out FMMU structure and methods to own files.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
673 |
ec_fmmu_init(fmmu, slave, slave->fmmu_count++); |
412 | 674 |
fmmu->domain = domain; |
675 |
fmmu->sync = sync; |
|
676 |
fmmu->logical_start_address = 0; |
|
677 |
||
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
610
diff
changeset
|
678 |
slave->pdos_registered = 1; |
609
611d738a1392
Moved state request on PDO registration to slave.c.
Florian Pose <fp@igh-essen.com>
parents:
607
diff
changeset
|
679 |
|
611d738a1392
Moved state request on PDO registration to slave.c.
Florian Pose <fp@igh-essen.com>
parents:
607
diff
changeset
|
680 |
ec_slave_request_state(slave, EC_SLAVE_STATE_OP); |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
681 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
682 |
return 0; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
683 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
684 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
685 |
/*****************************************************************************/ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
686 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
687 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
688 |
Outputs all information about a certain slave. |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
689 |
*/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
690 |
|
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
691 |
ssize_t ec_slave_info(const ec_slave_t *slave, /**< EtherCAT slave */ |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
692 |
char *buffer /**< Output buffer */ |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
693 |
) |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
694 |
{ |
626
a5e838c30733
Renamed ec_sii_sync_t to ec_sync_t.
Florian Pose <fp@igh-essen.com>
parents:
625
diff
changeset
|
695 |
ec_sync_t *sync; |
625
ec69acbbd156
Renamed ec_sii_pdo_t and ec_sii_pdo_entry_t to ec_pdo_t and
Florian Pose <fp@igh-essen.com>
parents:
624
diff
changeset
|
696 |
ec_pdo_t *pdo; |
ec69acbbd156
Renamed ec_sii_pdo_t and ec_sii_pdo_entry_t to ec_pdo_t and
Florian Pose <fp@igh-essen.com>
parents:
624
diff
changeset
|
697 |
ec_pdo_entry_t *pdo_entry; |
142 | 698 |
int first, i; |
464
6c21a8d8c785
SDO configurations in Sysfs.
Florian Pose <fp@igh-essen.com>
parents:
461
diff
changeset
|
699 |
ec_sdo_data_t *sdodata; |
6c21a8d8c785
SDO configurations in Sysfs.
Florian Pose <fp@igh-essen.com>
parents:
461
diff
changeset
|
700 |
char str[20]; |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
701 |
char *large_buffer, *buf; |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
702 |
unsigned int size; |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
703 |
|
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
704 |
if (!(large_buffer = (char *) kmalloc(PAGE_SIZE * 2, GFP_KERNEL))) { |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
705 |
return -ENOMEM; |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
706 |
} |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
707 |
|
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
708 |
buf = large_buffer; |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
709 |
|
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
710 |
buf += sprintf(buf, "Ring position: %i\n", |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
711 |
slave->ring_position); |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
712 |
buf += sprintf(buf, "State: "); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
713 |
buf += ec_state_string(slave->current_state, buf); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
714 |
buf += sprintf(buf, " ("); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
715 |
buf += ec_state_string(slave->requested_state, buf); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
716 |
buf += sprintf(buf, ")\n"); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
717 |
buf += sprintf(buf, "Flags: %s, %s\n\n", |
610
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
718 |
slave->online_state == EC_SLAVE_ONLINE ? "online" : "OFFLINE", |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
719 |
slave->error_flag ? "ERROR" : "ok"); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
720 |
|
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
721 |
buf += sprintf(buf, "Data link status:\n"); |
183
8ae1e011e96c
More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents:
182
diff
changeset
|
722 |
for (i = 0; i < 4; i++) { |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
723 |
buf += sprintf(buf, " Port %u: Phy %u (", |
764
41a5bdff9d9b
Minor output changes in slave info file.
Florian Pose <fp@igh-essen.com>
parents:
763
diff
changeset
|
724 |
i, slave->sii_physical_layer[i]); |
190
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
725 |
switch (slave->sii_physical_layer[i]) { |
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
726 |
case 0x00: |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
727 |
buf += sprintf(buf, "EBUS"); |
190
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
728 |
break; |
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
729 |
case 0x01: |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
730 |
buf += sprintf(buf, "100BASE-TX"); |
190
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
731 |
break; |
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
732 |
case 0x02: |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
733 |
buf += sprintf(buf, "100BASE-FX"); |
190
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
734 |
break; |
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
735 |
default: |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
736 |
buf += sprintf(buf, "unknown"); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
737 |
} |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
738 |
buf += sprintf(buf, "), Link %s, Loop %s, %s\n", |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
739 |
slave->dl_link[i] ? "up" : "down", |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
740 |
slave->dl_loop[i] ? "closed" : "open", |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
741 |
slave->dl_signal[i] ? "Signal detected" : "No signal"); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
742 |
} |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
743 |
buf += sprintf(buf, "\n"); |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
744 |
|
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
745 |
if (slave->sii_alias) |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
746 |
buf += sprintf(buf, "Configured station alias:" |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
747 |
" 0x%04X (%i)\n\n", slave->sii_alias, slave->sii_alias); |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
748 |
|
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
749 |
buf += sprintf(buf, "Identity:\n"); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
750 |
buf += sprintf(buf, " Vendor ID: 0x%08X (%u)\n", |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
751 |
slave->sii_vendor_id, slave->sii_vendor_id); |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
752 |
buf += sprintf(buf, " Product code: 0x%08X (%u)\n", |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
753 |
slave->sii_product_code, slave->sii_product_code); |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
754 |
buf += sprintf(buf, " Revision number: 0x%08X (%u)\n", |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
755 |
slave->sii_revision_number, slave->sii_revision_number); |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
756 |
buf += sprintf(buf, " Serial number: 0x%08X (%u)\n\n", |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
757 |
slave->sii_serial_number, slave->sii_serial_number); |
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
758 |
|
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
759 |
if (slave->sii_mailbox_protocols) { |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
760 |
buf += sprintf(buf, "Mailboxes:\n"); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
761 |
buf += sprintf(buf, " RX: 0x%04X/%u, TX: 0x%04X/%u\n", |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
762 |
slave->sii_rx_mailbox_offset, slave->sii_rx_mailbox_size, |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
763 |
slave->sii_tx_mailbox_offset, slave->sii_tx_mailbox_size); |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
764 |
buf += sprintf(buf, " Supported protocols: "); |
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
765 |
|
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
766 |
first = 1; |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
767 |
if (slave->sii_mailbox_protocols & EC_MBOX_AOE) { |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
768 |
buf += sprintf(buf, "AoE"); |
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
769 |
first = 0; |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
770 |
} |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
771 |
if (slave->sii_mailbox_protocols & EC_MBOX_EOE) { |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
772 |
if (!first) buf += sprintf(buf, ", "); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
773 |
buf += sprintf(buf, "EoE"); |
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
774 |
first = 0; |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
775 |
} |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
776 |
if (slave->sii_mailbox_protocols & EC_MBOX_COE) { |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
777 |
if (!first) buf += sprintf(buf, ", "); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
778 |
buf += sprintf(buf, "CoE"); |
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
779 |
first = 0; |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
780 |
} |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
781 |
if (slave->sii_mailbox_protocols & EC_MBOX_FOE) { |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
782 |
if (!first) buf += sprintf(buf, ", "); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
783 |
buf += sprintf(buf, "FoE"); |
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
784 |
first = 0; |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
785 |
} |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
786 |
if (slave->sii_mailbox_protocols & EC_MBOX_SOE) { |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
787 |
if (!first) buf += sprintf(buf, ", "); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
788 |
buf += sprintf(buf, "SoE"); |
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
789 |
first = 0; |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
790 |
} |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
791 |
if (slave->sii_mailbox_protocols & EC_MBOX_VOE) { |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
792 |
if (!first) buf += sprintf(buf, ", "); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
793 |
buf += sprintf(buf, "VoE"); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
794 |
} |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
795 |
buf += sprintf(buf, "\n\n"); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
796 |
} |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
797 |
|
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
798 |
buf += sprintf(buf, "Current consumption: %i mA\n\n", |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
799 |
slave->sii_current_on_ebus); |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
800 |
|
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
801 |
if (slave->sii_group || slave->sii_image || slave->sii_order |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
802 |
|| slave->sii_name) { |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
803 |
buf += sprintf(buf, "General:\n"); |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
804 |
|
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
805 |
if (slave->sii_group) |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
806 |
buf += sprintf(buf, " Group: %s\n", slave->sii_group); |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
807 |
if (slave->sii_image) |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
808 |
buf += sprintf(buf, " Image: %s\n", slave->sii_image); |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
809 |
if (slave->sii_order) |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
810 |
buf += sprintf(buf, " Order number: %s\n", |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
811 |
slave->sii_order); |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
812 |
if (slave->sii_name) |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
813 |
buf += sprintf(buf, " Name: %s\n", slave->sii_name); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
814 |
buf += sprintf(buf, "\n"); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
815 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
816 |
|
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
817 |
if (slave->sii_sync_count) { |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
818 |
buf += sprintf(buf, "Sync managers / PDO mapping:\n"); |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
819 |
|
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
820 |
for (i = 0; i < slave->sii_sync_count; i++) { |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
821 |
sync = &slave->sii_syncs[i]; |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
822 |
buf += sprintf(buf, |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
823 |
" SM%u: addr 0x%04X, size %i, control 0x%02X, %s\n", |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
824 |
sync->index, sync->physical_start_address, |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
825 |
ec_sync_size(sync), sync->control_register, |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
826 |
sync->enable ? "enable" : "disable"); |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
827 |
|
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
828 |
if (list_empty(&sync->pdos)) { |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
829 |
buf += sprintf(buf, " No PDOs mapped.\n"); |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
830 |
} else if (sync->mapping_source != EC_SYNC_MAPPING_NONE) { |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
831 |
buf += sprintf(buf, |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
832 |
" PDO mapping information from %s.\n", |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
833 |
sync->mapping_source == EC_SYNC_MAPPING_SII |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
834 |
? "SII" : "CoE"); |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
835 |
} |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
836 |
|
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
837 |
list_for_each_entry(pdo, &sync->pdos, list) { |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
838 |
buf += sprintf(buf, " %s 0x%04X \"%s\"\n", |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
839 |
pdo->type == EC_RX_PDO ? "RxPdo" : "TxPdo", |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
840 |
pdo->index, pdo->name ? pdo->name : "???"); |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
841 |
|
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
842 |
list_for_each_entry(pdo_entry, &pdo->entries, list) { |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
843 |
buf += sprintf(buf, |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
844 |
" 0x%04X:%X \"%s\", %i bit\n", |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
845 |
pdo_entry->index, pdo_entry->subindex, |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
846 |
pdo_entry->name ? pdo_entry->name : "???", |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
847 |
pdo_entry->bit_length); |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
848 |
} |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
849 |
} |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
850 |
} |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
851 |
buf += sprintf(buf, "\n"); |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
852 |
} |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
853 |
|
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
854 |
// type-cast to avoid warnings on some compilers |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
855 |
if (!list_empty((struct list_head *) &slave->sii_pdos)) { |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
856 |
buf += sprintf(buf, "Available PDOs from SII:\n"); |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
857 |
|
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
858 |
list_for_each_entry(pdo, &slave->sii_pdos, list) { |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
859 |
buf += sprintf(buf, " %s 0x%04X \"%s\"", |
750
bc42cd59329b
Minor: renamed [RT]XPDO to [RT]xPdo.
Florian Pose <fp@igh-essen.com>
parents:
747
diff
changeset
|
860 |
pdo->type == EC_RX_PDO ? "RxPdo" : "TxPdo", |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
861 |
pdo->index, pdo->name ? pdo->name : "???"); |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
862 |
if (pdo->sync_index >= 0) |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
863 |
buf += sprintf(buf, ", default mapping: SM%u.\n", |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
864 |
pdo->sync_index); |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
865 |
else |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
866 |
buf += sprintf(buf, ", no default mapping.\n"); |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
867 |
|
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
868 |
list_for_each_entry(pdo_entry, &pdo->entries, list) { |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
869 |
buf += sprintf(buf, " 0x%04X:%X \"%s\", %i bit\n", |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
870 |
pdo_entry->index, pdo_entry->subindex, |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
871 |
pdo_entry->name ? pdo_entry->name : "???", |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
872 |
pdo_entry->bit_length); |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
873 |
} |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
874 |
} |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
875 |
buf += sprintf(buf, "\n"); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
876 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
877 |
|
730
226fe5065cf2
Avoid warnings on some compilers.
Florian Pose <fp@igh-essen.com>
parents:
696
diff
changeset
|
878 |
// type-cast to avoid warnings on some compilers |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
879 |
if (!list_empty((struct list_head *) &slave->sdo_confs)) { |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
880 |
buf += sprintf(buf, "SDO configurations:\n"); |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
881 |
|
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
882 |
list_for_each_entry(sdodata, &slave->sdo_confs, list) { |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
883 |
switch (sdodata->size) { |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
884 |
case 1: sprintf(str, "%i", EC_READ_U8(sdodata->data)); break; |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
885 |
case 2: sprintf(str, "%i", EC_READ_U16(sdodata->data)); break; |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
886 |
case 4: sprintf(str, "%i", EC_READ_U32(sdodata->data)); break; |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
887 |
default: sprintf(str, "(invalid size)"); break; |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
888 |
} |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
889 |
buf += sprintf(buf, " 0x%04X:%-3i -> %s\n", |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
890 |
sdodata->index, sdodata->subindex, str); |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
891 |
} |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
892 |
buf += sprintf(buf, "\n"); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
893 |
} |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
894 |
|
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
895 |
size = buf - large_buffer; |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
896 |
if (size >= PAGE_SIZE) { |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
897 |
const char trunc[] = "\n---TRUNCATED---\n"; |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
898 |
unsigned int len = strlen(trunc); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
899 |
memcpy(large_buffer + PAGE_SIZE - len, trunc, len); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
900 |
} |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
901 |
|
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
902 |
size = min(size, (unsigned int) PAGE_SIZE); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
903 |
memcpy(buffer, large_buffer, size); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
904 |
kfree(large_buffer); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
905 |
return size; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
906 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
907 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
908 |
/*****************************************************************************/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
909 |
|
133
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
132
diff
changeset
|
910 |
/** |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
911 |
* Schedules an EEPROM write request. |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
912 |
* \return 0 case of success, otherwise error code. |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
913 |
*/ |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
914 |
|
758
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
915 |
int ec_slave_schedule_eeprom_writing( |
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
916 |
ec_eeprom_write_request_t *request /**< EEPROM write request */ |
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
917 |
) |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
918 |
{ |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
919 |
ec_master_t *master = request->slave->master; |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
920 |
|
649
a4d3fffdaed7
Renamed names of enum type ec_request_state_t.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
921 |
request->state = EC_REQUEST_QUEUED; |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
922 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
923 |
// schedule EEPROM write request. |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
924 |
down(&master->eeprom_sem); |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
925 |
list_add_tail(&request->list, &master->eeprom_requests); |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
926 |
up(&master->eeprom_sem); |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
927 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
928 |
// wait for processing through FSM |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
929 |
if (wait_event_interruptible(master->eeprom_queue, |
649
a4d3fffdaed7
Renamed names of enum type ec_request_state_t.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
930 |
request->state != EC_REQUEST_QUEUED)) { |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
931 |
// interrupted by signal |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
932 |
down(&master->eeprom_sem); |
649
a4d3fffdaed7
Renamed names of enum type ec_request_state_t.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
933 |
if (request->state == EC_REQUEST_QUEUED) { |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
934 |
list_del(&request->list); |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
935 |
up(&master->eeprom_sem); |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
936 |
return -EINTR; |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
937 |
} |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
938 |
// request already processing: interrupt not possible. |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
939 |
up(&master->eeprom_sem); |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
940 |
} |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
941 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
942 |
// wait until master FSM has finished processing |
649
a4d3fffdaed7
Renamed names of enum type ec_request_state_t.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
943 |
wait_event(master->eeprom_queue, |
a4d3fffdaed7
Renamed names of enum type ec_request_state_t.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
944 |
request->state != EC_REQUEST_IN_PROGRESS); |
a4d3fffdaed7
Renamed names of enum type ec_request_state_t.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
945 |
|
a4d3fffdaed7
Renamed names of enum type ec_request_state_t.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
946 |
return request->state == EC_REQUEST_COMPLETE ? 0 : -EIO; |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
947 |
} |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
948 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
949 |
/*****************************************************************************/ |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
950 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
951 |
/** |
735
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
952 |
* Calculates the EEPROM checksum field. |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
953 |
* |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
954 |
* The checksum is generated with the polynom x^8+x^2+x+1 (0x07) and an |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
955 |
* initial value of 0xff (see IEC 61158-6-12 ch. 5.4). |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
956 |
* |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
957 |
* The below code was originally generated with PYCRC |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
958 |
* http://www.tty1.net/pycrc |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
959 |
* |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
960 |
* ./pycrc.py --width=8 --poly=0x07 --reflect-in=0 --xor-in=0xff |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
961 |
* --reflect-out=0 --xor-out=0 --generate c --algorithm=bit-by-bit |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
962 |
* |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
963 |
* \return CRC8 |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
964 |
*/ |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
965 |
|
758
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
966 |
uint8_t ec_slave_eeprom_crc( |
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
967 |
const uint8_t *data, /**< pointer to data */ |
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
968 |
size_t length /**< number of bytes in \a data */ |
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
969 |
) |
735
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
970 |
{ |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
971 |
unsigned int i; |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
972 |
uint8_t bit, byte, crc = 0x48; |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
973 |
|
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
974 |
while (length--) { |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
975 |
byte = *data++; |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
976 |
for (i = 0; i < 8; i++) { |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
977 |
bit = crc & 0x80; |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
978 |
crc = (crc << 1) | ((byte >> (7 - i)) & 0x01); |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
979 |
if (bit) crc ^= 0x07; |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
980 |
} |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
981 |
} |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
982 |
|
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
983 |
for (i = 0; i < 8; i++) { |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
984 |
bit = crc & 0x80; |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
985 |
crc <<= 1; |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
986 |
if (bit) crc ^= 0x07; |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
987 |
} |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
988 |
|
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
989 |
return crc; |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
990 |
} |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
991 |
|
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
992 |
/*****************************************************************************/ |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
993 |
|
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
994 |
/** |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
995 |
* Writes complete EEPROM contents to a slave. |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
996 |
* \return data size written in case of success, otherwise error code. |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
997 |
*/ |
269 | 998 |
|
999 |
ssize_t ec_slave_write_eeprom(ec_slave_t *slave, /**< EtherCAT slave */ |
|
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1000 |
const uint8_t *data, /**< new EEPROM data */ |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1001 |
size_t size /**< size of data in bytes */ |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1002 |
) |
269 | 1003 |
{ |
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
1004 |
ec_eeprom_write_request_t request; |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
1005 |
const uint16_t *cat_header; |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
1006 |
uint16_t cat_type, cat_size; |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1007 |
int ret; |
735
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
1008 |
uint8_t crc; |
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
1009 |
|
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
1010 |
if (slave->master->mode != EC_MASTER_MODE_IDLE) { // FIXME |
306
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
302
diff
changeset
|
1011 |
EC_ERR("Writing EEPROMs only allowed in idle mode!\n"); |
599
a6ce861a167e
ec_slave_write_eeprom now returns certain error codes.
Florian Pose <fp@igh-essen.com>
parents:
597
diff
changeset
|
1012 |
return -EBUSY; |
269 | 1013 |
} |
1014 |
||
1015 |
if (size % 2) { |
|
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
1016 |
EC_ERR("EEPROM data size is odd! Dropping.\n"); |
599
a6ce861a167e
ec_slave_write_eeprom now returns certain error codes.
Florian Pose <fp@igh-essen.com>
parents:
597
diff
changeset
|
1017 |
return -EINVAL; |
269 | 1018 |
} |
1019 |
||
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
1020 |
// init EEPROM write request |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
1021 |
INIT_LIST_HEAD(&request.list); |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
1022 |
request.slave = slave; |
754
0b47b49c5976
Changed unit of ec_eeprom_write_request_t from word to byte.
Florian Pose <fp@igh-essen.com>
parents:
750
diff
changeset
|
1023 |
request.data = data; |
0b47b49c5976
Changed unit of ec_eeprom_write_request_t from word to byte.
Florian Pose <fp@igh-essen.com>
parents:
750
diff
changeset
|
1024 |
request.word_offset = 0; |
0b47b49c5976
Changed unit of ec_eeprom_write_request_t from word to byte.
Florian Pose <fp@igh-essen.com>
parents:
750
diff
changeset
|
1025 |
request.word_size = size / 2; |
0b47b49c5976
Changed unit of ec_eeprom_write_request_t from word to byte.
Florian Pose <fp@igh-essen.com>
parents:
750
diff
changeset
|
1026 |
|
0b47b49c5976
Changed unit of ec_eeprom_write_request_t from word to byte.
Florian Pose <fp@igh-essen.com>
parents:
750
diff
changeset
|
1027 |
if (request.word_size < 0x0041) { |
269 | 1028 |
EC_ERR("EEPROM data too short! Dropping.\n"); |
599
a6ce861a167e
ec_slave_write_eeprom now returns certain error codes.
Florian Pose <fp@igh-essen.com>
parents:
597
diff
changeset
|
1029 |
return -EINVAL; |
269 | 1030 |
} |
1031 |
||
735
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
1032 |
// calculate checksum |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
1033 |
crc = ec_slave_eeprom_crc(data, 14); // CRC over words 0 to 6 |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
1034 |
if (crc != data[14]) { |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
1035 |
EC_WARN("EEPROM CRC incorrect. Must be 0x%02x.\n", crc); |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
1036 |
} |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
1037 |
|
754
0b47b49c5976
Changed unit of ec_eeprom_write_request_t from word to byte.
Florian Pose <fp@igh-essen.com>
parents:
750
diff
changeset
|
1038 |
cat_header = (const uint16_t *) request.data |
0b47b49c5976
Changed unit of ec_eeprom_write_request_t from word to byte.
Florian Pose <fp@igh-essen.com>
parents:
750
diff
changeset
|
1039 |
+ EC_FIRST_EEPROM_CATEGORY_OFFSET; |
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
1040 |
cat_type = EC_READ_U16(cat_header); |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
1041 |
while (cat_type != 0xFFFF) { // cycle through categories |
754
0b47b49c5976
Changed unit of ec_eeprom_write_request_t from word to byte.
Florian Pose <fp@igh-essen.com>
parents:
750
diff
changeset
|
1042 |
if (cat_header + 1 > |
0b47b49c5976
Changed unit of ec_eeprom_write_request_t from word to byte.
Florian Pose <fp@igh-essen.com>
parents:
750
diff
changeset
|
1043 |
(const uint16_t *) request.data + request.word_size) { |
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
1044 |
EC_ERR("EEPROM data corrupted! Dropping.\n"); |
599
a6ce861a167e
ec_slave_write_eeprom now returns certain error codes.
Florian Pose <fp@igh-essen.com>
parents:
597
diff
changeset
|
1045 |
return -EINVAL; |
269 | 1046 |
} |
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
1047 |
cat_size = EC_READ_U16(cat_header + 1); |
754
0b47b49c5976
Changed unit of ec_eeprom_write_request_t from word to byte.
Florian Pose <fp@igh-essen.com>
parents:
750
diff
changeset
|
1048 |
if (cat_header + cat_size + 2 > |
0b47b49c5976
Changed unit of ec_eeprom_write_request_t from word to byte.
Florian Pose <fp@igh-essen.com>
parents:
750
diff
changeset
|
1049 |
(const uint16_t *) request.data + request.word_size) { |
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
1050 |
EC_ERR("EEPROM data corrupted! Dropping.\n"); |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
1051 |
return -EINVAL; |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
1052 |
} |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
1053 |
cat_header += cat_size + 2; |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
1054 |
cat_type = EC_READ_U16(cat_header); |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
1055 |
} |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
1056 |
|
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1057 |
// EEPROM data ok. schedule writing. |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1058 |
if ((ret = ec_slave_schedule_eeprom_writing(&request))) |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1059 |
return ret; // error code |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1060 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1061 |
return size; // success |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1062 |
} |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1063 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1064 |
/*****************************************************************************/ |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1065 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1066 |
/** |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1067 |
* Writes the Secondary slave address (alias) to the slave's EEPROM. |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1068 |
* \return data size written in case of success, otherwise error code. |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1069 |
*/ |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1070 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1071 |
ssize_t ec_slave_write_alias(ec_slave_t *slave, /**< EtherCAT slave */ |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1072 |
const uint8_t *data, /**< alias string */ |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1073 |
size_t size /**< size of data in bytes */ |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1074 |
) |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1075 |
{ |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1076 |
ec_eeprom_write_request_t request; |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1077 |
char *remainder; |
754
0b47b49c5976
Changed unit of ec_eeprom_write_request_t from word to byte.
Florian Pose <fp@igh-essen.com>
parents:
750
diff
changeset
|
1078 |
uint16_t alias; |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1079 |
int ret; |
754
0b47b49c5976
Changed unit of ec_eeprom_write_request_t from word to byte.
Florian Pose <fp@igh-essen.com>
parents:
750
diff
changeset
|
1080 |
uint8_t eeprom_data[16], crc; |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1081 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1082 |
if (slave->master->mode != EC_MASTER_MODE_IDLE) { // FIXME |
735
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
1083 |
EC_ERR("Writing to EEPROM is only allowed in idle mode!\n"); |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1084 |
return -EBUSY; |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1085 |
} |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1086 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1087 |
alias = simple_strtoul(data, &remainder, 0); |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1088 |
if (remainder == (char *) data || (*remainder && *remainder != '\n')) { |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1089 |
EC_ERR("Invalid alias value! Dropping.\n"); |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1090 |
return -EINVAL; |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1091 |
} |
735
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
1092 |
|
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
1093 |
if (!slave->eeprom_data || slave->eeprom_size < 16) { |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
1094 |
EC_ERR("Failed to read EEPROM contents from slave %u.\n", |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
1095 |
slave->ring_position); |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
1096 |
return -EINVAL; |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
1097 |
} |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
1098 |
|
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
1099 |
// copy first 7 words of recent EEPROM contents |
754
0b47b49c5976
Changed unit of ec_eeprom_write_request_t from word to byte.
Florian Pose <fp@igh-essen.com>
parents:
750
diff
changeset
|
1100 |
memcpy(eeprom_data, slave->eeprom_data, 14); |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1101 |
|
754
0b47b49c5976
Changed unit of ec_eeprom_write_request_t from word to byte.
Florian Pose <fp@igh-essen.com>
parents:
750
diff
changeset
|
1102 |
// write new alias address in word 4 |
0b47b49c5976
Changed unit of ec_eeprom_write_request_t from word to byte.
Florian Pose <fp@igh-essen.com>
parents:
750
diff
changeset
|
1103 |
EC_WRITE_U16(eeprom_data + 8, alias); |
735
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
1104 |
|
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
1105 |
// calculate new checksum over words 0 to 6 |
754
0b47b49c5976
Changed unit of ec_eeprom_write_request_t from word to byte.
Florian Pose <fp@igh-essen.com>
parents:
750
diff
changeset
|
1106 |
crc = ec_slave_eeprom_crc(eeprom_data, 14); |
0b47b49c5976
Changed unit of ec_eeprom_write_request_t from word to byte.
Florian Pose <fp@igh-essen.com>
parents:
750
diff
changeset
|
1107 |
EC_WRITE_U16(eeprom_data + 14, crc); |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1108 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1109 |
// init EEPROM write request |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1110 |
INIT_LIST_HEAD(&request.list); |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1111 |
request.slave = slave; |
754
0b47b49c5976
Changed unit of ec_eeprom_write_request_t from word to byte.
Florian Pose <fp@igh-essen.com>
parents:
750
diff
changeset
|
1112 |
request.data = eeprom_data; |
0b47b49c5976
Changed unit of ec_eeprom_write_request_t from word to byte.
Florian Pose <fp@igh-essen.com>
parents:
750
diff
changeset
|
1113 |
request.word_offset = 0x0000; |
0b47b49c5976
Changed unit of ec_eeprom_write_request_t from word to byte.
Florian Pose <fp@igh-essen.com>
parents:
750
diff
changeset
|
1114 |
request.word_size = 8; |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1115 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1116 |
if ((ret = ec_slave_schedule_eeprom_writing(&request))) |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1117 |
return ret; // error code |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1118 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1119 |
slave->sii_alias = alias; // FIXME: do this in state machine |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1120 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1121 |
return size; // success |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1122 |
} |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1123 |
|
269 | 1124 |
|
1125 |
/*****************************************************************************/ |
|
1126 |
||
1127 |
/** |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
1128 |
Formats attribute data for SysFS read access. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
1129 |
\return number of bytes to read |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
1130 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
1131 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
1132 |
ssize_t ec_show_slave_attribute(struct kobject *kobj, /**< slave's kobject */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
1133 |
struct attribute *attr, /**< attribute */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
1134 |
char *buffer /**< memory to store data */ |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
1135 |
) |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
1136 |
{ |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
1137 |
ec_slave_t *slave = container_of(kobj, ec_slave_t, kobj); |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
1138 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1139 |
if (attr == &attr_info) { |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1140 |
return ec_slave_info(slave, buffer); |
185
af570302dcee
Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
1141 |
} |
256
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1142 |
else if (attr == &attr_state) { |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1143 |
switch (slave->current_state) { |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1144 |
case EC_SLAVE_STATE_INIT: |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1145 |
return sprintf(buffer, "INIT\n"); |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1146 |
case EC_SLAVE_STATE_PREOP: |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1147 |
return sprintf(buffer, "PREOP\n"); |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1148 |
case EC_SLAVE_STATE_SAVEOP: |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1149 |
return sprintf(buffer, "SAVEOP\n"); |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1150 |
case EC_SLAVE_STATE_OP: |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1151 |
return sprintf(buffer, "OP\n"); |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1152 |
default: |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1153 |
return sprintf(buffer, "UNKNOWN\n"); |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1154 |
} |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1155 |
} |
266
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
1156 |
else if (attr == &attr_eeprom) { |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
1157 |
if (slave->eeprom_data) { |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
1158 |
if (slave->eeprom_size > PAGE_SIZE) { |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
1159 |
EC_ERR("EEPROM contents of slave %i exceed 1 page (%i/%i).\n", |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
1160 |
slave->ring_position, slave->eeprom_size, |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
1161 |
(int) PAGE_SIZE); |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
1162 |
} |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
1163 |
else { |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
1164 |
memcpy(buffer, slave->eeprom_data, slave->eeprom_size); |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
1165 |
return slave->eeprom_size; |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
1166 |
} |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
1167 |
} |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
1168 |
} |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1169 |
else if (attr == &attr_alias) { |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1170 |
return sprintf(buffer, "%u\n", slave->sii_alias); |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1171 |
} |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
1172 |
|
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
1173 |
return 0; |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
1174 |
} |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
1175 |
|
256
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1176 |
/*****************************************************************************/ |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1177 |
|
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1178 |
/** |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1179 |
Formats attribute data for SysFS write access. |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1180 |
\return number of bytes processed, or negative error code |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1181 |
*/ |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1182 |
|
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1183 |
ssize_t ec_store_slave_attribute(struct kobject *kobj, /**< slave's kobject */ |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1184 |
struct attribute *attr, /**< attribute */ |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1185 |
const char *buffer, /**< memory with data */ |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1186 |
size_t size /**< size of data to store */ |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1187 |
) |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1188 |
{ |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1189 |
ec_slave_t *slave = container_of(kobj, ec_slave_t, kobj); |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1190 |
|
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1191 |
if (attr == &attr_state) { |
403
7bb931deccd9
Added EC_SLAVE_STATE_ACK_ERR to ec_state_string(); added EC_STATE_STRING_SIZE
Florian Pose <fp@igh-essen.com>
parents:
400
diff
changeset
|
1192 |
char state[EC_STATE_STRING_SIZE]; |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1193 |
if (!strcmp(buffer, "INIT\n")) |
446 | 1194 |
ec_slave_request_state(slave, EC_SLAVE_STATE_INIT); |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1195 |
else if (!strcmp(buffer, "PREOP\n")) |
446 | 1196 |
ec_slave_request_state(slave, EC_SLAVE_STATE_PREOP); |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1197 |
else if (!strcmp(buffer, "SAVEOP\n")) |
446 | 1198 |
ec_slave_request_state(slave, EC_SLAVE_STATE_SAVEOP); |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1199 |
else if (!strcmp(buffer, "OP\n")) |
446 | 1200 |
ec_slave_request_state(slave, EC_SLAVE_STATE_OP); |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1201 |
else { |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1202 |
EC_ERR("Invalid slave state \"%s\"!\n", buffer); |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1203 |
return -EINVAL; |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1204 |
} |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1205 |
|
333
2b15335f9f35
Minor fix: Output of SysFS accepting new slave state.
Florian Pose <fp@igh-essen.com>
parents:
329
diff
changeset
|
1206 |
ec_state_string(slave->requested_state, state); |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1207 |
EC_INFO("Accepted new state %s for slave %i.\n", |
333
2b15335f9f35
Minor fix: Output of SysFS accepting new slave state.
Florian Pose <fp@igh-essen.com>
parents:
329
diff
changeset
|
1208 |
state, slave->ring_position); |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1209 |
return size; |
256
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1210 |
} |
269 | 1211 |
else if (attr == &attr_eeprom) { |
599
a6ce861a167e
ec_slave_write_eeprom now returns certain error codes.
Florian Pose <fp@igh-essen.com>
parents:
597
diff
changeset
|
1212 |
return ec_slave_write_eeprom(slave, buffer, size); |
269 | 1213 |
} |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1214 |
else if (attr == &attr_alias) { |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1215 |
return ec_slave_write_alias(slave, buffer, size); |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1216 |
} |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1217 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1218 |
return -EIO; |
256
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1219 |
} |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1220 |
|
275
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1221 |
/*****************************************************************************/ |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1222 |
|
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1223 |
/** |
758
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
1224 |
* Get the sync manager for either Rx- or Tx-PDOs. |
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
1225 |
* \return pointer to sync manager, or NULL. |
619
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
1226 |
*/ |
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
1227 |
|
626
a5e838c30733
Renamed ec_sii_sync_t to ec_sync_t.
Florian Pose <fp@igh-essen.com>
parents:
625
diff
changeset
|
1228 |
ec_sync_t *ec_slave_get_pdo_sync( |
619
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
1229 |
ec_slave_t *slave, /**< EtherCAT slave */ |
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
1230 |
ec_direction_t dir /**< input or output */ |
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
1231 |
) |
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
1232 |
{ |
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
1233 |
unsigned int sync_index; |
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
1234 |
|
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1235 |
if (dir != EC_DIR_INPUT && dir != EC_DIR_OUTPUT) { |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1236 |
EC_ERR("Invalid direction!\n"); |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1237 |
return NULL; |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1238 |
} |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1239 |
|
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1240 |
sync_index = (unsigned int) dir; |
619
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
1241 |
if (slave->sii_mailbox_protocols) sync_index += 2; |
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
1242 |
|
660
582a90a34303
Configure alternative PDO mapping only on slaves that have PDO sync
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
1243 |
if (sync_index >= slave->sii_sync_count) |
619
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
1244 |
return NULL; |
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
1245 |
|
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
1246 |
return &slave->sii_syncs[sync_index]; |
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
1247 |
} |
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
1248 |
|
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
1249 |
/*****************************************************************************/ |
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
1250 |
|
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
1251 |
/** |
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1252 |
\return 0 in case of success, else < 0 |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1253 |
*/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1254 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1255 |
int ec_slave_conf_sdo(ec_slave_t *slave, /**< EtherCAT slave */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1256 |
uint16_t sdo_index, /**< SDO index */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1257 |
uint8_t sdo_subindex, /**< SDO subindex */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1258 |
const uint8_t *data, /**< SDO data */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1259 |
size_t size /**< SDO size in bytes */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1260 |
) |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1261 |
{ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1262 |
ec_sdo_data_t *sdodata; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1263 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1264 |
if (!(slave->sii_mailbox_protocols & EC_MBOX_COE)) { |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1265 |
EC_ERR("Slave %i does not support CoE!\n", slave->ring_position); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1266 |
return -1; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1267 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1268 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1269 |
if (!(sdodata = (ec_sdo_data_t *) |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1270 |
kmalloc(sizeof(ec_sdo_data_t), GFP_KERNEL))) { |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1271 |
EC_ERR("Failed to allocate memory for SDO configuration object!\n"); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1272 |
return -1; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1273 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1274 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1275 |
if (!(sdodata->data = (uint8_t *) kmalloc(size, GFP_KERNEL))) { |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1276 |
EC_ERR("Failed to allocate memory for SDO configuration data!\n"); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1277 |
kfree(sdodata); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1278 |
return -1; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1279 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1280 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1281 |
sdodata->index = sdo_index; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1282 |
sdodata->subindex = sdo_subindex; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1283 |
memcpy(sdodata->data, data, size); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1284 |
sdodata->size = size; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1285 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1286 |
list_add_tail(&sdodata->list, &slave->sdo_confs); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1287 |
return 0; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1288 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1289 |
|
410 | 1290 |
/*****************************************************************************/ |
1291 |
||
1292 |
/** |
|
1293 |
\return 0 in case of success, else < 0 |
|
1294 |
*/ |
|
1295 |
||
1296 |
int ec_slave_validate(const ec_slave_t *slave, /**< EtherCAT slave */ |
|
1297 |
uint32_t vendor_id, /**< vendor ID */ |
|
1298 |
uint32_t product_code /**< product code */ |
|
1299 |
) |
|
1300 |
{ |
|
1301 |
if (vendor_id != slave->sii_vendor_id || |
|
1302 |
product_code != slave->sii_product_code) { |
|
643
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
635
diff
changeset
|
1303 |
EC_ERR("Invalid slave type at position %i:\n", slave->ring_position); |
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
635
diff
changeset
|
1304 |
EC_ERR(" Requested: 0x%08X 0x%08X\n", vendor_id, product_code); |
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
635
diff
changeset
|
1305 |
EC_ERR(" Found: 0x%08X 0x%08X\n", |
78929d878b2c
Removed X:Y addressing scheme, ec_slave_is_coupler(),
Florian Pose <fp@igh-essen.com>
parents:
635
diff
changeset
|
1306 |
slave->sii_vendor_id, slave->sii_product_code); |
410 | 1307 |
return -1; |
1308 |
} |
|
1309 |
return 0; |
|
1310 |
} |
|
1311 |
||
423
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1312 |
/*****************************************************************************/ |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1313 |
|
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1314 |
/** |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1315 |
Counts the total number of SDOs and entries in the dictionary. |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1316 |
*/ |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1317 |
|
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1318 |
void ec_slave_sdo_dict_info(const ec_slave_t *slave, /**< EtherCAT slave */ |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1319 |
unsigned int *sdo_count, /**< number of SDOs */ |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1320 |
unsigned int *entry_count /**< total number of |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1321 |
entries */ |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1322 |
) |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1323 |
{ |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1324 |
unsigned int sdos = 0, entries = 0; |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1325 |
ec_sdo_t *sdo; |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1326 |
ec_sdo_entry_t *entry; |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1327 |
|
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1328 |
list_for_each_entry(sdo, &slave->sdo_dictionary, list) { |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1329 |
sdos++; |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1330 |
list_for_each_entry(entry, &sdo->entries, list) { |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1331 |
entries++; |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1332 |
} |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1333 |
} |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1334 |
|
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1335 |
*sdo_count = sdos; |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1336 |
*entry_count = entries; |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1337 |
} |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1338 |
|
740
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1339 |
/*****************************************************************************/ |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1340 |
|
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1341 |
/** |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1342 |
* Get an SDO from the dictionary. |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1343 |
* \returns The desired SDO, of NULL. |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1344 |
*/ |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1345 |
|
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1346 |
ec_sdo_t *ec_slave_get_sdo( |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1347 |
ec_slave_t *slave /**< EtherCAT slave */, |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1348 |
uint16_t index /**< SDO index */ |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1349 |
) |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1350 |
{ |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1351 |
ec_sdo_t *sdo; |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1352 |
|
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1353 |
list_for_each_entry(sdo, &slave->sdo_dictionary, list) { |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1354 |
if (sdo->index != index) continue; |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1355 |
return sdo; |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1356 |
} |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1357 |
|
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1358 |
return NULL; |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1359 |
} |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1360 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1361 |
/****************************************************************************** |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1362 |
* Realtime interface |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1363 |
*****************************************************************************/ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1364 |
|
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1365 |
/** |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1366 |
\return 0 in case of success, else < 0 |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1367 |
\ingroup RealtimeInterface |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1368 |
*/ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1369 |
|
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1370 |
int ecrt_slave_conf_sdo8(ec_slave_t *slave, /**< EtherCAT slave */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1371 |
uint16_t sdo_index, /**< SDO index */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1372 |
uint8_t sdo_subindex, /**< SDO subindex */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1373 |
uint8_t value /**< new SDO value */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1374 |
) |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1375 |
{ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1376 |
uint8_t data[1]; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1377 |
EC_WRITE_U8(data, value); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1378 |
return ec_slave_conf_sdo(slave, sdo_index, sdo_subindex, data, 1); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1379 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1380 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1381 |
/*****************************************************************************/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1382 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1383 |
/** |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1384 |
\return 0 in case of success, else < 0 |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1385 |
\ingroup RealtimeInterface |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1386 |
*/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1387 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1388 |
int ecrt_slave_conf_sdo16(ec_slave_t *slave, /**< EtherCAT slave */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1389 |
uint16_t sdo_index, /**< SDO index */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1390 |
uint8_t sdo_subindex, /**< SDO subindex */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1391 |
uint16_t value /**< new SDO value */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1392 |
) |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1393 |
{ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1394 |
uint8_t data[2]; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1395 |
EC_WRITE_U16(data, value); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1396 |
return ec_slave_conf_sdo(slave, sdo_index, sdo_subindex, data, 2); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1397 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1398 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1399 |
/*****************************************************************************/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1400 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1401 |
/** |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1402 |
\return 0 in case of success, else < 0 |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1403 |
\ingroup RealtimeInterface |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1404 |
*/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1405 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1406 |
int ecrt_slave_conf_sdo32(ec_slave_t *slave, /**< EtherCAT slave */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1407 |
uint16_t sdo_index, /**< SDO index */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1408 |
uint8_t sdo_subindex, /**< SDO subindex */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1409 |
uint32_t value /**< new SDO value */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1410 |
) |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1411 |
{ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1412 |
uint8_t data[4]; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1413 |
EC_WRITE_U32(data, value); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1414 |
return ec_slave_conf_sdo(slave, sdo_index, sdo_subindex, data, 4); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1415 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1416 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1417 |
/*****************************************************************************/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1418 |
|
758
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
1419 |
/** |
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
1420 |
* Clear slave's PDO mapping. |
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
1421 |
*/ |
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
1422 |
|
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1423 |
void ecrt_slave_pdo_mapping_clear( |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1424 |
ec_slave_t *slave, /**< EtherCAT slave */ |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1425 |
ec_direction_t dir /**< output/input */ |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1426 |
) |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1427 |
{ |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1428 |
ec_sync_t *sync; |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1429 |
|
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1430 |
if (!(slave->sii_mailbox_protocols & EC_MBOX_COE)) { |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1431 |
EC_ERR("Slave %i does not support CoE!\n", slave->ring_position); |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1432 |
return; |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1433 |
} |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1434 |
|
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1435 |
if (!(sync = ec_slave_get_pdo_sync(slave, dir))) |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1436 |
return; |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1437 |
|
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1438 |
ec_sync_clear_pdos(sync); |
745
3f4e5a50733e
Minor: Moved setting of alternate PDO mapping flag.
Florian Pose <fp@igh-essen.com>
parents:
742
diff
changeset
|
1439 |
sync->alt_mapping = 1; |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1440 |
} |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1441 |
|
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1442 |
/*****************************************************************************/ |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1443 |
|
758
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
1444 |
/** |
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
1445 |
* Add a PDO to the list of known mapped PDOs. |
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
1446 |
*/ |
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
1447 |
|
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1448 |
int ecrt_slave_pdo_mapping_add( |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1449 |
ec_slave_t *slave, /**< EtherCAT slave */ |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1450 |
ec_direction_t dir, /**< input/output */ |
758
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
1451 |
uint16_t pdo_index /**< Index of mapped PDO */) |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1452 |
{ |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1453 |
ec_pdo_t *pdo; |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1454 |
ec_sync_t *sync; |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1455 |
unsigned int not_found = 1; |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1456 |
|
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1457 |
if (!(slave->sii_mailbox_protocols & EC_MBOX_COE)) { |
660
582a90a34303
Configure alternative PDO mapping only on slaves that have PDO sync
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
1458 |
EC_ERR("Slave %u does not support CoE!\n", slave->ring_position); |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1459 |
return -1; |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1460 |
} |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1461 |
|
747 | 1462 |
// does the slave provide the PDO? |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1463 |
list_for_each_entry(pdo, &slave->sii_pdos, list) { |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1464 |
if (pdo->index == pdo_index) { |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1465 |
not_found = 0; |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1466 |
break; |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1467 |
} |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1468 |
} |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1469 |
|
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1470 |
if (not_found) { |
660
582a90a34303
Configure alternative PDO mapping only on slaves that have PDO sync
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
1471 |
EC_ERR("Slave %u does not provide PDO 0x%04X!\n", |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1472 |
slave->ring_position, pdo_index); |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1473 |
return -1; |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1474 |
} |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1475 |
|
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1476 |
// check direction |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1477 |
if ((pdo->type == EC_TX_PDO && dir == EC_DIR_OUTPUT) || |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1478 |
(pdo->type == EC_RX_PDO && dir == EC_DIR_INPUT)) { |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1479 |
EC_ERR("Invalid direction for PDO 0x%04X.\n", pdo_index); |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1480 |
return -1; |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1481 |
} |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1482 |
|
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1483 |
|
660
582a90a34303
Configure alternative PDO mapping only on slaves that have PDO sync
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
1484 |
if (!(sync = ec_slave_get_pdo_sync(slave, dir))) { |
582a90a34303
Configure alternative PDO mapping only on slaves that have PDO sync
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
1485 |
EC_ERR("Failed to obtain sync manager for PDO mapping of slave %u!\n", |
582a90a34303
Configure alternative PDO mapping only on slaves that have PDO sync
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
1486 |
slave->ring_position); |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1487 |
return -1; |
660
582a90a34303
Configure alternative PDO mapping only on slaves that have PDO sync
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
1488 |
} |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1489 |
|
746
ef0f6eb5cd7c
Minor: Again moved setting of alternate PDO mapping flag.
Florian Pose <fp@igh-essen.com>
parents:
745
diff
changeset
|
1490 |
if (ec_sync_add_pdo(sync, pdo)) |
ef0f6eb5cd7c
Minor: Again moved setting of alternate PDO mapping flag.
Florian Pose <fp@igh-essen.com>
parents:
745
diff
changeset
|
1491 |
return -1; |
ef0f6eb5cd7c
Minor: Again moved setting of alternate PDO mapping flag.
Florian Pose <fp@igh-essen.com>
parents:
745
diff
changeset
|
1492 |
|
ef0f6eb5cd7c
Minor: Again moved setting of alternate PDO mapping flag.
Florian Pose <fp@igh-essen.com>
parents:
745
diff
changeset
|
1493 |
sync->alt_mapping = 1; |
ef0f6eb5cd7c
Minor: Again moved setting of alternate PDO mapping flag.
Florian Pose <fp@igh-essen.com>
parents:
745
diff
changeset
|
1494 |
return 0; |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1495 |
} |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1496 |
|
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1497 |
/*****************************************************************************/ |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1498 |
|
758
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
1499 |
/** |
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
1500 |
* Convenience function for ecrt_slave_pdo_mapping_clear() and |
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
1501 |
* ecrt_slave_pdo_mapping_add(). |
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
1502 |
*/ |
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
1503 |
|
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1504 |
int ecrt_slave_pdo_mapping(ec_slave_t *slave, /**< EtherCAT slave */ |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1505 |
ec_direction_t dir, /**< input/output */ |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1506 |
unsigned int num_args, /**< Number of following arguments */ |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1507 |
... /**< PDO indices to map */ |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1508 |
) |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1509 |
{ |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1510 |
va_list ap; |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1511 |
|
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1512 |
ecrt_slave_pdo_mapping_clear(slave, dir); |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1513 |
|
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1514 |
va_start(ap, num_args); |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1515 |
|
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1516 |
for (; num_args; num_args--) { |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1517 |
if (ecrt_slave_pdo_mapping_add( |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1518 |
slave, dir, (uint16_t) va_arg(ap, int))) { |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1519 |
return -1; |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1520 |
} |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1521 |
} |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1522 |
|
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1523 |
va_end(ap); |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1524 |
return 0; |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1525 |
} |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1526 |
|
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1527 |
|
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1528 |
/*****************************************************************************/ |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1529 |
|
526 | 1530 |
/** \cond */ |
164
ed85368b2b2e
AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents:
163
diff
changeset
|
1531 |
|
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1532 |
EXPORT_SYMBOL(ecrt_slave_conf_sdo8); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1533 |
EXPORT_SYMBOL(ecrt_slave_conf_sdo16); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1534 |
EXPORT_SYMBOL(ecrt_slave_conf_sdo32); |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1535 |
EXPORT_SYMBOL(ecrt_slave_pdo_mapping_clear); |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1536 |
EXPORT_SYMBOL(ecrt_slave_pdo_mapping_add); |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1537 |
EXPORT_SYMBOL(ecrt_slave_pdo_mapping); |
138
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
136
diff
changeset
|
1538 |
|
526 | 1539 |
/** \endcond */ |
1540 |
||
1541 |
/*****************************************************************************/ |