author | Florian Pose <fp@igh-essen.com> |
Mon, 05 Mar 2007 10:00:18 +0000 | |
changeset 611 | 16498ed938f4 |
parent 610 | 29489a43ecee |
child 612 | aede068f9a74 |
permissions | -rw-r--r-- |
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
26
diff
changeset
|
1 |
/****************************************************************************** |
0 | 2 |
* |
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
26
diff
changeset
|
3 |
* $Id$ |
0 | 4 |
* |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
5 |
* Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
6 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
8 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
10 |
* and/or modify it under the terms of the GNU General Public License |
246
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
11 |
* as published by the Free Software Foundation; either version 2 of the |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
12 |
* License, or (at your option) any later version. |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
13 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
14 |
* The IgH EtherCAT Master is distributed in the hope that it will be |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
15 |
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
17 |
* GNU General Public License for more details. |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
18 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
19 |
* You should have received a copy of the GNU General Public License |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
20 |
* along with the IgH EtherCAT Master; if not, write to the Free Software |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
21 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
22 |
* |
246
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
23 |
* The right to use EtherCAT Technology is granted and comes free of |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
24 |
* charge under condition of compatibility of product made by |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
25 |
* Licensee. People intending to distribute/sell products based on the |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
26 |
* code, have to sign an agreement to guarantee that products using |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
27 |
* software based on IgH EtherCAT master stay compatible with the actual |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
28 |
* EtherCAT specification (which are released themselves as an open |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
29 |
* standard) as the (only) precondition to have the right to use EtherCAT |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
30 |
* Technology, IP and trade marks. |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
31 |
* |
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
26
diff
changeset
|
32 |
*****************************************************************************/ |
0 | 33 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
34 |
/** |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
35 |
\file |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
36 |
EtherCAT slave methods. |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
37 |
*/ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
38 |
|
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
39 |
/*****************************************************************************/ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
40 |
|
24
d417dd9bdc2f
Wilhelms ?nderungen ?bernommen.
Florian Pose <fp@igh-essen.com>
parents:
23
diff
changeset
|
41 |
#include <linux/module.h> |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
42 |
#include <linux/delay.h> |
0 | 43 |
|
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
44 |
#include "globals.h" |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
45 |
#include "slave.h" |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
46 |
#include "datagram.h" |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
91
diff
changeset
|
47 |
#include "master.h" |
0 | 48 |
|
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
26
diff
changeset
|
49 |
/*****************************************************************************/ |
0 | 50 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
51 |
extern const ec_code_msg_t al_status_messages[]; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
52 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
53 |
/*****************************************************************************/ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
54 |
|
404
7f7f429e13c7
Removed clear functions from headers of kobject-classes.
Florian Pose <fp@igh-essen.com>
parents:
403
diff
changeset
|
55 |
void ec_slave_clear(struct kobject *); |
482
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
56 |
void ec_slave_sdos_clear(struct kobject *); |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
57 |
ssize_t ec_show_slave_attribute(struct kobject *, struct attribute *, char *); |
256
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
58 |
ssize_t ec_store_slave_attribute(struct kobject *, struct attribute *, |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
59 |
const char *, size_t); |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
60 |
|
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
61 |
/*****************************************************************************/ |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
62 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
63 |
/** \cond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
64 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
65 |
EC_SYSFS_READ_ATTR(info); |
256
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
66 |
EC_SYSFS_READ_WRITE_ATTR(state); |
269 | 67 |
EC_SYSFS_READ_WRITE_ATTR(eeprom); |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
68 |
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
|
69 |
|
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
70 |
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
|
71 |
&attr_info, |
256
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
72 |
&attr_state, |
266
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
73 |
&attr_eeprom, |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
74 |
&attr_alias, |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
75 |
NULL, |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
76 |
}; |
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 |
static struct sysfs_ops sysfs_ops = { |
256
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
79 |
.show = ec_show_slave_attribute, |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
80 |
.store = ec_store_slave_attribute |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
81 |
}; |
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 |
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
|
84 |
.release = ec_slave_clear, |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
85 |
.sysfs_ops = &sysfs_ops, |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
86 |
.default_attrs = def_attrs |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
87 |
}; |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
88 |
|
482
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
89 |
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
|
90 |
.release = ec_slave_sdos_clear |
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
91 |
}; |
419
cf724fc82a00
Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents:
418
diff
changeset
|
92 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
93 |
/** \endcond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
94 |
|
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
95 |
/*****************************************************************************/ |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
96 |
|
0 | 97 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
98 |
Slave constructor. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
99 |
\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
|
100 |
*/ |
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 |
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
|
103 |
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
|
104 |
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
|
105 |
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
|
106 |
) |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
107 |
{ |
142 | 108 |
unsigned int i; |
109 |
||
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
110 |
slave->ring_position = ring_position; |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
111 |
slave->station_address = station_address; |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
112 |
|
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
113 |
slave->master = master; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
114 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
115 |
slave->requested_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
|
116 |
slave->current_state = EC_SLAVE_STATE_UNKNOWN; |
523
584a4f60b067
Re-added slave.configured flag as slave.self_configured.
Florian Pose <fp@igh-essen.com>
parents:
520
diff
changeset
|
117 |
slave->self_configured = 0; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
118 |
slave->error_flag = 0; |
610
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
119 |
slave->online_state = EC_SLAVE_ONLINE; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
120 |
slave->fmmu_count = 0; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
121 |
|
188
c0e49f4a1c07
Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents:
185
diff
changeset
|
122 |
slave->coupler_index = 0; |
c0e49f4a1c07
Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents:
185
diff
changeset
|
123 |
slave->coupler_subindex = 0xFFFF; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
124 |
|
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
125 |
slave->base_type = 0; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
126 |
slave->base_revision = 0; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
127 |
slave->base_build = 0; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
128 |
slave->base_fmmu_count = 0; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
129 |
slave->base_sync_count = 0; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
130 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
131 |
slave->eeprom_data = NULL; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
132 |
slave->eeprom_size = 0; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
133 |
|
114 | 134 |
slave->sii_alias = 0; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
135 |
slave->sii_vendor_id = 0; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
136 |
slave->sii_product_code = 0; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
137 |
slave->sii_revision_number = 0; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
138 |
slave->sii_serial_number = 0; |
136
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
139 |
slave->sii_rx_mailbox_offset = 0; |
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
140 |
slave->sii_rx_mailbox_size = 0; |
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
141 |
slave->sii_tx_mailbox_offset = 0; |
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
142 |
slave->sii_tx_mailbox_size = 0; |
133
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
132
diff
changeset
|
143 |
slave->sii_mailbox_protocols = 0; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
144 |
slave->sii_group = NULL; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
145 |
slave->sii_image = NULL; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
146 |
slave->sii_order = NULL; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
147 |
slave->sii_name = NULL; |
499
fb005e975181
Current consumption in sysfs; "lsec -c" shows current consumption and remaining current.
Florian Pose <fp@igh-essen.com>
parents:
484
diff
changeset
|
148 |
slave->sii_current_on_ebus = 0; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
149 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
150 |
INIT_LIST_HEAD(&slave->sii_strings); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
151 |
INIT_LIST_HEAD(&slave->sii_syncs); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
152 |
INIT_LIST_HEAD(&slave->sii_pdos); |
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
133
diff
changeset
|
153 |
INIT_LIST_HEAD(&slave->sdo_dictionary); |
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
154 |
INIT_LIST_HEAD(&slave->sdo_confs); |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
155 |
|
419
cf724fc82a00
Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents:
418
diff
changeset
|
156 |
slave->sdo_dictionary_fetched = 0; |
cf724fc82a00
Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents:
418
diff
changeset
|
157 |
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
|
158 |
|
183
8ae1e011e96c
More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents:
182
diff
changeset
|
159 |
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
|
160 |
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
|
161 |
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
|
162 |
slave->dl_signal[i] = 0; |
190
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
163 |
slave->sii_physical_layer[i] = 0xFF; |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
164 |
} |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
165 |
|
484
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
166 |
// init kobject and add it to the hierarchy |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
167 |
memset(&slave->kobj, 0x00, sizeof(struct kobject)); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
168 |
kobject_init(&slave->kobj); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
169 |
slave->kobj.ktype = &ktype_ec_slave; |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
170 |
slave->kobj.parent = &master->kobj; |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
171 |
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
|
172 |
EC_ERR("Failed to set kobject name.\n"); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
173 |
goto out_slave_put; |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
174 |
} |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
175 |
if (kobject_add(&slave->kobj)) { |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
176 |
EC_ERR("Failed to add slave's kobject.\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 |
|
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
180 |
// init SDO kobject and add it to the hierarchy |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
181 |
memset(&slave->sdo_kobj, 0x00, sizeof(struct kobject)); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
182 |
kobject_init(&slave->sdo_kobj); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
183 |
slave->sdo_kobj.ktype = &ktype_ec_slave_sdos; |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
184 |
slave->sdo_kobj.parent = &slave->kobj; |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
185 |
if (kobject_set_name(&slave->sdo_kobj, "sdos")) { |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
186 |
EC_ERR("Failed to set kobject name.\n"); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
187 |
goto out_sdo_put; |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
188 |
} |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
189 |
if (kobject_add(&slave->sdo_kobj)) { |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
190 |
EC_ERR("Failed to add SDOs kobject.\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 |
|
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
194 |
return 0; |
484
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
195 |
|
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
196 |
out_sdo_put: |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
197 |
kobject_put(&slave->sdo_kobj); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
198 |
kobject_del(&slave->kobj); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
199 |
out_slave_put: |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
200 |
kobject_put(&slave->kobj); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
201 |
return -1; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
202 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
203 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
204 |
/*****************************************************************************/ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
205 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
206 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
207 |
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
|
208 |
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
|
209 |
*/ |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
210 |
|
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
211 |
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
|
212 |
{ |
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 |
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
|
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 |
// free all SDOs |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
216 |
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
|
217 |
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
|
218 |
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
|
219 |
} |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
220 |
|
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
221 |
// free SDO kobject |
484
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
482
diff
changeset
|
222 |
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
|
223 |
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
|
224 |
|
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 |
// 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
|
226 |
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
|
227 |
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
|
228 |
} |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
229 |
|
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
230 |
/*****************************************************************************/ |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
231 |
|
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
232 |
/** |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
233 |
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
|
234 |
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
|
235 |
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
|
236 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
237 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
238 |
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
|
239 |
{ |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
240 |
ec_slave_t *slave; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
241 |
ec_sii_string_t *string, *next_str; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
242 |
ec_sii_sync_t *sync, *next_sync; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
243 |
ec_sii_pdo_t *pdo, *next_pdo; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
244 |
ec_sii_pdo_entry_t *entry, *next_ent; |
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
245 |
ec_sdo_data_t *sdodata, *next_sdodata; |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
246 |
|
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
247 |
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
|
248 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
249 |
// free all string objects |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
250 |
list_for_each_entry_safe(string, next_str, &slave->sii_strings, list) { |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
251 |
list_del(&string->list); |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
252 |
kfree(string); |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
253 |
} |
121
1cd6f7a47b72
Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents:
119
diff
changeset
|
254 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
255 |
// free all sync managers |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
256 |
list_for_each_entry_safe(sync, next_sync, &slave->sii_syncs, list) { |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
257 |
list_del(&sync->list); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
258 |
kfree(sync); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
259 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
260 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
261 |
// free all PDOs |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
262 |
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
|
263 |
list_del(&pdo->list); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
264 |
if (pdo->name) kfree(pdo->name); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
265 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
266 |
// free all PDO entries |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
267 |
list_for_each_entry_safe(entry, next_ent, &pdo->entries, list) { |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
268 |
list_del(&entry->list); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
269 |
if (entry->name) kfree(entry->name); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
270 |
kfree(entry); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
271 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
272 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
273 |
kfree(pdo); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
274 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
275 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
276 |
if (slave->sii_group) kfree(slave->sii_group); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
277 |
if (slave->sii_image) kfree(slave->sii_image); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
278 |
if (slave->sii_order) kfree(slave->sii_order); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
279 |
if (slave->sii_name) kfree(slave->sii_name); |
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
133
diff
changeset
|
280 |
|
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
281 |
// free all SDO configurations |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
282 |
list_for_each_entry_safe(sdodata, next_sdodata, &slave->sdo_confs, list) { |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
283 |
list_del(&sdodata->list); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
284 |
kfree(sdodata->data); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
285 |
kfree(sdodata); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
286 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
287 |
|
266
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
288 |
if (slave->eeprom_data) kfree(slave->eeprom_data); |
418
7a43437bc48b
Fixed memory leak in master and slave destructors.
Florian Pose <fp@igh-essen.com>
parents:
416
diff
changeset
|
289 |
|
7a43437bc48b
Fixed memory leak in master and slave destructors.
Florian Pose <fp@igh-essen.com>
parents:
416
diff
changeset
|
290 |
kfree(slave); |
121
1cd6f7a47b72
Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents:
119
diff
changeset
|
291 |
} |
1cd6f7a47b72
Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents:
119
diff
changeset
|
292 |
|
1cd6f7a47b72
Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents:
119
diff
changeset
|
293 |
/*****************************************************************************/ |
1cd6f7a47b72
Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents:
119
diff
changeset
|
294 |
|
1cd6f7a47b72
Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents:
119
diff
changeset
|
295 |
/** |
482
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
296 |
*/ |
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
297 |
|
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
298 |
void ec_slave_sdos_clear(struct kobject *kobj /**< kobject for SDOs */) |
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
299 |
{ |
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
300 |
} |
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
301 |
|
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
302 |
/*****************************************************************************/ |
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
303 |
|
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
304 |
/** |
446 | 305 |
Reset slave from operation mode. |
306 |
*/ |
|
307 |
||
308 |
void ec_slave_reset(ec_slave_t *slave /**< EtherCAT slave */) |
|
309 |
{ |
|
465
3779b60a7c9b
BUGFIX: Remove SDO configurations when leaving OPERATION mode.
Florian Pose <fp@igh-essen.com>
parents:
464
diff
changeset
|
310 |
ec_sdo_data_t *sdodata, *next_sdodata; |
467
2274de57ca84
Remove estimated sync manager sizes when leaving operation mode.
Florian Pose <fp@igh-essen.com>
parents:
465
diff
changeset
|
311 |
ec_sii_sync_t *sync; |
465
3779b60a7c9b
BUGFIX: Remove SDO configurations when leaving OPERATION mode.
Florian Pose <fp@igh-essen.com>
parents:
464
diff
changeset
|
312 |
|
3779b60a7c9b
BUGFIX: Remove SDO configurations when leaving OPERATION mode.
Florian Pose <fp@igh-essen.com>
parents:
464
diff
changeset
|
313 |
// remove FMMU configurations |
446 | 314 |
slave->fmmu_count = 0; |
465
3779b60a7c9b
BUGFIX: Remove SDO configurations when leaving OPERATION mode.
Florian Pose <fp@igh-essen.com>
parents:
464
diff
changeset
|
315 |
|
3779b60a7c9b
BUGFIX: Remove SDO configurations when leaving OPERATION mode.
Florian Pose <fp@igh-essen.com>
parents:
464
diff
changeset
|
316 |
// free all SDO configurations |
3779b60a7c9b
BUGFIX: Remove SDO configurations when leaving OPERATION mode.
Florian Pose <fp@igh-essen.com>
parents:
464
diff
changeset
|
317 |
list_for_each_entry_safe(sdodata, next_sdodata, &slave->sdo_confs, list) { |
3779b60a7c9b
BUGFIX: Remove SDO configurations when leaving OPERATION mode.
Florian Pose <fp@igh-essen.com>
parents:
464
diff
changeset
|
318 |
list_del(&sdodata->list); |
3779b60a7c9b
BUGFIX: Remove SDO configurations when leaving OPERATION mode.
Florian Pose <fp@igh-essen.com>
parents:
464
diff
changeset
|
319 |
kfree(sdodata->data); |
3779b60a7c9b
BUGFIX: Remove SDO configurations when leaving OPERATION mode.
Florian Pose <fp@igh-essen.com>
parents:
464
diff
changeset
|
320 |
kfree(sdodata); |
3779b60a7c9b
BUGFIX: Remove SDO configurations when leaving OPERATION mode.
Florian Pose <fp@igh-essen.com>
parents:
464
diff
changeset
|
321 |
} |
467
2274de57ca84
Remove estimated sync manager sizes when leaving operation mode.
Florian Pose <fp@igh-essen.com>
parents:
465
diff
changeset
|
322 |
|
2274de57ca84
Remove estimated sync manager sizes when leaving operation mode.
Florian Pose <fp@igh-essen.com>
parents:
465
diff
changeset
|
323 |
// remove estimated sync manager sizes |
2274de57ca84
Remove estimated sync manager sizes when leaving operation mode.
Florian Pose <fp@igh-essen.com>
parents:
465
diff
changeset
|
324 |
list_for_each_entry(sync, &slave->sii_syncs, list) { |
2274de57ca84
Remove estimated sync manager sizes when leaving operation mode.
Florian Pose <fp@igh-essen.com>
parents:
465
diff
changeset
|
325 |
sync->est_length = 0; |
2274de57ca84
Remove estimated sync manager sizes when leaving operation mode.
Florian Pose <fp@igh-essen.com>
parents:
465
diff
changeset
|
326 |
} |
446 | 327 |
} |
328 |
||
329 |
/*****************************************************************************/ |
|
330 |
||
331 |
/** |
|
610
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
332 |
* 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
|
333 |
*/ |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
334 |
|
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
335 |
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
|
336 |
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
|
337 |
) |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
338 |
{ |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
339 |
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
|
340 |
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
|
341 |
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
|
342 |
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
|
343 |
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
|
344 |
ec_state_string(new_state, cur_state); |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
345 |
EC_DBG("Slave %i: %s -> %s.\n", |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
346 |
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
|
347 |
} |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
348 |
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
|
349 |
} |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
350 |
} |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
351 |
|
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
352 |
/*****************************************************************************/ |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
353 |
|
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
354 |
/** |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
355 |
* Sets the online state of a slave. |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
356 |
*/ |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
357 |
|
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
358 |
void ec_slave_set_online_state(ec_slave_t *slave, /**< EtherCAT slave */ |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
359 |
ec_slave_online_state_t new_state /**< new online state */ |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
360 |
) |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
361 |
{ |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
362 |
if (new_state == EC_SLAVE_OFFLINE && |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
363 |
slave->online_state == EC_SLAVE_ONLINE) { |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
364 |
if (slave->master->debug_level) |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
365 |
EC_DBG("Slave %i: offline.\n", slave->ring_position); |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
366 |
} |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
367 |
else if (new_state == EC_SLAVE_ONLINE && |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
368 |
slave->online_state == EC_SLAVE_OFFLINE) { |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
369 |
slave->error_flag = 0; // clear error flag |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
370 |
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
|
371 |
char cur_state[EC_STATE_STRING_SIZE]; |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
372 |
ec_state_string(slave->current_state, cur_state); |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
373 |
EC_DBG("Slave %i: online (%s).\n", |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
374 |
slave->ring_position, cur_state); |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
375 |
} |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
376 |
} |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
377 |
|
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
378 |
slave->online_state = new_state; |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
379 |
} |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
380 |
|
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
381 |
/*****************************************************************************/ |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
382 |
|
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
383 |
/** |
446 | 384 |
*/ |
385 |
||
386 |
void ec_slave_request_state(ec_slave_t *slave, /**< ETherCAT slave */ |
|
387 |
ec_slave_state_t state /**< new state */ |
|
388 |
) |
|
389 |
{ |
|
390 |
slave->requested_state = state; |
|
391 |
slave->error_flag = 0; |
|
392 |
} |
|
393 |
||
394 |
/*****************************************************************************/ |
|
395 |
||
396 |
/** |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
397 |
Fetches data from a STRING category. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
398 |
\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
|
399 |
*/ |
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 |
int ec_slave_fetch_strings(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
|
402 |
const uint8_t *data /**< category data */ |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
403 |
) |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
404 |
{ |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
405 |
unsigned int string_count, i; |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
406 |
size_t size; |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
407 |
off_t offset; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
408 |
ec_sii_string_t *string; |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
409 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
410 |
string_count = data[0]; |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
411 |
offset = 1; |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
412 |
for (i = 0; i < string_count; i++) { |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
413 |
size = data[offset]; |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
414 |
// allocate memory for string structure and data at a single blow |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
415 |
if (!(string = (ec_sii_string_t *) |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
416 |
kmalloc(sizeof(ec_sii_string_t) + size + 1, GFP_ATOMIC))) { |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
417 |
EC_ERR("Failed to allocate string memory.\n"); |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
418 |
return -1; |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
419 |
} |
121
1cd6f7a47b72
Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents:
119
diff
changeset
|
420 |
string->size = size; |
161
ddb7266d1c56
Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents:
160
diff
changeset
|
421 |
// string memory appended to string structure |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
422 |
string->data = (char *) string + sizeof(ec_sii_string_t); |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
423 |
memcpy(string->data, data + offset + 1, size); |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
424 |
string->data[size] = 0x00; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
425 |
list_add_tail(&string->list, &slave->sii_strings); |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
426 |
offset += 1 + size; |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
427 |
} |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
428 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
429 |
return 0; |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
430 |
} |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
431 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
432 |
/*****************************************************************************/ |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
433 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
434 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
435 |
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
|
436 |
\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
|
437 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
438 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
439 |
void ec_slave_fetch_general(ec_slave_t *slave, /**< EtherCAT slave */ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
440 |
const uint8_t *data /**< category data */ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
441 |
) |
123 | 442 |
{ |
190
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
443 |
unsigned int i; |
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
444 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
445 |
ec_slave_locate_string(slave, data[0], &slave->sii_group); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
446 |
ec_slave_locate_string(slave, data[1], &slave->sii_image); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
447 |
ec_slave_locate_string(slave, data[2], &slave->sii_order); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
448 |
ec_slave_locate_string(slave, data[3], &slave->sii_name); |
123 | 449 |
|
190
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
450 |
for (i = 0; i < 4; i++) |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
451 |
slave->sii_physical_layer[i] = |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
452 |
(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
|
453 |
|
fb005e975181
Current consumption in sysfs; "lsec -c" shows current consumption and remaining current.
Florian Pose <fp@igh-essen.com>
parents:
484
diff
changeset
|
454 |
slave->sii_current_on_ebus = EC_READ_S16(data + 0x0C); |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
455 |
} |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
456 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
457 |
/*****************************************************************************/ |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
458 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
459 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
460 |
Fetches data from a SYNC MANAGER category. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
461 |
\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
|
462 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
463 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
464 |
int ec_slave_fetch_sync(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
|
465 |
const uint8_t *data, /**< category data */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
466 |
size_t word_count /**< number of words */ |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
467 |
) |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
468 |
{ |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
469 |
unsigned int sync_count, i; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
470 |
ec_sii_sync_t *sync; |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
471 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
472 |
sync_count = word_count / 4; // sync manager struct is 4 words long |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
473 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
474 |
for (i = 0; i < sync_count; i++, data += 8) { |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
475 |
if (!(sync = (ec_sii_sync_t *) |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
476 |
kmalloc(sizeof(ec_sii_sync_t), GFP_ATOMIC))) { |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
477 |
EC_ERR("Failed to allocate Sync-Manager memory.\n"); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
478 |
return -1; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
479 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
480 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
481 |
sync->index = i; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
482 |
sync->physical_start_address = EC_READ_U16(data); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
483 |
sync->length = EC_READ_U16(data + 2); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
484 |
sync->control_register = EC_READ_U8 (data + 4); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
485 |
sync->enable = EC_READ_U8 (data + 6); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
486 |
|
416
4f007cd2a79d
ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents:
412
diff
changeset
|
487 |
sync->est_length = 0; |
4f007cd2a79d
ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents:
412
diff
changeset
|
488 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
489 |
list_add_tail(&sync->list, &slave->sii_syncs); |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
490 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
491 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
492 |
return 0; |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
493 |
} |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
494 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
495 |
/*****************************************************************************/ |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
496 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
497 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
498 |
Fetches data from a [RT]XPDO category. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
499 |
\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
|
500 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
501 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
502 |
int ec_slave_fetch_pdo(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
|
503 |
const uint8_t *data, /**< category data */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
504 |
size_t word_count, /**< number of words */ |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
505 |
ec_sii_pdo_type_t pdo_type /**< PDO type */ |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
506 |
) |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
507 |
{ |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
508 |
ec_sii_pdo_t *pdo; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
509 |
ec_sii_pdo_entry_t *entry; |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
510 |
unsigned int entry_count, i; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
511 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
512 |
while (word_count >= 4) { |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
513 |
if (!(pdo = (ec_sii_pdo_t *) |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
514 |
kmalloc(sizeof(ec_sii_pdo_t), GFP_ATOMIC))) { |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
515 |
EC_ERR("Failed to allocate PDO memory.\n"); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
516 |
return -1; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
517 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
518 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
519 |
INIT_LIST_HEAD(&pdo->entries); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
520 |
pdo->type = pdo_type; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
521 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
522 |
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
|
523 |
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
|
524 |
pdo->sync_index = EC_READ_U8(data + 3); |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
525 |
pdo->name = NULL; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
526 |
ec_slave_locate_string(slave, EC_READ_U8(data + 5), &pdo->name); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
527 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
528 |
list_add_tail(&pdo->list, &slave->sii_pdos); |
126
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 |
word_count -= 4; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
531 |
data += 8; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
532 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
533 |
for (i = 0; i < entry_count; i++) { |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
534 |
if (!(entry = (ec_sii_pdo_entry_t *) |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
535 |
kmalloc(sizeof(ec_sii_pdo_entry_t), GFP_ATOMIC))) { |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
536 |
EC_ERR("Failed to allocate PDO entry memory.\n"); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
537 |
return -1; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
538 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
539 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
540 |
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
|
541 |
entry->subindex = EC_READ_U8(data + 2); |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
542 |
entry->name = NULL; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
543 |
ec_slave_locate_string(slave, EC_READ_U8(data + 3), &entry->name); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
544 |
entry->bit_length = EC_READ_U8(data + 5); |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
545 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
546 |
list_add_tail(&entry->list, &pdo->entries); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
547 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
548 |
word_count -= 4; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
549 |
data += 8; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
550 |
} |
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 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
553 |
return 0; |
114 | 554 |
} |
555 |
||
556 |
/*****************************************************************************/ |
|
557 |
||
558 |
/** |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
559 |
Searches the string list for an index and allocates a new string. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
560 |
\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
|
561 |
\todo documentation |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
562 |
*/ |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
563 |
|
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
564 |
int ec_slave_locate_string(ec_slave_t *slave, /**< EtherCAT slave */ |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
565 |
unsigned int index, /**< string index */ |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
566 |
char **ptr /**< Address of the string pointer */ |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
567 |
) |
123 | 568 |
{ |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
569 |
ec_sii_string_t *string; |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
570 |
char *err_string; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
571 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
572 |
// Erst alten Speicher freigeben |
123 | 573 |
if (*ptr) { |
574 |
kfree(*ptr); |
|
575 |
*ptr = NULL; |
|
576 |
} |
|
577 |
||
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
578 |
// Index 0 bedeutet "nicht belegt" |
123 | 579 |
if (!index) return 0; |
580 |
||
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
581 |
// EEPROM-String mit Index finden und kopieren |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
582 |
list_for_each_entry(string, &slave->sii_strings, list) { |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
583 |
if (--index) continue; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
584 |
|
296
967aaacf9b20
Avoided crashes on kernel 2.4 acc. to patch by M. Schwerin.
Florian Pose <fp@igh-essen.com>
parents:
293
diff
changeset
|
585 |
if (!(*ptr = (char *) kmalloc(string->size + 1, GFP_ATOMIC))) { |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
586 |
EC_ERR("Unable to allocate string memory.\n"); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
587 |
return -1; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
588 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
589 |
memcpy(*ptr, string->data, string->size + 1); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
590 |
return 0; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
591 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
592 |
|
461
b9eda9235173
Print certain warnings only at debug_level.
Florian Pose <fp@igh-essen.com>
parents:
458
diff
changeset
|
593 |
if (slave->master->debug_level) |
b9eda9235173
Print certain warnings only at debug_level.
Florian Pose <fp@igh-essen.com>
parents:
458
diff
changeset
|
594 |
EC_WARN("String %i not found in slave %i.\n", |
b9eda9235173
Print certain warnings only at debug_level.
Florian Pose <fp@igh-essen.com>
parents:
458
diff
changeset
|
595 |
index, slave->ring_position); |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
596 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
597 |
err_string = "(string not found)"; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
598 |
|
296
967aaacf9b20
Avoided crashes on kernel 2.4 acc. to patch by M. Schwerin.
Florian Pose <fp@igh-essen.com>
parents:
293
diff
changeset
|
599 |
if (!(*ptr = (char *) kmalloc(strlen(err_string) + 1, GFP_ATOMIC))) { |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
600 |
EC_WARN("Unable to allocate string memory.\n"); |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
601 |
return -1; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
602 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
603 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
604 |
memcpy(*ptr, err_string, strlen(err_string) + 1); |
123 | 605 |
return 0; |
606 |
} |
|
607 |
||
608 |
/*****************************************************************************/ |
|
609 |
||
610 |
/** |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
611 |
Prepares an FMMU configuration. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
612 |
Configuration data for the FMMU is saved in the slave structure and is |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
613 |
written to the slave in ecrt_master_activate(). |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
614 |
The FMMU configuration is done in a way, that the complete data range |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
615 |
of the corresponding sync manager is covered. Seperate FMMUs are configured |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
616 |
for each domain. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
617 |
If the FMMU configuration is already prepared, the function returns with |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
618 |
success. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
619 |
\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
|
620 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
621 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
622 |
int ec_slave_prepare_fmmu(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
|
623 |
const ec_domain_t *domain, /**< domain */ |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
624 |
const ec_sii_sync_t *sync /**< sync manager */ |
160
7ddf8367196a
Renamed slave_set_fmmu() to slave_prepare_fmmu().
Florian Pose <fp@igh-essen.com>
parents:
157
diff
changeset
|
625 |
) |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
626 |
{ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
627 |
unsigned int i; |
412 | 628 |
ec_fmmu_t *fmmu; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
629 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
630 |
// FMMU configuration already prepared? |
412 | 631 |
for (i = 0; i < slave->fmmu_count; i++) { |
632 |
fmmu = &slave->fmmus[i]; |
|
633 |
if (fmmu->domain == domain && fmmu->sync == sync) |
|
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
634 |
return 0; |
412 | 635 |
} |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
636 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
637 |
// reserve new FMMU... |
91
0120d6214948
Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents:
89
diff
changeset
|
638 |
|
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
639 |
if (slave->fmmu_count >= slave->base_fmmu_count) { |
84
b4ae98855cea
printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents:
77
diff
changeset
|
640 |
EC_ERR("Slave %i FMMU limit reached!\n", slave->ring_position); |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
641 |
return -1; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
642 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
643 |
|
412 | 644 |
fmmu = &slave->fmmus[slave->fmmu_count]; |
645 |
||
646 |
fmmu->index = slave->fmmu_count; |
|
647 |
fmmu->domain = domain; |
|
648 |
fmmu->sync = sync; |
|
649 |
fmmu->logical_start_address = 0; |
|
650 |
||
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
651 |
slave->fmmu_count++; |
609
611d738a1392
Moved state request on PDO registration to slave.c.
Florian Pose <fp@igh-essen.com>
parents:
607
diff
changeset
|
652 |
|
611d738a1392
Moved state request on PDO registration to slave.c.
Florian Pose <fp@igh-essen.com>
parents:
607
diff
changeset
|
653 |
ec_slave_request_state(slave, EC_SLAVE_STATE_OP); |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
654 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
655 |
return 0; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
656 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
657 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
658 |
/*****************************************************************************/ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
659 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
660 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
661 |
Outputs all information about a certain slave. |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
662 |
*/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
663 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
664 |
size_t ec_slave_info(const ec_slave_t *slave, /**< EtherCAT slave */ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
665 |
char *buffer /**< Output buffer */ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
666 |
) |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
667 |
{ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
668 |
off_t off = 0; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
669 |
ec_sii_sync_t *sync; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
670 |
ec_sii_pdo_t *pdo; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
671 |
ec_sii_pdo_entry_t *pdo_entry; |
142 | 672 |
int first, i; |
464
6c21a8d8c785
SDO configurations in Sysfs.
Florian Pose <fp@igh-essen.com>
parents:
461
diff
changeset
|
673 |
ec_sdo_data_t *sdodata; |
6c21a8d8c785
SDO configurations in Sysfs.
Florian Pose <fp@igh-essen.com>
parents:
461
diff
changeset
|
674 |
char str[20]; |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
675 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
676 |
off += sprintf(buffer + off, "\nName: "); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
677 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
678 |
if (slave->sii_name) |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
679 |
off += sprintf(buffer + off, "%s", slave->sii_name); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
680 |
|
339 | 681 |
off += sprintf(buffer + off, "\nVendor ID: 0x%08X\n", |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
682 |
slave->sii_vendor_id); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
683 |
off += sprintf(buffer + off, "Product code: 0x%08X\n\n", |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
684 |
slave->sii_product_code); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
685 |
|
339 | 686 |
off += sprintf(buffer + off, "State: "); |
687 |
off += ec_state_string(slave->current_state, buffer + off); |
|
519
54787e1b57d4
Display requested state in slave info.
Florian Pose <fp@igh-essen.com>
parents:
499
diff
changeset
|
688 |
off += sprintf(buffer + off, " ("); |
54787e1b57d4
Display requested state in slave info.
Florian Pose <fp@igh-essen.com>
parents:
499
diff
changeset
|
689 |
off += ec_state_string(slave->requested_state, buffer + off); |
54787e1b57d4
Display requested state in slave info.
Florian Pose <fp@igh-essen.com>
parents:
499
diff
changeset
|
690 |
off += sprintf(buffer + off, ")\nFlags: %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
|
691 |
slave->online_state == EC_SLAVE_ONLINE ? "online" : "OFFLINE", |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
692 |
slave->error_flag ? "ERROR" : "ok"); |
458
6467f0f6e370
Added slave flags to Sysfs.
Florian Pose <fp@igh-essen.com>
parents:
448
diff
changeset
|
693 |
off += sprintf(buffer + off, "Ring position: %i\n", |
339 | 694 |
slave->ring_position); |
357
277de5572f99
Coupler information in slave info file, lines in lsec.
Florian Pose <fp@igh-essen.com>
parents:
349
diff
changeset
|
695 |
off += sprintf(buffer + off, "Advanced position: %i:%i\n", |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
696 |
slave->coupler_index, slave->coupler_subindex); |
499
fb005e975181
Current consumption in sysfs; "lsec -c" shows current consumption and remaining current.
Florian Pose <fp@igh-essen.com>
parents:
484
diff
changeset
|
697 |
off += sprintf(buffer + off, "Coupler: %s\n", |
357
277de5572f99
Coupler information in slave info file, lines in lsec.
Florian Pose <fp@igh-essen.com>
parents:
349
diff
changeset
|
698 |
ec_slave_is_coupler(slave) ? "yes" : "no"); |
499
fb005e975181
Current consumption in sysfs; "lsec -c" shows current consumption and remaining current.
Florian Pose <fp@igh-essen.com>
parents:
484
diff
changeset
|
699 |
off += sprintf(buffer + off, "Current consumption: %i mA\n\n", |
fb005e975181
Current consumption in sysfs; "lsec -c" shows current consumption and remaining current.
Florian Pose <fp@igh-essen.com>
parents:
484
diff
changeset
|
700 |
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
|
701 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
702 |
off += sprintf(buffer + off, "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
|
703 |
for (i = 0; i < 4; i++) { |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
704 |
off += sprintf(buffer + off, " Port %i (", i); |
190
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
705 |
switch (slave->sii_physical_layer[i]) { |
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
706 |
case 0x00: |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
707 |
off += sprintf(buffer + off, "EBUS"); |
190
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
708 |
break; |
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
709 |
case 0x01: |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
710 |
off += sprintf(buffer + off, "100BASE-TX"); |
190
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
711 |
break; |
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
712 |
case 0x02: |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
713 |
off += sprintf(buffer + off, "100BASE-FX"); |
190
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
714 |
break; |
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
715 |
default: |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
716 |
off += sprintf(buffer + off, "unknown (%i)", |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
717 |
slave->sii_physical_layer[i]); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
718 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
719 |
off += sprintf(buffer + off, ") Link %s, Loop %s, %s\n", |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
720 |
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
|
721 |
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
|
722 |
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
|
723 |
} |
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
724 |
|
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
725 |
if (slave->sii_mailbox_protocols) { |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
726 |
off += sprintf(buffer + off, "\nMailboxes:\n"); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
727 |
off += sprintf(buffer + off, " RX mailbox: 0x%04X/%i," |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
728 |
" TX mailbox: 0x%04X/%i\n", |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
729 |
slave->sii_rx_mailbox_offset, |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
730 |
slave->sii_rx_mailbox_size, |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
731 |
slave->sii_tx_mailbox_offset, |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
732 |
slave->sii_tx_mailbox_size); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
733 |
off += sprintf(buffer + off, " Supported protocols: "); |
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
734 |
|
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
735 |
first = 1; |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
736 |
if (slave->sii_mailbox_protocols & EC_MBOX_AOE) { |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
737 |
off += sprintf(buffer + off, "AoE"); |
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
738 |
first = 0; |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
739 |
} |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
740 |
if (slave->sii_mailbox_protocols & EC_MBOX_EOE) { |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
741 |
if (!first) off += sprintf(buffer + off, ", "); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
742 |
off += sprintf(buffer + off, "EoE"); |
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
743 |
first = 0; |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
744 |
} |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
745 |
if (slave->sii_mailbox_protocols & EC_MBOX_COE) { |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
746 |
if (!first) off += sprintf(buffer + off, ", "); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
747 |
off += sprintf(buffer + off, "CoE"); |
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
748 |
first = 0; |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
749 |
} |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
750 |
if (slave->sii_mailbox_protocols & EC_MBOX_FOE) { |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
751 |
if (!first) off += sprintf(buffer + off, ", "); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
752 |
off += sprintf(buffer + off, "FoE"); |
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
753 |
first = 0; |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
754 |
} |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
755 |
if (slave->sii_mailbox_protocols & EC_MBOX_SOE) { |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
756 |
if (!first) off += sprintf(buffer + off, ", "); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
757 |
off += sprintf(buffer + off, "SoE"); |
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
758 |
first = 0; |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
759 |
} |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
760 |
if (slave->sii_mailbox_protocols & EC_MBOX_VOE) { |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
761 |
if (!first) off += sprintf(buffer + off, ", "); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
762 |
off += sprintf(buffer + off, "VoE"); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
763 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
764 |
off += sprintf(buffer + off, "\n"); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
765 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
766 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
767 |
if (slave->sii_alias || slave->sii_group |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
768 |
|| slave->sii_image || slave->sii_order) |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
769 |
off += sprintf(buffer + off, "\nSII data:\n"); |
266
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
770 |
|
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
771 |
if (slave->sii_alias) |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
772 |
off += sprintf(buffer + off, " Configured station alias:" |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
773 |
" 0x%04X (%i)\n", slave->sii_alias, slave->sii_alias); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
774 |
if (slave->sii_group) |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
775 |
off += sprintf(buffer + off, " Group: %s\n", slave->sii_group); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
776 |
if (slave->sii_image) |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
777 |
off += sprintf(buffer + off, " Image: %s\n", slave->sii_image); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
778 |
if (slave->sii_order) |
339 | 779 |
off += sprintf(buffer + off, " Order number: %s\n", slave->sii_order); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
780 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
781 |
if (!list_empty(&slave->sii_syncs)) |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
782 |
off += sprintf(buffer + off, "\nSync-Managers:\n"); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
783 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
784 |
list_for_each_entry(sync, &slave->sii_syncs, list) { |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
785 |
off += sprintf(buffer + off, " %i: 0x%04X, length %i," |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
786 |
" control 0x%02X, %s\n", |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
787 |
sync->index, sync->physical_start_address, |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
788 |
sync->length, sync->control_register, |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
789 |
sync->enable ? "enable" : "disable"); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
790 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
791 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
792 |
if (!list_empty(&slave->sii_pdos)) |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
793 |
off += sprintf(buffer + off, "\nPDOs:\n"); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
794 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
795 |
list_for_each_entry(pdo, &slave->sii_pdos, list) { |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
796 |
off += sprintf(buffer + off, |
339 | 797 |
" %s \"%s\" (0x%04X), Sync-Manager %i\n", |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
798 |
pdo->type == EC_RX_PDO ? "RXPDO" : "TXPDO", |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
799 |
pdo->name ? pdo->name : "???", |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
800 |
pdo->index, pdo->sync_index); |
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
801 |
|
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
802 |
list_for_each_entry(pdo_entry, &pdo->entries, list) { |
339 | 803 |
off += sprintf(buffer + off, " \"%s\" 0x%04X:%X, %i bit\n", |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
804 |
pdo_entry->name ? pdo_entry->name : "???", |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
805 |
pdo_entry->index, pdo_entry->subindex, |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
806 |
pdo_entry->bit_length); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
807 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
808 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
809 |
|
464
6c21a8d8c785
SDO configurations in Sysfs.
Florian Pose <fp@igh-essen.com>
parents:
461
diff
changeset
|
810 |
if (!list_empty(&slave->sdo_confs)) |
6c21a8d8c785
SDO configurations in Sysfs.
Florian Pose <fp@igh-essen.com>
parents:
461
diff
changeset
|
811 |
off += sprintf(buffer + off, "\nSDO configurations:\n"); |
6c21a8d8c785
SDO configurations in Sysfs.
Florian Pose <fp@igh-essen.com>
parents:
461
diff
changeset
|
812 |
|
6c21a8d8c785
SDO configurations in Sysfs.
Florian Pose <fp@igh-essen.com>
parents:
461
diff
changeset
|
813 |
list_for_each_entry(sdodata, &slave->sdo_confs, list) { |
6c21a8d8c785
SDO configurations in Sysfs.
Florian Pose <fp@igh-essen.com>
parents:
461
diff
changeset
|
814 |
switch (sdodata->size) { |
6c21a8d8c785
SDO configurations in Sysfs.
Florian Pose <fp@igh-essen.com>
parents:
461
diff
changeset
|
815 |
case 1: sprintf(str, "%i", EC_READ_U8(sdodata->data)); break; |
6c21a8d8c785
SDO configurations in Sysfs.
Florian Pose <fp@igh-essen.com>
parents:
461
diff
changeset
|
816 |
case 2: sprintf(str, "%i", EC_READ_U16(sdodata->data)); break; |
6c21a8d8c785
SDO configurations in Sysfs.
Florian Pose <fp@igh-essen.com>
parents:
461
diff
changeset
|
817 |
case 4: sprintf(str, "%i", EC_READ_U32(sdodata->data)); break; |
6c21a8d8c785
SDO configurations in Sysfs.
Florian Pose <fp@igh-essen.com>
parents:
461
diff
changeset
|
818 |
default: sprintf(str, "(invalid size)"); break; |
6c21a8d8c785
SDO configurations in Sysfs.
Florian Pose <fp@igh-essen.com>
parents:
461
diff
changeset
|
819 |
} |
6c21a8d8c785
SDO configurations in Sysfs.
Florian Pose <fp@igh-essen.com>
parents:
461
diff
changeset
|
820 |
off += sprintf(buffer + off, " 0x%04X:%-3i -> %s\n", |
6c21a8d8c785
SDO configurations in Sysfs.
Florian Pose <fp@igh-essen.com>
parents:
461
diff
changeset
|
821 |
sdodata->index, sdodata->subindex, str); |
6c21a8d8c785
SDO configurations in Sysfs.
Florian Pose <fp@igh-essen.com>
parents:
461
diff
changeset
|
822 |
} |
6c21a8d8c785
SDO configurations in Sysfs.
Florian Pose <fp@igh-essen.com>
parents:
461
diff
changeset
|
823 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
824 |
off += sprintf(buffer + off, "\n"); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
825 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
826 |
return off; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
827 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
828 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
829 |
/*****************************************************************************/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
830 |
|
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
|
831 |
/** |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
832 |
* Schedules an EEPROM write request. |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
833 |
* \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
|
834 |
*/ |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
835 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
836 |
int ec_slave_schedule_eeprom_writing(ec_eeprom_write_request_t *request) |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
837 |
{ |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
838 |
ec_master_t *master = request->slave->master; |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
839 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
840 |
request->state = EC_EEPROM_REQ_QUEUED; |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
841 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
842 |
// schedule EEPROM write request. |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
843 |
down(&master->eeprom_sem); |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
844 |
list_add_tail(&request->list, &master->eeprom_requests); |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
845 |
up(&master->eeprom_sem); |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
846 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
847 |
// wait for processing through FSM |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
848 |
if (wait_event_interruptible(master->eeprom_queue, |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
849 |
request->state != EC_EEPROM_REQ_QUEUED)) { |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
850 |
// interrupted by signal |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
851 |
down(&master->eeprom_sem); |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
852 |
if (request->state == EC_EEPROM_REQ_QUEUED) { |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
853 |
list_del(&request->list); |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
854 |
up(&master->eeprom_sem); |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
855 |
return -EINTR; |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
856 |
} |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
857 |
// request already processing: interrupt not possible. |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
858 |
up(&master->eeprom_sem); |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
859 |
} |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
860 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
861 |
// wait until master FSM has finished processing |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
862 |
wait_event(master->eeprom_queue, request->state != EC_EEPROM_REQ_BUSY); |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
863 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
864 |
return request->state == EC_EEPROM_REQ_COMPLETED ? 0 : -EIO; |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
865 |
} |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
866 |
|
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 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
869 |
/** |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
870 |
* Writes complete EEPROM contents to a slave. |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
871 |
* \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
|
872 |
*/ |
269 | 873 |
|
874 |
ssize_t ec_slave_write_eeprom(ec_slave_t *slave, /**< EtherCAT slave */ |
|
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
875 |
const uint8_t *data, /**< new EEPROM data */ |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
876 |
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
|
877 |
) |
269 | 878 |
{ |
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
879 |
ec_eeprom_write_request_t request; |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
880 |
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
|
881 |
uint16_t cat_type, cat_size; |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
882 |
int ret; |
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
883 |
|
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
884 |
if (slave->master->mode != EC_MASTER_MODE_IDLE) { // FIXME |
306
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
302
diff
changeset
|
885 |
EC_ERR("Writing EEPROMs only allowed in idle mode!\n"); |
599
a6ce861a167e
ec_slave_write_eeprom now returns certain error codes.
Florian Pose <fp@igh-essen.com>
parents:
597
diff
changeset
|
886 |
return -EBUSY; |
269 | 887 |
} |
888 |
||
889 |
if (size % 2) { |
|
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
890 |
EC_ERR("EEPROM data size is odd! Dropping.\n"); |
599
a6ce861a167e
ec_slave_write_eeprom now returns certain error codes.
Florian Pose <fp@igh-essen.com>
parents:
597
diff
changeset
|
891 |
return -EINVAL; |
269 | 892 |
} |
893 |
||
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
894 |
// init EEPROM write request |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
895 |
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
|
896 |
request.slave = slave; |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
897 |
request.words = (const uint16_t *) data; |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
898 |
request.offset = 0; |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
899 |
request.size = size / 2; |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
900 |
|
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
901 |
if (request.size < 0x0041) { |
269 | 902 |
EC_ERR("EEPROM data too short! Dropping.\n"); |
599
a6ce861a167e
ec_slave_write_eeprom now returns certain error codes.
Florian Pose <fp@igh-essen.com>
parents:
597
diff
changeset
|
903 |
return -EINVAL; |
269 | 904 |
} |
905 |
||
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
906 |
cat_header = request.words + 0x0040; // first category header |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
907 |
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
|
908 |
while (cat_type != 0xFFFF) { // cycle through categories |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
909 |
if (cat_header + 1 > request.words + request.size) { |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
910 |
EC_ERR("EEPROM data corrupted! Dropping.\n"); |
599
a6ce861a167e
ec_slave_write_eeprom now returns certain error codes.
Florian Pose <fp@igh-essen.com>
parents:
597
diff
changeset
|
911 |
return -EINVAL; |
269 | 912 |
} |
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
913 |
cat_size = EC_READ_U16(cat_header + 1); |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
914 |
if (cat_header + cat_size + 2 > request.words + request.size) { |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
915 |
EC_ERR("EEPROM data corrupted! Dropping.\n"); |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
916 |
return -EINVAL; |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
917 |
} |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
918 |
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
|
919 |
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
|
920 |
} |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
599
diff
changeset
|
921 |
|
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
922 |
// EEPROM data ok. schedule writing. |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
923 |
if ((ret = ec_slave_schedule_eeprom_writing(&request))) |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
924 |
return ret; // error code |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
925 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
926 |
return size; // success |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
927 |
} |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
928 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
929 |
/*****************************************************************************/ |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
930 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
931 |
/** |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
932 |
* Writes the Secondary slave address (alias) to the slave's EEPROM. |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
933 |
* \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
|
934 |
*/ |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
935 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
936 |
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
|
937 |
const uint8_t *data, /**< alias string */ |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
938 |
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
|
939 |
) |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
940 |
{ |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
941 |
ec_eeprom_write_request_t request; |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
942 |
char *remainder; |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
943 |
uint16_t alias, word; |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
944 |
int ret; |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
945 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
946 |
if (slave->master->mode != EC_MASTER_MODE_IDLE) { // FIXME |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
947 |
EC_ERR("Writing EEPROMs only allowed in idle mode!\n"); |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
948 |
return -EBUSY; |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
949 |
} |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
950 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
951 |
alias = simple_strtoul(data, &remainder, 0); |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
952 |
if (remainder == (char *) data || (*remainder && *remainder != '\n')) { |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
953 |
EC_ERR("Invalid alias value! Dropping.\n"); |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
954 |
return -EINVAL; |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
955 |
} |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
956 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
957 |
// correct endianess |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
958 |
EC_WRITE_U16(&word, alias); |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
959 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
960 |
// init EEPROM write request |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
961 |
INIT_LIST_HEAD(&request.list); |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
962 |
request.slave = slave; |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
963 |
request.words = &word; |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
964 |
request.offset = 0x0004; |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
965 |
request.size = 1; |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
966 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
967 |
if ((ret = ec_slave_schedule_eeprom_writing(&request))) |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
968 |
return ret; // error code |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
969 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
970 |
slave->sii_alias = alias; // FIXME: do this in state machine |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
971 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
972 |
return size; // success |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
973 |
} |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
974 |
|
269 | 975 |
|
976 |
/*****************************************************************************/ |
|
977 |
||
978 |
/** |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
979 |
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
|
980 |
\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
|
981 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
982 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
983 |
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
|
984 |
struct attribute *attr, /**< attribute */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
985 |
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
|
986 |
) |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
987 |
{ |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
988 |
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
|
989 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
990 |
if (attr == &attr_info) { |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
991 |
return ec_slave_info(slave, buffer); |
185
af570302dcee
Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
992 |
} |
256
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
993 |
else if (attr == &attr_state) { |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
994 |
switch (slave->current_state) { |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
995 |
case EC_SLAVE_STATE_INIT: |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
996 |
return sprintf(buffer, "INIT\n"); |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
997 |
case EC_SLAVE_STATE_PREOP: |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
998 |
return sprintf(buffer, "PREOP\n"); |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
999 |
case EC_SLAVE_STATE_SAVEOP: |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1000 |
return sprintf(buffer, "SAVEOP\n"); |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1001 |
case EC_SLAVE_STATE_OP: |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1002 |
return sprintf(buffer, "OP\n"); |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1003 |
default: |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1004 |
return sprintf(buffer, "UNKNOWN\n"); |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1005 |
} |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1006 |
} |
266
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
1007 |
else if (attr == &attr_eeprom) { |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
1008 |
if (slave->eeprom_data) { |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
1009 |
if (slave->eeprom_size > PAGE_SIZE) { |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
1010 |
EC_ERR("EEPROM contents of slave %i exceed 1 page (%i/%i).\n", |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
1011 |
slave->ring_position, slave->eeprom_size, |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
1012 |
(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
|
1013 |
} |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
1014 |
else { |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
1015 |
memcpy(buffer, slave->eeprom_data, slave->eeprom_size); |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
1016 |
return slave->eeprom_size; |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
1017 |
} |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
1018 |
} |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
1019 |
} |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1020 |
else if (attr == &attr_alias) { |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1021 |
return sprintf(buffer, "%u\n", slave->sii_alias); |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1022 |
} |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
1023 |
|
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
1024 |
return 0; |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
1025 |
} |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
1026 |
|
256
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1027 |
/*****************************************************************************/ |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1028 |
|
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1029 |
/** |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1030 |
Formats attribute data for SysFS write access. |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1031 |
\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
|
1032 |
*/ |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1033 |
|
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1034 |
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
|
1035 |
struct attribute *attr, /**< attribute */ |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1036 |
const char *buffer, /**< memory with data */ |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1037 |
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
|
1038 |
) |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1039 |
{ |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1040 |
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
|
1041 |
|
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1042 |
if (attr == &attr_state) { |
403
7bb931deccd9
Added EC_SLAVE_STATE_ACK_ERR to ec_state_string(); added EC_STATE_STRING_SIZE
Florian Pose <fp@igh-essen.com>
parents:
400
diff
changeset
|
1043 |
char state[EC_STATE_STRING_SIZE]; |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1044 |
if (!strcmp(buffer, "INIT\n")) |
446 | 1045 |
ec_slave_request_state(slave, EC_SLAVE_STATE_INIT); |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1046 |
else if (!strcmp(buffer, "PREOP\n")) |
446 | 1047 |
ec_slave_request_state(slave, EC_SLAVE_STATE_PREOP); |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1048 |
else if (!strcmp(buffer, "SAVEOP\n")) |
446 | 1049 |
ec_slave_request_state(slave, EC_SLAVE_STATE_SAVEOP); |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1050 |
else if (!strcmp(buffer, "OP\n")) |
446 | 1051 |
ec_slave_request_state(slave, EC_SLAVE_STATE_OP); |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1052 |
else { |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1053 |
EC_ERR("Invalid slave state \"%s\"!\n", buffer); |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1054 |
return -EINVAL; |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1055 |
} |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1056 |
|
333
2b15335f9f35
Minor fix: Output of SysFS accepting new slave state.
Florian Pose <fp@igh-essen.com>
parents:
329
diff
changeset
|
1057 |
ec_state_string(slave->requested_state, state); |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1058 |
EC_INFO("Accepted new state %s for slave %i.\n", |
333
2b15335f9f35
Minor fix: Output of SysFS accepting new slave state.
Florian Pose <fp@igh-essen.com>
parents:
329
diff
changeset
|
1059 |
state, slave->ring_position); |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1060 |
return size; |
256
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1061 |
} |
269 | 1062 |
else if (attr == &attr_eeprom) { |
599
a6ce861a167e
ec_slave_write_eeprom now returns certain error codes.
Florian Pose <fp@igh-essen.com>
parents:
597
diff
changeset
|
1063 |
return ec_slave_write_eeprom(slave, buffer, size); |
269 | 1064 |
} |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1065 |
else if (attr == &attr_alias) { |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1066 |
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
|
1067 |
} |
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1068 |
|
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
606
diff
changeset
|
1069 |
return -EIO; |
256
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1070 |
} |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
1071 |
|
275
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1072 |
/*****************************************************************************/ |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1073 |
|
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1074 |
/** |
298
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
296
diff
changeset
|
1075 |
Calculates the size of a sync manager by evaluating PDO sizes. |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
296
diff
changeset
|
1076 |
\return sync manager size |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
296
diff
changeset
|
1077 |
*/ |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
296
diff
changeset
|
1078 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1079 |
uint16_t ec_slave_calc_sync_size(const ec_slave_t *slave, |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1080 |
/**< EtherCAT slave */ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1081 |
const ec_sii_sync_t *sync |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1082 |
/**< sync manager */ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1083 |
) |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1084 |
{ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1085 |
ec_sii_pdo_t *pdo; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1086 |
ec_sii_pdo_entry_t *pdo_entry; |
416
4f007cd2a79d
ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents:
412
diff
changeset
|
1087 |
unsigned int bit_size, byte_size; |
298
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
296
diff
changeset
|
1088 |
|
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
296
diff
changeset
|
1089 |
if (sync->length) return sync->length; |
416
4f007cd2a79d
ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents:
412
diff
changeset
|
1090 |
if (sync->est_length) return sync->est_length; |
298
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
296
diff
changeset
|
1091 |
|
320
71d559ec66d7
Fixed bug with bit-sized PDOs leading to wrong Sync-Manager sizes.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
1092 |
bit_size = 0; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1093 |
list_for_each_entry(pdo, &slave->sii_pdos, list) { |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1094 |
if (pdo->sync_index != sync->index) continue; |
298
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
296
diff
changeset
|
1095 |
|
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
296
diff
changeset
|
1096 |
list_for_each_entry(pdo_entry, &pdo->entries, list) { |
320
71d559ec66d7
Fixed bug with bit-sized PDOs leading to wrong Sync-Manager sizes.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
1097 |
bit_size += pdo_entry->bit_length; |
71d559ec66d7
Fixed bug with bit-sized PDOs leading to wrong Sync-Manager sizes.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
1098 |
} |
71d559ec66d7
Fixed bug with bit-sized PDOs leading to wrong Sync-Manager sizes.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
1099 |
} |
71d559ec66d7
Fixed bug with bit-sized PDOs leading to wrong Sync-Manager sizes.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
1100 |
|
71d559ec66d7
Fixed bug with bit-sized PDOs leading to wrong Sync-Manager sizes.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
1101 |
if (bit_size % 8) // round up to full bytes |
416
4f007cd2a79d
ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents:
412
diff
changeset
|
1102 |
byte_size = bit_size / 8 + 1; |
320
71d559ec66d7
Fixed bug with bit-sized PDOs leading to wrong Sync-Manager sizes.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
1103 |
else |
416
4f007cd2a79d
ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents:
412
diff
changeset
|
1104 |
byte_size = bit_size / 8; |
4f007cd2a79d
ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents:
412
diff
changeset
|
1105 |
|
4f007cd2a79d
ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents:
412
diff
changeset
|
1106 |
return byte_size; |
298
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
296
diff
changeset
|
1107 |
} |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
296
diff
changeset
|
1108 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1109 |
/*****************************************************************************/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1110 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1111 |
/** |
556
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1112 |
Initializes a sync manager configuration page with EEPROM data. |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1113 |
The referenced memory (\a data) must be at least EC_SYNC_SIZE bytes. |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1114 |
*/ |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1115 |
|
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1116 |
void ec_slave_sync_config(const ec_slave_t *slave, /**< EtherCAT slave */ |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1117 |
const ec_sii_sync_t *sync, /**< sync manager */ |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1118 |
uint8_t *data /**> configuration memory */ |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1119 |
) |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1120 |
{ |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1121 |
size_t sync_size; |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1122 |
|
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1123 |
sync_size = ec_slave_calc_sync_size(slave, sync); |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1124 |
|
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1125 |
if (slave->master->debug_level) { |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1126 |
EC_DBG("Slave %3i, SM %i: Addr 0x%04X, Size %3i, Ctrl 0x%02X, En %i\n", |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1127 |
slave->ring_position, sync->index, sync->physical_start_address, |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1128 |
sync_size, sync->control_register, sync->enable); |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1129 |
} |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1130 |
|
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1131 |
EC_WRITE_U16(data, sync->physical_start_address); |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1132 |
EC_WRITE_U16(data + 2, sync_size); |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1133 |
EC_WRITE_U8 (data + 4, sync->control_register); |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1134 |
EC_WRITE_U8 (data + 5, 0x00); // status byte (read only) |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1135 |
EC_WRITE_U16(data + 6, sync->enable ? 0x0001 : 0x0000); // enable |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1136 |
} |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1137 |
|
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1138 |
/*****************************************************************************/ |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1139 |
|
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1140 |
/** |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1141 |
Initializes an FMMU configuration page. |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1142 |
The referenced memory (\a data) must be at least EC_FMMU_SIZE bytes. |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1143 |
*/ |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1144 |
|
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1145 |
void ec_slave_fmmu_config(const ec_slave_t *slave, /**< EtherCAT slave */ |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1146 |
const ec_fmmu_t *fmmu, /**< FMMU */ |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1147 |
uint8_t *data /**> configuration memory */ |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1148 |
) |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1149 |
{ |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1150 |
size_t sync_size; |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1151 |
|
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1152 |
sync_size = ec_slave_calc_sync_size(slave, fmmu->sync); |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1153 |
|
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1154 |
if (slave->master->debug_level) { |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1155 |
EC_DBG("Slave %3i, FMMU %2i:" |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1156 |
" LogAddr 0x%08X, Size %3i, PhysAddr 0x%04X, Dir %s\n", |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1157 |
slave->ring_position, fmmu->index, fmmu->logical_start_address, |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1158 |
sync_size, fmmu->sync->physical_start_address, |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1159 |
((fmmu->sync->control_register & 0x04) ? "out" : "in")); |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1160 |
} |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1161 |
|
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1162 |
EC_WRITE_U32(data, fmmu->logical_start_address); |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1163 |
EC_WRITE_U16(data + 4, sync_size); // size of fmmu |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1164 |
EC_WRITE_U8 (data + 6, 0x00); // logical start bit |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1165 |
EC_WRITE_U8 (data + 7, 0x07); // logical end bit |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1166 |
EC_WRITE_U16(data + 8, fmmu->sync->physical_start_address); |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1167 |
EC_WRITE_U8 (data + 10, 0x00); // physical start bit |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1168 |
EC_WRITE_U8 (data + 11, ((fmmu->sync->control_register & 0x04) |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1169 |
? 0x02 : 0x01)); |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1170 |
EC_WRITE_U16(data + 12, 0x0001); // enable |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1171 |
EC_WRITE_U16(data + 14, 0x0000); // reserved |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1172 |
} |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1173 |
|
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1174 |
/*****************************************************************************/ |
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1175 |
|
dc5829af044d
Made ec_sync_config() and ec_fmmu_config() to methods of ec_slave_t.
Florian Pose <fp@igh-essen.com>
parents:
526
diff
changeset
|
1176 |
/** |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1177 |
\return non-zero if slave is a bus coupler |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1178 |
*/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1179 |
|
343
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
1180 |
int ec_slave_is_coupler(const ec_slave_t *slave /**< EtherCAT slave */) |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1181 |
{ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1182 |
// TODO: Better bus coupler criterion |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1183 |
return slave->sii_vendor_id == 0x00000002 |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1184 |
&& slave->sii_product_code == 0x044C2C52; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1185 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1186 |
|
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1187 |
/*****************************************************************************/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1188 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1189 |
/** |
394
ff1b018a9b09
Added ec_slave_has_subbus()
Florian Pose <fp@igh-essen.com>
parents:
357
diff
changeset
|
1190 |
\return non-zero if slave is a bus coupler |
ff1b018a9b09
Added ec_slave_has_subbus()
Florian Pose <fp@igh-essen.com>
parents:
357
diff
changeset
|
1191 |
*/ |
ff1b018a9b09
Added ec_slave_has_subbus()
Florian Pose <fp@igh-essen.com>
parents:
357
diff
changeset
|
1192 |
|
ff1b018a9b09
Added ec_slave_has_subbus()
Florian Pose <fp@igh-essen.com>
parents:
357
diff
changeset
|
1193 |
int ec_slave_has_subbus(const ec_slave_t *slave /**< EtherCAT slave */) |
ff1b018a9b09
Added ec_slave_has_subbus()
Florian Pose <fp@igh-essen.com>
parents:
357
diff
changeset
|
1194 |
{ |
ff1b018a9b09
Added ec_slave_has_subbus()
Florian Pose <fp@igh-essen.com>
parents:
357
diff
changeset
|
1195 |
return slave->sii_vendor_id == 0x00000002 |
400
99c1085fd5e2
Corrected subbus product code.
Florian Pose <fp@igh-essen.com>
parents:
399
diff
changeset
|
1196 |
&& slave->sii_product_code == 0x04602c22; |
394
ff1b018a9b09
Added ec_slave_has_subbus()
Florian Pose <fp@igh-essen.com>
parents:
357
diff
changeset
|
1197 |
} |
ff1b018a9b09
Added ec_slave_has_subbus()
Florian Pose <fp@igh-essen.com>
parents:
357
diff
changeset
|
1198 |
|
ff1b018a9b09
Added ec_slave_has_subbus()
Florian Pose <fp@igh-essen.com>
parents:
357
diff
changeset
|
1199 |
/*****************************************************************************/ |
ff1b018a9b09
Added ec_slave_has_subbus()
Florian Pose <fp@igh-essen.com>
parents:
357
diff
changeset
|
1200 |
|
ff1b018a9b09
Added ec_slave_has_subbus()
Florian Pose <fp@igh-essen.com>
parents:
357
diff
changeset
|
1201 |
/** |
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1202 |
\return 0 in case of success, else < 0 |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1203 |
*/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1204 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1205 |
int ec_slave_conf_sdo(ec_slave_t *slave, /**< EtherCAT slave */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1206 |
uint16_t sdo_index, /**< SDO index */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1207 |
uint8_t sdo_subindex, /**< SDO subindex */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1208 |
const uint8_t *data, /**< SDO data */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1209 |
size_t size /**< SDO size in bytes */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1210 |
) |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1211 |
{ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1212 |
ec_sdo_data_t *sdodata; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1213 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1214 |
if (!(slave->sii_mailbox_protocols & EC_MBOX_COE)) { |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1215 |
EC_ERR("Slave %i does not support CoE!\n", slave->ring_position); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1216 |
return -1; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1217 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1218 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1219 |
if (!(sdodata = (ec_sdo_data_t *) |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1220 |
kmalloc(sizeof(ec_sdo_data_t), GFP_KERNEL))) { |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1221 |
EC_ERR("Failed to allocate memory for SDO configuration object!\n"); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1222 |
return -1; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1223 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1224 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1225 |
if (!(sdodata->data = (uint8_t *) kmalloc(size, GFP_KERNEL))) { |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1226 |
EC_ERR("Failed to allocate memory for SDO configuration data!\n"); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1227 |
kfree(sdodata); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1228 |
return -1; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1229 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1230 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1231 |
sdodata->index = sdo_index; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1232 |
sdodata->subindex = sdo_subindex; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1233 |
memcpy(sdodata->data, data, size); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1234 |
sdodata->size = size; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1235 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1236 |
list_add_tail(&sdodata->list, &slave->sdo_confs); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1237 |
return 0; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1238 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1239 |
|
410 | 1240 |
/*****************************************************************************/ |
1241 |
||
1242 |
/** |
|
1243 |
\return 0 in case of success, else < 0 |
|
1244 |
*/ |
|
1245 |
||
1246 |
int ec_slave_validate(const ec_slave_t *slave, /**< EtherCAT slave */ |
|
1247 |
uint32_t vendor_id, /**< vendor ID */ |
|
1248 |
uint32_t product_code /**< product code */ |
|
1249 |
) |
|
1250 |
{ |
|
1251 |
if (vendor_id != slave->sii_vendor_id || |
|
1252 |
product_code != slave->sii_product_code) { |
|
1253 |
EC_ERR("Invalid slave type at position %i - Requested: 0x%08X 0x%08X," |
|
1254 |
" found: 0x%08X 0x%08X\".\n", slave->ring_position, vendor_id, |
|
1255 |
product_code, slave->sii_vendor_id, slave->sii_product_code); |
|
1256 |
return -1; |
|
1257 |
} |
|
1258 |
return 0; |
|
1259 |
} |
|
1260 |
||
423
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1261 |
/*****************************************************************************/ |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1262 |
|
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1263 |
/** |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1264 |
Counts the total number of SDOs and entries in the dictionary. |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1265 |
*/ |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1266 |
|
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1267 |
void ec_slave_sdo_dict_info(const ec_slave_t *slave, /**< EtherCAT slave */ |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1268 |
unsigned int *sdo_count, /**< number of SDOs */ |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1269 |
unsigned int *entry_count /**< total number of |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1270 |
entries */ |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1271 |
) |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1272 |
{ |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1273 |
unsigned int sdos = 0, entries = 0; |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1274 |
ec_sdo_t *sdo; |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1275 |
ec_sdo_entry_t *entry; |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1276 |
|
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1277 |
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
|
1278 |
sdos++; |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1279 |
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
|
1280 |
entries++; |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1281 |
} |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1282 |
} |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1283 |
|
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1284 |
*sdo_count = sdos; |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1285 |
*entry_count = entries; |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1286 |
} |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
1287 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1288 |
/****************************************************************************** |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1289 |
* Realtime interface |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1290 |
*****************************************************************************/ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1291 |
|
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1292 |
/** |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1293 |
\return 0 in case of success, else < 0 |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1294 |
\ingroup RealtimeInterface |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1295 |
*/ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1296 |
|
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1297 |
int ecrt_slave_conf_sdo8(ec_slave_t *slave, /**< EtherCAT slave */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1298 |
uint16_t sdo_index, /**< SDO index */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1299 |
uint8_t sdo_subindex, /**< SDO subindex */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1300 |
uint8_t value /**< new SDO value */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1301 |
) |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1302 |
{ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1303 |
uint8_t data[1]; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1304 |
EC_WRITE_U8(data, value); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1305 |
return ec_slave_conf_sdo(slave, sdo_index, sdo_subindex, data, 1); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1306 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1307 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1308 |
/*****************************************************************************/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1309 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1310 |
/** |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1311 |
\return 0 in case of success, else < 0 |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1312 |
\ingroup RealtimeInterface |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1313 |
*/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1314 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1315 |
int ecrt_slave_conf_sdo16(ec_slave_t *slave, /**< EtherCAT slave */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1316 |
uint16_t sdo_index, /**< SDO index */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1317 |
uint8_t sdo_subindex, /**< SDO subindex */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1318 |
uint16_t value /**< new SDO value */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1319 |
) |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1320 |
{ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1321 |
uint8_t data[2]; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1322 |
EC_WRITE_U16(data, value); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1323 |
return ec_slave_conf_sdo(slave, sdo_index, sdo_subindex, data, 2); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1324 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1325 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1326 |
/*****************************************************************************/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1327 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1328 |
/** |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1329 |
\return 0 in case of success, else < 0 |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1330 |
\ingroup RealtimeInterface |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1331 |
*/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1332 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1333 |
int ecrt_slave_conf_sdo32(ec_slave_t *slave, /**< EtherCAT slave */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1334 |
uint16_t sdo_index, /**< SDO index */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1335 |
uint8_t sdo_subindex, /**< SDO subindex */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1336 |
uint32_t value /**< new SDO value */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1337 |
) |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1338 |
{ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1339 |
uint8_t data[4]; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1340 |
EC_WRITE_U32(data, value); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1341 |
return ec_slave_conf_sdo(slave, sdo_index, sdo_subindex, data, 4); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1342 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1343 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1344 |
/*****************************************************************************/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1345 |
|
526 | 1346 |
/** \cond */ |
164
ed85368b2b2e
AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents:
163
diff
changeset
|
1347 |
|
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1348 |
EXPORT_SYMBOL(ecrt_slave_conf_sdo8); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1349 |
EXPORT_SYMBOL(ecrt_slave_conf_sdo16); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1350 |
EXPORT_SYMBOL(ecrt_slave_conf_sdo32); |
138
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
136
diff
changeset
|
1351 |
|
526 | 1352 |
/** \endcond */ |
1353 |
||
1354 |
/*****************************************************************************/ |