author | Florian Pose <fp@igh-essen.com> |
Wed, 19 Sep 2012 22:40:32 +0200 | |
branch | stable-1.5 |
changeset 2428 | 8a270ea612ee |
parent 2421 | bc2d4bf9cbe5 |
child 2522 | ec403cf308eb |
permissions | -rw-r--r-- |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
2099
e485694c6427
Minor: Fixed broken keyword strings.
Florian Pose <fp@igh-essen.com>
parents:
2081
diff
changeset
|
3 |
* $Id$ |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
* |
1326
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
5 |
* Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH |
197
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 |
* |
1326
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it and/or |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
10 |
* modify it under the terms of the GNU General Public License version 2, as |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
11 |
* published by the Free Software Foundation. |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
12 |
* |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
13 |
* The IgH EtherCAT Master is distributed in the hope that it will be useful, |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
16 |
* Public License for more details. |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
17 |
* |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
18 |
* You should have received a copy of the GNU General Public License along |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
19 |
* with the IgH EtherCAT Master; if not, write to the Free Software |
197
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 |
* |
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1333
diff
changeset
|
22 |
* --- |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1333
diff
changeset
|
23 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1333
diff
changeset
|
24 |
* The license mentioned above concerns the source code only. Using the |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1333
diff
changeset
|
25 |
* EtherCAT technology and brand is only permitted in compliance with the |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1333
diff
changeset
|
26 |
* industrial property and similar rights of Beckhoff Automation GmbH. |
246
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
237
diff
changeset
|
27 |
* |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
*****************************************************************************/ |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
30 |
/** |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
31 |
\file |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
32 |
Methods of an EtherCAT datagram. |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
33 |
*/ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
34 |
|
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
35 |
/*****************************************************************************/ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
36 |
|
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
#include <linux/slab.h> |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
39 |
#include "datagram.h" |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
#include "master.h" |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
|
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
/*****************************************************************************/ |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
44 |
/** \cond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
45 |
|
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
46 |
#define EC_FUNC_HEADER \ |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
47 |
ret = ec_datagram_prealloc(datagram, data_size); \ |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
48 |
if (unlikely(ret)) \ |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
49 |
return ret; \ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
50 |
datagram->index = 0; \ |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
51 |
datagram->working_counter = 0; \ |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
293
diff
changeset
|
52 |
datagram->state = EC_DATAGRAM_INIT; |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
53 |
|
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
54 |
#define EC_FUNC_FOOTER \ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
55 |
datagram->data_size = data_size; \ |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
56 |
return 0; |
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
57 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
58 |
/** \endcond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
59 |
|
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
60 |
/*****************************************************************************/ |
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
61 |
|
816
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
62 |
/** Array of datagram type strings used in ec_datagram_type_string(). |
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
63 |
* |
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
64 |
* \attention This is indexed by ec_datagram_type_t. |
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
65 |
*/ |
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
66 |
static const char *type_strings[] = { |
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
67 |
"?", |
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
68 |
"APRD", |
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
69 |
"APWR", |
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
70 |
"APRW", |
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
71 |
"FPRD", |
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
72 |
"FPWR", |
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
73 |
"FPRW", |
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
74 |
"BRD", |
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
75 |
"BWR", |
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
76 |
"BRW", |
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
77 |
"LRD", |
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
78 |
"LWR", |
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
79 |
"LRW", |
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
80 |
"ARMW", |
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
81 |
"FRMW" |
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
82 |
}; |
2421 | 83 |
|
816
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
84 |
/*****************************************************************************/ |
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
85 |
|
809 | 86 |
/** Constructor. |
87 |
*/ |
|
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
88 |
void ec_datagram_init(ec_datagram_t *datagram /**< EtherCAT datagram. */) |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
89 |
{ |
446 | 90 |
INIT_LIST_HEAD(&datagram->queue); // mark as unqueued |
2268
5e1d3c9430e0
Datagram device_index member.
Florian Pose <fp@igh-essen.com>
parents:
2099
diff
changeset
|
91 |
datagram->device_index = EC_DEVICE_MAIN; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
293
diff
changeset
|
92 |
datagram->type = EC_DATAGRAM_NONE; |
708
90bdb315f560
Fixed EtherCAT addressing problem on big-endian systems. The slaves
Florian Pose <fp@igh-essen.com>
parents:
514
diff
changeset
|
93 |
memset(datagram->address, 0x00, EC_ADDR_LEN); |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
94 |
datagram->data = NULL; |
809 | 95 |
datagram->data_origin = EC_ORIG_INTERNAL; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
96 |
datagram->mem_size = 0; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
97 |
datagram->data_size = 0; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
98 |
datagram->index = 0x00; |
809 | 99 |
datagram->working_counter = 0x0000; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
293
diff
changeset
|
100 |
datagram->state = EC_DATAGRAM_INIT; |
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
998
diff
changeset
|
101 |
#ifdef EC_HAVE_CYCLES |
344
5d8281f1aa2a
Replaced longer cycle timestamps with jiffies.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
102 |
datagram->cycles_sent = 0; |
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
998
diff
changeset
|
103 |
#endif |
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
104 |
datagram->jiffies_sent = 0; |
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
998
diff
changeset
|
105 |
#ifdef EC_HAVE_CYCLES |
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
106 |
datagram->cycles_received = 0; |
1040
d2527675cdd5
Disable use of CPU timestamp counter by default.
Florian Pose <fp@igh-essen.com>
parents:
998
diff
changeset
|
107 |
#endif |
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
108 |
datagram->jiffies_received = 0; |
719
03d5b96632fb
Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents:
713
diff
changeset
|
109 |
datagram->skip_count = 0; |
03d5b96632fb
Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents:
713
diff
changeset
|
110 |
datagram->stats_output_jiffies = 0; |
809 | 111 |
memset(datagram->name, 0x00, EC_DATAGRAM_NAME_SIZE); |
112 |
} |
|
113 |
||
114 |
/*****************************************************************************/ |
|
115 |
||
116 |
/** Destructor. |
|
117 |
*/ |
|
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
118 |
void ec_datagram_clear(ec_datagram_t *datagram /**< EtherCAT datagram. */) |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
119 |
{ |
1553
4e8d56d6f12a
Bugfix: Unqueue datagram before destroying.
Florian Pose <fp@igh-essen.com>
parents:
1543
diff
changeset
|
120 |
ec_datagram_unqueue(datagram); |
4e8d56d6f12a
Bugfix: Unqueue datagram before destroying.
Florian Pose <fp@igh-essen.com>
parents:
1543
diff
changeset
|
121 |
|
1333
7b9898062c8f
merge -c1614 branches/stable-1.4: Fixed datagram cleaning.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
122 |
if (datagram->data_origin == EC_ORIG_INTERNAL && datagram->data) { |
809 | 123 |
kfree(datagram->data); |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
124 |
datagram->data = NULL; |
1333
7b9898062c8f
merge -c1614 branches/stable-1.4: Fixed datagram cleaning.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
125 |
} |
809 | 126 |
} |
127 |
||
128 |
/*****************************************************************************/ |
|
129 |
||
1553
4e8d56d6f12a
Bugfix: Unqueue datagram before destroying.
Florian Pose <fp@igh-essen.com>
parents:
1543
diff
changeset
|
130 |
/** Unqueue datagram. |
4e8d56d6f12a
Bugfix: Unqueue datagram before destroying.
Florian Pose <fp@igh-essen.com>
parents:
1543
diff
changeset
|
131 |
*/ |
4e8d56d6f12a
Bugfix: Unqueue datagram before destroying.
Florian Pose <fp@igh-essen.com>
parents:
1543
diff
changeset
|
132 |
void ec_datagram_unqueue(ec_datagram_t *datagram /**< EtherCAT datagram. */) |
4e8d56d6f12a
Bugfix: Unqueue datagram before destroying.
Florian Pose <fp@igh-essen.com>
parents:
1543
diff
changeset
|
133 |
{ |
4e8d56d6f12a
Bugfix: Unqueue datagram before destroying.
Florian Pose <fp@igh-essen.com>
parents:
1543
diff
changeset
|
134 |
if (!list_empty(&datagram->queue)) { |
4e8d56d6f12a
Bugfix: Unqueue datagram before destroying.
Florian Pose <fp@igh-essen.com>
parents:
1543
diff
changeset
|
135 |
list_del_init(&datagram->queue); |
4e8d56d6f12a
Bugfix: Unqueue datagram before destroying.
Florian Pose <fp@igh-essen.com>
parents:
1543
diff
changeset
|
136 |
} |
4e8d56d6f12a
Bugfix: Unqueue datagram before destroying.
Florian Pose <fp@igh-essen.com>
parents:
1543
diff
changeset
|
137 |
} |
4e8d56d6f12a
Bugfix: Unqueue datagram before destroying.
Florian Pose <fp@igh-essen.com>
parents:
1543
diff
changeset
|
138 |
|
4e8d56d6f12a
Bugfix: Unqueue datagram before destroying.
Florian Pose <fp@igh-essen.com>
parents:
1543
diff
changeset
|
139 |
/*****************************************************************************/ |
4e8d56d6f12a
Bugfix: Unqueue datagram before destroying.
Florian Pose <fp@igh-essen.com>
parents:
1543
diff
changeset
|
140 |
|
809 | 141 |
/** Allocates internal payload memory. |
142 |
* |
|
143 |
* If the allocated memory is already larger than requested, nothing ist done. |
|
144 |
* |
|
145 |
* \attention If external payload memory has been provided, no range checking |
|
146 |
* is done! |
|
147 |
* |
|
1312
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
148 |
* \return 0 in case of success, otherwise \a -ENOMEM. |
809 | 149 |
*/ |
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
150 |
int ec_datagram_prealloc( |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
151 |
ec_datagram_t *datagram, /**< EtherCAT datagram. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
152 |
size_t size /**< New payload size in bytes. */ |
809 | 153 |
) |
154 |
{ |
|
155 |
if (datagram->data_origin == EC_ORIG_EXTERNAL |
|
156 |
|| size <= datagram->mem_size) |
|
157 |
return 0; |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
158 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
159 |
if (datagram->data) { |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
160 |
kfree(datagram->data); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
161 |
datagram->data = NULL; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
162 |
datagram->mem_size = 0; |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
163 |
} |
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
164 |
|
998
05a24788f3b2
Replaced a few GFP_ATOMIC allocations with GFP_KERNEL ones.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
165 |
if (!(datagram->data = kmalloc(size, GFP_KERNEL))) { |
1543
373cd456dc26
Avoid warnings on x86_64 platform. Thanks to Thomas Elste.
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
166 |
EC_ERR("Failed to allocate %zu bytes of datagram memory!\n", size); |
1312
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
167 |
return -ENOMEM; |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
168 |
} |
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
169 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
170 |
datagram->mem_size = size; |
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
171 |
return 0; |
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
172 |
} |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
173 |
|
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
174 |
/*****************************************************************************/ |
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
175 |
|
1225
4d5b739edcb5
Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents:
1040
diff
changeset
|
176 |
/** Fills the datagram payload memory with zeros. |
4d5b739edcb5
Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents:
1040
diff
changeset
|
177 |
*/ |
4d5b739edcb5
Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents:
1040
diff
changeset
|
178 |
void ec_datagram_zero(ec_datagram_t *datagram /**< EtherCAT datagram. */) |
4d5b739edcb5
Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents:
1040
diff
changeset
|
179 |
{ |
4d5b739edcb5
Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents:
1040
diff
changeset
|
180 |
memset(datagram->data, 0x00, datagram->data_size); |
4d5b739edcb5
Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents:
1040
diff
changeset
|
181 |
} |
4d5b739edcb5
Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents:
1040
diff
changeset
|
182 |
|
4d5b739edcb5
Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents:
1040
diff
changeset
|
183 |
/*****************************************************************************/ |
4d5b739edcb5
Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents:
1040
diff
changeset
|
184 |
|
809 | 185 |
/** Initializes an EtherCAT APRD datagram. |
186 |
* |
|
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
187 |
* \return Return value of ec_datagram_prealloc(). |
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
188 |
*/ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
189 |
int ec_datagram_aprd( |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
190 |
ec_datagram_t *datagram, /**< EtherCAT datagram. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
191 |
uint16_t ring_position, /**< Auto-increment address. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
192 |
uint16_t mem_address, /**< Physical memory address. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
193 |
size_t data_size /**< Number of bytes to read. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
194 |
) |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
195 |
{ |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
196 |
int ret; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
197 |
EC_FUNC_HEADER; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
293
diff
changeset
|
198 |
datagram->type = EC_DATAGRAM_APRD; |
708
90bdb315f560
Fixed EtherCAT addressing problem on big-endian systems. The slaves
Florian Pose <fp@igh-essen.com>
parents:
514
diff
changeset
|
199 |
EC_WRITE_S16(datagram->address, (int16_t) ring_position * (-1)); |
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
200 |
EC_WRITE_U16(datagram->address + 2, mem_address); |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
201 |
EC_FUNC_FOOTER; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
202 |
} |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
203 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
204 |
/*****************************************************************************/ |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
205 |
|
809 | 206 |
/** Initializes an EtherCAT APWR datagram. |
207 |
* |
|
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
208 |
* \return Return value of ec_datagram_prealloc(). |
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
209 |
*/ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
210 |
int ec_datagram_apwr( |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
211 |
ec_datagram_t *datagram, /**< EtherCAT datagram. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
212 |
uint16_t ring_position, /**< Auto-increment address. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
213 |
uint16_t mem_address, /**< Physical memory address. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
214 |
size_t data_size /**< Number of bytes to write. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
215 |
) |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
216 |
{ |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
217 |
int ret; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
218 |
EC_FUNC_HEADER; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
293
diff
changeset
|
219 |
datagram->type = EC_DATAGRAM_APWR; |
708
90bdb315f560
Fixed EtherCAT addressing problem on big-endian systems. The slaves
Florian Pose <fp@igh-essen.com>
parents:
514
diff
changeset
|
220 |
EC_WRITE_S16(datagram->address, (int16_t) ring_position * (-1)); |
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
221 |
EC_WRITE_U16(datagram->address + 2, mem_address); |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
222 |
EC_FUNC_FOOTER; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
223 |
} |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
224 |
|
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
225 |
/*****************************************************************************/ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
226 |
|
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
227 |
/** Initializes an EtherCAT APRW datagram. |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
228 |
* |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
229 |
* \return Return value of ec_datagram_prealloc(). |
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
230 |
*/ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
231 |
int ec_datagram_aprw( |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
232 |
ec_datagram_t *datagram, /**< EtherCAT datagram. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
233 |
uint16_t ring_position, /**< Auto-increment address. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
234 |
uint16_t mem_address, /**< Physical memory address. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
235 |
size_t data_size /**< Number of bytes to write. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
236 |
) |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
237 |
{ |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
238 |
int ret; |
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
239 |
EC_FUNC_HEADER; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
240 |
datagram->type = EC_DATAGRAM_APRW; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
241 |
EC_WRITE_S16(datagram->address, (int16_t) ring_position * (-1)); |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
242 |
EC_WRITE_U16(datagram->address + 2, mem_address); |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
243 |
EC_FUNC_FOOTER; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
244 |
} |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
245 |
|
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
246 |
/*****************************************************************************/ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
247 |
|
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
248 |
/** Initializes an EtherCAT ARMW datagram. |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
249 |
* |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
250 |
* \return Return value of ec_datagram_prealloc(). |
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
251 |
*/ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
252 |
int ec_datagram_armw( |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
253 |
ec_datagram_t *datagram, /**< EtherCAT datagram. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
254 |
uint16_t ring_position, /**< Auto-increment address. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
255 |
uint16_t mem_address, /**< Physical memory address. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
256 |
size_t data_size /**< Number of bytes to read. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
257 |
) |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
258 |
{ |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
259 |
int ret; |
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
260 |
EC_FUNC_HEADER; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
261 |
datagram->type = EC_DATAGRAM_ARMW; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
262 |
EC_WRITE_S16(datagram->address, (int16_t) ring_position * (-1)); |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
263 |
EC_WRITE_U16(datagram->address + 2, mem_address); |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
264 |
EC_FUNC_FOOTER; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
265 |
} |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
266 |
|
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
267 |
/*****************************************************************************/ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
268 |
|
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
269 |
/** Initializes an EtherCAT FPRD datagram. |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
270 |
* |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
271 |
* \return Return value of ec_datagram_prealloc(). |
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
272 |
*/ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
273 |
int ec_datagram_fprd( |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
274 |
ec_datagram_t *datagram, /**< EtherCAT datagram. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
275 |
uint16_t configured_address, /**< Configured station address. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
276 |
uint16_t mem_address, /**< Physical memory address. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
277 |
size_t data_size /**< Number of bytes to read. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
278 |
) |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
279 |
{ |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
280 |
int ret; |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
281 |
|
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
282 |
if (unlikely(configured_address == 0x0000)) |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
283 |
EC_WARN("Using configured station address 0x0000!\n"); |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
284 |
|
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
285 |
EC_FUNC_HEADER; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
286 |
datagram->type = EC_DATAGRAM_FPRD; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
287 |
EC_WRITE_U16(datagram->address, configured_address); |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
288 |
EC_WRITE_U16(datagram->address + 2, mem_address); |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
289 |
EC_FUNC_FOOTER; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
290 |
} |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
291 |
|
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
292 |
/*****************************************************************************/ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
293 |
|
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
294 |
/** Initializes an EtherCAT FPWR datagram. |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
295 |
* |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
296 |
* \return Return value of ec_datagram_prealloc(). |
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
297 |
*/ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
298 |
int ec_datagram_fpwr( |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
299 |
ec_datagram_t *datagram, /**< EtherCAT datagram. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
300 |
uint16_t configured_address, /**< Configured station address. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
301 |
uint16_t mem_address, /**< Physical memory address. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
302 |
size_t data_size /**< Number of bytes to write. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
303 |
) |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
304 |
{ |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
305 |
int ret; |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
306 |
|
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
307 |
if (unlikely(configured_address == 0x0000)) |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
308 |
EC_WARN("Using configured station address 0x0000!\n"); |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
309 |
|
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
310 |
EC_FUNC_HEADER; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
311 |
datagram->type = EC_DATAGRAM_FPWR; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
312 |
EC_WRITE_U16(datagram->address, configured_address); |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
313 |
EC_WRITE_U16(datagram->address + 2, mem_address); |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
314 |
EC_FUNC_FOOTER; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
315 |
} |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
316 |
|
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
317 |
/*****************************************************************************/ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
318 |
|
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
319 |
/** Initializes an EtherCAT FPRW datagram. |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
320 |
* |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
321 |
* \return Return value of ec_datagram_prealloc(). |
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
322 |
*/ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
323 |
int ec_datagram_fprw( |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
324 |
ec_datagram_t *datagram, /**< EtherCAT datagram. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
325 |
uint16_t configured_address, /**< Configured station address. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
326 |
uint16_t mem_address, /**< Physical memory address. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
327 |
size_t data_size /**< Number of bytes to write. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
328 |
) |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
329 |
{ |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
330 |
int ret; |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
331 |
|
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
332 |
if (unlikely(configured_address == 0x0000)) |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
333 |
EC_WARN("Using configured station address 0x0000!\n"); |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
334 |
|
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
335 |
EC_FUNC_HEADER; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
336 |
datagram->type = EC_DATAGRAM_FPRW; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
337 |
EC_WRITE_U16(datagram->address, configured_address); |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
338 |
EC_WRITE_U16(datagram->address + 2, mem_address); |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
339 |
EC_FUNC_FOOTER; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
340 |
} |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
341 |
|
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
342 |
/*****************************************************************************/ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
343 |
|
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
344 |
/** Initializes an EtherCAT FRMW datagram. |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
345 |
* |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
346 |
* \return Return value of ec_datagram_prealloc(). |
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
347 |
*/ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
348 |
int ec_datagram_frmw( |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
349 |
ec_datagram_t *datagram, /**< EtherCAT datagram. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
350 |
uint16_t configured_address, /**< Configured station address. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
351 |
uint16_t mem_address, /**< Physical memory address. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
352 |
size_t data_size /**< Number of bytes to write. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
353 |
) |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
354 |
{ |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
355 |
int ret; |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
356 |
|
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
357 |
if (unlikely(configured_address == 0x0000)) |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
358 |
EC_WARN("Using configured station address 0x0000!\n"); |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
359 |
|
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
360 |
EC_FUNC_HEADER; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
361 |
datagram->type = EC_DATAGRAM_FRMW; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
362 |
EC_WRITE_U16(datagram->address, configured_address); |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
363 |
EC_WRITE_U16(datagram->address + 2, mem_address); |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
364 |
EC_FUNC_FOOTER; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
365 |
} |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
366 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
367 |
/*****************************************************************************/ |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
368 |
|
809 | 369 |
/** Initializes an EtherCAT BRD datagram. |
370 |
* |
|
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
371 |
* \return Return value of ec_datagram_prealloc(). |
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
372 |
*/ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
373 |
int ec_datagram_brd( |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
374 |
ec_datagram_t *datagram, /**< EtherCAT datagram. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
375 |
uint16_t mem_address, /**< Physical memory address. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
376 |
size_t data_size /**< Number of bytes to read. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
377 |
) |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
378 |
{ |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
379 |
int ret; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
380 |
EC_FUNC_HEADER; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
293
diff
changeset
|
381 |
datagram->type = EC_DATAGRAM_BRD; |
708
90bdb315f560
Fixed EtherCAT addressing problem on big-endian systems. The slaves
Florian Pose <fp@igh-essen.com>
parents:
514
diff
changeset
|
382 |
EC_WRITE_U16(datagram->address, 0x0000); |
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
383 |
EC_WRITE_U16(datagram->address + 2, mem_address); |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
384 |
EC_FUNC_FOOTER; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
385 |
} |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
386 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
387 |
/*****************************************************************************/ |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
388 |
|
809 | 389 |
/** Initializes an EtherCAT BWR datagram. |
390 |
* |
|
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
391 |
* \return Return value of ec_datagram_prealloc(). |
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
392 |
*/ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
393 |
int ec_datagram_bwr( |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
394 |
ec_datagram_t *datagram, /**< EtherCAT datagram. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
395 |
uint16_t mem_address, /**< Physical memory address. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
396 |
size_t data_size /**< Number of bytes to write. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
397 |
) |
98
f564d0929292
MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
398 |
{ |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
399 |
int ret; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
400 |
EC_FUNC_HEADER; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
293
diff
changeset
|
401 |
datagram->type = EC_DATAGRAM_BWR; |
708
90bdb315f560
Fixed EtherCAT addressing problem on big-endian systems. The slaves
Florian Pose <fp@igh-essen.com>
parents:
514
diff
changeset
|
402 |
EC_WRITE_U16(datagram->address, 0x0000); |
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
403 |
EC_WRITE_U16(datagram->address + 2, mem_address); |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
404 |
EC_FUNC_FOOTER; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
405 |
} |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
406 |
|
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
407 |
/*****************************************************************************/ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
408 |
|
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
409 |
/** Initializes an EtherCAT BRW datagram. |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
410 |
* |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
411 |
* \return Return value of ec_datagram_prealloc(). |
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
412 |
*/ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
413 |
int ec_datagram_brw( |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
414 |
ec_datagram_t *datagram, /**< EtherCAT datagram. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
415 |
uint16_t mem_address, /**< Physical memory address. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
416 |
size_t data_size /**< Number of bytes to write. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
417 |
) |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
418 |
{ |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
419 |
int ret; |
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
420 |
EC_FUNC_HEADER; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
421 |
datagram->type = EC_DATAGRAM_BRW; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
422 |
EC_WRITE_U16(datagram->address, 0x0000); |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
423 |
EC_WRITE_U16(datagram->address + 2, mem_address); |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
424 |
EC_FUNC_FOOTER; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
425 |
} |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
426 |
|
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
427 |
/*****************************************************************************/ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
428 |
|
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
429 |
/** Initializes an EtherCAT LRD datagram. |
809 | 430 |
* |
2269
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
431 |
* \return Return value of ec_datagram_prealloc(). |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
432 |
*/ |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
433 |
int ec_datagram_lrd( |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
434 |
ec_datagram_t *datagram, /**< EtherCAT datagram. */ |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
435 |
uint32_t offset, /**< Logical address. */ |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
436 |
size_t data_size /**< Number of bytes to read/write. */ |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
437 |
) |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
438 |
{ |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
439 |
int ret; |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
440 |
EC_FUNC_HEADER; |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
441 |
datagram->type = EC_DATAGRAM_LRD; |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
442 |
EC_WRITE_U32(datagram->address, offset); |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
443 |
EC_FUNC_FOOTER; |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
444 |
} |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
445 |
|
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
446 |
/*****************************************************************************/ |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
447 |
|
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
448 |
/** Initializes an EtherCAT LWR datagram. |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
449 |
* |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
450 |
* \return Return value of ec_datagram_prealloc(). |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
451 |
*/ |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
452 |
int ec_datagram_lwr( |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
453 |
ec_datagram_t *datagram, /**< EtherCAT datagram. */ |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
454 |
uint32_t offset, /**< Logical address. */ |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
455 |
size_t data_size /**< Number of bytes to read/write. */ |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
456 |
) |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
457 |
{ |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
458 |
int ret; |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
459 |
EC_FUNC_HEADER; |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
460 |
datagram->type = EC_DATAGRAM_LWR; |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
461 |
EC_WRITE_U32(datagram->address, offset); |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
462 |
EC_FUNC_FOOTER; |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
463 |
} |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
464 |
|
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
465 |
/*****************************************************************************/ |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
466 |
|
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
467 |
/** Initializes an EtherCAT LRW datagram. |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
468 |
* |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
469 |
* \return Return value of ec_datagram_prealloc(). |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
470 |
*/ |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
471 |
int ec_datagram_lrw( |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
472 |
ec_datagram_t *datagram, /**< EtherCAT datagram. */ |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
473 |
uint32_t offset, /**< Logical address. */ |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
474 |
size_t data_size /**< Number of bytes to read/write. */ |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
475 |
) |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
476 |
{ |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
477 |
int ret; |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
478 |
EC_FUNC_HEADER; |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
479 |
datagram->type = EC_DATAGRAM_LRW; |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
480 |
EC_WRITE_U32(datagram->address, offset); |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
481 |
EC_FUNC_FOOTER; |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
482 |
} |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
483 |
|
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
484 |
/*****************************************************************************/ |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
485 |
|
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
486 |
/** Initializes an EtherCAT LRD datagram with external memory. |
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
487 |
* |
809 | 488 |
* \attention It is assumed, that the external memory is at least \a data_size |
489 |
* bytes large. |
|
490 |
* |
|
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
491 |
* \return Return value of ec_datagram_prealloc(). |
809 | 492 |
*/ |
2269
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
493 |
int ec_datagram_lrd_ext( |
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
494 |
ec_datagram_t *datagram, /**< EtherCAT datagram. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
495 |
uint32_t offset, /**< Logical address. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
496 |
size_t data_size, /**< Number of bytes to read/write. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
497 |
uint8_t *external_memory /**< Pointer to the memory to use. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
498 |
) |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
499 |
{ |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
500 |
int ret; |
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
501 |
datagram->data = external_memory; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
502 |
datagram->data_origin = EC_ORIG_EXTERNAL; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
503 |
EC_FUNC_HEADER; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
504 |
datagram->type = EC_DATAGRAM_LRD; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
505 |
EC_WRITE_U32(datagram->address, offset); |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
506 |
EC_FUNC_FOOTER; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
507 |
} |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
508 |
|
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
509 |
/*****************************************************************************/ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
510 |
|
2269
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
511 |
/** Initializes an EtherCAT LWR datagram with external memory. |
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
512 |
* |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
513 |
* \attention It is assumed, that the external memory is at least \a data_size |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
514 |
* bytes large. |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
515 |
* |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
516 |
* \return Return value of ec_datagram_prealloc(). |
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
517 |
*/ |
2269
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
518 |
int ec_datagram_lwr_ext( |
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
519 |
ec_datagram_t *datagram, /**< EtherCAT datagram. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
520 |
uint32_t offset, /**< Logical address. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
521 |
size_t data_size, /**< Number of bytes to read/write. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
522 |
uint8_t *external_memory /**< Pointer to the memory to use. */ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
523 |
) |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
524 |
{ |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
525 |
int ret; |
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
526 |
datagram->data = external_memory; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
527 |
datagram->data_origin = EC_ORIG_EXTERNAL; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
528 |
EC_FUNC_HEADER; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
529 |
datagram->type = EC_DATAGRAM_LWR; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
530 |
EC_WRITE_U32(datagram->address, offset); |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
531 |
EC_FUNC_FOOTER; |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
532 |
} |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
533 |
|
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
534 |
/*****************************************************************************/ |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
535 |
|
2269
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
536 |
/** Initializes an EtherCAT LRW datagram with external memory. |
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
537 |
* |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
538 |
* \attention It is assumed, that the external memory is at least \a data_size |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
539 |
* bytes large. |
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
540 |
* |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
541 |
* \return Return value of ec_datagram_prealloc(). |
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
542 |
*/ |
2269
1d0711235a61
Redundant outputs via datagram pairs.
Florian Pose <fp@igh-essen.com>
parents:
2268
diff
changeset
|
543 |
int ec_datagram_lrw_ext( |
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
809
diff
changeset
|
544 |
ec_datagram_t *datagram, /**< EtherCAT datagram. */ |
809 | 545 |
uint32_t offset, /**< Logical address. */ |
546 |
size_t data_size, /**< Number of bytes to read/write. */ |
|
547 |
uint8_t *external_memory /**< Pointer to the memory to use. */ |
|
548 |
) |
|
549 |
{ |
|
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
550 |
int ret; |
809 | 551 |
datagram->data = external_memory; |
552 |
datagram->data_origin = EC_ORIG_EXTERNAL; |
|
144
fdc24bf62f80
Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents:
104
diff
changeset
|
553 |
EC_FUNC_HEADER; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
293
diff
changeset
|
554 |
datagram->type = EC_DATAGRAM_LRW; |
708
90bdb315f560
Fixed EtherCAT addressing problem on big-endian systems. The slaves
Florian Pose <fp@igh-essen.com>
parents:
514
diff
changeset
|
555 |
EC_WRITE_U32(datagram->address, offset); |
90bdb315f560
Fixed EtherCAT addressing problem on big-endian systems. The slaves
Florian Pose <fp@igh-essen.com>
parents:
514
diff
changeset
|
556 |
EC_FUNC_FOOTER; |
90bdb315f560
Fixed EtherCAT addressing problem on big-endian systems. The slaves
Florian Pose <fp@igh-essen.com>
parents:
514
diff
changeset
|
557 |
} |
90bdb315f560
Fixed EtherCAT addressing problem on big-endian systems. The slaves
Florian Pose <fp@igh-essen.com>
parents:
514
diff
changeset
|
558 |
|
90bdb315f560
Fixed EtherCAT addressing problem on big-endian systems. The slaves
Florian Pose <fp@igh-essen.com>
parents:
514
diff
changeset
|
559 |
/*****************************************************************************/ |
713
ae41cadd25b6
Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents:
708
diff
changeset
|
560 |
|
1822
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
561 |
/** Prints the state of a datagram. |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
562 |
* |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
563 |
* Outputs a text message. |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
564 |
*/ |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
565 |
void ec_datagram_print_state( |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
566 |
const ec_datagram_t *datagram /**< EtherCAT datagram */ |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
567 |
) |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
568 |
{ |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
569 |
printk("Datagram "); |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
570 |
switch (datagram->state) { |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
571 |
case EC_DATAGRAM_INIT: |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
572 |
printk("initialized"); |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
573 |
break; |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
574 |
case EC_DATAGRAM_QUEUED: |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
575 |
printk("queued"); |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
576 |
break; |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
577 |
case EC_DATAGRAM_SENT: |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
578 |
printk("sent"); |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
579 |
break; |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
580 |
case EC_DATAGRAM_RECEIVED: |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
581 |
printk("received"); |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
582 |
break; |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
583 |
case EC_DATAGRAM_TIMED_OUT: |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
584 |
printk("timed out"); |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
585 |
break; |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
586 |
case EC_DATAGRAM_ERROR: |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
587 |
printk("error"); |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
588 |
break; |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
589 |
default: |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
590 |
printk("???"); |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
591 |
} |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
592 |
|
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
593 |
printk(".\n"); |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
594 |
} |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
595 |
|
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
596 |
/*****************************************************************************/ |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1553
diff
changeset
|
597 |
|
809 | 598 |
/** Evaluates the working counter of a single-cast datagram. |
599 |
* |
|
713
ae41cadd25b6
Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents:
708
diff
changeset
|
600 |
* Outputs an error message. |
ae41cadd25b6
Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents:
708
diff
changeset
|
601 |
*/ |
ae41cadd25b6
Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents:
708
diff
changeset
|
602 |
void ec_datagram_print_wc_error( |
758
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
719
diff
changeset
|
603 |
const ec_datagram_t *datagram /**< EtherCAT datagram */ |
713
ae41cadd25b6
Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents:
708
diff
changeset
|
604 |
) |
ae41cadd25b6
Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents:
708
diff
changeset
|
605 |
{ |
ae41cadd25b6
Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents:
708
diff
changeset
|
606 |
if (datagram->working_counter == 0) |
ae41cadd25b6
Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents:
708
diff
changeset
|
607 |
printk("No response."); |
ae41cadd25b6
Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents:
708
diff
changeset
|
608 |
else if (datagram->working_counter > 1) |
ae41cadd25b6
Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents:
708
diff
changeset
|
609 |
printk("%u slaves responded!", datagram->working_counter); |
ae41cadd25b6
Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents:
708
diff
changeset
|
610 |
else |
ae41cadd25b6
Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents:
708
diff
changeset
|
611 |
printk("Success."); |
ae41cadd25b6
Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents:
708
diff
changeset
|
612 |
printk("\n"); |
ae41cadd25b6
Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents:
708
diff
changeset
|
613 |
} |
ae41cadd25b6
Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents:
708
diff
changeset
|
614 |
|
ae41cadd25b6
Better handling of unexpected working counters; introduced
Florian Pose <fp@igh-essen.com>
parents:
708
diff
changeset
|
615 |
/*****************************************************************************/ |
719
03d5b96632fb
Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents:
713
diff
changeset
|
616 |
|
809 | 617 |
/** Outputs datagram statistics at most every second. |
618 |
*/ |
|
719
03d5b96632fb
Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents:
713
diff
changeset
|
619 |
void ec_datagram_output_stats( |
03d5b96632fb
Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents:
713
diff
changeset
|
620 |
ec_datagram_t *datagram |
03d5b96632fb
Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents:
713
diff
changeset
|
621 |
) |
03d5b96632fb
Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents:
713
diff
changeset
|
622 |
{ |
2081
9c3fd68997d4
Fixed datagram statistics output (skipped datagrams).
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
623 |
if (jiffies - datagram->stats_output_jiffies > HZ) { |
719
03d5b96632fb
Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents:
713
diff
changeset
|
624 |
datagram->stats_output_jiffies = jiffies; |
2421 | 625 |
|
719
03d5b96632fb
Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents:
713
diff
changeset
|
626 |
if (unlikely(datagram->skip_count)) { |
1543
373cd456dc26
Avoid warnings on x86_64 platform. Thanks to Thomas Elste.
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
627 |
EC_WARN("Datagram %p (%s) was SKIPPED %u time%s.\n", |
373cd456dc26
Avoid warnings on x86_64 platform. Thanks to Thomas Elste.
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
628 |
datagram, datagram->name, |
719
03d5b96632fb
Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents:
713
diff
changeset
|
629 |
datagram->skip_count, |
03d5b96632fb
Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents:
713
diff
changeset
|
630 |
datagram->skip_count == 1 ? "" : "s"); |
03d5b96632fb
Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents:
713
diff
changeset
|
631 |
datagram->skip_count = 0; |
03d5b96632fb
Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents:
713
diff
changeset
|
632 |
} |
03d5b96632fb
Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents:
713
diff
changeset
|
633 |
} |
03d5b96632fb
Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents:
713
diff
changeset
|
634 |
} |
03d5b96632fb
Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents:
713
diff
changeset
|
635 |
|
03d5b96632fb
Store skipped information in datagrams; name datagrams for statistics
Florian Pose <fp@igh-essen.com>
parents:
713
diff
changeset
|
636 |
/*****************************************************************************/ |
816
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
637 |
|
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
638 |
/** Returns a string describing the datagram type. |
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
639 |
*/ |
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
640 |
const char *ec_datagram_type_string( |
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
641 |
const ec_datagram_t *datagram /**< EtherCAT datagram. */ |
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
642 |
) |
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
643 |
{ |
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
644 |
return type_strings[datagram->type]; |
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
645 |
} |
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
646 |
|
d02761e14eb0
Introduced ec_datagram_type_string().
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
647 |
/*****************************************************************************/ |