author | Florian Pose <fp@igh-essen.com> |
Fri, 19 May 2006 13:38:16 +0000 | |
changeset 252 | 111a5c195b8d |
parent 246 | 0bf7c769de06 |
child 279 | 12f48c1cb143 |
permissions | -rw-r--r-- |
64 | 1 |
/****************************************************************************** |
2 |
* |
|
3 |
* $Id$ |
|
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:
199
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:
199
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:
199
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:
199
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:
199
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:
199
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:
199
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:
199
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:
199
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:
199
diff
changeset
|
30 |
* Technology, IP and trade marks. |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
31 |
* |
64 | 32 |
*****************************************************************************/ |
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 |
Canopen-over-EtherCAT functions. |
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 |
|
64 | 41 |
#include <linux/delay.h> |
80
8cd08d73b560
CANopen SDO read implementiert.
Florian Pose <fp@igh-essen.com>
parents:
77
diff
changeset
|
42 |
#include <linux/slab.h> |
8cd08d73b560
CANopen SDO read implementiert.
Florian Pose <fp@igh-essen.com>
parents:
77
diff
changeset
|
43 |
#include <linux/module.h> |
64 | 44 |
|
45 |
#include "master.h" |
|
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
46 |
#include "mailbox.h" |
64 | 47 |
|
48 |
/*****************************************************************************/ |
|
49 |
||
138
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
50 |
void ec_canopen_abort_msg(uint32_t); |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
51 |
int ec_slave_fetch_sdo_descriptions(ec_slave_t *); |
139 | 52 |
int ec_slave_fetch_sdo_entries(ec_slave_t *, ec_sdo_t *, uint8_t); |
138
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
53 |
|
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
54 |
/*****************************************************************************/ |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
55 |
|
164
ed85368b2b2e
AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
56 |
const ec_code_msg_t sdo_abort_messages[]; |
111
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
57 |
|
138
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
58 |
/*****************************************************************************/ |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
59 |
|
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
60 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
61 |
Reads 32 bit of a CANopen SDO in expedited mode. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
62 |
\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
|
63 |
*/ |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
64 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
65 |
int ec_slave_sdo_read_exp(ec_slave_t *slave, /**< EtherCAT slave */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
66 |
uint16_t sdo_index, /**< SDO index */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
67 |
uint8_t sdo_subindex, /**< SDO subindex */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
68 |
uint8_t *target /**< 4-byte memory */ |
139 | 69 |
) |
70 |
{ |
|
71 |
size_t rec_size; |
|
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
139
diff
changeset
|
72 |
uint8_t *data; |
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
139
diff
changeset
|
73 |
|
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
74 |
if (!(data = ec_slave_mbox_prepare_send(slave, 0x03, 6))) return -1; |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
75 |
|
139 | 76 |
EC_WRITE_U16(data, 0x2 << 12); // SDO request |
77 |
EC_WRITE_U8 (data + 2, (0x1 << 1 // expedited transfer |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
78 |
| 0x2 << 5)); // initiate upload request |
139 | 79 |
EC_WRITE_U16(data + 3, sdo_index); |
80 |
EC_WRITE_U8 (data + 5, sdo_subindex); |
|
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
81 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
82 |
if (!(data = ec_slave_mbox_simple_io(slave, &rec_size))) return -1; |
139 | 83 |
|
84 |
if (EC_READ_U16(data) >> 12 == 0x2 && // SDO request |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
85 |
EC_READ_U8 (data + 2) >> 5 == 0x4) { // abort SDO transfer request |
157
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
86 |
EC_ERR("SDO upload 0x%04X:%X aborted on slave %i.\n", |
139 | 87 |
sdo_index, sdo_subindex, slave->ring_position); |
88 |
ec_canopen_abort_msg(EC_READ_U32(data + 6)); |
|
89 |
return -1; |
|
90 |
} |
|
91 |
||
92 |
if (EC_READ_U16(data) >> 12 != 0x3 || // SDO response |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
93 |
EC_READ_U8 (data + 2) >> 5 != 0x2 || // upload response |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
94 |
EC_READ_U16(data + 3) != sdo_index || // index |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
95 |
EC_READ_U8 (data + 5) != sdo_subindex) { // subindex |
159
acb250c92896
Fixed invalid format string.
Florian Pose <fp@igh-essen.com>
parents:
157
diff
changeset
|
96 |
EC_ERR("SDO upload 0x%04X:%X failed:\n", sdo_index, sdo_subindex); |
139 | 97 |
EC_ERR("Invalid SDO upload response at slave %i!\n", |
98 |
slave->ring_position); |
|
157
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
99 |
ec_print_data(data, rec_size); |
139 | 100 |
return -1; |
101 |
} |
|
102 |
||
103 |
memcpy(target, data + 6, 4); |
|
104 |
return 0; |
|
105 |
} |
|
106 |
||
107 |
/*****************************************************************************/ |
|
108 |
||
109 |
/** |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
110 |
Writes a CANopen SDO using expedited mode. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
111 |
\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
|
112 |
*/ |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
113 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
114 |
int ec_slave_sdo_write_exp(ec_slave_t *slave, /**< EtherCAT slave */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
115 |
uint16_t sdo_index, /**< SDO index */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
116 |
uint8_t sdo_subindex, /**< SDO subindex */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
117 |
const uint8_t *sdo_data, /**< new value */ |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
118 |
size_t size /**< Data size in bytes (1 - 4) */ |
138
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
119 |
) |
64 | 120 |
{ |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
139
diff
changeset
|
121 |
uint8_t *data; |
133
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
122 |
size_t rec_size; |
64 | 123 |
|
124 |
if (size == 0 || size > 4) { |
|
138
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
125 |
EC_ERR("Invalid data size!\n"); |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
126 |
return -1; |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
127 |
} |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
128 |
|
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
129 |
if (!(data = ec_slave_mbox_prepare_send(slave, 0x03, 0x0A))) return -1; |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
130 |
|
139 | 131 |
EC_WRITE_U16(data, 0x2 << 12); // SDO request |
132 |
EC_WRITE_U8 (data + 2, (0x1 // size specified |
|
133 |
| 0x1 << 1 // expedited transfer |
|
134 |
| (4 - size) << 2 // data set size |
|
135 |
| 0x1 << 5)); // initiate download request |
|
133
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
136 |
EC_WRITE_U16(data + 3, sdo_index); |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
137 |
EC_WRITE_U8 (data + 5, sdo_subindex); |
138
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
138 |
memcpy(data + 6, sdo_data, size); |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
139 |
if (size < 4) memset(data + 6 + size, 0x00, 4 - size); |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
140 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
141 |
if (!(data = ec_slave_mbox_simple_io(slave, &rec_size))) return -1; |
133
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
142 |
|
139 | 143 |
if (EC_READ_U16(data) >> 12 == 0x2 && // SDO request |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
144 |
EC_READ_U8 (data + 2) >> 5 == 0x4) { // abort SDO transfer request |
157
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
145 |
EC_ERR("SDO download 0x%04X:%X (%i bytes) aborted on slave %i.\n", |
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
146 |
sdo_index, sdo_subindex, size, slave->ring_position); |
133
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
147 |
ec_canopen_abort_msg(EC_READ_U32(data + 6)); |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
148 |
return -1; |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
149 |
} |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
150 |
|
139 | 151 |
if (EC_READ_U16(data) >> 12 != 0x3 || // SDO response |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
152 |
EC_READ_U8 (data + 2) >> 5 != 0x3 || // download response |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
153 |
EC_READ_U16(data + 3) != sdo_index || // index |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
154 |
EC_READ_U8 (data + 5) != sdo_subindex) { // subindex |
157
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
155 |
EC_ERR("SDO download 0x%04X:%X (%i bytes) failed:\n", |
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
156 |
sdo_index, sdo_subindex, size); |
111
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
157 |
EC_ERR("Invalid SDO download response at slave %i!\n", |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
66
diff
changeset
|
158 |
slave->ring_position); |
157
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
159 |
ec_print_data(data, rec_size); |
64 | 160 |
return -1; |
161 |
} |
|
162 |
||
163 |
return 0; |
|
164 |
} |
|
165 |
||
166 |
/*****************************************************************************/ |
|
167 |
||
80
8cd08d73b560
CANopen SDO read implementiert.
Florian Pose <fp@igh-essen.com>
parents:
77
diff
changeset
|
168 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
169 |
Reads a CANopen SDO in normal mode. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
170 |
\return 0 in case of success, else < 0 |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
171 |
\ingroup RealtimeInterface |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
172 |
\todo Make size non-pointer. |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
173 |
*/ |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
174 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
175 |
int ecrt_slave_sdo_read(ec_slave_t *slave, /**< EtherCAT slave */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
176 |
uint16_t sdo_index, /**< SDO index */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
177 |
uint8_t sdo_subindex, /**< SDO subindex */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
178 |
uint8_t *target, /**< memory for value */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
179 |
size_t *size /**< target memory size */ |
137
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
180 |
) |
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
181 |
{ |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
139
diff
changeset
|
182 |
uint8_t *data; |
137
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
183 |
size_t rec_size, data_size; |
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
184 |
uint32_t complete_size; |
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
185 |
|
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
186 |
if (!(data = ec_slave_mbox_prepare_send(slave, 0x03, 6))) return -1; |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
187 |
|
139 | 188 |
EC_WRITE_U16(data, 0x2 << 12); // SDO request |
189 |
EC_WRITE_U8 (data + 2, 0x2 << 5); // initiate upload request |
|
137
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
190 |
EC_WRITE_U16(data + 3, sdo_index); |
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
191 |
EC_WRITE_U8 (data + 5, sdo_subindex); |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
192 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
193 |
if (!(data = ec_slave_mbox_simple_io(slave, &rec_size))) return -1; |
137
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
194 |
|
139 | 195 |
if (EC_READ_U16(data) >> 12 == 0x2 && // SDO request |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
196 |
EC_READ_U8 (data + 2) >> 5 == 0x4) { // abort SDO transfer request |
157
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
197 |
EC_ERR("SDO upload 0x%04X:%X aborted on slave %i.\n", |
137
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
198 |
sdo_index, sdo_subindex, slave->ring_position); |
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
199 |
ec_canopen_abort_msg(EC_READ_U32(data + 6)); |
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
200 |
return -1; |
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
201 |
} |
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
202 |
|
139 | 203 |
if (EC_READ_U16(data) >> 12 != 0x3 || // SDO response |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
204 |
EC_READ_U8 (data + 2) >> 5 != 0x2 || // initiate upload response |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
205 |
EC_READ_U16(data + 3) != sdo_index || // index |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
206 |
EC_READ_U8 (data + 5) != sdo_subindex) { // subindex |
157
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
207 |
EC_ERR("SDO upload 0x%04X:%X failed:\n", sdo_index, sdo_subindex); |
137
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
208 |
EC_ERR("Invalid SDO upload response at slave %i!\n", |
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
209 |
slave->ring_position); |
157
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
210 |
ec_print_data(data, rec_size); |
137
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
211 |
return -1; |
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
212 |
} |
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
213 |
|
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
214 |
if (rec_size < 10) { |
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
215 |
EC_ERR("Received currupted SDO upload response!\n"); |
157
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
216 |
ec_print_data(data, rec_size); |
137
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
217 |
return -1; |
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
218 |
} |
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
219 |
|
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
220 |
if ((complete_size = EC_READ_U32(data + 6)) > *size) { |
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
221 |
EC_ERR("SDO data does not fit into buffer (%i / %i)!\n", |
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
222 |
complete_size, *size); |
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
223 |
return -1; |
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
224 |
} |
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
225 |
|
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
226 |
data_size = rec_size - 10; |
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
227 |
|
157
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
228 |
if (data_size != complete_size) { |
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
229 |
EC_ERR("SDO data incomplete - Fragmenting not implemented.\n"); |
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
230 |
return -1; |
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
231 |
} |
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
232 |
|
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
233 |
memcpy(target, data + 10, data_size); |
137
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
234 |
return 0; |
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
235 |
} |
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
236 |
|
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
237 |
/*****************************************************************************/ |
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
238 |
|
3fb18812871a
SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents:
135
diff
changeset
|
239 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
240 |
Fetches the SDO dictionary of a slave. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
241 |
\return 0 in case of success, else < 0 |
133
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
242 |
*/ |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
243 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
244 |
int ec_slave_fetch_sdo_list(ec_slave_t *slave /**< EtherCAT slave */) |
133
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
245 |
{ |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
139
diff
changeset
|
246 |
uint8_t *data; |
133
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
247 |
size_t rec_size; |
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
248 |
unsigned int i, sdo_count; |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
249 |
ec_sdo_t *sdo; |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
250 |
uint16_t sdo_index; |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
251 |
|
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
252 |
if (!(data = ec_slave_mbox_prepare_send(slave, 0x03, 8))) return -1; |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
253 |
|
139 | 254 |
EC_WRITE_U16(data, 0x8 << 12); // SDO information |
255 |
EC_WRITE_U8 (data + 2, 0x01); // Get OD List Request |
|
256 |
EC_WRITE_U8 (data + 3, 0x00); |
|
138
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
257 |
EC_WRITE_U16(data + 4, 0x0000); |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
258 |
EC_WRITE_U16(data + 6, 0x0001); // deliver all SDOs! |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
259 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
260 |
if (unlikely(ec_master_simple_io(slave->master, &slave->mbox_command))) { |
157
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
261 |
EC_ERR("Mailbox checking failed on slave %i!\n", slave->ring_position); |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
139
diff
changeset
|
262 |
return -1; |
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
139
diff
changeset
|
263 |
} |
133
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
264 |
|
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
265 |
do { |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
266 |
if (!(data = ec_slave_mbox_simple_receive(slave, 0x03, &rec_size))) |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
139
diff
changeset
|
267 |
return -1; |
133
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
268 |
|
139 | 269 |
if (EC_READ_U16(data) >> 12 == 0x8 && // SDO information |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
270 |
(EC_READ_U8(data + 2) & 0x7F) == 0x07) { // error response |
133
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
271 |
EC_ERR("SDO information error response at slave %i!\n", |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
272 |
slave->ring_position); |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
273 |
ec_canopen_abort_msg(EC_READ_U32(data + 6)); |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
274 |
return -1; |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
275 |
} |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
276 |
|
139 | 277 |
if (EC_READ_U16(data) >> 12 != 0x8 || // SDO information |
133
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
278 |
(EC_READ_U8 (data + 2) & 0x7F) != 0x02) { // Get OD List response |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
279 |
EC_ERR("Invalid SDO list response at slave %i!\n", |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
280 |
slave->ring_position); |
157
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
281 |
ec_print_data(data, rec_size); |
133
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
282 |
return -1; |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
283 |
} |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
284 |
|
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
285 |
if (rec_size < 8) { |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
286 |
EC_ERR("Invalid data size!\n"); |
157
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
287 |
ec_print_data(data, rec_size); |
133
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
288 |
return -1; |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
289 |
} |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
290 |
|
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
291 |
sdo_count = (rec_size - 8) / 2; |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
292 |
for (i = 0; i < sdo_count; i++) { |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
293 |
sdo_index = EC_READ_U16(data + 8 + i * 2); |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
294 |
if (!sdo_index) continue; // sometimes index is 0... ??? |
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
295 |
|
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
296 |
if (!(sdo = (ec_sdo_t *) kmalloc(sizeof(ec_sdo_t), GFP_KERNEL))) { |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
297 |
EC_ERR("Failed to allocate memory for SDO!\n"); |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
298 |
return -1; |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
299 |
} |
157
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
300 |
|
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
301 |
// Initialize SDO object |
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
302 |
sdo->index = sdo_index; |
175
2e4b18203ade
Altered CoE "Get object description response" fields
Florian Pose <fp@igh-essen.com>
parents:
164
diff
changeset
|
303 |
//sdo->unkown = 0x0000; |
2e4b18203ade
Altered CoE "Get object description response" fields
Florian Pose <fp@igh-essen.com>
parents:
164
diff
changeset
|
304 |
sdo->object_code = 0x00; |
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
305 |
sdo->name = NULL; |
157
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
306 |
INIT_LIST_HEAD(&sdo->entries); |
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
307 |
|
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
308 |
list_add_tail(&sdo->list, &slave->sdo_dictionary); |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
309 |
} |
157
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
310 |
} |
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
311 |
while (EC_READ_U8(data + 2) & 0x80); |
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
312 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
313 |
// Fetch all SDO descriptions |
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
314 |
if (ec_slave_fetch_sdo_descriptions(slave)) return -1; |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
315 |
|
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
316 |
return 0; |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
317 |
} |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
318 |
|
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
319 |
/*****************************************************************************/ |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
320 |
|
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
321 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
322 |
Fetches the SDO descriptions for the known SDOs. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
323 |
\return 0 in case of success, else < 0 |
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
324 |
*/ |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
325 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
326 |
int ec_slave_fetch_sdo_descriptions(ec_slave_t *slave /**< EtherCAT slave */) |
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
327 |
{ |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
139
diff
changeset
|
328 |
uint8_t *data; |
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
329 |
size_t rec_size, name_size; |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
330 |
ec_sdo_t *sdo; |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
331 |
|
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
332 |
list_for_each_entry(sdo, &slave->sdo_dictionary, list) { |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
333 |
if (!(data = ec_slave_mbox_prepare_send(slave, 0x03, 8))) return -1; |
139 | 334 |
EC_WRITE_U16(data, 0x8 << 12); // SDO information |
335 |
EC_WRITE_U8 (data + 2, 0x03); // Get object description request |
|
336 |
EC_WRITE_U8 (data + 3, 0x00); |
|
138
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
337 |
EC_WRITE_U16(data + 4, 0x0000); |
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
338 |
EC_WRITE_U16(data + 6, sdo->index); // SDO index |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
339 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
340 |
if (!(data = ec_slave_mbox_simple_io(slave, &rec_size))) return -1; |
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
341 |
|
139 | 342 |
if (EC_READ_U16(data) >> 12 == 0x8 && // SDO information |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
343 |
(EC_READ_U8 (data + 2) & 0x7F) == 0x07) { // error response |
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
344 |
EC_ERR("SDO information error response at slave %i while" |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
345 |
" fetching SDO 0x%04X!\n", slave->ring_position, |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
346 |
sdo->index); |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
347 |
ec_canopen_abort_msg(EC_READ_U32(data + 6)); |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
348 |
return -1; |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
349 |
} |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
350 |
|
139 | 351 |
if (EC_READ_U16(data) >> 12 != 0x8 || // SDO information |
352 |
(EC_READ_U8 (data + 2) & 0x7F) != 0x04 || // Object desc. response |
|
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
353 |
EC_READ_U16(data + 6) != sdo->index) { // SDO index |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
354 |
EC_ERR("Invalid object description response at slave %i while" |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
355 |
" fetching SDO 0x%04X!\n", slave->ring_position, |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
356 |
sdo->index); |
157
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
357 |
ec_print_data(data, rec_size); |
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
358 |
return -1; |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
359 |
} |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
360 |
|
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
361 |
if (rec_size < 12) { |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
362 |
EC_ERR("Invalid data size!\n"); |
157
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
363 |
ec_print_data(data, rec_size); |
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
364 |
return -1; |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
365 |
} |
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
366 |
|
175
2e4b18203ade
Altered CoE "Get object description response" fields
Florian Pose <fp@igh-essen.com>
parents:
164
diff
changeset
|
367 |
EC_DBG("object desc response:\n"); |
2e4b18203ade
Altered CoE "Get object description response" fields
Florian Pose <fp@igh-essen.com>
parents:
164
diff
changeset
|
368 |
ec_print_data(data, rec_size); |
2e4b18203ade
Altered CoE "Get object description response" fields
Florian Pose <fp@igh-essen.com>
parents:
164
diff
changeset
|
369 |
|
2e4b18203ade
Altered CoE "Get object description response" fields
Florian Pose <fp@igh-essen.com>
parents:
164
diff
changeset
|
370 |
//sdo->unknown = EC_READ_U16(data + 8); |
2e4b18203ade
Altered CoE "Get object description response" fields
Florian Pose <fp@igh-essen.com>
parents:
164
diff
changeset
|
371 |
sdo->object_code = EC_READ_U8(data + 11); |
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
372 |
|
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
373 |
name_size = rec_size - 12; |
139 | 374 |
if (name_size) { |
375 |
if (!(sdo->name = kmalloc(name_size + 1, GFP_KERNEL))) { |
|
376 |
EC_ERR("Failed to allocate SDO name!\n"); |
|
377 |
return -1; |
|
378 |
} |
|
379 |
||
380 |
memcpy(sdo->name, data + 12, name_size); |
|
381 |
sdo->name[name_size] = 0; |
|
382 |
} |
|
383 |
||
384 |
if (EC_READ_U8(data + 2) & 0x80) { |
|
385 |
EC_ERR("Fragment follows (not implemented)!\n"); |
|
386 |
return -1; |
|
387 |
} |
|
388 |
||
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
389 |
// Fetch all entries (subindices) |
139 | 390 |
if (ec_slave_fetch_sdo_entries(slave, sdo, EC_READ_U8(data + 10))) |
391 |
return -1; |
|
392 |
} |
|
393 |
||
394 |
return 0; |
|
395 |
} |
|
396 |
||
397 |
/*****************************************************************************/ |
|
398 |
||
399 |
/** |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
400 |
Fetches all entries (subindices) to an SDO. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
401 |
\return 0 in case of success, else < 0 |
139 | 402 |
*/ |
403 |
||
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
404 |
int ec_slave_fetch_sdo_entries(ec_slave_t *slave, /**< EtherCAT slave */ |
139 | 405 |
ec_sdo_t *sdo, /**< SDO */ |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
406 |
uint8_t subindices /**< number of subindices */ |
139 | 407 |
) |
408 |
{ |
|
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
139
diff
changeset
|
409 |
uint8_t *data; |
139 | 410 |
size_t rec_size, data_size; |
411 |
uint8_t i; |
|
412 |
ec_sdo_entry_t *entry; |
|
413 |
||
414 |
for (i = 1; i <= subindices; i++) { |
|
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
415 |
if (!(data = ec_slave_mbox_prepare_send(slave, 0x03, 10))) |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
416 |
return -1; |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
417 |
|
139 | 418 |
EC_WRITE_U16(data, 0x8 << 12); // SDO information |
419 |
EC_WRITE_U8 (data + 2, 0x05); // Get entry description request |
|
420 |
EC_WRITE_U8 (data + 3, 0x00); |
|
421 |
EC_WRITE_U16(data + 4, 0x0000); |
|
422 |
EC_WRITE_U16(data + 6, sdo->index); // SDO index |
|
423 |
EC_WRITE_U8 (data + 8, i); // SDO subindex |
|
424 |
EC_WRITE_U8 (data + 9, 0x00); // value info (no values) |
|
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
425 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
144
diff
changeset
|
426 |
if (!(data = ec_slave_mbox_simple_io(slave, &rec_size))) return -1; |
139 | 427 |
|
428 |
if (EC_READ_U16(data) >> 12 == 0x8 && // SDO information |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
429 |
(EC_READ_U8 (data + 2) & 0x7F) == 0x07) { // error response |
139 | 430 |
EC_ERR("SDO information error response at slave %i while" |
431 |
" fetching SDO entry 0x%04X:%i!\n", slave->ring_position, |
|
432 |
sdo->index, i); |
|
433 |
ec_canopen_abort_msg(EC_READ_U32(data + 6)); |
|
434 |
return -1; |
|
435 |
} |
|
436 |
||
437 |
if (EC_READ_U16(data) >> 12 != 0x8 || // SDO information |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
438 |
(EC_READ_U8(data + 2) & 0x7F) != 0x06 || // Entry desc. response |
139 | 439 |
EC_READ_U16(data + 6) != sdo->index || // SDO index |
440 |
EC_READ_U8(data + 8) != i) { // SDO subindex |
|
441 |
EC_ERR("Invalid entry description response at slave %i while" |
|
161
ddb7266d1c56
Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents:
159
diff
changeset
|
442 |
" fetching SDO entry 0x%04X:%i!\n", slave->ring_position, |
139 | 443 |
sdo->index, i); |
157
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
444 |
ec_print_data(data, rec_size); |
139 | 445 |
return -1; |
446 |
} |
|
447 |
||
448 |
if (rec_size < 16) { |
|
449 |
EC_ERR("Invalid data size!\n"); |
|
157
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
450 |
ec_print_data(data, rec_size); |
139 | 451 |
return -1; |
452 |
} |
|
453 |
||
454 |
if (!EC_READ_U16(data + 12)) // bit length = 0 |
|
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
455 |
continue; |
139 | 456 |
|
457 |
data_size = rec_size - 16; |
|
458 |
||
459 |
if (!(entry = (ec_sdo_entry_t *) |
|
460 |
kmalloc(sizeof(ec_sdo_entry_t) + data_size + 1, GFP_KERNEL))) { |
|
161
ddb7266d1c56
Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents:
159
diff
changeset
|
461 |
EC_ERR("Failed to allocate entry!\n"); |
139 | 462 |
return -1; |
463 |
} |
|
464 |
||
465 |
entry->subindex = i; |
|
466 |
entry->data_type = EC_READ_U16(data + 10); |
|
467 |
entry->bit_length = EC_READ_U16(data + 12); |
|
161
ddb7266d1c56
Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents:
159
diff
changeset
|
468 |
|
ddb7266d1c56
Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents:
159
diff
changeset
|
469 |
// memory for name string appended to entry |
ddb7266d1c56
Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents:
159
diff
changeset
|
470 |
entry->name = (uint8_t *) entry + sizeof(ec_sdo_entry_t); |
ddb7266d1c56
Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents:
159
diff
changeset
|
471 |
|
ddb7266d1c56
Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents:
159
diff
changeset
|
472 |
memcpy(entry->name, data + 16, data_size); |
ddb7266d1c56
Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents:
159
diff
changeset
|
473 |
entry->name[data_size] = 0; |
139 | 474 |
|
475 |
list_add_tail(&entry->list, &sdo->entries); |
|
135
80d493917205
Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents:
134
diff
changeset
|
476 |
} |
133
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
477 |
|
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
478 |
return 0; |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
479 |
} |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
480 |
|
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
481 |
/*****************************************************************************/ |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
482 |
|
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
483 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
484 |
Outputs an SDO abort message. |
133
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
485 |
*/ |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
486 |
|
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
487 |
void ec_canopen_abort_msg(uint32_t abort_code) |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
488 |
{ |
164
ed85368b2b2e
AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
489 |
const ec_code_msg_t *abort_msg; |
133
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
490 |
|
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
491 |
for (abort_msg = sdo_abort_messages; abort_msg->code; abort_msg++) { |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
492 |
if (abort_msg->code == abort_code) { |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
493 |
EC_ERR("SDO abort message 0x%08X: \"%s\".\n", |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
494 |
abort_msg->code, abort_msg->message); |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
495 |
return; |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
496 |
} |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
497 |
} |
157
37c6dd0ff0b1
Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
145
diff
changeset
|
498 |
|
133
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
499 |
EC_ERR("Unknown SDO abort code 0x%08X.\n", abort_code); |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
500 |
} |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
501 |
|
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
502 |
/*****************************************************************************/ |
b36d187ecc0b
Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents:
113
diff
changeset
|
503 |
|
164
ed85368b2b2e
AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
504 |
const ec_code_msg_t sdo_abort_messages[] = { |
111
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
505 |
{0x05030000, "Toggle bit not changed"}, |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
506 |
{0x05040000, "SDO protocol timeout"}, |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
507 |
{0x05040001, "Client/Server command specifier not valid or unknown"}, |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
508 |
{0x05040005, "Out of memory"}, |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
509 |
{0x06010000, "Unsupported access to an object"}, |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
510 |
{0x06010001, "Attempt to read a write-only object"}, |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
511 |
{0x06010002, "Attempt to write a read-only object"}, |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
512 |
{0x06020000, "This object does not exist in the object directory"}, |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
513 |
{0x06040041, "The object cannot be mapped into the PDO"}, |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
514 |
{0x06040042, "The number and length of the objects to be mapped would" |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
515 |
" exceed the PDO length"}, |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
516 |
{0x06040043, "General parameter incompatibility reason"}, |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
517 |
{0x06040047, "Gerneral internal incompatibility in device"}, |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
518 |
{0x06060000, "Access failure due to a hardware error"}, |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
519 |
{0x06070010, "Data type does not match, length of service parameter does" |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
520 |
" not match"}, |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
521 |
{0x06070012, "Data type does not match, length of service parameter too" |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
522 |
" high"}, |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
523 |
{0x06070013, "Data type does not match, length of service parameter too" |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
524 |
" low"}, |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
525 |
{0x06090011, "Subindex does not exist"}, |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
526 |
{0x06090030, "Value range of parameter exceeded"}, |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
527 |
{0x06090031, "Value of parameter written too high"}, |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
528 |
{0x06090032, "Value of parameter written too low"}, |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
529 |
{0x06090036, "Maximum value is less than minimum value"}, |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
530 |
{0x08000000, "General error"}, |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
531 |
{0x08000020, "Data cannot be transferred or stored to the application"}, |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
532 |
{0x08000021, "Data cannot be transferred or stored to the application" |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
533 |
" because of local control"}, |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
534 |
{0x08000022, "Data cannot be transferred or stored to the application" |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
535 |
" because of the present device state"}, |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
536 |
{0x08000023, "Object dictionary dynamic generation fails or no object" |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
537 |
" dictionary is present"}, |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
538 |
{} |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
539 |
}; |
9963537ec776
Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
540 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
541 |
/****************************************************************************** |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
542 |
* Realtime interface |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
543 |
*****************************************************************************/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
544 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
545 |
/** |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
546 |
Reads an 8-bit SDO in expedited mode. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
547 |
See ec_slave_sdo_read_exp() |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
548 |
\return 0 in case of success, else < 0 |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
549 |
\ingroup RealtimeInterface |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
550 |
*/ |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
551 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
552 |
int ecrt_slave_sdo_read_exp8(ec_slave_t *slave, /**< EtherCAT slave */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
553 |
uint16_t sdo_index, /**< SDO index */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
554 |
uint8_t sdo_subindex, /**< SDO subindex */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
555 |
uint8_t *target /**< memory for read value */ |
138
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
556 |
) |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
557 |
{ |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
558 |
uint8_t data[4]; |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
559 |
if (ec_slave_sdo_read_exp(slave, sdo_index, sdo_subindex, data)) return -1; |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
560 |
*target = EC_READ_U8(data); |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
561 |
return 0; |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
562 |
} |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
563 |
|
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
564 |
/*****************************************************************************/ |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
565 |
|
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
566 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
567 |
Reads a 16-bit SDO in expedited mode. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
568 |
See ec_slave_sdo_read_exp() |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
569 |
\return 0 in case of success, else < 0 |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
570 |
\ingroup RealtimeInterface |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
571 |
*/ |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
572 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
573 |
int ecrt_slave_sdo_read_exp16(ec_slave_t *slave, /**< EtherCAT slave */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
574 |
uint16_t sdo_index, /**< SDO index */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
575 |
uint8_t sdo_subindex, /**< SDO subindex */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
576 |
uint16_t *target /**< memory for read value */ |
138
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
577 |
) |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
578 |
{ |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
579 |
uint8_t data[4]; |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
580 |
if (ec_slave_sdo_read_exp(slave, sdo_index, sdo_subindex, data)) return -1; |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
581 |
*target = EC_READ_U16(data); |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
582 |
return 0; |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
583 |
} |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
584 |
|
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
585 |
/*****************************************************************************/ |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
586 |
|
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
587 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
588 |
Reads a 32-bit SDO in expedited mode. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
589 |
See ec_slave_sdo_read_exp() |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
590 |
\return 0 in case of success, else < 0 |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
591 |
\ingroup RealtimeInterface |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
592 |
*/ |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
593 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
594 |
int ecrt_slave_sdo_read_exp32(ec_slave_t *slave, /**< EtherCAT slave */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
595 |
uint16_t sdo_index, /**< SDO index */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
596 |
uint8_t sdo_subindex, /**< SDO subindex */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
597 |
uint32_t *target /**< memory for read value */ |
138
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
598 |
) |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
599 |
{ |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
600 |
uint8_t data[4]; |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
601 |
if (ec_slave_sdo_read_exp(slave, sdo_index, sdo_subindex, data)) return -1; |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
602 |
*target = EC_READ_U32(data); |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
603 |
return 0; |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
604 |
} |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
605 |
|
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
606 |
/*****************************************************************************/ |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
607 |
|
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
608 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
609 |
Writes an 8-bit SDO in expedited mode. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
610 |
\return 0 in case of success, else < 0 |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
611 |
\ingroup RealtimeInterface |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
612 |
*/ |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
613 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
614 |
int ecrt_slave_sdo_write_exp8(ec_slave_t *slave, /**< EtherCAT slave */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
615 |
uint16_t sdo_index, /**< SDO index */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
616 |
uint8_t sdo_subindex, /**< SDO subindex */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
617 |
uint8_t value /**< new value */ |
138
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
618 |
) |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
619 |
{ |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
620 |
return ec_slave_sdo_write_exp(slave, sdo_index, sdo_subindex, &value, 1); |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
621 |
} |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
622 |
|
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
623 |
/*****************************************************************************/ |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
624 |
|
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
625 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
626 |
Writes a 16-bit SDO in expedited mode. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
627 |
\return 0 in case of success, else < 0 |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
628 |
\ingroup RealtimeInterface |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
629 |
*/ |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
630 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
631 |
int ecrt_slave_sdo_write_exp16(ec_slave_t *slave, /**< EtherCAT slave */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
632 |
uint16_t sdo_index, /**< SDO index */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
633 |
uint8_t sdo_subindex, /**< SDO subindex */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
634 |
uint16_t value /**< new value */ |
138
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
635 |
) |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
636 |
{ |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
637 |
uint8_t data[2]; |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
638 |
EC_WRITE_U16(data, value); |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
639 |
return ec_slave_sdo_write_exp(slave, sdo_index, sdo_subindex, data, 2); |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
640 |
} |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
641 |
|
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
642 |
/*****************************************************************************/ |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
643 |
|
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
644 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
645 |
Writes a 32-bit SDO in expedited mode. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
646 |
\return 0 in case of success, else < 0 |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
647 |
\ingroup RealtimeInterface |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
648 |
*/ |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
649 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
650 |
int ecrt_slave_sdo_write_exp32(ec_slave_t *slave, /**< EtherCAT slave */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
651 |
uint16_t sdo_index, /**< SDO index */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
652 |
uint8_t sdo_subindex, /**< SDO subindex */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
175
diff
changeset
|
653 |
uint32_t value /**< new value */ |
138
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
654 |
) |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
655 |
{ |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
656 |
uint8_t data[4]; |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
657 |
EC_WRITE_U32(data, value); |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
658 |
return ec_slave_sdo_write_exp(slave, sdo_index, sdo_subindex, data, 4); |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
659 |
} |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
660 |
|
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
661 |
/*****************************************************************************/ |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
662 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
663 |
/** \cond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
664 |
|
138
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
665 |
EXPORT_SYMBOL(ecrt_slave_sdo_read_exp8); |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
666 |
EXPORT_SYMBOL(ecrt_slave_sdo_read_exp16); |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
667 |
EXPORT_SYMBOL(ecrt_slave_sdo_read_exp32); |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
668 |
EXPORT_SYMBOL(ecrt_slave_sdo_write_exp8); |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
669 |
EXPORT_SYMBOL(ecrt_slave_sdo_write_exp16); |
7e743a61a991
SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents:
137
diff
changeset
|
670 |
EXPORT_SYMBOL(ecrt_slave_sdo_write_exp32); |
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
671 |
EXPORT_SYMBOL(ecrt_slave_sdo_read); |
64 | 672 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
673 |
/** \endcond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
674 |
|
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
675 |
/*****************************************************************************/ |