author | Florian Pose <fp@igh-essen.com> |
Thu, 10 Jul 2008 09:36:47 +0000 | |
changeset 1109 | 11ac4051db6b |
parent 1082 | ff06c58e269c |
child 1183 | d77f634ab0b5 |
permissions | -rw-r--r-- |
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
26
diff
changeset
|
1 |
/****************************************************************************** |
0 | 2 |
* |
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
26
diff
changeset
|
3 |
* $Id$ |
0 | 4 |
* |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
5 |
* Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
6 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
8 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
10 |
* and/or modify it under the terms of the GNU General Public License |
246
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
11 |
* as published by the Free Software Foundation; either version 2 of the |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
12 |
* License, or (at your option) any later version. |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
13 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
14 |
* The IgH EtherCAT Master is distributed in the hope that it will be |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
15 |
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
17 |
* GNU General Public License for more details. |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
18 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
19 |
* You should have received a copy of the GNU General Public License |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
20 |
* along with the IgH EtherCAT Master; if not, write to the Free Software |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
21 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
22 |
* |
246
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
23 |
* The right to use EtherCAT Technology is granted and comes free of |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
24 |
* charge under condition of compatibility of product made by |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
25 |
* Licensee. People intending to distribute/sell products based on the |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
26 |
* code, have to sign an agreement to guarantee that products using |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
27 |
* software based on IgH EtherCAT master stay compatible with the actual |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
28 |
* EtherCAT specification (which are released themselves as an open |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
29 |
* standard) as the (only) precondition to have the right to use EtherCAT |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
30 |
* Technology, IP and trade marks. |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
31 |
* |
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
26
diff
changeset
|
32 |
*****************************************************************************/ |
0 | 33 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
34 |
/** |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
35 |
\file |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
36 |
EtherCAT slave methods. |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
37 |
*/ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
38 |
|
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
39 |
/*****************************************************************************/ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
40 |
|
24
d417dd9bdc2f
Wilhelms ?nderungen ?bernommen.
Florian Pose <fp@igh-essen.com>
parents:
23
diff
changeset
|
41 |
#include <linux/module.h> |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
42 |
#include <linux/delay.h> |
0 | 43 |
|
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
44 |
#include "globals.h" |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
45 |
#include "datagram.h" |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
91
diff
changeset
|
46 |
#include "master.h" |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
47 |
#include "slave_config.h" |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
48 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
49 |
#include "slave.h" |
0 | 50 |
|
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
26
diff
changeset
|
51 |
/*****************************************************************************/ |
0 | 52 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
53 |
extern const ec_code_msg_t al_status_messages[]; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
54 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
55 |
/*****************************************************************************/ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
56 |
|
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
57 |
char *ec_slave_sii_string(ec_slave_t *, unsigned int); |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
58 |
|
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 |
|
0 | 61 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
62 |
Slave constructor. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
63 |
\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
|
64 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
65 |
|
992
50a44cbd30af
Removed kobjects from sdo and slave.
Florian Pose <fp@igh-essen.com>
parents:
980
diff
changeset
|
66 |
void ec_slave_init( |
50a44cbd30af
Removed kobjects from sdo and slave.
Florian Pose <fp@igh-essen.com>
parents:
980
diff
changeset
|
67 |
ec_slave_t *slave, /**< EtherCAT slave */ |
50a44cbd30af
Removed kobjects from sdo and slave.
Florian Pose <fp@igh-essen.com>
parents:
980
diff
changeset
|
68 |
ec_master_t *master, /**< EtherCAT master */ |
50a44cbd30af
Removed kobjects from sdo and slave.
Florian Pose <fp@igh-essen.com>
parents:
980
diff
changeset
|
69 |
uint16_t ring_position, /**< ring position */ |
50a44cbd30af
Removed kobjects from sdo and slave.
Florian Pose <fp@igh-essen.com>
parents:
980
diff
changeset
|
70 |
uint16_t station_address /**< station address to configure */ |
50a44cbd30af
Removed kobjects from sdo and slave.
Florian Pose <fp@igh-essen.com>
parents:
980
diff
changeset
|
71 |
) |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
72 |
{ |
142 | 73 |
unsigned int i; |
74 |
||
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
992
diff
changeset
|
75 |
slave->master = master; |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
76 |
slave->ring_position = ring_position; |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
77 |
slave->station_address = station_address; |
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
78 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
79 |
slave->config = NULL; |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
649
diff
changeset
|
80 |
slave->requested_state = EC_SLAVE_STATE_PREOP; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
81 |
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
|
82 |
slave->error_flag = 0; |
908
386b908033be
Replaced self_configured flag with force_config flag.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
83 |
slave->force_config = 0; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
84 |
|
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
85 |
slave->base_type = 0; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
86 |
slave->base_revision = 0; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
87 |
slave->base_build = 0; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
88 |
slave->base_fmmu_count = 0; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
89 |
|
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
90 |
for (i = 0; i < EC_MAX_PORTS; i++) { |
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
992
diff
changeset
|
91 |
slave->ports[i].dl_link = 0; |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
992
diff
changeset
|
92 |
slave->ports[i].dl_loop = 0; |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
992
diff
changeset
|
93 |
slave->ports[i].dl_signal = 0; |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
992
diff
changeset
|
94 |
slave->sii.physical_layer[i] = 0xFF; |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
992
diff
changeset
|
95 |
} |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
992
diff
changeset
|
96 |
|
977 | 97 |
slave->sii_words = NULL; |
98 |
slave->sii_nwords = 0; |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
99 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
100 |
slave->sii.alias = 0; |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
101 |
slave->sii.vendor_id = 0; |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
102 |
slave->sii.product_code = 0; |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
103 |
slave->sii.revision_number = 0; |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
104 |
slave->sii.serial_number = 0; |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
105 |
slave->sii.rx_mailbox_offset = 0; |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
106 |
slave->sii.rx_mailbox_size = 0; |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
107 |
slave->sii.tx_mailbox_offset = 0; |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
108 |
slave->sii.tx_mailbox_size = 0; |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
109 |
slave->sii.mailbox_protocols = 0; |
835
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
110 |
|
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
111 |
slave->sii.strings = NULL; |
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
112 |
slave->sii.string_count = 0; |
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
113 |
|
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
114 |
slave->sii.has_general = 0; |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
115 |
slave->sii.group = NULL; |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
116 |
slave->sii.image = NULL; |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
117 |
slave->sii.order = NULL; |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
118 |
slave->sii.name = NULL; |
835
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
119 |
memset(&slave->sii.coe_details, 0x00, sizeof(ec_sii_coe_details_t)); |
836 | 120 |
memset(&slave->sii.general_flags, 0x00, sizeof(ec_sii_general_flags_t)); |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
121 |
slave->sii.current_on_ebus = 0; |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
122 |
|
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
123 |
slave->sii.syncs = NULL; |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
124 |
slave->sii.sync_count = 0; |
835
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
125 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
126 |
INIT_LIST_HEAD(&slave->sii.pdos); |
835
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
127 |
|
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
133
diff
changeset
|
128 |
INIT_LIST_HEAD(&slave->sdo_dictionary); |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
129 |
|
419
cf724fc82a00
Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents:
418
diff
changeset
|
130 |
slave->sdo_dictionary_fetched = 0; |
cf724fc82a00
Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents:
418
diff
changeset
|
131 |
slave->jiffies_preop = 0; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
132 |
} |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
133 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
134 |
/*****************************************************************************/ |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
135 |
|
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
55
diff
changeset
|
136 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
137 |
Slave destructor. |
448
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
138 |
Clears and frees a slave object. |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
139 |
*/ |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
140 |
|
992
50a44cbd30af
Removed kobjects from sdo and slave.
Florian Pose <fp@igh-essen.com>
parents:
980
diff
changeset
|
141 |
void ec_slave_clear(ec_slave_t *slave /**< EtherCAT slave */) |
448
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
142 |
{ |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
143 |
ec_sdo_t *sdo, *next_sdo; |
992
50a44cbd30af
Removed kobjects from sdo and slave.
Florian Pose <fp@igh-essen.com>
parents:
980
diff
changeset
|
144 |
unsigned int i; |
50a44cbd30af
Removed kobjects from sdo and slave.
Florian Pose <fp@igh-essen.com>
parents:
980
diff
changeset
|
145 |
ec_pdo_t *pdo, *next_pdo; |
448
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
146 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
147 |
if (slave->config) |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
148 |
ec_slave_config_detach(slave->config); |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
149 |
|
814 | 150 |
// free all Sdos |
448
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
151 |
list_for_each_entry_safe(sdo, next_sdo, &slave->sdo_dictionary, list) { |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
152 |
list_del(&sdo->list); |
992
50a44cbd30af
Removed kobjects from sdo and slave.
Florian Pose <fp@igh-essen.com>
parents:
980
diff
changeset
|
153 |
ec_sdo_clear(sdo); |
50a44cbd30af
Removed kobjects from sdo and slave.
Florian Pose <fp@igh-essen.com>
parents:
980
diff
changeset
|
154 |
kfree(sdo); |
50a44cbd30af
Removed kobjects from sdo and slave.
Florian Pose <fp@igh-essen.com>
parents:
980
diff
changeset
|
155 |
} |
182
8c0bc99229a9
Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
156 |
|
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
157 |
// free all strings |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
158 |
if (slave->sii.strings) { |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
159 |
for (i = 0; i < slave->sii.string_count; i++) |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
160 |
kfree(slave->sii.strings[i]); |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
161 |
kfree(slave->sii.strings); |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
162 |
} |
121
1cd6f7a47b72
Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents:
119
diff
changeset
|
163 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
164 |
// free all sync managers |
870
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
165 |
ec_slave_clear_sync_managers(slave); |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
166 |
|
814 | 167 |
// free all SII Pdos |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
168 |
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
|
169 |
list_del(&pdo->list); |
627
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
626
diff
changeset
|
170 |
ec_pdo_clear(pdo); |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
171 |
kfree(pdo); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
172 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
173 |
|
977 | 174 |
if (slave->sii_words) |
175 |
kfree(slave->sii_words); |
|
482
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
176 |
} |
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
177 |
|
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
178 |
/*****************************************************************************/ |
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
179 |
|
870
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
180 |
/** Clear the sync manager array. |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
181 |
*/ |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
182 |
void ec_slave_clear_sync_managers(ec_slave_t *slave /**< EtherCAT slave. */) |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
183 |
{ |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
184 |
unsigned int i; |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
185 |
|
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
186 |
if (slave->sii.syncs) { |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
187 |
for (i = 0; i < slave->sii.sync_count; i++) { |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
188 |
ec_sync_clear(&slave->sii.syncs[i]); |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
189 |
} |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
190 |
kfree(slave->sii.syncs); |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
191 |
slave->sii.syncs = NULL; |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
192 |
} |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
193 |
} |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
194 |
|
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
195 |
/*****************************************************************************/ |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
196 |
|
482
fbaaaf2a6234
Added clear function for SDO kobject.
Florian Pose <fp@igh-essen.com>
parents:
467
diff
changeset
|
197 |
/** |
610
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
198 |
* Sets the application state of a slave. |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
199 |
*/ |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
200 |
|
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
201 |
void ec_slave_set_state(ec_slave_t *slave, /**< EtherCAT slave */ |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
202 |
ec_slave_state_t new_state /**< new application state */ |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
203 |
) |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
204 |
{ |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
205 |
if (new_state != slave->current_state) { |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
206 |
if (slave->master->debug_level) { |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
207 |
char old_state[EC_STATE_STRING_SIZE], |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
208 |
cur_state[EC_STATE_STRING_SIZE]; |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
209 |
ec_state_string(slave->current_state, old_state); |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
210 |
ec_state_string(new_state, cur_state); |
784
0a0994fdafb8
Esthetic surgery for slave.
Florian Pose <fp@igh-essen.com>
parents:
772
diff
changeset
|
211 |
EC_DBG("Slave %u: %s -> %s.\n", |
610
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
212 |
slave->ring_position, old_state, cur_state); |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
213 |
} |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
214 |
slave->current_state = new_state; |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
215 |
} |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
216 |
} |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
217 |
|
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
218 |
/*****************************************************************************/ |
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
219 |
|
29489a43ecee
Introduced ec_slave_online_state_t, ec_slave_set_online_state(), renamed
Florian Pose <fp@igh-essen.com>
parents:
609
diff
changeset
|
220 |
/** |
758
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
221 |
* Request a slave state and resets the error flag. |
446 | 222 |
*/ |
223 |
||
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
224 |
void ec_slave_request_state(ec_slave_t *slave, /**< EtherCAT slave */ |
446 | 225 |
ec_slave_state_t state /**< new state */ |
226 |
) |
|
227 |
{ |
|
228 |
slave->requested_state = state; |
|
229 |
slave->error_flag = 0; |
|
230 |
} |
|
231 |
||
232 |
/*****************************************************************************/ |
|
233 |
||
234 |
/** |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
235 |
Fetches data from a STRING category. |
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
236 |
\todo range checking |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
237 |
\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
|
238 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
239 |
|
620
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
240 |
int ec_slave_fetch_sii_strings( |
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
241 |
ec_slave_t *slave, /**< EtherCAT slave */ |
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
242 |
const uint8_t *data, /**< category data */ |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
243 |
size_t data_size /**< number of bytes */ |
620
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
244 |
) |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
245 |
{ |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
246 |
int i; |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
247 |
size_t size; |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
248 |
off_t offset; |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
249 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
250 |
slave->sii.string_count = data[0]; |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
251 |
|
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
252 |
if (!slave->sii.string_count) |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
253 |
return 0; |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
254 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
255 |
if (!(slave->sii.strings = |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
256 |
kmalloc(sizeof(char *) * slave->sii.string_count, |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
257 |
GFP_KERNEL))) { |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
258 |
EC_ERR("Failed to allocate string array memory.\n"); |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
259 |
goto out_zero; |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
260 |
} |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
261 |
|
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
262 |
offset = 1; |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
263 |
for (i = 0; i < slave->sii.string_count; i++) { |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
264 |
size = data[offset]; |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
265 |
// allocate memory for string structure and data at a single blow |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
266 |
if (!(slave->sii.strings[i] = |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
267 |
kmalloc(sizeof(char) * size + 1, GFP_KERNEL))) { |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
268 |
EC_ERR("Failed to allocate string memory.\n"); |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
269 |
goto out_free; |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
270 |
} |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
271 |
memcpy(slave->sii.strings[i], data + offset + 1, size); |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
272 |
slave->sii.strings[i][size] = 0x00; // append binary zero |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
273 |
offset += 1 + size; |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
274 |
} |
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 |
return 0; |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
277 |
|
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
278 |
out_free: |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
279 |
for (i--; i >= 0; i--) kfree(slave->sii.strings[i]); |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
280 |
kfree(slave->sii.strings); |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
281 |
slave->sii.strings = NULL; |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
282 |
out_zero: |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
283 |
slave->sii.string_count = 0; |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
284 |
return -1; |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
285 |
} |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
286 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
287 |
/*****************************************************************************/ |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
288 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
289 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
290 |
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
|
291 |
\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
|
292 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
293 |
|
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
294 |
int ec_slave_fetch_sii_general( |
620
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
295 |
ec_slave_t *slave, /**< EtherCAT slave */ |
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
296 |
const uint8_t *data, /**< category data */ |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
297 |
size_t data_size /**< size in bytes */ |
620
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
298 |
) |
123 | 299 |
{ |
190
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
300 |
unsigned int i; |
876
8acdecb5a75e
Fixed general flags on big-endian archs.
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
301 |
uint8_t flags; |
190
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
302 |
|
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
303 |
if (data_size != 32) { |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
304 |
EC_ERR("Wrong size of general category (%u/32) in slave %u.\n", |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
305 |
data_size, slave->ring_position); |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
306 |
return -1; |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
307 |
} |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
308 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
309 |
slave->sii.group = ec_slave_sii_string(slave, data[0]); |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
310 |
slave->sii.image = ec_slave_sii_string(slave, data[1]); |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
311 |
slave->sii.order = ec_slave_sii_string(slave, data[2]); |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
312 |
slave->sii.name = ec_slave_sii_string(slave, data[3]); |
123 | 313 |
|
190
4e32bcc6b361
Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents:
188
diff
changeset
|
314 |
for (i = 0; i < 4; i++) |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
315 |
slave->sii.physical_layer[i] = |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
316 |
(data[4] & (0x03 << (i * 2))) >> (i * 2); |
499
fb005e975181
Current consumption in sysfs; "lsec -c" shows current consumption and remaining current.
Florian Pose <fp@igh-essen.com>
parents:
484
diff
changeset
|
317 |
|
876
8acdecb5a75e
Fixed general flags on big-endian archs.
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
318 |
// read CoE details |
8acdecb5a75e
Fixed general flags on big-endian archs.
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
319 |
flags = EC_READ_U8(data + 5); |
8acdecb5a75e
Fixed general flags on big-endian archs.
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
320 |
slave->sii.coe_details.enable_sdo = (flags >> 0) & 0x01; |
8acdecb5a75e
Fixed general flags on big-endian archs.
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
321 |
slave->sii.coe_details.enable_sdo_info = (flags >> 1) & 0x01; |
8acdecb5a75e
Fixed general flags on big-endian archs.
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
322 |
slave->sii.coe_details.enable_pdo_assign = (flags >> 2) & 0x01; |
8acdecb5a75e
Fixed general flags on big-endian archs.
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
323 |
slave->sii.coe_details.enable_pdo_configuration = (flags >> 3) & 0x01; |
8acdecb5a75e
Fixed general flags on big-endian archs.
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
324 |
slave->sii.coe_details.enable_upload_at_startup = (flags >> 4) & 0x01; |
8acdecb5a75e
Fixed general flags on big-endian archs.
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
325 |
slave->sii.coe_details.enable_sdo_complete_access = (flags >> 5) & 0x01; |
8acdecb5a75e
Fixed general flags on big-endian archs.
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
326 |
|
8acdecb5a75e
Fixed general flags on big-endian archs.
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
327 |
// read general flags |
8acdecb5a75e
Fixed general flags on big-endian archs.
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
328 |
flags = EC_READ_U8(data + 0x000B); |
8acdecb5a75e
Fixed general flags on big-endian archs.
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
329 |
slave->sii.general_flags.enable_safeop = (flags >> 0) & 0x01; |
8acdecb5a75e
Fixed general flags on big-endian archs.
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
330 |
slave->sii.general_flags.enable_not_lrw = (flags >> 1) & 0x01; |
8acdecb5a75e
Fixed general flags on big-endian archs.
Florian Pose <fp@igh-essen.com>
parents:
873
diff
changeset
|
331 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
332 |
slave->sii.current_on_ebus = EC_READ_S16(data + 0x0C); |
835
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
333 |
slave->sii.has_general = 1; |
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
334 |
return 0; |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
335 |
} |
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 |
|
870
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
339 |
/** Fetches data from a SYNC MANAGER category. |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
340 |
* |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
341 |
* Appends the sync managers described in the category to the existing ones. |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
342 |
* |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
343 |
* \return 0 in case of success, else < 0 |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
344 |
*/ |
620
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
345 |
int ec_slave_fetch_sii_syncs( |
870
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
346 |
ec_slave_t *slave, /**< EtherCAT slave. */ |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
347 |
const uint8_t *data, /**< Category data. */ |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
348 |
size_t data_size /**< Number of bytes. */ |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
349 |
) |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
350 |
{ |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
351 |
unsigned int i, count, total_count; |
626
a5e838c30733
Renamed ec_sii_sync_t to ec_sync_t.
Florian Pose <fp@igh-essen.com>
parents:
625
diff
changeset
|
352 |
ec_sync_t *sync; |
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
353 |
size_t memsize; |
870
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
354 |
ec_sync_t *syncs; |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
355 |
uint8_t index; |
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
356 |
|
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
357 |
// one sync manager struct is 4 words long |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
358 |
if (data_size % 8) { |
870
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
359 |
EC_ERR("Invalid SII sync manager category size %u in slave %u.\n", |
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
360 |
data_size, slave->ring_position); |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
361 |
return -1; |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
362 |
} |
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
363 |
|
870
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
364 |
count = data_size / 8; |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
365 |
|
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
366 |
if (count) { |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
367 |
total_count = count + slave->sii.sync_count; |
1082
ff06c58e269c
Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
368 |
if (total_count > EC_MAX_SYNC_MANAGERS) { |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
369 |
EC_ERR("Exceeded maximum number of sync managers!\n"); |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
370 |
return -1; |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
371 |
} |
870
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
372 |
memsize = sizeof(ec_sync_t) * total_count; |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
373 |
if (!(syncs = kmalloc(memsize, GFP_KERNEL))) { |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
374 |
EC_ERR("Failed to allocate %u bytes for sync managers.\n", |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
375 |
memsize); |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
376 |
return -1; |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
377 |
} |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
378 |
|
873
ec01ba291896
Fixed bug in copying sync managers. Now making a deep copy.
Florian Pose <fp@igh-essen.com>
parents:
872
diff
changeset
|
379 |
for (i = 0; i < slave->sii.sync_count; i++) |
ec01ba291896
Fixed bug in copying sync managers. Now making a deep copy.
Florian Pose <fp@igh-essen.com>
parents:
872
diff
changeset
|
380 |
ec_sync_init_copy(syncs + i, slave->sii.syncs + i); |
870
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
381 |
|
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
382 |
// initialize new sync managers |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
383 |
for (i = 0; i < count; i++, data += 8) { |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
384 |
index = i + slave->sii.sync_count; |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
385 |
sync = &syncs[index]; |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
386 |
|
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
387 |
ec_sync_init(sync, slave); |
870
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
388 |
sync->physical_start_address = EC_READ_U16(data); |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
389 |
sync->default_length = EC_READ_U16(data + 2); |
870
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
390 |
sync->control_register = EC_READ_U8(data + 4); |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
391 |
sync->enable = EC_READ_U8(data + 6); |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
392 |
} |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
393 |
|
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
394 |
if (slave->sii.syncs) |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
395 |
kfree(slave->sii.syncs); |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
396 |
slave->sii.syncs = syncs; |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
397 |
slave->sii.sync_count = total_count; |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
398 |
} |
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
865
diff
changeset
|
399 |
|
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
400 |
return 0; |
118
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
401 |
} |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
402 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
403 |
/*****************************************************************************/ |
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
404 |
|
dc71ce4cc641
Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents:
114
diff
changeset
|
405 |
/** |
814 | 406 |
Fetches data from a [RT]XPdo category. |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
407 |
\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
|
408 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
409 |
|
620
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
410 |
int ec_slave_fetch_sii_pdos( |
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
411 |
ec_slave_t *slave, /**< EtherCAT slave */ |
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
412 |
const uint8_t *data, /**< category data */ |
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
413 |
size_t data_size, /**< number of bytes */ |
814 | 414 |
ec_direction_t dir /**< Pdo direction. */ |
620
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
415 |
) |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
416 |
{ |
625
ec69acbbd156
Renamed ec_sii_pdo_t and ec_sii_pdo_entry_t to ec_pdo_t and
Florian Pose <fp@igh-essen.com>
parents:
624
diff
changeset
|
417 |
ec_pdo_t *pdo; |
ec69acbbd156
Renamed ec_sii_pdo_t and ec_sii_pdo_entry_t to ec_pdo_t and
Florian Pose <fp@igh-essen.com>
parents:
624
diff
changeset
|
418 |
ec_pdo_entry_t *entry; |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
419 |
unsigned int entry_count, i; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
420 |
|
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
421 |
while (data_size >= 8) { |
625
ec69acbbd156
Renamed ec_sii_pdo_t and ec_sii_pdo_entry_t to ec_pdo_t and
Florian Pose <fp@igh-essen.com>
parents:
624
diff
changeset
|
422 |
if (!(pdo = kmalloc(sizeof(ec_pdo_t), GFP_KERNEL))) { |
814 | 423 |
EC_ERR("Failed to allocate Pdo memory.\n"); |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
424 |
return -1; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
425 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
426 |
|
627
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
626
diff
changeset
|
427 |
ec_pdo_init(pdo); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
428 |
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
|
429 |
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
|
430 |
pdo->sync_index = EC_READ_U8(data + 3); |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
431 |
if (ec_pdo_set_name(pdo, |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
432 |
ec_slave_sii_string(slave, EC_READ_U8(data + 5)))) { |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
433 |
ec_pdo_clear(pdo); |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
434 |
kfree(pdo); |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
435 |
return -1; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
436 |
} |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
437 |
list_add_tail(&pdo->list, &slave->sii.pdos); |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
438 |
|
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
439 |
data_size -= 8; |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
440 |
data += 8; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
441 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
442 |
for (i = 0; i < entry_count; i++) { |
625
ec69acbbd156
Renamed ec_sii_pdo_t and ec_sii_pdo_entry_t to ec_pdo_t and
Florian Pose <fp@igh-essen.com>
parents:
624
diff
changeset
|
443 |
if (!(entry = kmalloc(sizeof(ec_pdo_entry_t), GFP_KERNEL))) { |
814 | 444 |
EC_ERR("Failed to allocate Pdo entry memory.\n"); |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
445 |
return -1; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
446 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
447 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
448 |
ec_pdo_entry_init(entry); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
449 |
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
|
450 |
entry->subindex = EC_READ_U8(data + 2); |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
451 |
if (ec_pdo_entry_set_name(entry, |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
452 |
ec_slave_sii_string(slave, EC_READ_U8(data + 3)))) { |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
453 |
ec_pdo_entry_clear(entry); |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
454 |
kfree(entry); |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
455 |
return -1; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
456 |
} |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
320
diff
changeset
|
457 |
entry->bit_length = EC_READ_U8(data + 5); |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
458 |
list_add_tail(&entry->list, &pdo->entries); |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
459 |
|
742
03d2fe3d4a93
Improved checking of EEPROM data while reading.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
460 |
data_size -= 8; |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
461 |
data += 8; |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
462 |
} |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
463 |
|
814 | 464 |
// if sync manager index is positive, the Pdo is mapped by default |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
465 |
if (pdo->sync_index >= 0) { |
762
15214036c72a
Store PDO mapping source in sync manager.
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
466 |
ec_sync_t *sync; |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
467 |
|
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
468 |
if (!(sync = ec_slave_get_sync(slave, pdo->sync_index))) { |
814 | 469 |
EC_ERR("Invalid SM index %i for Pdo 0x%04X in slave %u.", |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
470 |
pdo->sync_index, pdo->index, slave->ring_position); |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
471 |
return -1; |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
472 |
} |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
473 |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
876
diff
changeset
|
474 |
if (ec_pdo_list_add_pdo_copy(&sync->pdos, pdo)) |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
475 |
return -1; |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
476 |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
876
diff
changeset
|
477 |
sync->assign_source = EC_ASSIGN_SII; |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
478 |
} |
126
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
479 |
} |
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
480 |
|
bbc963b9fead
Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents:
124
diff
changeset
|
481 |
return 0; |
114 | 482 |
} |
483 |
||
484 |
/*****************************************************************************/ |
|
485 |
||
486 |
/** |
|
784
0a0994fdafb8
Esthetic surgery for slave.
Florian Pose <fp@igh-essen.com>
parents:
772
diff
changeset
|
487 |
Searches the string list for an index. |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
190
diff
changeset
|
488 |
\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
|
489 |
*/ |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
490 |
|
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
491 |
char *ec_slave_sii_string( |
620
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
492 |
ec_slave_t *slave, /**< EtherCAT slave */ |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
493 |
unsigned int index /**< string index */ |
620
4f76acbf54a0
Renamed SII fetching functions (non-functional).
Florian Pose <fp@igh-essen.com>
parents:
619
diff
changeset
|
494 |
) |
123 | 495 |
{ |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
496 |
if (!index--) |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
497 |
return NULL; |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
498 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
499 |
if (index >= slave->sii.string_count) { |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
500 |
if (slave->master->debug_level) |
784
0a0994fdafb8
Esthetic surgery for slave.
Florian Pose <fp@igh-essen.com>
parents:
772
diff
changeset
|
501 |
EC_WARN("String %u not found in slave %u.\n", |
624
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
502 |
index, slave->ring_position); |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
503 |
return NULL; |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
504 |
} |
11332ad89f47
Simplified handling of EEPROM strings.
Florian Pose <fp@igh-essen.com>
parents:
620
diff
changeset
|
505 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
506 |
return slave->sii.strings[index]; |
123 | 507 |
} |
508 |
||
509 |
/*****************************************************************************/ |
|
510 |
||
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
511 |
/** Get the sync manager given an index. |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
512 |
* |
758
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
754
diff
changeset
|
513 |
* \return pointer to sync manager, or NULL. |
619
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
514 |
*/ |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
515 |
ec_sync_t *ec_slave_get_sync( |
912
6630f4dbcfd2
Improved working counter output; fixed problem with slaves that have a single sync manager used for outputs.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
516 |
ec_slave_t *slave, /**< EtherCAT slave. */ |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
517 |
uint8_t sync_index /**< Sync manager index. */ |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
518 |
) |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
519 |
{ |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
520 |
if (sync_index < slave->sii.sync_count) { |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
521 |
return &slave->sii.syncs[sync_index]; |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
522 |
} else { |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
523 |
return NULL; |
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
632
diff
changeset
|
524 |
} |
619
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
525 |
} |
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
526 |
|
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
527 |
/*****************************************************************************/ |
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
528 |
|
15becb1879fd
Introduced ec_slave_get_pdo_sync().
Florian Pose <fp@igh-essen.com>
parents:
618
diff
changeset
|
529 |
/** |
814 | 530 |
Counts the total number of Sdos and entries in the dictionary. |
423
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
531 |
*/ |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
532 |
|
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
533 |
void ec_slave_sdo_dict_info(const ec_slave_t *slave, /**< EtherCAT slave */ |
814 | 534 |
unsigned int *sdo_count, /**< number of Sdos */ |
423
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
535 |
unsigned int *entry_count /**< total number of |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
536 |
entries */ |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
537 |
) |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
538 |
{ |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
539 |
unsigned int sdos = 0, entries = 0; |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
540 |
ec_sdo_t *sdo; |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
541 |
ec_sdo_entry_t *entry; |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
542 |
|
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
543 |
list_for_each_entry(sdo, &slave->sdo_dictionary, list) { |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
544 |
sdos++; |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
545 |
list_for_each_entry(entry, &sdo->entries, list) { |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
546 |
entries++; |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
547 |
} |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
548 |
} |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
549 |
|
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
550 |
*sdo_count = sdos; |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
551 |
*entry_count = entries; |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
552 |
} |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
421
diff
changeset
|
553 |
|
740
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
554 |
/*****************************************************************************/ |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
555 |
|
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
556 |
/** |
814 | 557 |
* Get an Sdo from the dictionary. |
558 |
* \returns The desired Sdo, or NULL. |
|
740
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
559 |
*/ |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
560 |
|
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
561 |
ec_sdo_t *ec_slave_get_sdo( |
964
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
562 |
ec_slave_t *slave, /**< EtherCAT slave */ |
814 | 563 |
uint16_t index /**< Sdo index */ |
740
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
564 |
) |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
565 |
{ |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
566 |
ec_sdo_t *sdo; |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
567 |
|
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
568 |
list_for_each_entry(sdo, &slave->sdo_dictionary, list) { |
967
93807963b906
Added ec_slave_get_sdo_const().
Florian Pose <fp@igh-essen.com>
parents:
964
diff
changeset
|
569 |
if (sdo->index != index) |
93807963b906
Added ec_slave_get_sdo_const().
Florian Pose <fp@igh-essen.com>
parents:
964
diff
changeset
|
570 |
continue; |
93807963b906
Added ec_slave_get_sdo_const().
Florian Pose <fp@igh-essen.com>
parents:
964
diff
changeset
|
571 |
return sdo; |
93807963b906
Added ec_slave_get_sdo_const().
Florian Pose <fp@igh-essen.com>
parents:
964
diff
changeset
|
572 |
} |
93807963b906
Added ec_slave_get_sdo_const().
Florian Pose <fp@igh-essen.com>
parents:
964
diff
changeset
|
573 |
|
93807963b906
Added ec_slave_get_sdo_const().
Florian Pose <fp@igh-essen.com>
parents:
964
diff
changeset
|
574 |
return NULL; |
93807963b906
Added ec_slave_get_sdo_const().
Florian Pose <fp@igh-essen.com>
parents:
964
diff
changeset
|
575 |
} |
93807963b906
Added ec_slave_get_sdo_const().
Florian Pose <fp@igh-essen.com>
parents:
964
diff
changeset
|
576 |
|
93807963b906
Added ec_slave_get_sdo_const().
Florian Pose <fp@igh-essen.com>
parents:
964
diff
changeset
|
577 |
/*****************************************************************************/ |
93807963b906
Added ec_slave_get_sdo_const().
Florian Pose <fp@igh-essen.com>
parents:
964
diff
changeset
|
578 |
|
93807963b906
Added ec_slave_get_sdo_const().
Florian Pose <fp@igh-essen.com>
parents:
964
diff
changeset
|
579 |
/** |
93807963b906
Added ec_slave_get_sdo_const().
Florian Pose <fp@igh-essen.com>
parents:
964
diff
changeset
|
580 |
* Get an Sdo from the dictionary. |
93807963b906
Added ec_slave_get_sdo_const().
Florian Pose <fp@igh-essen.com>
parents:
964
diff
changeset
|
581 |
* |
93807963b906
Added ec_slave_get_sdo_const().
Florian Pose <fp@igh-essen.com>
parents:
964
diff
changeset
|
582 |
* const version. |
93807963b906
Added ec_slave_get_sdo_const().
Florian Pose <fp@igh-essen.com>
parents:
964
diff
changeset
|
583 |
* |
93807963b906
Added ec_slave_get_sdo_const().
Florian Pose <fp@igh-essen.com>
parents:
964
diff
changeset
|
584 |
* \returns The desired Sdo, or NULL. |
93807963b906
Added ec_slave_get_sdo_const().
Florian Pose <fp@igh-essen.com>
parents:
964
diff
changeset
|
585 |
*/ |
93807963b906
Added ec_slave_get_sdo_const().
Florian Pose <fp@igh-essen.com>
parents:
964
diff
changeset
|
586 |
|
93807963b906
Added ec_slave_get_sdo_const().
Florian Pose <fp@igh-essen.com>
parents:
964
diff
changeset
|
587 |
const ec_sdo_t *ec_slave_get_sdo_const( |
93807963b906
Added ec_slave_get_sdo_const().
Florian Pose <fp@igh-essen.com>
parents:
964
diff
changeset
|
588 |
const ec_slave_t *slave, /**< EtherCAT slave */ |
93807963b906
Added ec_slave_get_sdo_const().
Florian Pose <fp@igh-essen.com>
parents:
964
diff
changeset
|
589 |
uint16_t index /**< Sdo index */ |
93807963b906
Added ec_slave_get_sdo_const().
Florian Pose <fp@igh-essen.com>
parents:
964
diff
changeset
|
590 |
) |
93807963b906
Added ec_slave_get_sdo_const().
Florian Pose <fp@igh-essen.com>
parents:
964
diff
changeset
|
591 |
{ |
93807963b906
Added ec_slave_get_sdo_const().
Florian Pose <fp@igh-essen.com>
parents:
964
diff
changeset
|
592 |
const ec_sdo_t *sdo; |
93807963b906
Added ec_slave_get_sdo_const().
Florian Pose <fp@igh-essen.com>
parents:
964
diff
changeset
|
593 |
|
93807963b906
Added ec_slave_get_sdo_const().
Florian Pose <fp@igh-essen.com>
parents:
964
diff
changeset
|
594 |
list_for_each_entry(sdo, &slave->sdo_dictionary, list) { |
93807963b906
Added ec_slave_get_sdo_const().
Florian Pose <fp@igh-essen.com>
parents:
964
diff
changeset
|
595 |
if (sdo->index != index) |
93807963b906
Added ec_slave_get_sdo_const().
Florian Pose <fp@igh-essen.com>
parents:
964
diff
changeset
|
596 |
continue; |
740
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
597 |
return sdo; |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
598 |
} |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
599 |
|
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
600 |
return NULL; |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
601 |
} |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
735
diff
changeset
|
602 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
784
diff
changeset
|
603 |
/*****************************************************************************/ |
799 | 604 |
|
964
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
605 |
/** Get an Sdo from the dictionary, given its position in the list. |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
606 |
* \returns The desired Sdo, or NULL. |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
607 |
*/ |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
608 |
|
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
609 |
const ec_sdo_t *ec_slave_get_sdo_by_pos_const( |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
610 |
const ec_slave_t *slave, /**< EtherCAT slave. */ |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
611 |
uint16_t sdo_position /**< Sdo list position. */ |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
612 |
) |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
613 |
{ |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
614 |
const ec_sdo_t *sdo; |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
615 |
|
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
616 |
list_for_each_entry(sdo, &slave->sdo_dictionary, list) { |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
617 |
if (sdo_position--) |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
618 |
continue; |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
619 |
return sdo; |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
620 |
} |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
621 |
|
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
622 |
return NULL; |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
623 |
} |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
624 |
|
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
625 |
/*****************************************************************************/ |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
626 |
|
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
627 |
/** Get the number of Sdos in the dictionary. |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
628 |
* \returns Sdo count. |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
629 |
*/ |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
630 |
|
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
631 |
uint16_t ec_slave_sdo_count( |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
632 |
const ec_slave_t *slave /**< EtherCAT slave. */ |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
633 |
) |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
634 |
{ |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
635 |
const ec_sdo_t *sdo; |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
636 |
uint16_t count = 0; |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
637 |
|
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
638 |
list_for_each_entry(sdo, &slave->sdo_dictionary, list) { |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
639 |
count++; |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
640 |
} |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
641 |
|
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
642 |
return count; |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
643 |
} |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
644 |
|
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
645 |
/*****************************************************************************/ |
957f21465052
Added ec_slave_get_sdo_by_pos_const() and ec_slave_sdo_count().
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
646 |
|
799 | 647 |
/** Finds a mapped Pdo. |
648 |
* \returns The desired Pdo object, or NULL. |
|
649 |
*/ |
|
650 |
const ec_pdo_t *ec_slave_find_pdo( |
|
651 |
const ec_slave_t *slave, /**< Slave. */ |
|
652 |
uint16_t index /**< Pdo index to find. */ |
|
653 |
) |
|
654 |
{ |
|
655 |
unsigned int i; |
|
656 |
const ec_sync_t *sync; |
|
657 |
const ec_pdo_t *pdo; |
|
658 |
||
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
659 |
for (i = 0; i < slave->sii.sync_count; i++) { |
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
660 |
sync = &slave->sii.syncs[i]; |
799 | 661 |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
876
diff
changeset
|
662 |
if (!(pdo = ec_pdo_list_find_pdo_const(&sync->pdos, index))) |
799 | 663 |
continue; |
664 |
||
665 |
return pdo; |
|
666 |
} |
|
667 |
||
668 |
return NULL; |
|
669 |
} |
|
670 |
||
671 |
/*****************************************************************************/ |