author | Florian Pose <fp@igh-essen.com> |
Wed, 18 Oct 2006 13:19:21 +0000 | |
changeset 417 | a4193f7ba5b4 |
parent 416 | 4f007cd2a79d |
child 418 | 7a43437bc48b |
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 *); |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
56 |
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
|
57 |
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
|
58 |
const char *, size_t); |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
59 |
|
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 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
62 |
/** \cond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
63 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
64 |
EC_SYSFS_READ_ATTR(info); |
256
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
65 |
EC_SYSFS_READ_WRITE_ATTR(state); |
269 | 66 |
EC_SYSFS_READ_WRITE_ATTR(eeprom); |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
67 |
|
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
68 |
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
|
69 |
&attr_info, |
256
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
70 |
&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
|
71 |
&attr_eeprom, |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
72 |
NULL, |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
73 |
}; |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
74 |
|
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
75 |
static struct sysfs_ops sysfs_ops = { |
256
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
76 |
.show = ec_show_slave_attribute, |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
77 |
.store = ec_store_slave_attribute |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
78 |
}; |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
79 |
|
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
80 |
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
|
81 |
.release = ec_slave_clear, |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
82 |
.sysfs_ops = &sysfs_ops, |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
83 |
.default_attrs = def_attrs |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
84 |
}; |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
85 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
86 |
/** \endcond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
87 |
|
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
88 |
/*****************************************************************************/ |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
89 |
|
0 | 90 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
91 |
Slave constructor. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
92 |
\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
|
93 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
94 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
95 |
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
|
96 |
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
|
97 |
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
|
98 |
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
|
99 |
) |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
100 |
{ |
142 | 101 |
unsigned int i; |
102 |
||
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
103 |
slave->ring_position = ring_position; |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
104 |
slave->station_address = station_address; |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
105 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
106 |
// init kobject and add it to the hierarchy |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
107 |
memset(&slave->kobj, 0x00, sizeof(struct kobject)); |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
108 |
kobject_init(&slave->kobj); |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
109 |
slave->kobj.ktype = &ktype_ec_slave; |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
110 |
slave->kobj.parent = &master->kobj; |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
111 |
if (kobject_set_name(&slave->kobj, "slave%03i", slave->ring_position)) { |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
112 |
EC_ERR("Failed to set kobject name.\n"); |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
113 |
kobject_put(&slave->kobj); |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
114 |
return -1; |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
115 |
} |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
116 |
|
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
117 |
slave->master = master; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
118 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
119 |
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
|
120 |
slave->current_state = EC_SLAVE_STATE_UNKNOWN; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
121 |
slave->error_flag = 0; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
122 |
slave->online = 1; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
123 |
slave->fmmu_count = 0; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
124 |
slave->registered = 0; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
125 |
|
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
|
126 |
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
|
127 |
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
|
128 |
|
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
129 |
slave->base_type = 0; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
130 |
slave->base_revision = 0; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
131 |
slave->base_build = 0; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
132 |
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
|
133 |
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
|
134 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
135 |
slave->eeprom_data = NULL; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
136 |
slave->eeprom_size = 0; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
137 |
slave->new_eeprom_data = NULL; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
138 |
slave->new_eeprom_size = 0; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
139 |
|
114 | 140 |
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
|
141 |
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
|
142 |
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
|
143 |
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
|
144 |
slave->sii_serial_number = 0; |
136
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
145 |
slave->sii_rx_mailbox_offset = 0; |
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
146 |
slave->sii_rx_mailbox_size = 0; |
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
147 |
slave->sii_tx_mailbox_offset = 0; |
a03a684cac89
Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
148 |
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
|
149 |
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
|
150 |
slave->sii_group = NULL; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
151 |
slave->sii_image = NULL; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
152 |
slave->sii_order = NULL; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
153 |
slave->sii_name = NULL; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
154 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
155 |
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
|
156 |
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
|
157 |
INIT_LIST_HEAD(&slave->sii_pdos); |
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
133
diff
changeset
|
158 |
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
|
159 |
INIT_LIST_HEAD(&slave->sdo_confs); |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
160 |
|
183
8ae1e011e96c
More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents:
182
diff
changeset
|
161 |
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
|
162 |
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
|
163 |
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
|
164 |
slave->dl_signal[i] = 0; |
190
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
165 |
slave->sii_physical_layer[i] = 0xFF; |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
166 |
} |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
167 |
|
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
168 |
return 0; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
169 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
170 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
171 |
/*****************************************************************************/ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
172 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
173 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
174 |
Slave destructor. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
175 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
176 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
177 |
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
|
178 |
{ |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
179 |
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
|
180 |
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
|
181 |
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
|
182 |
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
|
183 |
ec_sii_pdo_entry_t *entry, *next_ent; |
157
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
155
diff
changeset
|
184 |
ec_sdo_t *sdo, *next_sdo; |
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
185 |
ec_sdo_data_t *sdodata, *next_sdodata; |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
186 |
|
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
187 |
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
|
188 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
189 |
// 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
|
190 |
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
|
191 |
list_del(&string->list); |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
192 |
kfree(string); |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
193 |
} |
121
1cd6f7a47b72
Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents:
119
diff
changeset
|
194 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
195 |
// 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
|
196 |
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
|
197 |
list_del(&sync->list); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
198 |
kfree(sync); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
199 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
200 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
201 |
// free all PDOs |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
202 |
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
|
203 |
list_del(&pdo->list); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
204 |
if (pdo->name) kfree(pdo->name); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
205 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
206 |
// free all PDO entries |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
207 |
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
|
208 |
list_del(&entry->list); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
209 |
if (entry->name) kfree(entry->name); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
210 |
kfree(entry); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
211 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
212 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
213 |
kfree(pdo); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
214 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
215 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
216 |
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
|
217 |
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
|
218 |
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
|
219 |
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
|
220 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
221 |
// free all SDOs |
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
133
diff
changeset
|
222 |
list_for_each_entry_safe(sdo, next_sdo, &slave->sdo_dictionary, list) { |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
133
diff
changeset
|
223 |
list_del(&sdo->list); |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
404
diff
changeset
|
224 |
kobject_del(&sdo->kobj); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
404
diff
changeset
|
225 |
kobject_put(&sdo->kobj); |
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
133
diff
changeset
|
226 |
} |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
227 |
|
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
228 |
// free all SDO configurations |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
229 |
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
|
230 |
list_del(&sdodata->list); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
231 |
kfree(sdodata->data); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
232 |
kfree(sdodata); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
233 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
234 |
|
266
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
235 |
if (slave->eeprom_data) kfree(slave->eeprom_data); |
269 | 236 |
if (slave->new_eeprom_data) kfree(slave->new_eeprom_data); |
121
1cd6f7a47b72
Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents:
119
diff
changeset
|
237 |
} |
1cd6f7a47b72
Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents:
119
diff
changeset
|
238 |
|
1cd6f7a47b72
Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents:
119
diff
changeset
|
239 |
/*****************************************************************************/ |
1cd6f7a47b72
Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents:
119
diff
changeset
|
240 |
|
1cd6f7a47b72
Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents:
119
diff
changeset
|
241 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
242 |
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
|
243 |
\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
|
244 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
245 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
246 |
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
|
247 |
const uint8_t *data /**< category data */ |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
248 |
) |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
249 |
{ |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
250 |
unsigned int string_count, i; |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
251 |
size_t size; |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
252 |
off_t offset; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
253 |
ec_sii_string_t *string; |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
254 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
255 |
string_count = data[0]; |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
256 |
offset = 1; |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
257 |
for (i = 0; i < string_count; i++) { |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
258 |
size = data[offset]; |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
259 |
// 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
|
260 |
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
|
261 |
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
|
262 |
EC_ERR("Failed to allocate string memory.\n"); |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
263 |
return -1; |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
264 |
} |
121
1cd6f7a47b72
Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents:
119
diff
changeset
|
265 |
string->size = size; |
161
ddb7266d1c56
Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents:
160
diff
changeset
|
266 |
// 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
|
267 |
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
|
268 |
memcpy(string->data, data + offset + 1, size); |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
269 |
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
|
270 |
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
|
271 |
offset += 1 + size; |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
272 |
} |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
273 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
274 |
return 0; |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
275 |
} |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
276 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
277 |
/*****************************************************************************/ |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
278 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
279 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
280 |
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
|
281 |
\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
|
282 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
283 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
284 |
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
|
285 |
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
|
286 |
) |
123 | 287 |
{ |
190
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
288 |
unsigned int i; |
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
289 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
290 |
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
|
291 |
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
|
292 |
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
|
293 |
ec_slave_locate_string(slave, data[3], &slave->sii_name); |
123 | 294 |
|
190
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
295 |
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
|
296 |
slave->sii_physical_layer[i] = |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
297 |
(data[4] & (0x03 << (i * 2))) >> (i * 2); |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
298 |
} |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
299 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
300 |
/*****************************************************************************/ |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
301 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
302 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
303 |
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
|
304 |
\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
|
305 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
306 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
307 |
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
|
308 |
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
|
309 |
size_t word_count /**< number of words */ |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
310 |
) |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
311 |
{ |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
312 |
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
|
313 |
ec_sii_sync_t *sync; |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
314 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
315 |
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
|
316 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
317 |
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
|
318 |
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
|
319 |
kmalloc(sizeof(ec_sii_sync_t), GFP_ATOMIC))) { |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
320 |
EC_ERR("Failed to allocate Sync-Manager memory.\n"); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
321 |
return -1; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
322 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
323 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
324 |
sync->index = i; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
325 |
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
|
326 |
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
|
327 |
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
|
328 |
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
|
329 |
|
416
4f007cd2a79d
ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents:
412
diff
changeset
|
330 |
sync->est_length = 0; |
4f007cd2a79d
ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents:
412
diff
changeset
|
331 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
332 |
list_add_tail(&sync->list, &slave->sii_syncs); |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
333 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
334 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
335 |
return 0; |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
336 |
} |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
337 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
338 |
/*****************************************************************************/ |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
339 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
340 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
341 |
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
|
342 |
\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
|
343 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
344 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
345 |
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
|
346 |
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
|
347 |
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
|
348 |
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
|
349 |
) |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
350 |
{ |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
351 |
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
|
352 |
ec_sii_pdo_entry_t *entry; |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
353 |
unsigned int entry_count, i; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
354 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
355 |
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
|
356 |
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
|
357 |
kmalloc(sizeof(ec_sii_pdo_t), GFP_ATOMIC))) { |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
358 |
EC_ERR("Failed to allocate PDO memory.\n"); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
359 |
return -1; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
360 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
361 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
362 |
INIT_LIST_HEAD(&pdo->entries); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
363 |
pdo->type = pdo_type; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
364 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
365 |
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
|
366 |
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
|
367 |
pdo->sync_index = EC_READ_U8(data + 3); |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
368 |
pdo->name = NULL; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
369 |
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
|
370 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
371 |
list_add_tail(&pdo->list, &slave->sii_pdos); |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
372 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
373 |
word_count -= 4; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
374 |
data += 8; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
375 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
376 |
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
|
377 |
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
|
378 |
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
|
379 |
EC_ERR("Failed to allocate PDO entry memory.\n"); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
380 |
return -1; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
381 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
382 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
383 |
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
|
384 |
entry->subindex = EC_READ_U8(data + 2); |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
385 |
entry->name = NULL; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
386 |
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
|
387 |
entry->bit_length = EC_READ_U8(data + 5); |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
388 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
389 |
list_add_tail(&entry->list, &pdo->entries); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
390 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
391 |
word_count -= 4; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
392 |
data += 8; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
393 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
394 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
395 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
396 |
return 0; |
114 | 397 |
} |
398 |
||
399 |
/*****************************************************************************/ |
|
400 |
||
401 |
/** |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
402 |
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
|
403 |
\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
|
404 |
\todo documentation |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
405 |
*/ |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
406 |
|
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
407 |
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
|
408 |
unsigned int index, /**< string index */ |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
409 |
char **ptr /**< Address of the string pointer */ |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
410 |
) |
123 | 411 |
{ |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
412 |
ec_sii_string_t *string; |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
413 |
char *err_string; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
414 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
415 |
// Erst alten Speicher freigeben |
123 | 416 |
if (*ptr) { |
417 |
kfree(*ptr); |
|
418 |
*ptr = NULL; |
|
419 |
} |
|
420 |
||
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
421 |
// Index 0 bedeutet "nicht belegt" |
123 | 422 |
if (!index) return 0; |
423 |
||
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
424 |
// 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
|
425 |
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
|
426 |
if (--index) continue; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
427 |
|
296
967aaacf9b20
Avoided crashes on kernel 2.4 acc. to patch by M. Schwerin.
Florian Pose <fp@igh-essen.com>
parents:
293
diff
changeset
|
428 |
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
|
429 |
EC_ERR("Unable to allocate string memory.\n"); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
430 |
return -1; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
431 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
432 |
memcpy(*ptr, string->data, string->size + 1); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
433 |
return 0; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
434 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
435 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
436 |
EC_WARN("String %i not found in slave %i.\n", index, slave->ring_position); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
437 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
438 |
err_string = "(string not found)"; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
439 |
|
296
967aaacf9b20
Avoided crashes on kernel 2.4 acc. to patch by M. Schwerin.
Florian Pose <fp@igh-essen.com>
parents:
293
diff
changeset
|
440 |
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
|
441 |
EC_WARN("Unable to allocate string memory.\n"); |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
442 |
return -1; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
443 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
444 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
445 |
memcpy(*ptr, err_string, strlen(err_string) + 1); |
123 | 446 |
return 0; |
447 |
} |
|
448 |
||
449 |
/*****************************************************************************/ |
|
450 |
||
451 |
/** |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
452 |
Prepares an FMMU configuration. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
453 |
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
|
454 |
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
|
455 |
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
|
456 |
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
|
457 |
for each domain. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
458 |
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
|
459 |
success. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
460 |
\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
|
461 |
*/ |
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 |
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
|
464 |
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
|
465 |
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
|
466 |
) |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
467 |
{ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
468 |
unsigned int i; |
412 | 469 |
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
|
470 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
471 |
// FMMU configuration already prepared? |
412 | 472 |
for (i = 0; i < slave->fmmu_count; i++) { |
473 |
fmmu = &slave->fmmus[i]; |
|
474 |
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
|
475 |
return 0; |
412 | 476 |
} |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
477 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
478 |
// reserve new FMMU... |
91
0120d6214948
Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents:
89
diff
changeset
|
479 |
|
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
480 |
if (slave->fmmu_count >= slave->base_fmmu_count) { |
84
b4ae98855cea
printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents:
77
diff
changeset
|
481 |
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
|
482 |
return -1; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
483 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
484 |
|
412 | 485 |
fmmu = &slave->fmmus[slave->fmmu_count]; |
486 |
||
487 |
fmmu->index = slave->fmmu_count; |
|
488 |
fmmu->domain = domain; |
|
489 |
fmmu->sync = sync; |
|
490 |
fmmu->logical_start_address = 0; |
|
491 |
||
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
492 |
slave->fmmu_count++; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
493 |
slave->registered = 1; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
494 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
495 |
return 0; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
496 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
497 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
498 |
/*****************************************************************************/ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
499 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
500 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
501 |
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
|
502 |
*/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
503 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
504 |
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
|
505 |
char *buffer /**< Output buffer */ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
506 |
) |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
507 |
{ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
508 |
off_t off = 0; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
509 |
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
|
510 |
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
|
511 |
ec_sii_pdo_entry_t *pdo_entry; |
142 | 512 |
int first, i; |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
513 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
514 |
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
|
515 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
516 |
if (slave->sii_name) |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
517 |
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
|
518 |
|
339 | 519 |
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
|
520 |
slave->sii_vendor_id); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
521 |
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
|
522 |
slave->sii_product_code); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
523 |
|
339 | 524 |
off += sprintf(buffer + off, "State: "); |
525 |
off += ec_state_string(slave->current_state, buffer + off); |
|
526 |
off += sprintf(buffer + off, "\nRing position: %i\n", |
|
527 |
slave->ring_position); |
|
357
277de5572f99
Coupler information in slave info file, lines in lsec.
Florian Pose <fp@igh-essen.com>
parents:
349
diff
changeset
|
528 |
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
|
529 |
slave->coupler_index, slave->coupler_subindex); |
357
277de5572f99
Coupler information in slave info file, lines in lsec.
Florian Pose <fp@igh-essen.com>
parents:
349
diff
changeset
|
530 |
off += sprintf(buffer + off, "Coupler: %s\n\n", |
277de5572f99
Coupler information in slave info file, lines in lsec.
Florian Pose <fp@igh-essen.com>
parents:
349
diff
changeset
|
531 |
ec_slave_is_coupler(slave) ? "yes" : "no"); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
532 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
533 |
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
|
534 |
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
|
535 |
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
|
536 |
switch (slave->sii_physical_layer[i]) { |
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
537 |
case 0x00: |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
538 |
off += sprintf(buffer + off, "EBUS"); |
190
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
539 |
break; |
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
540 |
case 0x01: |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
541 |
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
|
542 |
break; |
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
543 |
case 0x02: |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
544 |
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
|
545 |
break; |
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
546 |
default: |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
547 |
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
|
548 |
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
|
549 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
550 |
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
|
551 |
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
|
552 |
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
|
553 |
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
|
554 |
} |
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
555 |
|
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
556 |
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
|
557 |
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
|
558 |
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
|
559 |
" 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
|
560 |
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
|
561 |
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
|
562 |
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
|
563 |
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
|
564 |
off += sprintf(buffer + off, " Supported protocols: "); |
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
565 |
|
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
566 |
first = 1; |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
567 |
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
|
568 |
off += sprintf(buffer + off, "AoE"); |
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
569 |
first = 0; |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
570 |
} |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
571 |
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
|
572 |
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
|
573 |
off += sprintf(buffer + off, "EoE"); |
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
574 |
first = 0; |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
575 |
} |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
576 |
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
|
577 |
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
|
578 |
off += sprintf(buffer + off, "CoE"); |
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
579 |
first = 0; |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
580 |
} |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
581 |
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
|
582 |
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
|
583 |
off += sprintf(buffer + off, "FoE"); |
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
584 |
first = 0; |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
585 |
} |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
586 |
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
|
587 |
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
|
588 |
off += sprintf(buffer + off, "SoE"); |
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
589 |
first = 0; |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
590 |
} |
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
591 |
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
|
592 |
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
|
593 |
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
|
594 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
595 |
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
|
596 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
597 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
598 |
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
|
599 |
|| 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
|
600 |
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
|
601 |
|
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
602 |
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
|
603 |
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
|
604 |
" 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
|
605 |
if (slave->sii_group) |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
606 |
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
|
607 |
if (slave->sii_image) |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
608 |
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
|
609 |
if (slave->sii_order) |
339 | 610 |
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
|
611 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
612 |
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
|
613 |
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
|
614 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
615 |
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
|
616 |
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
|
617 |
" 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
|
618 |
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
|
619 |
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
|
620 |
sync->enable ? "enable" : "disable"); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
621 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
622 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
623 |
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
|
624 |
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
|
625 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
626 |
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
|
627 |
off += sprintf(buffer + off, |
339 | 628 |
" %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
|
629 |
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
|
630 |
pdo->name ? pdo->name : "???", |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
631 |
pdo->index, pdo->sync_index); |
147
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
632 |
|
a355b587b4bc
Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
633 |
list_for_each_entry(pdo_entry, &pdo->entries, list) { |
339 | 634 |
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
|
635 |
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
|
636 |
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
|
637 |
pdo_entry->bit_length); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
638 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
639 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
640 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
641 |
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
|
642 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
643 |
return off; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
644 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
645 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
646 |
/*****************************************************************************/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
647 |
|
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
|
648 |
/** |
269 | 649 |
Schedules an EEPROM write operation. |
650 |
\return 0 in case of success, else < 0 |
|
651 |
*/ |
|
652 |
||
653 |
ssize_t ec_slave_write_eeprom(ec_slave_t *slave, /**< EtherCAT slave */ |
|
654 |
const uint8_t *data, /**< new EEPROM data */ |
|
655 |
size_t size /**< size of data in bytes */ |
|
656 |
) |
|
657 |
{ |
|
658 |
uint16_t word_size, cat_type, cat_size; |
|
659 |
const uint16_t *data_words, *next_header; |
|
660 |
uint16_t *new_data; |
|
661 |
||
662 |
if (!slave->master->eeprom_write_enable) { |
|
663 |
EC_ERR("Writing EEPROMs not allowed! Enable via" |
|
664 |
" eeprom_write_enable SysFS entry.\n"); |
|
665 |
return -1; |
|
666 |
} |
|
667 |
||
306
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
302
diff
changeset
|
668 |
if (slave->master->mode != EC_MASTER_MODE_IDLE) { |
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
302
diff
changeset
|
669 |
EC_ERR("Writing EEPROMs only allowed in idle mode!\n"); |
269 | 670 |
return -1; |
671 |
} |
|
672 |
||
673 |
if (slave->new_eeprom_data) { |
|
674 |
EC_ERR("Slave %i already has a pending EEPROM write operation!\n", |
|
675 |
slave->ring_position); |
|
676 |
return -1; |
|
677 |
} |
|
678 |
||
679 |
// coarse check of the data |
|
680 |
||
681 |
if (size % 2) { |
|
682 |
EC_ERR("EEPROM size is odd! Dropping.\n"); |
|
683 |
return -1; |
|
684 |
} |
|
685 |
||
686 |
data_words = (const uint16_t *) data; |
|
687 |
word_size = size / 2; |
|
688 |
||
689 |
if (word_size < 0x0041) { |
|
690 |
EC_ERR("EEPROM data too short! Dropping.\n"); |
|
691 |
return -1; |
|
692 |
} |
|
693 |
||
694 |
next_header = data_words + 0x0040; |
|
695 |
cat_type = EC_READ_U16(next_header); |
|
696 |
while (cat_type != 0xFFFF) { |
|
697 |
cat_type = EC_READ_U16(next_header); |
|
698 |
cat_size = EC_READ_U16(next_header + 1); |
|
699 |
if ((next_header + cat_size + 2) - data_words >= word_size) { |
|
700 |
EC_ERR("EEPROM data seems to be corrupted! Dropping.\n"); |
|
701 |
return -1; |
|
702 |
} |
|
703 |
next_header += cat_size + 2; |
|
704 |
cat_type = EC_READ_U16(next_header); |
|
705 |
} |
|
706 |
||
707 |
// data ok! |
|
708 |
||
709 |
if (!(new_data = (uint16_t *) kmalloc(word_size * 2, GFP_KERNEL))) { |
|
710 |
EC_ERR("Unable to allocate memory for new EEPROM data!\n"); |
|
711 |
return -1; |
|
712 |
} |
|
713 |
memcpy(new_data, data, size); |
|
714 |
||
715 |
slave->new_eeprom_size = word_size; |
|
716 |
slave->new_eeprom_data = new_data; |
|
717 |
||
718 |
EC_INFO("EEPROM writing scheduled for slave %i, %i words.\n", |
|
719 |
slave->ring_position, word_size); |
|
720 |
return 0; |
|
721 |
} |
|
722 |
||
723 |
/*****************************************************************************/ |
|
724 |
||
725 |
/** |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
726 |
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
|
727 |
\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
|
728 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
729 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
730 |
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
|
731 |
struct attribute *attr, /**< attribute */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
732 |
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
|
733 |
) |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
734 |
{ |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
735 |
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
|
736 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
737 |
if (attr == &attr_info) { |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
738 |
return ec_slave_info(slave, buffer); |
185
af570302dcee
Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents:
184
diff
changeset
|
739 |
} |
256
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
740 |
else if (attr == &attr_state) { |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
741 |
switch (slave->current_state) { |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
742 |
case EC_SLAVE_STATE_INIT: |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
743 |
return sprintf(buffer, "INIT\n"); |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
744 |
case EC_SLAVE_STATE_PREOP: |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
745 |
return sprintf(buffer, "PREOP\n"); |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
746 |
case EC_SLAVE_STATE_SAVEOP: |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
747 |
return sprintf(buffer, "SAVEOP\n"); |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
748 |
case EC_SLAVE_STATE_OP: |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
749 |
return sprintf(buffer, "OP\n"); |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
750 |
default: |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
751 |
return sprintf(buffer, "UNKNOWN\n"); |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
752 |
} |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
753 |
} |
266
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
754 |
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
|
755 |
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
|
756 |
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
|
757 |
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
|
758 |
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
|
759 |
(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
|
760 |
} |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
761 |
else { |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
762 |
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
|
763 |
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
|
764 |
} |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
765 |
} |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
264
diff
changeset
|
766 |
} |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
767 |
|
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
768 |
return 0; |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
769 |
} |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
770 |
|
256
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
771 |
/*****************************************************************************/ |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
772 |
|
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
773 |
/** |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
774 |
Formats attribute data for SysFS write access. |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
775 |
\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
|
776 |
*/ |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
777 |
|
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
778 |
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
|
779 |
struct attribute *attr, /**< attribute */ |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
780 |
const char *buffer, /**< memory with data */ |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
781 |
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
|
782 |
) |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
783 |
{ |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
784 |
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
|
785 |
|
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
786 |
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
|
787 |
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
|
788 |
if (!strcmp(buffer, "INIT\n")) |
256
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
789 |
slave->requested_state = EC_SLAVE_STATE_INIT; |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
790 |
else if (!strcmp(buffer, "PREOP\n")) |
256
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
791 |
slave->requested_state = EC_SLAVE_STATE_PREOP; |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
792 |
else if (!strcmp(buffer, "SAVEOP\n")) |
256
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
793 |
slave->requested_state = EC_SLAVE_STATE_SAVEOP; |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
794 |
else if (!strcmp(buffer, "OP\n")) |
256
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
795 |
slave->requested_state = EC_SLAVE_STATE_OP; |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
796 |
else { |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
797 |
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
|
798 |
return -EINVAL; |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
799 |
} |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
800 |
|
333
2b15335f9f35
Minor fix: Output of SysFS accepting new slave state.
Florian Pose <fp@igh-essen.com>
parents:
329
diff
changeset
|
801 |
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
|
802 |
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
|
803 |
state, slave->ring_position); |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
804 |
slave->error_flag = 0; |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
805 |
return size; |
256
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
806 |
} |
269 | 807 |
else if (attr == &attr_eeprom) { |
808 |
if (!ec_slave_write_eeprom(slave, buffer, size)) |
|
809 |
return size; |
|
810 |
} |
|
256
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
811 |
|
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
812 |
return -EINVAL; |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
813 |
} |
dc71aee17f8a
SysFS write access for slave state.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
814 |
|
275
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
815 |
/*****************************************************************************/ |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
816 |
|
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
817 |
/** |
298
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
296
diff
changeset
|
818 |
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
|
819 |
\return sync manager size |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
296
diff
changeset
|
820 |
*/ |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
296
diff
changeset
|
821 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
822 |
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
|
823 |
/**< EtherCAT slave */ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
824 |
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
|
825 |
/**< sync manager */ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
826 |
) |
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 |
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
|
829 |
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
|
830 |
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
|
831 |
|
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
296
diff
changeset
|
832 |
if (sync->length) return sync->length; |
416
4f007cd2a79d
ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents:
412
diff
changeset
|
833 |
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
|
834 |
|
320
71d559ec66d7
Fixed bug with bit-sized PDOs leading to wrong Sync-Manager sizes.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
835 |
bit_size = 0; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
836 |
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
|
837 |
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
|
838 |
|
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
296
diff
changeset
|
839 |
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
|
840 |
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
|
841 |
} |
71d559ec66d7
Fixed bug with bit-sized PDOs leading to wrong Sync-Manager sizes.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
842 |
} |
71d559ec66d7
Fixed bug with bit-sized PDOs leading to wrong Sync-Manager sizes.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
843 |
|
71d559ec66d7
Fixed bug with bit-sized PDOs leading to wrong Sync-Manager sizes.
Florian Pose <fp@igh-essen.com>
parents:
315
diff
changeset
|
844 |
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
|
845 |
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
|
846 |
else |
416
4f007cd2a79d
ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents:
412
diff
changeset
|
847 |
byte_size = bit_size / 8; |
4f007cd2a79d
ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents:
412
diff
changeset
|
848 |
|
4f007cd2a79d
ecrt_domain_register_pdo_range() implemented.
Florian Pose <fp@igh-essen.com>
parents:
412
diff
changeset
|
849 |
return byte_size; |
298
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
296
diff
changeset
|
850 |
} |
d491d1f84ebc
Prefer EEPROM sync manager information for config.
Florian Pose <fp@igh-essen.com>
parents:
296
diff
changeset
|
851 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
852 |
/*****************************************************************************/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
853 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
854 |
/** |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
855 |
\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
|
856 |
*/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
857 |
|
343
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
858 |
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
|
859 |
{ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
860 |
// 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
|
861 |
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
|
862 |
&& 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
|
863 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
864 |
|
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
865 |
/*****************************************************************************/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
866 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
867 |
/** |
394
ff1b018a9b09
Added ec_slave_has_subbus()
Florian Pose <fp@igh-essen.com>
parents:
357
diff
changeset
|
868 |
\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
|
869 |
*/ |
ff1b018a9b09
Added ec_slave_has_subbus()
Florian Pose <fp@igh-essen.com>
parents:
357
diff
changeset
|
870 |
|
ff1b018a9b09
Added ec_slave_has_subbus()
Florian Pose <fp@igh-essen.com>
parents:
357
diff
changeset
|
871 |
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
|
872 |
{ |
ff1b018a9b09
Added ec_slave_has_subbus()
Florian Pose <fp@igh-essen.com>
parents:
357
diff
changeset
|
873 |
return slave->sii_vendor_id == 0x00000002 |
400
99c1085fd5e2
Corrected subbus product code.
Florian Pose <fp@igh-essen.com>
parents:
399
diff
changeset
|
874 |
&& slave->sii_product_code == 0x04602c22; |
394
ff1b018a9b09
Added ec_slave_has_subbus()
Florian Pose <fp@igh-essen.com>
parents:
357
diff
changeset
|
875 |
} |
ff1b018a9b09
Added ec_slave_has_subbus()
Florian Pose <fp@igh-essen.com>
parents:
357
diff
changeset
|
876 |
|
ff1b018a9b09
Added ec_slave_has_subbus()
Florian Pose <fp@igh-essen.com>
parents:
357
diff
changeset
|
877 |
/*****************************************************************************/ |
ff1b018a9b09
Added ec_slave_has_subbus()
Florian Pose <fp@igh-essen.com>
parents:
357
diff
changeset
|
878 |
|
ff1b018a9b09
Added ec_slave_has_subbus()
Florian Pose <fp@igh-essen.com>
parents:
357
diff
changeset
|
879 |
/** |
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
880 |
\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
|
881 |
*/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
882 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
883 |
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
|
884 |
uint16_t sdo_index, /**< SDO index */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
885 |
uint8_t sdo_subindex, /**< SDO subindex */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
886 |
const uint8_t *data, /**< SDO data */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
887 |
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
|
888 |
) |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
889 |
{ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
890 |
ec_sdo_data_t *sdodata; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
891 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
892 |
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
|
893 |
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
|
894 |
return -1; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
895 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
896 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
897 |
if (!(sdodata = (ec_sdo_data_t *) |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
898 |
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
|
899 |
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
|
900 |
return -1; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
901 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
902 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
903 |
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
|
904 |
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
|
905 |
kfree(sdodata); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
906 |
return -1; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
907 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
908 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
909 |
sdodata->index = sdo_index; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
910 |
sdodata->subindex = sdo_subindex; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
911 |
memcpy(sdodata->data, data, size); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
912 |
sdodata->size = size; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
913 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
914 |
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
|
915 |
return 0; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
916 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
917 |
|
410 | 918 |
/*****************************************************************************/ |
919 |
||
920 |
/** |
|
921 |
\return 0 in case of success, else < 0 |
|
922 |
*/ |
|
923 |
||
924 |
int ec_slave_validate(const ec_slave_t *slave, /**< EtherCAT slave */ |
|
925 |
uint32_t vendor_id, /**< vendor ID */ |
|
926 |
uint32_t product_code /**< product code */ |
|
927 |
) |
|
928 |
{ |
|
929 |
if (vendor_id != slave->sii_vendor_id || |
|
930 |
product_code != slave->sii_product_code) { |
|
931 |
EC_ERR("Invalid slave type at position %i - Requested: 0x%08X 0x%08X," |
|
932 |
" found: 0x%08X 0x%08X\".\n", slave->ring_position, vendor_id, |
|
933 |
product_code, slave->sii_vendor_id, slave->sii_product_code); |
|
934 |
return -1; |
|
935 |
} |
|
936 |
return 0; |
|
937 |
} |
|
938 |
||
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
939 |
/****************************************************************************** |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
940 |
* Realtime interface |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
941 |
*****************************************************************************/ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
942 |
|
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
943 |
/** |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
944 |
\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
|
945 |
\ingroup RealtimeInterface |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
946 |
*/ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
947 |
|
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
948 |
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
|
949 |
uint16_t sdo_index, /**< SDO index */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
950 |
uint8_t sdo_subindex, /**< SDO subindex */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
951 |
uint8_t value /**< new SDO value */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
952 |
) |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
953 |
{ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
954 |
uint8_t data[1]; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
955 |
EC_WRITE_U8(data, value); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
956 |
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
|
957 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
958 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
959 |
/*****************************************************************************/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
960 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
961 |
/** |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
962 |
\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
|
963 |
\ingroup RealtimeInterface |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
964 |
*/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
965 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
966 |
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
|
967 |
uint16_t sdo_index, /**< SDO index */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
968 |
uint8_t sdo_subindex, /**< SDO subindex */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
969 |
uint16_t value /**< new SDO value */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
970 |
) |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
971 |
{ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
972 |
uint8_t data[2]; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
973 |
EC_WRITE_U16(data, value); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
974 |
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
|
975 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
976 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
977 |
/*****************************************************************************/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
978 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
979 |
/** |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
980 |
\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
|
981 |
\ingroup RealtimeInterface |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
982 |
*/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
983 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
984 |
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
|
985 |
uint16_t sdo_index, /**< SDO index */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
986 |
uint8_t sdo_subindex, /**< SDO subindex */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
987 |
uint32_t value /**< new SDO value */ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
988 |
) |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
989 |
{ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
990 |
uint8_t data[4]; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
991 |
EC_WRITE_U32(data, value); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
992 |
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
|
993 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
994 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
995 |
/*****************************************************************************/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
996 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
997 |
/** |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
998 |
\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
|
999 |
\ingroup RealtimeInterface |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1000 |
*/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1001 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1002 |
int ecrt_slave_pdo_size(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
|
1003 |
uint16_t pdo_index, /**< PDO index */ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1004 |
uint8_t pdo_subindex, /**< PDO subindex */ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1005 |
size_t size /**< new PDO size */ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1006 |
) |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1007 |
{ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1008 |
EC_WARN("ecrt_slave_pdo_size() currently not available.\n"); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1009 |
return -1; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1010 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1011 |
#if 0 |
275
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1012 |
unsigned int i, j, field_counter; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1013 |
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
|
1014 |
const ec_pdo_t *pdo; |
275
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1015 |
ec_varsize_t *var; |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1016 |
|
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1017 |
if (!slave->type) { |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1018 |
EC_ERR("Slave %i has no type information!\n", slave->ring_position); |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1019 |
return -1; |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1020 |
} |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1021 |
|
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1022 |
field_counter = 0; |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1023 |
for (i = 0; (sync = slave->type->sync_managers[i]); i++) { |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1024 |
for (j = 0; (field = sync->fields[j]); j++) { |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1025 |
if (!strcmp(field->name, field_name)) { |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1026 |
if (field_counter++ == field_index) { |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1027 |
// is the size of this field variable? |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1028 |
if (field->size) { |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1029 |
EC_ERR("Field \"%s\"[%i] of slave %i has no variable" |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1030 |
" size!\n", field->name, field_index, |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1031 |
slave->ring_position); |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1032 |
return -1; |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1033 |
} |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1034 |
// does a size specification already exist? |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1035 |
list_for_each_entry(var, &slave->varsize_fields, list) { |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1036 |
if (var->field == field) { |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1037 |
EC_WARN("Resizing field \"%s\"[%i] of slave %i.\n", |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1038 |
field->name, field_index, |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1039 |
slave->ring_position); |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1040 |
var->size = size; |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1041 |
return 0; |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1042 |
} |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1043 |
} |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1044 |
// create a new size specification... |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1045 |
if (!(var = kmalloc(sizeof(ec_varsize_t), GFP_KERNEL))) { |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1046 |
EC_ERR("Failed to allocate memory for varsize_t!\n"); |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1047 |
return -1; |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1048 |
} |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1049 |
var->field = field; |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1050 |
var->size = size; |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1051 |
list_add_tail(&var->list, &slave->varsize_fields); |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1052 |
return 0; |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1053 |
} |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1054 |
} |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1055 |
} |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1056 |
} |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1057 |
|
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1058 |
EC_ERR("Slave %i (\"%s %s\") has no field \"%s\"[%i]!\n", |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1059 |
slave->ring_position, slave->type->vendor_name, |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1060 |
slave->type->product_name, field_name, field_index); |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1061 |
return -1; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1062 |
#endif |
275
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1063 |
} |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1064 |
|
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1065 |
/*****************************************************************************/ |
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1066 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1067 |
/**< \cond */ |
164
ed85368b2b2e
AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents:
163
diff
changeset
|
1068 |
|
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1069 |
EXPORT_SYMBOL(ecrt_slave_conf_sdo8); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1070 |
EXPORT_SYMBOL(ecrt_slave_conf_sdo16); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
1071 |
EXPORT_SYMBOL(ecrt_slave_conf_sdo32); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
1072 |
EXPORT_SYMBOL(ecrt_slave_pdo_size); |
138
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
136
diff
changeset
|
1073 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1074 |
/**< \endcond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1075 |
|
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
1076 |
/*****************************************************************************/ |