author | Florian Pose <fp@igh-essen.com> |
Wed, 04 Jan 2012 18:00:36 +0100 | |
branch | redundancy |
changeset 2309 | b0ddf0ea0a60 |
parent 1823 | 2bf892fe8080 |
child 2421 | bc2d4bf9cbe5 |
child 2589 | 2b9c78543663 |
permissions | -rw-r--r-- |
627
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
* $Id$ |
4793ca94f082
Layed out PDO structures to own files.
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 |
627
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
* |
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
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 |
627
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
20 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
21 |
* |
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1332
diff
changeset
|
22 |
* --- |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1332
diff
changeset
|
23 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1332
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:
1332
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:
1332
diff
changeset
|
26 |
* industrial property and similar rights of Beckhoff Automation GmbH. |
627
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
27 |
* |
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
*****************************************************************************/ |
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
|
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
30 |
/** |
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
31 |
\file |
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
EtherCAT process data object methods. |
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
*/ |
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
|
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
/*****************************************************************************/ |
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
|
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
#include <linux/slab.h> |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1186
diff
changeset
|
38 |
#include <linux/err.h> |
627
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
|
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
#include "pdo.h" |
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
|
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
/*****************************************************************************/ |
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
44 |
/** PDO constructor. |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
45 |
*/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
46 |
void ec_pdo_init( |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
47 |
ec_pdo_t *pdo /**< EtherCAT PDO */ |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
48 |
) |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
49 |
{ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
50 |
pdo->sync_index = -1; // not assigned |
627
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
51 |
pdo->name = NULL; |
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
52 |
INIT_LIST_HEAD(&pdo->entries); |
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
53 |
} |
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
54 |
|
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
55 |
/*****************************************************************************/ |
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
56 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
57 |
/** PDO copy constructor. |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1186
diff
changeset
|
58 |
* |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1186
diff
changeset
|
59 |
* \retval 0 Success. |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1186
diff
changeset
|
60 |
* \retval <0 Error code. |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
61 |
*/ |
1332
d62633fea8ed
merge -c1610 branches/stable-1.4: Added missing doxygen docs.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
62 |
int ec_pdo_init_copy( |
d62633fea8ed
merge -c1610 branches/stable-1.4: Added missing doxygen docs.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
63 |
ec_pdo_t *pdo, /**< PDO to create. */ |
d62633fea8ed
merge -c1610 branches/stable-1.4: Added missing doxygen docs.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
64 |
const ec_pdo_t *other_pdo /**< PDO to copy from. */ |
d62633fea8ed
merge -c1610 branches/stable-1.4: Added missing doxygen docs.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
65 |
) |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
66 |
{ |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1186
diff
changeset
|
67 |
int ret = 0; |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1186
diff
changeset
|
68 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
69 |
pdo->index = other_pdo->index; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
70 |
pdo->sync_index = other_pdo->sync_index; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
71 |
pdo->name = NULL; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
72 |
INIT_LIST_HEAD(&pdo->entries); |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
73 |
|
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1186
diff
changeset
|
74 |
ret = ec_pdo_set_name(pdo, other_pdo->name); |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1186
diff
changeset
|
75 |
if (ret < 0) |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
76 |
goto out_return; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
77 |
|
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1186
diff
changeset
|
78 |
ret = ec_pdo_copy_entries(pdo, other_pdo); |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1186
diff
changeset
|
79 |
if (ret < 0) |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
80 |
goto out_clear; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
81 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
82 |
return 0; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
83 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
84 |
out_clear: |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
85 |
ec_pdo_clear(pdo); |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
86 |
out_return: |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1186
diff
changeset
|
87 |
return ret; |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
88 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
89 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
90 |
/*****************************************************************************/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
91 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
92 |
/** PDO destructor. |
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
93 |
*/ |
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
94 |
void ec_pdo_clear(ec_pdo_t *pdo /**< EtherCAT PDO. */) |
627
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
95 |
{ |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
96 |
if (pdo->name) |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
97 |
kfree(pdo->name); |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
98 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
99 |
ec_pdo_clear_entries(pdo); |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
100 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
101 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
102 |
/*****************************************************************************/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
103 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
104 |
/** Clear PDO entry list. |
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
105 |
*/ |
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
106 |
void ec_pdo_clear_entries(ec_pdo_t *pdo /**< EtherCAT PDO. */) |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
107 |
{ |
627
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
108 |
ec_pdo_entry_t *entry, *next; |
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
109 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
110 |
// free all PDO entries |
627
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
111 |
list_for_each_entry_safe(entry, next, &pdo->entries, list) { |
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
112 |
list_del(&entry->list); |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
113 |
ec_pdo_entry_clear(entry); |
627
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
114 |
kfree(entry); |
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
115 |
} |
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
116 |
} |
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
117 |
|
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
118 |
/*****************************************************************************/ |
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
119 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
120 |
/** Set PDO name. |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1186
diff
changeset
|
121 |
* |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1186
diff
changeset
|
122 |
* \retval 0 Success. |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1186
diff
changeset
|
123 |
* \retval <0 Error code. |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
124 |
*/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
125 |
int ec_pdo_set_name( |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
126 |
ec_pdo_t *pdo, /**< PDO. */ |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
127 |
const char *name /**< New name. */ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
128 |
) |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
129 |
{ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
130 |
unsigned int len; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
131 |
|
1186
ff481f097c97
Attach Pdo names from dictionary.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
132 |
if (pdo->name && name && !strcmp(pdo->name, name)) |
ff481f097c97
Attach Pdo names from dictionary.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
133 |
return 0; |
ff481f097c97
Attach Pdo names from dictionary.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
134 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
135 |
if (pdo->name) |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
136 |
kfree(pdo->name); |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
137 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
138 |
if (name && (len = strlen(name))) { |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
139 |
if (!(pdo->name = (char *) kmalloc(len + 1, GFP_KERNEL))) { |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
140 |
EC_ERR("Failed to allocate PDO name.\n"); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1186
diff
changeset
|
141 |
return -ENOMEM; |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
142 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
143 |
memcpy(pdo->name, name, len + 1); |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
144 |
} else { |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
145 |
pdo->name = NULL; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
146 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
147 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
148 |
return 0; |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
149 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
150 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
151 |
/*****************************************************************************/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
152 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
153 |
/** Add a new PDO entry to the configuration. |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1186
diff
changeset
|
154 |
* |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1186
diff
changeset
|
155 |
* \retval Pointer to the added entry, otherwise a ERR_PTR() code. |
842
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
826
diff
changeset
|
156 |
*/ |
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
826
diff
changeset
|
157 |
ec_pdo_entry_t *ec_pdo_add_entry( |
1332
d62633fea8ed
merge -c1610 branches/stable-1.4: Added missing doxygen docs.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
158 |
ec_pdo_t *pdo, /**< PDO. */ |
d62633fea8ed
merge -c1610 branches/stable-1.4: Added missing doxygen docs.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
159 |
uint16_t index, /**< New entry's index. */ |
d62633fea8ed
merge -c1610 branches/stable-1.4: Added missing doxygen docs.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
160 |
uint8_t subindex, /**< New entry's subindex. */ |
d62633fea8ed
merge -c1610 branches/stable-1.4: Added missing doxygen docs.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
161 |
uint8_t bit_length /**< New entry's bit length. */ |
842
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
826
diff
changeset
|
162 |
) |
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
826
diff
changeset
|
163 |
{ |
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
826
diff
changeset
|
164 |
ec_pdo_entry_t *entry; |
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
826
diff
changeset
|
165 |
|
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
826
diff
changeset
|
166 |
if (!(entry = kmalloc(sizeof(ec_pdo_entry_t), GFP_KERNEL))) { |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
167 |
EC_ERR("Failed to allocate memory for PDO entry.\n"); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1186
diff
changeset
|
168 |
return ERR_PTR(-ENOMEM); |
842
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
826
diff
changeset
|
169 |
} |
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
826
diff
changeset
|
170 |
|
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
826
diff
changeset
|
171 |
ec_pdo_entry_init(entry); |
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
826
diff
changeset
|
172 |
entry->index = index; |
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
826
diff
changeset
|
173 |
entry->subindex = subindex; |
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
826
diff
changeset
|
174 |
entry->bit_length = bit_length; |
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
826
diff
changeset
|
175 |
list_add_tail(&entry->list, &pdo->entries); |
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
826
diff
changeset
|
176 |
return entry; |
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
826
diff
changeset
|
177 |
} |
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
826
diff
changeset
|
178 |
|
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
826
diff
changeset
|
179 |
/*****************************************************************************/ |
40e27e5a8dce
Added ecrt_slave_config_pdo() and ecrt_slave_config_pdo_entry().
Florian Pose <fp@igh-essen.com>
parents:
826
diff
changeset
|
180 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
181 |
/** Copy PDO entries from another PDO. |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1186
diff
changeset
|
182 |
* |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1186
diff
changeset
|
183 |
* \retval 0 Success. |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1186
diff
changeset
|
184 |
* \retval <0 Error code. |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
185 |
*/ |
1332
d62633fea8ed
merge -c1610 branches/stable-1.4: Added missing doxygen docs.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
186 |
int ec_pdo_copy_entries( |
d62633fea8ed
merge -c1610 branches/stable-1.4: Added missing doxygen docs.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
187 |
ec_pdo_t *pdo, /**< PDO whos entries shall be replaced. */ |
d62633fea8ed
merge -c1610 branches/stable-1.4: Added missing doxygen docs.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
188 |
const ec_pdo_t *other /**< Pdo with entries to copy. */ |
d62633fea8ed
merge -c1610 branches/stable-1.4: Added missing doxygen docs.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
189 |
) |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
190 |
{ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
191 |
ec_pdo_entry_t *entry, *other_entry; |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1186
diff
changeset
|
192 |
int ret; |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
193 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
194 |
ec_pdo_clear_entries(pdo); |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
195 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
196 |
list_for_each_entry(other_entry, &other->entries, list) { |
627
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
197 |
if (!(entry = (ec_pdo_entry_t *) |
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
198 |
kmalloc(sizeof(ec_pdo_entry_t), GFP_KERNEL))) { |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
199 |
EC_ERR("Failed to allocate memory for PDO entry copy.\n"); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1186
diff
changeset
|
200 |
return -ENOMEM; |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
201 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
202 |
|
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1186
diff
changeset
|
203 |
ret = ec_pdo_entry_init_copy(entry, other_entry); |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1186
diff
changeset
|
204 |
if (ret < 0) { |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
205 |
kfree(entry); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1186
diff
changeset
|
206 |
return ret; |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
207 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
208 |
|
627
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
209 |
list_add_tail(&entry->list, &pdo->entries); |
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
210 |
} |
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
211 |
|
4793ca94f082
Layed out PDO structures to own files.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
212 |
return 0; |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
213 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
214 |
|
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
215 |
/*****************************************************************************/ |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
627
diff
changeset
|
216 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
217 |
/** Compares the entries of two PDOs. |
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
218 |
* |
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
219 |
* \retval 1 The entries of the given PDOs are equal. |
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
220 |
* \retval 0 The entries of the given PDOs differ. |
799 | 221 |
*/ |
222 |
int ec_pdo_equal_entries( |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
223 |
const ec_pdo_t *pdo1, /**< First PDO. */ |
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
224 |
const ec_pdo_t *pdo2 /**< Second PDO. */ |
799 | 225 |
) |
226 |
{ |
|
227 |
const struct list_head *head1, *head2, *item1, *item2; |
|
228 |
const ec_pdo_entry_t *entry1, *entry2; |
|
229 |
||
230 |
head1 = item1 = &pdo1->entries; |
|
231 |
head2 = item2 = &pdo2->entries; |
|
232 |
||
233 |
while (1) { |
|
234 |
item1 = item1->next; |
|
235 |
item2 = item2->next; |
|
236 |
||
237 |
if ((item1 == head1) ^ (item2 == head2)) // unequal lengths |
|
238 |
return 0; |
|
826 | 239 |
if (item1 == head1) // both finished |
799 | 240 |
break; |
241 |
||
242 |
entry1 = list_entry(item1, ec_pdo_entry_t, list); |
|
243 |
entry2 = list_entry(item2, ec_pdo_entry_t, list); |
|
244 |
if (!ec_pdo_entry_equal(entry1, entry2)) |
|
245 |
return 0; |
|
246 |
} |
|
247 |
||
248 |
return 1; |
|
249 |
} |
|
250 |
||
251 |
/*****************************************************************************/ |
|
934
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
252 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
253 |
/** Get the number of PDO entries. |
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
254 |
* |
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
255 |
* \return Number of PDO entries. |
934
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
256 |
*/ |
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
257 |
unsigned int ec_pdo_entry_count( |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
258 |
const ec_pdo_t *pdo /**< PDO. */ |
934
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
259 |
) |
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
260 |
{ |
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
261 |
const ec_pdo_entry_t *entry; |
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
262 |
unsigned int num = 0; |
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
263 |
|
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
264 |
list_for_each_entry(entry, &pdo->entries, list) { |
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
265 |
num++; |
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
266 |
} |
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
267 |
|
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
268 |
return num; |
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
269 |
} |
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
270 |
|
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
271 |
/*****************************************************************************/ |
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
272 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
273 |
/** Finds a PDO entry via its position in the list. |
934
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
274 |
* |
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
275 |
* Const version. |
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
276 |
*/ |
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
277 |
const ec_pdo_entry_t *ec_pdo_find_entry_by_pos_const( |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
278 |
const ec_pdo_t *pdo, /**< PDO. */ |
934
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
279 |
unsigned int pos /**< Position in the list. */ |
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
280 |
) |
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
281 |
{ |
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
282 |
const ec_pdo_entry_t *entry; |
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
283 |
|
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
284 |
list_for_each_entry(entry, &pdo->entries, list) { |
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
285 |
if (pos--) |
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
286 |
continue; |
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
287 |
return entry; |
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
288 |
} |
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
289 |
|
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
290 |
return NULL; |
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
291 |
} |
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
292 |
|
96241b092fac
Added entry access functions.
Florian Pose <fp@igh-essen.com>
parents:
933
diff
changeset
|
293 |
/*****************************************************************************/ |
1823
2bf892fe8080
Improved output when PDO assignment/mapping fails.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
294 |
|
2bf892fe8080
Improved output when PDO assignment/mapping fails.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
295 |
/** Outputs the PDOs in the list. |
2bf892fe8080
Improved output when PDO assignment/mapping fails.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
296 |
*/ |
2bf892fe8080
Improved output when PDO assignment/mapping fails.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
297 |
void ec_pdo_print_entries( |
2bf892fe8080
Improved output when PDO assignment/mapping fails.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
298 |
const ec_pdo_t *pdo /**< PDO. */ |
2bf892fe8080
Improved output when PDO assignment/mapping fails.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
299 |
) |
2bf892fe8080
Improved output when PDO assignment/mapping fails.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
300 |
{ |
2bf892fe8080
Improved output when PDO assignment/mapping fails.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
301 |
const ec_pdo_entry_t *entry; |
2bf892fe8080
Improved output when PDO assignment/mapping fails.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
302 |
|
2bf892fe8080
Improved output when PDO assignment/mapping fails.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
303 |
if (list_empty(&pdo->entries)) { |
2bf892fe8080
Improved output when PDO assignment/mapping fails.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
304 |
printk("(none)"); |
2bf892fe8080
Improved output when PDO assignment/mapping fails.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
305 |
} else { |
2bf892fe8080
Improved output when PDO assignment/mapping fails.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
306 |
list_for_each_entry(entry, &pdo->entries, list) { |
2bf892fe8080
Improved output when PDO assignment/mapping fails.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
307 |
printk("0x%04X:%02X/%u", |
2bf892fe8080
Improved output when PDO assignment/mapping fails.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
308 |
entry->index, entry->subindex, entry->bit_length); |
2bf892fe8080
Improved output when PDO assignment/mapping fails.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
309 |
if (entry->list.next != &pdo->entries) |
2bf892fe8080
Improved output when PDO assignment/mapping fails.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
310 |
printk(" "); |
2bf892fe8080
Improved output when PDO assignment/mapping fails.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
311 |
} |
2bf892fe8080
Improved output when PDO assignment/mapping fails.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
312 |
} |
2bf892fe8080
Improved output when PDO assignment/mapping fails.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
313 |
} |
2bf892fe8080
Improved output when PDO assignment/mapping fails.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
314 |
|
2bf892fe8080
Improved output when PDO assignment/mapping fails.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
315 |
/*****************************************************************************/ |