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