author | Florian Pose <fp@igh-essen.com> |
Fri, 06 Jun 2008 09:22:19 +0000 | |
changeset 963 | 01702c78fe0a |
parent 960 | 36e460ffbb5e |
child 964 | 957f21465052 |
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" |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
45 |
#include "datagram.h" |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
91
diff
changeset
|
46 |
#include "master.h" |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
47 |
#include "slave_config.h" |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
48 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
49 |
#include "slave.h" |
0 | 50 |
|
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
26
diff
changeset
|
51 |
/*****************************************************************************/ |
0 | 52 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
53 |
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
|
54 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
55 |
/*****************************************************************************/ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
56 |
|
404
7f7f429e13c7
Removed clear functions from headers of kobject-classes.
Florian Pose <fp@igh-essen.com>
parents:
403
diff
changeset
|
57 |
void ec_slave_clear(struct kobject *); |
482
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
58 |
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
|
59 |
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
|
60 |
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
|
61 |
const char *, size_t); |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
62 |
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
|
63 |
|
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
64 |
/*****************************************************************************/ |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
65 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
66 |
/** \cond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
67 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
68 |
EC_SYSFS_READ_ATTR(info); |
872 | 69 |
EC_SYSFS_READ_WRITE_ATTR(sii); |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
70 |
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
|
71 |
|
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
72 |
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
|
73 |
&attr_info, |
872 | 74 |
&attr_sii, |
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 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
116 |
slave->config = NULL; |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
649
diff
changeset
|
117 |
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
|
118 |
slave->current_state = EC_SLAVE_STATE_UNKNOWN; |
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; |
908
386b908033be
Replaced self_configured flag with force_config flag.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
120 |
slave->force_config = 0; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
121 |
|
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
122 |
slave->base_type = 0; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
123 |
slave->base_revision = 0; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
124 |
slave->base_build = 0; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
125 |
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
|
126 |
|
872 | 127 |
slave->sii_data = NULL; |
128 |
slave->sii_size = 0; |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
129 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
130 |
slave->sii.alias = 0; |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
131 |
slave->sii.vendor_id = 0; |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
132 |
slave->sii.product_code = 0; |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
133 |
slave->sii.revision_number = 0; |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
134 |
slave->sii.serial_number = 0; |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
135 |
slave->sii.rx_mailbox_offset = 0; |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
136 |
slave->sii.rx_mailbox_size = 0; |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
137 |
slave->sii.tx_mailbox_offset = 0; |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
138 |
slave->sii.tx_mailbox_size = 0; |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
139 |
slave->sii.mailbox_protocols = 0; |
835
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
140 |
|
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
141 |
slave->sii.strings = NULL; |
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
142 |
slave->sii.string_count = 0; |
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
143 |
|
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
144 |
slave->sii.has_general = 0; |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
145 |
slave->sii.group = NULL; |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
146 |
slave->sii.image = NULL; |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
147 |
slave->sii.order = NULL; |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
148 |
slave->sii.name = NULL; |
835
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
149 |
memset(&slave->sii.coe_details, 0x00, sizeof(ec_sii_coe_details_t)); |
836 | 150 |
memset(&slave->sii.general_flags, 0x00, sizeof(ec_sii_general_flags_t)); |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
151 |
slave->sii.current_on_ebus = 0; |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
152 |
|
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
153 |
slave->sii.syncs = NULL; |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
154 |
slave->sii.sync_count = 0; |
835
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
155 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
156 |
INIT_LIST_HEAD(&slave->sii.pdos); |
835
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
157 |
|
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
133
diff
changeset
|
158 |
INIT_LIST_HEAD(&slave->sdo_dictionary); |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
159 |
|
419
cf724fc82a00
Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents:
418
diff
changeset
|
160 |
slave->sdo_dictionary_fetched = 0; |
cf724fc82a00
Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents:
418
diff
changeset
|
161 |
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
|
162 |
|
183
8ae1e011e96c
More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents:
182
diff
changeset
|
163 |
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
|
164 |
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
|
165 |
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
|
166 |
slave->dl_signal[i] = 0; |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
167 |
slave->sii.physical_layer[i] = 0xFF; |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
168 |
} |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
169 |
|
484
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
170 |
// init kobject and add it to the hierarchy |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
171 |
memset(&slave->kobj, 0x00, sizeof(struct kobject)); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
172 |
kobject_init(&slave->kobj); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
173 |
slave->kobj.ktype = &ktype_ec_slave; |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
174 |
slave->kobj.parent = &master->kobj; |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
175 |
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
|
176 |
EC_ERR("Failed to set kobject name.\n"); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
177 |
goto out_slave_put; |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
178 |
} |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
179 |
if (kobject_add(&slave->kobj)) { |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
180 |
EC_ERR("Failed to add slave's kobject.\n"); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
181 |
goto out_slave_put; |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
182 |
} |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
183 |
|
814 | 184 |
// init Sdo kobject and add it to the hierarchy |
484
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
185 |
memset(&slave->sdo_kobj, 0x00, sizeof(struct kobject)); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
186 |
kobject_init(&slave->sdo_kobj); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
187 |
slave->sdo_kobj.ktype = &ktype_ec_slave_sdos; |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
188 |
slave->sdo_kobj.parent = &slave->kobj; |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
189 |
if (kobject_set_name(&slave->sdo_kobj, "sdos")) { |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
190 |
EC_ERR("Failed to set kobject name.\n"); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
191 |
goto out_sdo_put; |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
192 |
} |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
193 |
if (kobject_add(&slave->sdo_kobj)) { |
814 | 194 |
EC_ERR("Failed to add Sdos kobject.\n"); |
484
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
195 |
goto out_sdo_put; |
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 |
|
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
198 |
return 0; |
484
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
199 |
|
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
200 |
out_sdo_put: |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
201 |
kobject_put(&slave->sdo_kobj); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
202 |
kobject_del(&slave->kobj); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
203 |
out_slave_put: |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
204 |
kobject_put(&slave->kobj); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
205 |
return -1; |
73
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 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
208 |
/*****************************************************************************/ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
209 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
210 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
211 |
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
|
212 |
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
|
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 |
|
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 |
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
|
216 |
{ |
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 |
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
|
218 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
219 |
if (slave->config) |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
220 |
ec_slave_config_detach(slave->config); |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
221 |
|
814 | 222 |
// free all Sdos |
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
|
223 |
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
|
224 |
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
|
225 |
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
|
226 |
} |
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 |
|
814 | 228 |
// free Sdo kobject |
484
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
229 |
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
|
230 |
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
|
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 |
// 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
|
233 |
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
|
234 |
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
|
235 |
} |
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 |
|
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
237 |
/*****************************************************************************/ |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
238 |
|
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
239 |
/** |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
240 |
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
|
241 |
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
|
242 |
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
|
243 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
244 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
245 |
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
|
246 |
{ |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
247 |
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
|
248 |
ec_pdo_t *pdo, *next_pdo; |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
249 |
unsigned int i; |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
250 |
|
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
251 |
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
|
252 |
|
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
253 |
// free all strings |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
254 |
if (slave->sii.strings) { |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
255 |
for (i = 0; i < slave->sii.string_count; i++) |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
256 |
kfree(slave->sii.strings[i]); |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
257 |
kfree(slave->sii.strings); |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
258 |
} |
121
1cd6f7a47b72
Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents:
119
diff
changeset
|
259 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
260 |
// free all sync managers |
870
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
261 |
ec_slave_clear_sync_managers(slave); |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
262 |
|
814 | 263 |
// free all SII Pdos |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
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 |
|
872 | 270 |
if (slave->sii_data) |
271 |
kfree(slave->sii_data); |
|
418
7a43437bc48b
Fixed memory leak in master and slave destructors.
Florian Pose <fp@igh-essen.com>
parents:
416
diff
changeset
|
272 |
|
7a43437bc48b
Fixed memory leak in master and slave destructors.
Florian Pose <fp@igh-essen.com>
parents:
416
diff
changeset
|
273 |
kfree(slave); |
121
1cd6f7a47b72
Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents:
119
diff
changeset
|
274 |
} |
1cd6f7a47b72
Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents:
119
diff
changeset
|
275 |
|
1cd6f7a47b72
Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents:
119
diff
changeset
|
276 |
/*****************************************************************************/ |
1cd6f7a47b72
Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents:
119
diff
changeset
|
277 |
|
1cd6f7a47b72
Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents:
119
diff
changeset
|
278 |
/** |
814 | 279 |
* Sdo kobject clear method. |
758
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
280 |
*/ |
482
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
281 |
|
814 | 282 |
void ec_slave_sdos_clear(struct kobject *kobj /**< kobject for Sdos */) |
482
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
283 |
{ |
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
284 |
} |
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
285 |
|
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
286 |
/*****************************************************************************/ |
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
287 |
|
870
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
288 |
/** Clear the sync manager array. |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
289 |
*/ |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
290 |
void ec_slave_clear_sync_managers(ec_slave_t *slave /**< EtherCAT slave. */) |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
291 |
{ |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
292 |
unsigned int i; |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
293 |
|
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
294 |
if (slave->sii.syncs) { |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
295 |
for (i = 0; i < slave->sii.sync_count; i++) { |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
296 |
ec_sync_clear(&slave->sii.syncs[i]); |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
297 |
} |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
298 |
kfree(slave->sii.syncs); |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
299 |
slave->sii.syncs = NULL; |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
300 |
} |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
301 |
} |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
302 |
|
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
303 |
/*****************************************************************************/ |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
304 |
|
482
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
305 |
/** |
610
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
306 |
* 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
|
307 |
*/ |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
308 |
|
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
309 |
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
|
310 |
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
|
311 |
) |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
312 |
{ |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
313 |
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
|
314 |
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
|
315 |
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
|
316 |
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
|
317 |
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
|
318 |
ec_state_string(new_state, cur_state); |
784
0a0994fdafb8
Esthetic surgery for slave.
Florian Pose <fp@igh-essen.com>
parents:
772
diff
changeset
|
319 |
EC_DBG("Slave %u: %s -> %s.\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
|
320 |
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
|
321 |
} |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
322 |
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
|
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 |
|
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
326 |
/*****************************************************************************/ |
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 |
/** |
758
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
329 |
* Request a slave state and resets the error flag. |
446 | 330 |
*/ |
331 |
||
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
332 |
void ec_slave_request_state(ec_slave_t *slave, /**< EtherCAT slave */ |
446 | 333 |
ec_slave_state_t state /**< new state */ |
334 |
) |
|
335 |
{ |
|
336 |
slave->requested_state = state; |
|
337 |
slave->error_flag = 0; |
|
338 |
} |
|
339 |
||
340 |
/*****************************************************************************/ |
|
341 |
||
342 |
/** |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
343 |
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
|
344 |
\todo range checking |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
345 |
\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
|
346 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
347 |
|
620
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
348 |
int ec_slave_fetch_sii_strings( |
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
349 |
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
|
350 |
const uint8_t *data, /**< category data */ |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
351 |
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
|
352 |
) |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
353 |
{ |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
354 |
int i; |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
355 |
size_t size; |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
356 |
off_t offset; |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
357 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
358 |
slave->sii.string_count = data[0]; |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
359 |
|
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
360 |
if (!slave->sii.string_count) |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
361 |
return 0; |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
362 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
363 |
if (!(slave->sii.strings = |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
364 |
kmalloc(sizeof(char *) * slave->sii.string_count, |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
365 |
GFP_KERNEL))) { |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
366 |
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
|
367 |
goto out_zero; |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
368 |
} |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
369 |
|
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
370 |
offset = 1; |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
371 |
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
|
372 |
size = data[offset]; |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
373 |
// allocate memory for string structure and data at a single blow |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
374 |
if (!(slave->sii.strings[i] = |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
375 |
kmalloc(sizeof(char) * size + 1, GFP_KERNEL))) { |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
376 |
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
|
377 |
goto out_free; |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
378 |
} |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
379 |
memcpy(slave->sii.strings[i], data + offset + 1, size); |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
380 |
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
|
381 |
offset += 1 + size; |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
382 |
} |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
383 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
384 |
return 0; |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
385 |
|
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
386 |
out_free: |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
387 |
for (i--; i >= 0; i--) kfree(slave->sii.strings[i]); |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
388 |
kfree(slave->sii.strings); |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
389 |
slave->sii.strings = NULL; |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
390 |
out_zero: |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
391 |
slave->sii.string_count = 0; |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
392 |
return -1; |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
393 |
} |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
394 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
395 |
/*****************************************************************************/ |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
396 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
397 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
398 |
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
|
399 |
\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
|
400 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
401 |
|
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
402 |
int ec_slave_fetch_sii_general( |
620
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
403 |
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
|
404 |
const uint8_t *data, /**< category data */ |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
405 |
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
|
406 |
) |
123 | 407 |
{ |
190
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
408 |
unsigned int i; |
876
8acdecb5a75e
Fixed general flags on big-endian archs.
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
409 |
uint8_t flags; |
190
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
410 |
|
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
411 |
if (data_size != 32) { |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
412 |
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
|
413 |
data_size, slave->ring_position); |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
414 |
return -1; |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
415 |
} |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
416 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
417 |
slave->sii.group = ec_slave_sii_string(slave, data[0]); |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
418 |
slave->sii.image = ec_slave_sii_string(slave, data[1]); |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
419 |
slave->sii.order = ec_slave_sii_string(slave, data[2]); |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
420 |
slave->sii.name = ec_slave_sii_string(slave, data[3]); |
123 | 421 |
|
190
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
422 |
for (i = 0; i < 4; i++) |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
423 |
slave->sii.physical_layer[i] = |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
424 |
(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
|
425 |
|
876
8acdecb5a75e
Fixed general flags on big-endian archs.
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
426 |
// read CoE details |
8acdecb5a75e
Fixed general flags on big-endian archs.
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
427 |
flags = EC_READ_U8(data + 5); |
8acdecb5a75e
Fixed general flags on big-endian archs.
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
428 |
slave->sii.coe_details.enable_sdo = (flags >> 0) & 0x01; |
8acdecb5a75e
Fixed general flags on big-endian archs.
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
429 |
slave->sii.coe_details.enable_sdo_info = (flags >> 1) & 0x01; |
8acdecb5a75e
Fixed general flags on big-endian archs.
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
430 |
slave->sii.coe_details.enable_pdo_assign = (flags >> 2) & 0x01; |
8acdecb5a75e
Fixed general flags on big-endian archs.
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
431 |
slave->sii.coe_details.enable_pdo_configuration = (flags >> 3) & 0x01; |
8acdecb5a75e
Fixed general flags on big-endian archs.
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
432 |
slave->sii.coe_details.enable_upload_at_startup = (flags >> 4) & 0x01; |
8acdecb5a75e
Fixed general flags on big-endian archs.
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
433 |
slave->sii.coe_details.enable_sdo_complete_access = (flags >> 5) & 0x01; |
8acdecb5a75e
Fixed general flags on big-endian archs.
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
434 |
|
8acdecb5a75e
Fixed general flags on big-endian archs.
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
435 |
// read general flags |
8acdecb5a75e
Fixed general flags on big-endian archs.
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
436 |
flags = EC_READ_U8(data + 0x000B); |
8acdecb5a75e
Fixed general flags on big-endian archs.
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
437 |
slave->sii.general_flags.enable_safeop = (flags >> 0) & 0x01; |
8acdecb5a75e
Fixed general flags on big-endian archs.
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
438 |
slave->sii.general_flags.enable_not_lrw = (flags >> 1) & 0x01; |
8acdecb5a75e
Fixed general flags on big-endian archs.
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
439 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
440 |
slave->sii.current_on_ebus = EC_READ_S16(data + 0x0C); |
835
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
441 |
slave->sii.has_general = 1; |
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
442 |
return 0; |
118
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 |
|
870
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
447 |
/** Fetches data from a SYNC MANAGER category. |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
448 |
* |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
449 |
* Appends the sync managers described in the category to the existing ones. |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
450 |
* |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
451 |
* \return 0 in case of success, else < 0 |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
452 |
*/ |
620
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
453 |
int ec_slave_fetch_sii_syncs( |
870
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
454 |
ec_slave_t *slave, /**< EtherCAT slave. */ |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
455 |
const uint8_t *data, /**< Category data. */ |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
456 |
size_t data_size /**< Number of bytes. */ |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
457 |
) |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
458 |
{ |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
459 |
unsigned int i, count, total_count; |
626
a5e838c30733
Renamed ec_sii_sync_t to ec_sync_t.
Florian Pose <fp@igh-essen.com>
parents:
625
diff
changeset
|
460 |
ec_sync_t *sync; |
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
461 |
size_t memsize; |
870
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
462 |
ec_sync_t *syncs; |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
463 |
uint8_t index; |
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
464 |
|
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
465 |
// 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
|
466 |
if (data_size % 8) { |
870
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
467 |
EC_ERR("Invalid SII sync manager category size %u in slave %u.\n", |
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
468 |
data_size, slave->ring_position); |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
469 |
return -1; |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
470 |
} |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
471 |
|
870
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
472 |
count = data_size / 8; |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
473 |
|
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
474 |
if (count) { |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
475 |
total_count = count + slave->sii.sync_count; |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
476 |
memsize = sizeof(ec_sync_t) * total_count; |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
477 |
if (!(syncs = kmalloc(memsize, GFP_KERNEL))) { |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
478 |
EC_ERR("Failed to allocate %u bytes for sync managers.\n", |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
479 |
memsize); |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
480 |
return -1; |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
481 |
} |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
482 |
|
873
ec01ba291896
Fixed bug in copying sync managers. Now making a deep copy.
Florian Pose <fp@igh-essen.com>
parents:
872
diff
changeset
|
483 |
for (i = 0; i < slave->sii.sync_count; i++) |
ec01ba291896
Fixed bug in copying sync managers. Now making a deep copy.
Florian Pose <fp@igh-essen.com>
parents:
872
diff
changeset
|
484 |
ec_sync_init_copy(syncs + i, slave->sii.syncs + i); |
870
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
485 |
|
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
486 |
// initialize new sync managers |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
487 |
for (i = 0; i < count; i++, data += 8) { |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
488 |
index = i + slave->sii.sync_count; |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
489 |
sync = &syncs[index]; |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
490 |
|
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
491 |
ec_sync_init(sync, slave, index); |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
492 |
sync->physical_start_address = EC_READ_U16(data); |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
493 |
sync->length = EC_READ_U16(data + 2); |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
494 |
sync->control_register = EC_READ_U8(data + 4); |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
495 |
sync->enable = EC_READ_U8(data + 6); |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
496 |
} |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
497 |
|
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
498 |
if (slave->sii.syncs) |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
499 |
kfree(slave->sii.syncs); |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
500 |
slave->sii.syncs = syncs; |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
501 |
slave->sii.sync_count = total_count; |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
502 |
} |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
503 |
|
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
504 |
return 0; |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
505 |
} |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
506 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
507 |
/*****************************************************************************/ |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
508 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
509 |
/** |
814 | 510 |
Fetches data from a [RT]XPdo category. |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
511 |
\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
|
512 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
513 |
|
620
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
514 |
int ec_slave_fetch_sii_pdos( |
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
515 |
ec_slave_t *slave, /**< EtherCAT slave */ |
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
516 |
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
|
517 |
size_t data_size, /**< number of bytes */ |
814 | 518 |
ec_direction_t dir /**< Pdo direction. */ |
620
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
519 |
) |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
520 |
{ |
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
|
521 |
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
|
522 |
ec_pdo_entry_t *entry; |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
523 |
unsigned int entry_count, i; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
524 |
|
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
525 |
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
|
526 |
if (!(pdo = kmalloc(sizeof(ec_pdo_t), GFP_KERNEL))) { |
814 | 527 |
EC_ERR("Failed to allocate Pdo memory.\n"); |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
528 |
return -1; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
529 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
530 |
|
627
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
626
diff
changeset
|
531 |
ec_pdo_init(pdo); |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
532 |
pdo->dir = dir; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
533 |
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
|
534 |
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
|
535 |
pdo->sync_index = EC_READ_U8(data + 3); |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
536 |
if (ec_pdo_set_name(pdo, |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
537 |
ec_slave_sii_string(slave, EC_READ_U8(data + 5)))) { |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
538 |
ec_pdo_clear(pdo); |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
539 |
kfree(pdo); |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
540 |
return -1; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
541 |
} |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
542 |
list_add_tail(&pdo->list, &slave->sii.pdos); |
126
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 |
data_size -= 8; |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
545 |
data += 8; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
546 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
547 |
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
|
548 |
if (!(entry = kmalloc(sizeof(ec_pdo_entry_t), GFP_KERNEL))) { |
814 | 549 |
EC_ERR("Failed to allocate Pdo entry memory.\n"); |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
550 |
return -1; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
551 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
552 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
553 |
ec_pdo_entry_init(entry); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
554 |
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
|
555 |
entry->subindex = EC_READ_U8(data + 2); |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
556 |
if (ec_pdo_entry_set_name(entry, |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
557 |
ec_slave_sii_string(slave, EC_READ_U8(data + 3)))) { |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
558 |
ec_pdo_entry_clear(entry); |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
559 |
kfree(entry); |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
560 |
return -1; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
561 |
} |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
562 |
entry->bit_length = EC_READ_U8(data + 5); |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
563 |
list_add_tail(&entry->list, &pdo->entries); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
564 |
|
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
565 |
data_size -= 8; |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
566 |
data += 8; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
567 |
} |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
568 |
|
814 | 569 |
// if sync manager index is positive, the Pdo is mapped by default |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
570 |
if (pdo->sync_index >= 0) { |
762
15214036c72a
Store PDO mapping source in sync manager.
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
571 |
ec_sync_t *sync; |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
572 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
573 |
if (pdo->sync_index >= slave->sii.sync_count) { |
814 | 574 |
EC_ERR("Invalid SM index %i for Pdo 0x%04X in slave %u.", |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
575 |
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
|
576 |
return -1; |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
577 |
} |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
578 |
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
|
579 |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
876
diff
changeset
|
580 |
if (ec_pdo_list_add_pdo_copy(&sync->pdos, pdo)) |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
581 |
return -1; |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
582 |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
876
diff
changeset
|
583 |
sync->assign_source = EC_ASSIGN_SII; |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
584 |
} |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
585 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
586 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
587 |
return 0; |
114 | 588 |
} |
589 |
||
590 |
/*****************************************************************************/ |
|
591 |
||
592 |
/** |
|
784
0a0994fdafb8
Esthetic surgery for slave.
Florian Pose <fp@igh-essen.com>
parents:
772
diff
changeset
|
593 |
Searches the string list for an index. |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
594 |
\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
|
595 |
*/ |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
596 |
|
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
597 |
char *ec_slave_sii_string( |
620
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
598 |
ec_slave_t *slave, /**< EtherCAT slave */ |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
599 |
unsigned int index /**< string index */ |
620
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
600 |
) |
123 | 601 |
{ |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
602 |
if (!index--) |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
603 |
return NULL; |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
604 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
605 |
if (index >= slave->sii.string_count) { |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
606 |
if (slave->master->debug_level) |
784
0a0994fdafb8
Esthetic surgery for slave.
Florian Pose <fp@igh-essen.com>
parents:
772
diff
changeset
|
607 |
EC_WARN("String %u not found in slave %u.\n", |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
608 |
index, slave->ring_position); |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
609 |
return NULL; |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
610 |
} |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
611 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
612 |
return slave->sii.strings[index]; |
123 | 613 |
} |
614 |
||
615 |
/*****************************************************************************/ |
|
616 |
||
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
617 |
/** Outputs all information about a certain slave. |
630
1b755b7342eb
Layed out FMMU structure and methods to own files.
Florian Pose <fp@igh-essen.com>
parents:
628
diff
changeset
|
618 |
*/ |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
619 |
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
|
620 |
char *buffer /**< Output buffer */ |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
621 |
) |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
622 |
{ |
871 | 623 |
const ec_sync_t *sync; |
624 |
const ec_pdo_t *pdo; |
|
625 |
const ec_pdo_entry_t *pdo_entry; |
|
142 | 626 |
int first, i; |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
627 |
char *large_buffer, *buf; |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
628 |
unsigned int size; |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
629 |
|
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
630 |
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
|
631 |
return -ENOMEM; |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
632 |
} |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
633 |
|
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
634 |
buf = large_buffer; |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
635 |
|
784
0a0994fdafb8
Esthetic surgery for slave.
Florian Pose <fp@igh-essen.com>
parents:
772
diff
changeset
|
636 |
buf += sprintf(buf, "Ring position: %u\n", |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
637 |
slave->ring_position); |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
638 |
buf += sprintf(buf, "State: "); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
639 |
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
|
640 |
buf += sprintf(buf, " ("); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
641 |
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
|
642 |
buf += sprintf(buf, ")\n"); |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
643 |
buf += sprintf(buf, "Flags: %s\n\n", 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
|
644 |
|
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
645 |
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
|
646 |
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
|
647 |
buf += sprintf(buf, " Port %u: Phy %u (", |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
648 |
i, slave->sii.physical_layer[i]); |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
649 |
switch (slave->sii.physical_layer[i]) { |
190
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
650 |
case 0x00: |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
651 |
buf += sprintf(buf, "EBUS"); |
190
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
652 |
break; |
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
653 |
case 0x01: |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
654 |
buf += sprintf(buf, "100BASE-TX"); |
190
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
655 |
break; |
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
656 |
case 0x02: |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
657 |
buf += sprintf(buf, "100BASE-FX"); |
190
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
658 |
break; |
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
659 |
default: |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
660 |
buf += sprintf(buf, "unknown"); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
661 |
} |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
662 |
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
|
663 |
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
|
664 |
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
|
665 |
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
|
666 |
} |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
667 |
buf += sprintf(buf, "\n"); |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
668 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
669 |
if (slave->sii.alias) |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
670 |
buf += sprintf(buf, "Configured station alias:" |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
671 |
" 0x%04X (%u)\n\n", slave->sii.alias, slave->sii.alias); |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
672 |
|
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
673 |
buf += sprintf(buf, "Identity:\n"); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
674 |
buf += sprintf(buf, " Vendor ID: 0x%08X (%u)\n", |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
675 |
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
|
676 |
buf += sprintf(buf, " Product code: 0x%08X (%u)\n", |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
677 |
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
|
678 |
buf += sprintf(buf, " Revision number: 0x%08X (%u)\n", |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
679 |
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
|
680 |
buf += sprintf(buf, " Serial number: 0x%08X (%u)\n\n", |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
681 |
slave->sii.serial_number, slave->sii.serial_number); |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
682 |
|
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
683 |
if (slave->sii.mailbox_protocols) { |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
684 |
buf += sprintf(buf, "Mailboxes:\n"); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
685 |
buf += sprintf(buf, " RX: 0x%04X/%u, TX: 0x%04X/%u\n", |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
686 |
slave->sii.rx_mailbox_offset, slave->sii.rx_mailbox_size, |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
687 |
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
|
688 |
buf += sprintf(buf, " Supported protocols: "); |
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
689 |
|
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
690 |
first = 1; |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
691 |
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
|
692 |
buf += sprintf(buf, "AoE"); |
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
693 |
first = 0; |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
694 |
} |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
695 |
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
|
696 |
if (!first) buf += sprintf(buf, ", "); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
697 |
buf += sprintf(buf, "EoE"); |
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
698 |
first = 0; |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
699 |
} |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
700 |
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
|
701 |
if (!first) buf += sprintf(buf, ", "); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
702 |
buf += sprintf(buf, "CoE"); |
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
703 |
first = 0; |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
704 |
} |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
705 |
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
|
706 |
if (!first) buf += sprintf(buf, ", "); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
707 |
buf += sprintf(buf, "FoE"); |
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
708 |
first = 0; |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
709 |
} |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
710 |
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
|
711 |
if (!first) buf += sprintf(buf, ", "); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
712 |
buf += sprintf(buf, "SoE"); |
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
713 |
first = 0; |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
714 |
} |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
715 |
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
|
716 |
if (!first) buf += sprintf(buf, ", "); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
717 |
buf += sprintf(buf, "VoE"); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
718 |
} |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
719 |
buf += sprintf(buf, "\n\n"); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
720 |
} |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
721 |
|
835
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
722 |
if (slave->sii.has_general) { |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
723 |
buf += sprintf(buf, "General:\n"); |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
724 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
725 |
if (slave->sii.group) |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
726 |
buf += sprintf(buf, " Group: %s\n", slave->sii.group); |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
727 |
if (slave->sii.image) |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
728 |
buf += sprintf(buf, " Image: %s\n", slave->sii.image); |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
729 |
if (slave->sii.order) |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
730 |
buf += sprintf(buf, " Order number: %s\n", |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
731 |
slave->sii.order); |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
732 |
if (slave->sii.name) |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
733 |
buf += sprintf(buf, " Name: %s\n", slave->sii.name); |
835
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
734 |
if (slave->sii.mailbox_protocols & EC_MBOX_COE) { |
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
735 |
buf += sprintf(buf, " CoE details:\n"); |
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
736 |
buf += sprintf(buf, " Enable Sdo: %s\n", |
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
737 |
slave->sii.coe_details.enable_sdo ? "yes" : "no"); |
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
738 |
buf += sprintf(buf, " Enable Sdo Info: %s\n", |
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
739 |
slave->sii.coe_details.enable_sdo_info ? "yes" : "no"); |
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
740 |
buf += sprintf(buf, " Enable Pdo Assign: %s\n", |
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
741 |
slave->sii.coe_details.enable_pdo_assign ? "yes" : "no"); |
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
742 |
buf += sprintf(buf, " Enable Pdo Configuration: %s\n", |
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
743 |
slave->sii.coe_details.enable_pdo_configuration ? |
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
744 |
"yes" : "no"); |
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
745 |
buf += sprintf(buf, " Enable Upload at startup: %s\n", |
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
746 |
slave->sii.coe_details.enable_upload_at_startup ? |
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
747 |
"yes" : "no"); |
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
748 |
buf += sprintf(buf, " Enable Sdo complete access: %s\n", |
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
749 |
slave->sii.coe_details.enable_sdo_complete_access |
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
750 |
? "yes" : "no"); |
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
751 |
} |
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
752 |
|
836 | 753 |
buf += sprintf(buf, " Flags:\n"); |
754 |
buf += sprintf(buf, " Enable SafeOp: %s\n", |
|
755 |
slave->sii.general_flags.enable_safeop ? "yes" : "no"); |
|
756 |
buf += sprintf(buf, " Enable notLRW: %s\n", |
|
757 |
slave->sii.general_flags.enable_not_lrw ? "yes" : "no"); |
|
835
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
758 |
buf += sprintf(buf, " Current consumption: %i mA\n\n", |
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
759 |
slave->sii.current_on_ebus); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
760 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
761 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
762 |
if (slave->sii.sync_count) { |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
876
diff
changeset
|
763 |
buf += sprintf(buf, "Sync managers / assigned Pdos:\n"); |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
764 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
765 |
for (i = 0; i < slave->sii.sync_count; i++) { |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
766 |
sync = &slave->sii.syncs[i]; |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
767 |
buf += sprintf(buf, |
784
0a0994fdafb8
Esthetic surgery for slave.
Florian Pose <fp@igh-essen.com>
parents:
772
diff
changeset
|
768 |
" SM%u: addr 0x%04X, size %u, control 0x%02X, %s\n", |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
769 |
sync->index, sync->physical_start_address, |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
770 |
sync->length, sync->control_register, |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
771 |
sync->enable ? "enable" : "disable"); |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
772 |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
876
diff
changeset
|
773 |
if (list_empty(&sync->pdos.list)) { |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
876
diff
changeset
|
774 |
buf += sprintf(buf, " No Pdos assigned.\n"); |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
876
diff
changeset
|
775 |
} else if (sync->assign_source != EC_ASSIGN_NONE) { |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
876
diff
changeset
|
776 |
buf += sprintf(buf, " Pdo assignment from "); |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
876
diff
changeset
|
777 |
switch (sync->assign_source) { |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
876
diff
changeset
|
778 |
case EC_ASSIGN_SII: |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
876
diff
changeset
|
779 |
buf += sprintf(buf, "SII"); |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
876
diff
changeset
|
780 |
break; |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
876
diff
changeset
|
781 |
case EC_ASSIGN_COE: |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
876
diff
changeset
|
782 |
buf += sprintf(buf, "CoE"); |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
876
diff
changeset
|
783 |
break; |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
876
diff
changeset
|
784 |
case EC_ASSIGN_CUSTOM: |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
876
diff
changeset
|
785 |
buf += sprintf(buf, "application"); |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
876
diff
changeset
|
786 |
break; |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
876
diff
changeset
|
787 |
default: |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
876
diff
changeset
|
788 |
buf += sprintf(buf, "?"); |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
876
diff
changeset
|
789 |
break; |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
876
diff
changeset
|
790 |
} |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
876
diff
changeset
|
791 |
buf += sprintf(buf, ".\n"); |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
792 |
} |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
793 |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
876
diff
changeset
|
794 |
list_for_each_entry(pdo, &sync->pdos.list, list) { |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
795 |
buf += sprintf(buf, " %s 0x%04X \"%s\"\n", |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
796 |
pdo->dir == EC_DIR_OUTPUT ? "RxPdo" : "TxPdo", |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
797 |
pdo->index, pdo->name ? pdo->name : "???"); |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
798 |
|
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
799 |
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
|
800 |
buf += sprintf(buf, |
926
6bb33c6ec770
Output subindices with %02X.
Florian Pose <fp@igh-essen.com>
parents:
912
diff
changeset
|
801 |
" 0x%04X:%02X, %u bit, \"%s\"\n", |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
802 |
pdo_entry->index, pdo_entry->subindex, |
926
6bb33c6ec770
Output subindices with %02X.
Florian Pose <fp@igh-essen.com>
parents:
912
diff
changeset
|
803 |
pdo_entry->bit_length, |
6bb33c6ec770
Output subindices with %02X.
Florian Pose <fp@igh-essen.com>
parents:
912
diff
changeset
|
804 |
pdo_entry->name ? pdo_entry->name : "???"); |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
805 |
} |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
806 |
} |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
807 |
} |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
808 |
buf += sprintf(buf, "\n"); |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
809 |
} |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
810 |
|
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
811 |
// type-cast to avoid warnings on some compilers |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
812 |
if (!list_empty((struct list_head *) &slave->sii.pdos)) { |
814 | 813 |
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
|
814 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
815 |
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
|
816 |
buf += sprintf(buf, " %s 0x%04X \"%s\"", |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
817 |
pdo->dir == EC_DIR_OUTPUT ? "RxPdo" : "TxPdo", |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
818 |
pdo->index, pdo->name ? pdo->name : "???"); |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
819 |
if (pdo->sync_index >= 0) |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
876
diff
changeset
|
820 |
buf += sprintf(buf, ", default assignment: SM%u.\n", |
763
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
821 |
pdo->sync_index); |
5e238783b71a
Re-ordered slave info file.
Florian Pose <fp@igh-essen.com>
parents:
762
diff
changeset
|
822 |
else |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
876
diff
changeset
|
823 |
buf += sprintf(buf, ", no default assignment.\n"); |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
824 |
|
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
825 |
list_for_each_entry(pdo_entry, &pdo->entries, list) { |
926
6bb33c6ec770
Output subindices with %02X.
Florian Pose <fp@igh-essen.com>
parents:
912
diff
changeset
|
826 |
buf += sprintf(buf, " 0x%04X:%02X, %u bit, \"%s\"\n", |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
827 |
pdo_entry->index, pdo_entry->subindex, |
926
6bb33c6ec770
Output subindices with %02X.
Florian Pose <fp@igh-essen.com>
parents:
912
diff
changeset
|
828 |
pdo_entry->bit_length, |
6bb33c6ec770
Output subindices with %02X.
Florian Pose <fp@igh-essen.com>
parents:
912
diff
changeset
|
829 |
pdo_entry->name ? pdo_entry->name : "???"); |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
830 |
} |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
831 |
} |
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
832 |
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
|
833 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
834 |
|
772
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
835 |
size = buf - large_buffer; |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
836 |
if (size >= PAGE_SIZE) { |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
837 |
const char trunc[] = "\n---TRUNCATED---\n"; |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
838 |
unsigned int len = strlen(trunc); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
839 |
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
|
840 |
} |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
841 |
|
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
842 |
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
|
843 |
memcpy(buffer, large_buffer, size); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
844 |
kfree(large_buffer); |
6c29e74d6763
Detection of page exceeding slave information file.
Florian Pose <fp@igh-essen.com>
parents:
765
diff
changeset
|
845 |
return size; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
846 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
847 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
848 |
/*****************************************************************************/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
849 |
|
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
|
850 |
/** |
872 | 851 |
* Schedules an SII write request. |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
852 |
* \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
|
853 |
*/ |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
854 |
|
872 | 855 |
int ec_slave_schedule_sii_writing( |
856 |
ec_sii_write_request_t *request /**< SII write request */ |
|
758
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
857 |
) |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
858 |
{ |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
859 |
ec_master_t *master = request->slave->master; |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
860 |
|
649
a4d3fffdaed7
Renamed names of enum type ec_request_state_t.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
861 |
request->state = EC_REQUEST_QUEUED; |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
862 |
|
872 | 863 |
// schedule SII write request. |
864 |
down(&master->sii_sem); |
|
865 |
list_add_tail(&request->list, &master->sii_requests); |
|
866 |
up(&master->sii_sem); |
|
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
867 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
868 |
// wait for processing through FSM |
872 | 869 |
if (wait_event_interruptible(master->sii_queue, |
649
a4d3fffdaed7
Renamed names of enum type ec_request_state_t.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
870 |
request->state != EC_REQUEST_QUEUED)) { |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
871 |
// interrupted by signal |
872 | 872 |
down(&master->sii_sem); |
649
a4d3fffdaed7
Renamed names of enum type ec_request_state_t.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
873 |
if (request->state == EC_REQUEST_QUEUED) { |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
874 |
list_del(&request->list); |
872 | 875 |
up(&master->sii_sem); |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
876 |
return -EINTR; |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
877 |
} |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
878 |
// request already processing: interrupt not possible. |
872 | 879 |
up(&master->sii_sem); |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
880 |
} |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
881 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
882 |
// wait until master FSM has finished processing |
872 | 883 |
wait_event(master->sii_queue, |
861
6e3de145421a
Introduced ec_sdo_request_state_t, making ec_request_t private again;
Florian Pose <fp@igh-essen.com>
parents:
856
diff
changeset
|
884 |
request->state != EC_REQUEST_BUSY); |
6e3de145421a
Introduced ec_sdo_request_state_t, making ec_request_t private again;
Florian Pose <fp@igh-essen.com>
parents:
856
diff
changeset
|
885 |
|
6e3de145421a
Introduced ec_sdo_request_state_t, making ec_request_t private again;
Florian Pose <fp@igh-essen.com>
parents:
856
diff
changeset
|
886 |
return request->state == EC_REQUEST_SUCCESS ? 0 : -EIO; |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
887 |
} |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
888 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
889 |
/*****************************************************************************/ |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
890 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
891 |
/** |
872 | 892 |
* Calculates the SII checksum field. |
735
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
893 |
* |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
894 |
* 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
|
895 |
* 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
|
896 |
* |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
897 |
* 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
|
898 |
* http://www.tty1.net/pycrc |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
899 |
* |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
900 |
* ./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
|
901 |
* --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
|
902 |
* |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
903 |
* \return CRC8 |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
904 |
*/ |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
905 |
|
872 | 906 |
uint8_t ec_slave_sii_crc( |
758
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
907 |
const uint8_t *data, /**< pointer to data */ |
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
908 |
size_t length /**< number of bytes in \a data */ |
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
909 |
) |
735
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
910 |
{ |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
911 |
unsigned int i; |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
912 |
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
|
913 |
|
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
914 |
while (length--) { |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
915 |
byte = *data++; |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
916 |
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
|
917 |
bit = crc & 0x80; |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
918 |
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
|
919 |
if (bit) crc ^= 0x07; |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
920 |
} |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
921 |
} |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
922 |
|
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
923 |
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
|
924 |
bit = crc & 0x80; |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
925 |
crc <<= 1; |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
926 |
if (bit) crc ^= 0x07; |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
927 |
} |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
928 |
|
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
929 |
return crc; |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
930 |
} |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
931 |
|
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
932 |
/*****************************************************************************/ |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
933 |
|
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
934 |
/** |
872 | 935 |
* Writes complete SII contents to a slave. |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
936 |
* \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
|
937 |
*/ |
269 | 938 |
|
872 | 939 |
ssize_t ec_slave_write_sii(ec_slave_t *slave, /**< EtherCAT slave */ |
940 |
const uint8_t *data, /**< new SII data */ |
|
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
941 |
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
|
942 |
) |
269 | 943 |
{ |
872 | 944 |
ec_sii_write_request_t request; |
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
945 |
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
|
946 |
uint16_t cat_type, cat_size; |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
947 |
int ret; |
735
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
948 |
uint8_t crc; |
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
949 |
|
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
950 |
if (slave->master->mode != EC_MASTER_MODE_IDLE) { // FIXME |
872 | 951 |
EC_ERR("Writing SIIs 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
|
952 |
return -EBUSY; |
269 | 953 |
} |
954 |
||
955 |
if (size % 2) { |
|
872 | 956 |
EC_ERR("SII data size is odd (%u bytes)! SII data must be" |
856
7b8be5c61d92
Improved error messages on EEPROM writing.
Florian Pose <fp@igh-essen.com>
parents:
839
diff
changeset
|
957 |
" word-aligned. Dropping.\n", size); |
599
a6ce861a167e
ec_slave_write_eeprom now returns certain error codes.
Florian Pose <fp@igh-essen.com>
parents:
597
diff
changeset
|
958 |
return -EINVAL; |
269 | 959 |
} |
960 |
||
872 | 961 |
// init SII write request |
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
962 |
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
|
963 |
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
|
964 |
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
|
965 |
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
|
966 |
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
|
967 |
|
0b47b49c5976
Changed unit of ec_eeprom_write_request_t from word to byte.
Florian Pose <fp@igh-essen.com>
parents:
750
diff
changeset
|
968 |
if (request.word_size < 0x0041) { |
872 | 969 |
EC_ERR("SII data too short (%u words)! Mimimum is" |
856
7b8be5c61d92
Improved error messages on EEPROM writing.
Florian Pose <fp@igh-essen.com>
parents:
839
diff
changeset
|
970 |
" 40 fixed words + 1 delimiter. Dropping.\n", |
7b8be5c61d92
Improved error messages on EEPROM writing.
Florian Pose <fp@igh-essen.com>
parents:
839
diff
changeset
|
971 |
request.word_size); |
599
a6ce861a167e
ec_slave_write_eeprom now returns certain error codes.
Florian Pose <fp@igh-essen.com>
parents:
597
diff
changeset
|
972 |
return -EINVAL; |
269 | 973 |
} |
974 |
||
735
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
975 |
// calculate checksum |
872 | 976 |
crc = ec_slave_sii_crc(data, 14); // CRC over words 0 to 6 |
735
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
977 |
if (crc != data[14]) { |
872 | 978 |
EC_WARN("SII CRC incorrect. Must be 0x%02x.\n", crc); |
735
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
979 |
} |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
980 |
|
754
0b47b49c5976
Changed unit of ec_eeprom_write_request_t from word to byte.
Florian Pose <fp@igh-essen.com>
parents:
750
diff
changeset
|
981 |
cat_header = (const uint16_t *) request.data |
872 | 982 |
+ EC_FIRST_SII_CATEGORY_OFFSET; |
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
983 |
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
|
984 |
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
|
985 |
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
|
986 |
(const uint16_t *) request.data + request.word_size) { |
872 | 987 |
EC_ERR("SII 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
|
988 |
return -EINVAL; |
269 | 989 |
} |
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
990 |
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
|
991 |
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
|
992 |
(const uint16_t *) request.data + request.word_size) { |
872 | 993 |
EC_ERR("SII data corrupted! Dropping.\n"); |
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
994 |
return -EINVAL; |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
995 |
} |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
996 |
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
|
997 |
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
|
998 |
} |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
999 |
|
872 | 1000 |
// SII data ok. schedule writing. |
1001 |
if ((ret = ec_slave_schedule_sii_writing(&request))) |
|
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1002 |
return ret; // error code |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1003 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1004 |
return size; // success |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1005 |
} |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1006 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1007 |
/*****************************************************************************/ |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1008 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1009 |
/** |
872 | 1010 |
* Writes the Secondary slave address (alias) to the slave's SII. |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1011 |
* \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
|
1012 |
*/ |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1013 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1014 |
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
|
1015 |
const uint8_t *data, /**< alias string */ |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1016 |
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
|
1017 |
) |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1018 |
{ |
872 | 1019 |
ec_sii_write_request_t request; |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1020 |
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
|
1021 |
uint16_t alias; |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1022 |
int ret; |
872 | 1023 |
uint8_t sii_data[16], crc; |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1024 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1025 |
if (slave->master->mode != EC_MASTER_MODE_IDLE) { // FIXME |
872 | 1026 |
EC_ERR("Writing to SII 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
|
1027 |
return -EBUSY; |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1028 |
} |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1029 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1030 |
alias = simple_strtoul(data, &remainder, 0); |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1031 |
if (remainder == (char *) data || (*remainder && *remainder != '\n')) { |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1032 |
EC_ERR("Invalid alias value! Dropping.\n"); |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1033 |
return -EINVAL; |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1034 |
} |
735
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
1035 |
|
872 | 1036 |
if (!slave->sii_data || slave->sii_size < 16) { |
1037 |
EC_ERR("Failed to read SII contents from slave %u.\n", |
|
735
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
1038 |
slave->ring_position); |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
1039 |
return -EINVAL; |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
1040 |
} |
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
1041 |
|
872 | 1042 |
// copy first 7 words of recent SII contents |
1043 |
memcpy(sii_data, slave->sii_data, 14); |
|
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1044 |
|
754
0b47b49c5976
Changed unit of ec_eeprom_write_request_t from word to byte.
Florian Pose <fp@igh-essen.com>
parents:
750
diff
changeset
|
1045 |
// write new alias address in word 4 |
872 | 1046 |
EC_WRITE_U16(sii_data + 8, alias); |
735
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
1047 |
|
0773628aabab
Calculate checksum when writing EEPROM or alias address.
Florian Pose <fp@igh-essen.com>
parents:
730
diff
changeset
|
1048 |
// calculate new checksum over words 0 to 6 |
872 | 1049 |
crc = ec_slave_sii_crc(sii_data, 14); |
1050 |
EC_WRITE_U16(sii_data + 14, crc); |
|
1051 |
||
1052 |
// init SII write request |
|
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1053 |
INIT_LIST_HEAD(&request.list); |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1054 |
request.slave = slave; |
872 | 1055 |
request.data = sii_data; |
754
0b47b49c5976
Changed unit of ec_eeprom_write_request_t from word to byte.
Florian Pose <fp@igh-essen.com>
parents:
750
diff
changeset
|
1056 |
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
|
1057 |
request.word_size = 8; |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1058 |
|
872 | 1059 |
if ((ret = ec_slave_schedule_sii_writing(&request))) |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1060 |
return ret; // error code |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1061 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
1062 |
slave->sii.alias = alias; // FIXME: do this in state machine |
607
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 |
return size; // success |
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 |
|
269 | 1067 |
/*****************************************************************************/ |
1068 |
||
1069 |
/** |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
1070 |
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
|
1071 |
\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
|
1072 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
1073 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
1074 |
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
|
1075 |
struct attribute *attr, /**< attribute */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
1076 |
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
|
1077 |
) |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
1078 |
{ |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
1079 |
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
|
1080 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1081 |
if (attr == &attr_info) { |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1082 |
return ec_slave_info(slave, buffer); |
960
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
928
diff
changeset
|
1083 |
} else if (attr == &attr_sii) { |
872 | 1084 |
if (slave->sii_data) { |
1085 |
if (slave->sii_size > PAGE_SIZE) { |
|
1086 |
EC_ERR("SII contents of slave %u exceed 1 page (%u/%u).\n", |
|
1087 |
slave->ring_position, slave->sii_size, |
|
266
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
1088 |
(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
|
1089 |
} |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
1090 |
else { |
872 | 1091 |
memcpy(buffer, slave->sii_data, slave->sii_size); |
1092 |
return slave->sii_size; |
|
266
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
1093 |
} |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
1094 |
} |
960
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
928
diff
changeset
|
1095 |
} else if (attr == &attr_alias) { |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
1096 |
return sprintf(buffer, "%u\n", slave->sii.alias); |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1097 |
} |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
1098 |
|
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
1099 |
return 0; |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
1100 |
} |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
1101 |
|
256
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1102 |
/*****************************************************************************/ |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1103 |
|
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1104 |
/** |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1105 |
Formats attribute data for SysFS write access. |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1106 |
\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
|
1107 |
*/ |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1108 |
|
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1109 |
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
|
1110 |
struct attribute *attr, /**< attribute */ |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1111 |
const char *buffer, /**< memory with data */ |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1112 |
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
|
1113 |
) |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1114 |
{ |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1115 |
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
|
1116 |
|
960
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
928
diff
changeset
|
1117 |
if (attr == &attr_sii) { |
872 | 1118 |
return ec_slave_write_sii(slave, buffer, size); |
960
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
928
diff
changeset
|
1119 |
} else if (attr == &attr_alias) { |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1120 |
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
|
1121 |
} |
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 |
return -EIO; |
256
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1124 |
} |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1125 |
|
275
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1126 |
/*****************************************************************************/ |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1127 |
|
912
6630f4dbcfd2
Improved working counter output; fixed problem with slaves that have a single sync manager used for outputs.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
1128 |
/** Get the sync manager for either Rx- or Tx-Pdos. |
6630f4dbcfd2
Improved working counter output; fixed problem with slaves that have a single sync manager used for outputs.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
1129 |
* |
6630f4dbcfd2
Improved working counter output; fixed problem with slaves that have a single sync manager used for outputs.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
1130 |
* \todo This seems not to be correct in every case... |
758
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
1131 |
* \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
|
1132 |
*/ |
626
a5e838c30733
Renamed ec_sii_sync_t to ec_sync_t.
Florian Pose <fp@igh-essen.com>
parents:
625
diff
changeset
|
1133 |
ec_sync_t *ec_slave_get_pdo_sync( |
912
6630f4dbcfd2
Improved working counter output; fixed problem with slaves that have a single sync manager used for outputs.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
1134 |
ec_slave_t *slave, /**< EtherCAT slave. */ |
6630f4dbcfd2
Improved working counter output; fixed problem with slaves that have a single sync manager used for outputs.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
1135 |
ec_direction_t dir /**< Input or output. */ |
619
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
1136 |
) |
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
1137 |
{ |
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
1138 |
unsigned int sync_index; |
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
1139 |
|
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1140 |
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
|
1141 |
EC_ERR("Invalid direction!\n"); |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1142 |
return NULL; |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1143 |
} |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
1144 |
|
912
6630f4dbcfd2
Improved working counter output; fixed problem with slaves that have a single sync manager used for outputs.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
1145 |
if (slave->sii.sync_count != 1) { |
6630f4dbcfd2
Improved working counter output; fixed problem with slaves that have a single sync manager used for outputs.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
1146 |
sync_index = (unsigned int) dir; |
6630f4dbcfd2
Improved working counter output; fixed problem with slaves that have a single sync manager used for outputs.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
1147 |
if (slave->sii.mailbox_protocols) sync_index += 2; |
6630f4dbcfd2
Improved working counter output; fixed problem with slaves that have a single sync manager used for outputs.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
1148 |
|
6630f4dbcfd2
Improved working counter output; fixed problem with slaves that have a single sync manager used for outputs.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
1149 |
if (sync_index >= slave->sii.sync_count) |
6630f4dbcfd2
Improved working counter output; fixed problem with slaves that have a single sync manager used for outputs.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
1150 |
return NULL; |
6630f4dbcfd2
Improved working counter output; fixed problem with slaves that have a single sync manager used for outputs.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
1151 |
} else { // sync_count == 1 |
6630f4dbcfd2
Improved working counter output; fixed problem with slaves that have a single sync manager used for outputs.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
1152 |
// A single sync manager may be used for inputs OR outputs! |
6630f4dbcfd2
Improved working counter output; fixed problem with slaves that have a single sync manager used for outputs.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
1153 |
if (ec_sync_direction(&slave->sii.syncs[0]) != dir) |
6630f4dbcfd2
Improved working counter output; fixed problem with slaves that have a single sync manager used for outputs.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
1154 |
return NULL; |
6630f4dbcfd2
Improved working counter output; fixed problem with slaves that have a single sync manager used for outputs.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
1155 |
sync_index = 0; |
6630f4dbcfd2
Improved working counter output; fixed problem with slaves that have a single sync manager used for outputs.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
1156 |
} |
619
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
1157 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
1158 |
return &slave->sii.syncs[sync_index]; |
619
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
1159 |
} |
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
1160 |
|
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
1161 |
/*****************************************************************************/ |
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
1162 |
|
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
1163 |
/** |
814 | 1164 |
Counts the total number of Sdos and entries in the dictionary. |
423
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1165 |
*/ |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1166 |
|
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1167 |
void ec_slave_sdo_dict_info(const ec_slave_t *slave, /**< EtherCAT slave */ |
814 | 1168 |
unsigned int *sdo_count, /**< number of Sdos */ |
423
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1169 |
unsigned int *entry_count /**< total number of |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1170 |
entries */ |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1171 |
) |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1172 |
{ |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1173 |
unsigned int sdos = 0, entries = 0; |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1174 |
ec_sdo_t *sdo; |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1175 |
ec_sdo_entry_t *entry; |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1176 |
|
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1177 |
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
|
1178 |
sdos++; |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1179 |
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
|
1180 |
entries++; |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1181 |
} |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1182 |
} |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1183 |
|
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1184 |
*sdo_count = sdos; |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1185 |
*entry_count = entries; |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1186 |
} |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1187 |
|
740
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1188 |
/*****************************************************************************/ |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1189 |
|
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1190 |
/** |
814 | 1191 |
* Get an Sdo from the dictionary. |
1192 |
* \returns The desired Sdo, or NULL. |
|
740
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1193 |
*/ |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1194 |
|
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1195 |
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
|
1196 |
ec_slave_t *slave /**< EtherCAT slave */, |
814 | 1197 |
uint16_t index /**< Sdo index */ |
740
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1198 |
) |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1199 |
{ |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1200 |
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
|
1201 |
|
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1202 |
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
|
1203 |
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
|
1204 |
return sdo; |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1205 |
} |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1206 |
|
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1207 |
return NULL; |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1208 |
} |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
1209 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
1210 |
/*****************************************************************************/ |
799 | 1211 |
|
1212 |
/** Finds a mapped Pdo. |
|
1213 |
* \returns The desired Pdo object, or NULL. |
|
1214 |
*/ |
|
1215 |
const ec_pdo_t *ec_slave_find_pdo( |
|
1216 |
const ec_slave_t *slave, /**< Slave. */ |
|
1217 |
uint16_t index /**< Pdo index to find. */ |
|
1218 |
) |
|
1219 |
{ |
|
1220 |
unsigned int i; |
|
1221 |
const ec_sync_t *sync; |
|
1222 |
const ec_pdo_t *pdo; |
|
1223 |
||
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
1224 |
for (i = 0; i < slave->sii.sync_count; i++) { |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
1225 |
sync = &slave->sii.syncs[i]; |
799 | 1226 |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
876
diff
changeset
|
1227 |
if (!(pdo = ec_pdo_list_find_pdo_const(&sync->pdos, index))) |
799 | 1228 |
continue; |
1229 |
||
1230 |
return pdo; |
|
1231 |
} |
|
1232 |
||
1233 |
return NULL; |
|
1234 |
} |
|
1235 |
||
1236 |
/*****************************************************************************/ |