author | Florian Pose <fp@igh-essen.com> |
Fri, 08 Feb 2013 20:00:16 +0100 | |
branch | stable-1.5 |
changeset 2512 | a01947bc9ab6 |
parent 2507 | 4ccf7634e664 |
child 2653 | 291dddb7233e |
permissions | -rw-r--r-- |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
2421 | 2 |
* |
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
|
3 |
* $Id$ |
2421 | 4 |
* |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
5 |
* Copyright (C) 2006-2012 Florian Pose, Ingenieurgemeinschaft IgH |
2421 | 6 |
* |
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
|
7 |
* This file is part of the IgH EtherCAT master userspace library. |
2421 | 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 userspace library is free software; you can |
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 |
* redistribute it and/or modify it under the terms of the GNU Lesser 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
|
11 |
* Public License as published by the Free Software Foundation; version 2.1 |
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 |
* of the License. |
1287 | 13 |
* |
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
|
14 |
* The IgH EtherCAT master userspace library is distributed in the hope that |
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 |
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
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 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
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 |
* GNU Lesser General Public License for more details. |
1287 | 18 |
* |
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
|
19 |
* You should have received a copy of the GNU Lesser General Public License |
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
|
20 |
* along with the IgH EtherCAT master userspace library. If not, see |
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
|
21 |
* <http://www.gnu.org/licenses/>. |
2421 | 22 |
* |
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1352
diff
changeset
|
23 |
* --- |
2421 | 24 |
* |
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1352
diff
changeset
|
25 |
* The license mentioned above concerns the source code only. Using the |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1352
diff
changeset
|
26 |
* EtherCAT technology and brand is only permitted in compliance with the |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1352
diff
changeset
|
27 |
* industrial property and similar rights of Beckhoff Automation GmbH. |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
* |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
*****************************************************************************/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
30 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
31 |
#include <stdlib.h> |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
#include <stdio.h> |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
#include <string.h> |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
34 |
#include <errno.h> /* ENOENT */ |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
35 |
|
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
36 |
#include "ioctl.h" |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
#include "slave_config.h" |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
#include "domain.h" |
1352
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
39 |
#include "sdo_request.h" |
2443
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
40 |
#include "reg_request.h" |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
41 |
#include "voe_handler.h" |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
#include "master.h" |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
/*****************************************************************************/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
45 |
|
1959
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
46 |
void ec_slave_config_clear(ec_slave_config_t *sc) |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
47 |
{ |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
48 |
ec_sdo_request_t *r, *next_r; |
2443
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
49 |
ec_reg_request_t *e, *next_e; |
1959
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
50 |
ec_voe_handler_t *v, *next_v; |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
51 |
|
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
52 |
r = sc->first_sdo_request; |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
53 |
while (r) { |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
54 |
next_r = r->next; |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
55 |
ec_sdo_request_clear(r); |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
56 |
r = next_r; |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
57 |
} |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
58 |
|
2443
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
59 |
e = sc->first_reg_request; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
60 |
while (e) { |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
61 |
next_e = e->next; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
62 |
ec_reg_request_clear(e); |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
63 |
e = next_e; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
64 |
} |
1959
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
65 |
|
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
66 |
v = sc->first_voe_handler; |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
67 |
while (v) { |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
68 |
next_v = v->next; |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
69 |
ec_voe_handler_clear(v); |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
70 |
v = next_v; |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
71 |
} |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
72 |
} |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
73 |
|
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
74 |
/*****************************************************************************/ |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
75 |
|
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
76 |
int ecrt_slave_config_sync_manager(ec_slave_config_t *sc, uint8_t sync_index, |
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1508
diff
changeset
|
77 |
ec_direction_t dir, ec_watchdog_mode_t watchdog_mode) |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
78 |
{ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
79 |
ec_ioctl_config_t data; |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
80 |
int ret; |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
81 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
82 |
if (sync_index >= EC_MAX_SYNC_MANAGERS) |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
83 |
return -ENOENT; |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
84 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
85 |
memset(&data, 0x00, sizeof(ec_ioctl_config_t)); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
86 |
data.config_index = sc->index; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
87 |
data.syncs[sync_index].dir = dir; |
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1508
diff
changeset
|
88 |
data.syncs[sync_index].watchdog_mode = watchdog_mode; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1508
diff
changeset
|
89 |
data.syncs[sync_index].config_this = 1; |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
90 |
|
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
91 |
ret = ioctl(sc->master->fd, EC_IOCTL_SC_SYNC, &data); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
92 |
if (EC_IOCTL_IS_ERROR(ret)) { |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
93 |
fprintf(stderr, "Failed to config sync manager: %s\n", |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
94 |
strerror(EC_IOCTL_ERRNO(ret))); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
95 |
return -EC_IOCTL_ERRNO(ret); |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
96 |
} |
2421 | 97 |
|
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
98 |
return 0; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
99 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
100 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
101 |
/*****************************************************************************/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
102 |
|
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1508
diff
changeset
|
103 |
void ecrt_slave_config_watchdog(ec_slave_config_t *sc, |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1508
diff
changeset
|
104 |
uint16_t divider, uint16_t intervals) |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1508
diff
changeset
|
105 |
{ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1508
diff
changeset
|
106 |
ec_ioctl_config_t data; |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
107 |
int ret; |
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1508
diff
changeset
|
108 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1508
diff
changeset
|
109 |
memset(&data, 0x00, sizeof(ec_ioctl_config_t)); |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1508
diff
changeset
|
110 |
data.config_index = sc->index; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1508
diff
changeset
|
111 |
data.watchdog_divider = divider; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1508
diff
changeset
|
112 |
data.watchdog_intervals = intervals; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1508
diff
changeset
|
113 |
|
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
114 |
ret = ioctl(sc->master->fd, EC_IOCTL_SC_WATCHDOG, &data); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
115 |
if (EC_IOCTL_IS_ERROR(ret)) { |
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1508
diff
changeset
|
116 |
fprintf(stderr, "Failed to config watchdog: %s\n", |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
117 |
strerror(EC_IOCTL_ERRNO(ret))); |
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1508
diff
changeset
|
118 |
} |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1508
diff
changeset
|
119 |
} |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1508
diff
changeset
|
120 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1508
diff
changeset
|
121 |
/*****************************************************************************/ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1508
diff
changeset
|
122 |
|
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
123 |
int ecrt_slave_config_pdo_assign_add(ec_slave_config_t *sc, |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
124 |
uint8_t sync_index, uint16_t pdo_index) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
125 |
{ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
126 |
ec_ioctl_config_pdo_t data; |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
127 |
int ret; |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
128 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
129 |
data.config_index = sc->index; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
130 |
data.sync_index = sync_index; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
131 |
data.index = pdo_index; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
132 |
|
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
133 |
ret = ioctl(sc->master->fd, EC_IOCTL_SC_ADD_PDO, &data); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
134 |
if (EC_IOCTL_IS_ERROR(ret)) { |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
135 |
fprintf(stderr, "Failed to add PDO: %s\n", |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
136 |
strerror(EC_IOCTL_ERRNO(ret))); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
137 |
return -EC_IOCTL_ERRNO(ret); |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
138 |
} |
2421 | 139 |
|
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
140 |
return 0; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
141 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
142 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
143 |
/*****************************************************************************/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
144 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
145 |
void ecrt_slave_config_pdo_assign_clear(ec_slave_config_t *sc, |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
146 |
uint8_t sync_index) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
147 |
{ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
148 |
ec_ioctl_config_pdo_t data; |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
149 |
int ret; |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
150 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
151 |
data.config_index = sc->index; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
152 |
data.sync_index = sync_index; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
153 |
|
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
154 |
ret = ioctl(sc->master->fd, EC_IOCTL_SC_CLEAR_PDOS, &data); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
155 |
if (EC_IOCTL_IS_ERROR(ret)) { |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
156 |
fprintf(stderr, "Failed to clear PDOs: %s\n", |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
157 |
strerror(EC_IOCTL_ERRNO(ret))); |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
158 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
159 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
160 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
161 |
/*****************************************************************************/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
162 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
163 |
int ecrt_slave_config_pdo_mapping_add(ec_slave_config_t *sc, |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
164 |
uint16_t pdo_index, uint16_t entry_index, uint8_t entry_subindex, |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
165 |
uint8_t entry_bit_length) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
166 |
{ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
167 |
ec_ioctl_add_pdo_entry_t data; |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
168 |
int ret; |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
169 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
170 |
data.config_index = sc->index; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
171 |
data.pdo_index = pdo_index; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
172 |
data.entry_index = entry_index; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
173 |
data.entry_subindex = entry_subindex; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
174 |
data.entry_bit_length = entry_bit_length; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
175 |
|
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
176 |
ret = ioctl(sc->master->fd, EC_IOCTL_SC_ADD_ENTRY, &data); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
177 |
if (EC_IOCTL_IS_ERROR(ret)) { |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
178 |
fprintf(stderr, "Failed to add PDO entry: %s\n", |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
179 |
strerror(EC_IOCTL_ERRNO(ret))); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
180 |
return -EC_IOCTL_ERRNO(ret); |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
181 |
} |
2421 | 182 |
|
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
183 |
return 0; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
184 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
185 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
186 |
/*****************************************************************************/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
187 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
188 |
void ecrt_slave_config_pdo_mapping_clear(ec_slave_config_t *sc, |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
189 |
uint16_t pdo_index) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
190 |
{ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
191 |
ec_ioctl_config_pdo_t data; |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
192 |
int ret; |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
193 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
194 |
data.config_index = sc->index; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
195 |
data.index = pdo_index; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
196 |
|
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
197 |
ret = ioctl(sc->master->fd, EC_IOCTL_SC_CLEAR_ENTRIES, &data); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
198 |
if (EC_IOCTL_IS_ERROR(ret)) { |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
199 |
fprintf(stderr, "Failed to clear PDO entries: %s\n", |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
200 |
strerror(EC_IOCTL_ERRNO(ret))); |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
201 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
202 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
203 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
204 |
/*****************************************************************************/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
205 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
206 |
int ecrt_slave_config_pdos(ec_slave_config_t *sc, |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
207 |
unsigned int n_syncs, const ec_sync_info_t syncs[]) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
208 |
{ |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
209 |
int ret; |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
210 |
unsigned int i, j, k; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
211 |
const ec_sync_info_t *sync_info; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
212 |
const ec_pdo_info_t *pdo_info; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
213 |
const ec_pdo_entry_info_t *entry_info; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
214 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
215 |
if (!syncs) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
216 |
return 0; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
217 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
218 |
for (i = 0; i < n_syncs; i++) { |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
219 |
sync_info = &syncs[i]; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
220 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
221 |
if (sync_info->index == (uint8_t) EC_END) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
222 |
break; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
223 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
224 |
if (sync_info->index >= EC_MAX_SYNC_MANAGERS) { |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
225 |
fprintf(stderr, "Invalid sync manager index %u!\n", |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
226 |
sync_info->index); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
227 |
return -ENOENT; |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
228 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
229 |
|
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1508
diff
changeset
|
230 |
ret = ecrt_slave_config_sync_manager(sc, sync_info->index, |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1508
diff
changeset
|
231 |
sync_info->dir, sync_info->watchdog_mode); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
232 |
if (ret) |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
233 |
return ret; |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
234 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
235 |
if (sync_info->n_pdos && sync_info->pdos) { |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
236 |
ecrt_slave_config_pdo_assign_clear(sc, sync_info->index); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
237 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
238 |
for (j = 0; j < sync_info->n_pdos; j++) { |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
239 |
pdo_info = &sync_info->pdos[j]; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
240 |
|
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
241 |
ret = ecrt_slave_config_pdo_assign_add( |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
242 |
sc, sync_info->index, pdo_info->index); |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
243 |
if (ret) |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
244 |
return ret; |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
245 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
246 |
if (pdo_info->n_entries && pdo_info->entries) { |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
247 |
ecrt_slave_config_pdo_mapping_clear(sc, pdo_info->index); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
248 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
249 |
for (k = 0; k < pdo_info->n_entries; k++) { |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
250 |
entry_info = &pdo_info->entries[k]; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
251 |
|
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
252 |
ret = ecrt_slave_config_pdo_mapping_add(sc, |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
253 |
pdo_info->index, entry_info->index, |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
254 |
entry_info->subindex, |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
255 |
entry_info->bit_length); |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
256 |
if (ret) |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
257 |
return ret; |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
258 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
259 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
260 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
261 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
262 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
263 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
264 |
return 0; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
265 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
266 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
267 |
/*****************************************************************************/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
268 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
269 |
int ecrt_slave_config_reg_pdo_entry( |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
270 |
ec_slave_config_t *sc, |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
271 |
uint16_t index, |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
272 |
uint8_t subindex, |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
273 |
ec_domain_t *domain, |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
274 |
unsigned int *bit_position |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
275 |
) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
276 |
{ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
277 |
ec_ioctl_reg_pdo_entry_t data; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
278 |
int ret; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
279 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
280 |
data.config_index = sc->index; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
281 |
data.entry_index = index; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
282 |
data.entry_subindex = subindex; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
283 |
data.domain_index = domain->index; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
284 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
285 |
ret = ioctl(sc->master->fd, EC_IOCTL_SC_REG_PDO_ENTRY, &data); |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
286 |
if (EC_IOCTL_IS_ERROR(ret)) { |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
287 |
fprintf(stderr, "Failed to register PDO entry: %s\n", |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
288 |
strerror(EC_IOCTL_ERRNO(ret))); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
289 |
return -EC_IOCTL_ERRNO(ret); |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
290 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
291 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
292 |
if (bit_position) { |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
293 |
*bit_position = data.bit_position; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
294 |
} else { |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
295 |
if (data.bit_position) { |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
296 |
fprintf(stderr, "PDO entry 0x%04X:%02X does not byte-align " |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
297 |
"in config %u:%u.\n", index, subindex, |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
298 |
sc->alias, sc->position); |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
299 |
return -EFAULT; |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
300 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
301 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
302 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
303 |
return ret; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
304 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
305 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
306 |
/*****************************************************************************/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
307 |
|
2505
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
308 |
int ecrt_slave_config_reg_pdo_entry_pos( |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
309 |
ec_slave_config_t *sc, |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
310 |
uint8_t sync_index, |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
311 |
unsigned int pdo_pos, |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
312 |
unsigned int entry_pos, |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
313 |
ec_domain_t *domain, |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
314 |
unsigned int *bit_position |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
315 |
) |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
316 |
{ |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
317 |
ec_ioctl_reg_pdo_pos_t io; |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
318 |
int ret; |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
319 |
|
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
320 |
io.config_index = sc->index; |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
321 |
io.sync_index = sync_index; |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
322 |
io.pdo_pos = pdo_pos; |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
323 |
io.entry_pos = entry_pos; |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
324 |
io.domain_index = domain->index; |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
325 |
|
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
326 |
ret = ioctl(sc->master->fd, EC_IOCTL_SC_REG_PDO_POS, &io); |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
327 |
if (EC_IOCTL_IS_ERROR(ret)) { |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
328 |
fprintf(stderr, "Failed to register PDO entry: %s\n", |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
329 |
strerror(EC_IOCTL_ERRNO(ret))); |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
330 |
return -EC_IOCTL_ERRNO(ret); |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
331 |
} |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
332 |
|
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
333 |
if (bit_position) { |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
334 |
*bit_position = io.bit_position; |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
335 |
} else { |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
336 |
if (io.bit_position) { |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
337 |
fprintf(stderr, "PDO entry %u/%u/%u does not byte-align " |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
338 |
"in config %u:%u.\n", sync_index, pdo_pos, entry_pos, |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
339 |
sc->alias, sc->position); |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
340 |
return -EFAULT; |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
341 |
} |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
342 |
} |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
343 |
|
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
344 |
return ret; |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
345 |
} |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
346 |
|
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
347 |
/*****************************************************************************/ |
5ef3197e5e1f
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
Florian Pose <fp@igh-essen.com>
parents:
2480
diff
changeset
|
348 |
|
1448
d7ba0c408a07
Merged ecrt_slave_config_dc_assign_activate() and
Florian Pose <fp@igh-essen.com>
parents:
1438
diff
changeset
|
349 |
void ecrt_slave_config_dc(ec_slave_config_t *sc, uint16_t assign_activate, |
2449
5db725cc40f9
Changed the datatypes of the shift times in ecrt_slave_config_dc()
Florian Pose <fp@igh-essen.com>
parents:
2443
diff
changeset
|
350 |
uint32_t sync0_cycle_time, int32_t sync0_shift_time, |
5db725cc40f9
Changed the datatypes of the shift times in ecrt_slave_config_dc()
Florian Pose <fp@igh-essen.com>
parents:
2443
diff
changeset
|
351 |
uint32_t sync1_cycle_time, int32_t sync1_shift_time) |
1413
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1371
diff
changeset
|
352 |
{ |
1455
aa18fcfe0fd1
Output DC config in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1448
diff
changeset
|
353 |
ec_ioctl_config_t data; |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
354 |
int ret; |
1455
aa18fcfe0fd1
Output DC config in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1448
diff
changeset
|
355 |
|
aa18fcfe0fd1
Output DC config in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1448
diff
changeset
|
356 |
data.config_index = sc->index; |
aa18fcfe0fd1
Output DC config in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1448
diff
changeset
|
357 |
data.dc_assign_activate = assign_activate; |
1508 | 358 |
data.dc_sync[0].cycle_time = sync0_cycle_time; |
359 |
data.dc_sync[0].shift_time = sync0_shift_time; |
|
360 |
data.dc_sync[1].cycle_time = sync1_cycle_time; |
|
361 |
data.dc_sync[1].shift_time = sync1_shift_time; |
|
1438
1d30b96bb04f
Replaced ecrt_slave_config_dc_cycle_times() and ecrt_slave_config_dc_shift_times() by ecrt_slave_config_dc_sync_signals().
Florian Pose <fp@igh-essen.com>
parents:
1413
diff
changeset
|
362 |
|
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
363 |
ret = ioctl(sc->master->fd, EC_IOCTL_SC_DC, &data); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
364 |
if (EC_IOCTL_IS_ERROR(ret)) { |
2449
5db725cc40f9
Changed the datatypes of the shift times in ecrt_slave_config_dc()
Florian Pose <fp@igh-essen.com>
parents:
2443
diff
changeset
|
365 |
fprintf(stderr, "Failed to set DC parameters: %s\n", |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
366 |
strerror(EC_IOCTL_ERRNO(ret))); |
1413
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1371
diff
changeset
|
367 |
} |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1371
diff
changeset
|
368 |
} |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1371
diff
changeset
|
369 |
|
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1371
diff
changeset
|
370 |
/*****************************************************************************/ |
44c2b7c0ae1a
Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents:
1371
diff
changeset
|
371 |
|
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
372 |
int ecrt_slave_config_sdo(ec_slave_config_t *sc, uint16_t index, |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
373 |
uint8_t subindex, const uint8_t *sdo_data, size_t size) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
374 |
{ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
375 |
ec_ioctl_sc_sdo_t data; |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
376 |
int ret; |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
377 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
378 |
data.config_index = sc->index; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
379 |
data.index = index; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
380 |
data.subindex = subindex; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
381 |
data.data = sdo_data; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
382 |
data.size = size; |
1526
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1509
diff
changeset
|
383 |
data.complete_access = 0; |
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1509
diff
changeset
|
384 |
|
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
385 |
ret = ioctl(sc->master->fd, EC_IOCTL_SC_SDO, &data); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
386 |
if (EC_IOCTL_IS_ERROR(ret)) { |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
387 |
fprintf(stderr, "Failed to configure SDO: %s\n", |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
388 |
strerror(EC_IOCTL_ERRNO(ret))); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
389 |
return -EC_IOCTL_ERRNO(ret); |
1526
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1509
diff
changeset
|
390 |
} |
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1509
diff
changeset
|
391 |
|
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1509
diff
changeset
|
392 |
return 0; |
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1509
diff
changeset
|
393 |
} |
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1509
diff
changeset
|
394 |
|
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1509
diff
changeset
|
395 |
/*****************************************************************************/ |
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1509
diff
changeset
|
396 |
|
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1509
diff
changeset
|
397 |
int ecrt_slave_config_complete_sdo(ec_slave_config_t *sc, uint16_t index, |
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1509
diff
changeset
|
398 |
const uint8_t *sdo_data, size_t size) |
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1509
diff
changeset
|
399 |
{ |
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1509
diff
changeset
|
400 |
ec_ioctl_sc_sdo_t data; |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
401 |
int ret; |
1526
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1509
diff
changeset
|
402 |
|
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1509
diff
changeset
|
403 |
data.config_index = sc->index; |
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1509
diff
changeset
|
404 |
data.index = index; |
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1509
diff
changeset
|
405 |
data.subindex = 0; |
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1509
diff
changeset
|
406 |
data.data = sdo_data; |
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1509
diff
changeset
|
407 |
data.size = size; |
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1509
diff
changeset
|
408 |
data.complete_access = 1; |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
409 |
|
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
410 |
ret = ioctl(sc->master->fd, EC_IOCTL_SC_SDO, &data); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
411 |
if (EC_IOCTL_IS_ERROR(ret)) { |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
412 |
fprintf(stderr, "Failed to configure SDO: %s\n", |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
413 |
strerror(EC_IOCTL_ERRNO(ret))); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
414 |
return -EC_IOCTL_ERRNO(ret); |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
415 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
416 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
417 |
return 0; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
418 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
419 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
420 |
/*****************************************************************************/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
421 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
422 |
int ecrt_slave_config_sdo8(ec_slave_config_t *sc, uint16_t index, |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
423 |
uint8_t subindex, uint8_t value) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
424 |
{ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
425 |
uint8_t data[1]; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
426 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
427 |
EC_WRITE_U8(data, value); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
428 |
return ecrt_slave_config_sdo(sc, index, subindex, data, 1); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
429 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
430 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
431 |
/*****************************************************************************/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
432 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
433 |
int ecrt_slave_config_sdo16(ec_slave_config_t *sc, uint16_t index, |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
434 |
uint8_t subindex, uint16_t value) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
435 |
{ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
436 |
uint8_t data[2]; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
437 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
438 |
EC_WRITE_U16(data, value); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
439 |
return ecrt_slave_config_sdo(sc, index, subindex, data, 2); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
440 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
441 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
442 |
/*****************************************************************************/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
443 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
444 |
int ecrt_slave_config_sdo32(ec_slave_config_t *sc, uint16_t index, |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
445 |
uint8_t subindex, uint32_t value) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
446 |
{ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
447 |
uint8_t data[4]; |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
448 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
449 |
EC_WRITE_U32(data, value); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
450 |
return ecrt_slave_config_sdo(sc, index, subindex, data, 4); |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
451 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
452 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
453 |
/*****************************************************************************/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
454 |
|
2438
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
455 |
int ecrt_slave_config_emerg_size(ec_slave_config_t *sc, size_t elements) |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
456 |
{ |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
457 |
ec_ioctl_sc_emerg_t io; |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
458 |
int ret; |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
459 |
|
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
460 |
io.config_index = sc->index; |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
461 |
io.size = elements; |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
462 |
|
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
463 |
ret = ioctl(sc->master->fd, EC_IOCTL_SC_EMERG_SIZE, &io); |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
464 |
if (EC_IOCTL_IS_ERROR(ret)) { |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
465 |
fprintf(stderr, "Failed to set emergency ring size: %s\n", |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
466 |
strerror(EC_IOCTL_ERRNO(ret))); |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
467 |
return -EC_IOCTL_ERRNO(ret); |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
468 |
} |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
469 |
|
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
470 |
return 0; |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
471 |
} |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
472 |
|
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
473 |
/*****************************************************************************/ |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
474 |
|
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
475 |
int ecrt_slave_config_emerg_pop(ec_slave_config_t *sc, uint8_t *target) |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
476 |
{ |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
477 |
ec_ioctl_sc_emerg_t io; |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
478 |
int ret; |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
479 |
|
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
480 |
io.config_index = sc->index; |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
481 |
io.target = target; |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
482 |
|
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
483 |
ret = ioctl(sc->master->fd, EC_IOCTL_SC_EMERG_POP, &io); |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
484 |
if (EC_IOCTL_IS_ERROR(ret)) { |
2507
4ccf7634e664
Fixed annoying fprintf in ecrt_slave_config_emerg_pop().
Florian Pose <fp@igh-essen.com>
parents:
2505
diff
changeset
|
485 |
if (EC_IOCTL_ERRNO(ret) != ENOENT) { |
4ccf7634e664
Fixed annoying fprintf in ecrt_slave_config_emerg_pop().
Florian Pose <fp@igh-essen.com>
parents:
2505
diff
changeset
|
486 |
fprintf(stderr, "Failed to get emergency message: %s\n", |
4ccf7634e664
Fixed annoying fprintf in ecrt_slave_config_emerg_pop().
Florian Pose <fp@igh-essen.com>
parents:
2505
diff
changeset
|
487 |
strerror(EC_IOCTL_ERRNO(ret))); |
4ccf7634e664
Fixed annoying fprintf in ecrt_slave_config_emerg_pop().
Florian Pose <fp@igh-essen.com>
parents:
2505
diff
changeset
|
488 |
} |
2438
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
489 |
return -EC_IOCTL_ERRNO(ret); |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
490 |
} |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
491 |
|
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
492 |
return 0; |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
493 |
} |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
494 |
|
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
495 |
/*****************************************************************************/ |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
496 |
|
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
497 |
int ecrt_slave_config_emerg_clear(ec_slave_config_t *sc) |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
498 |
{ |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
499 |
ec_ioctl_sc_emerg_t io; |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
500 |
int ret; |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
501 |
|
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
502 |
io.config_index = sc->index; |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
503 |
|
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
504 |
ret = ioctl(sc->master->fd, EC_IOCTL_SC_EMERG_CLEAR, &io); |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
505 |
if (EC_IOCTL_IS_ERROR(ret)) { |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
506 |
fprintf(stderr, "Failed to clear emergency ring: %s\n", |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
507 |
strerror(EC_IOCTL_ERRNO(ret))); |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
508 |
return -EC_IOCTL_ERRNO(ret); |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
509 |
} |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
510 |
|
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
511 |
return 0; |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
512 |
} |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
513 |
|
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
514 |
/*****************************************************************************/ |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
515 |
|
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
516 |
int ecrt_slave_config_emerg_overruns(ec_slave_config_t *sc) |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
517 |
{ |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
518 |
ec_ioctl_sc_emerg_t io; |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
519 |
int ret; |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
520 |
|
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
521 |
io.config_index = sc->index; |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
522 |
|
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
523 |
ret = ioctl(sc->master->fd, EC_IOCTL_SC_EMERG_OVERRUNS, &io); |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
524 |
if (EC_IOCTL_IS_ERROR(ret)) { |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
525 |
fprintf(stderr, "Failed to get emergency overruns: %s\n", |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
526 |
strerror(EC_IOCTL_ERRNO(ret))); |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
527 |
return -EC_IOCTL_ERRNO(ret); |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
528 |
} |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
529 |
|
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
530 |
return io.overruns; |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
531 |
} |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
532 |
|
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
533 |
/*****************************************************************************/ |
9c3e629a220c
Added API for querying CoE emergency requests.
Florian Pose <fp@igh-essen.com>
parents:
2433
diff
changeset
|
534 |
|
1959
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
535 |
void ec_slave_config_add_sdo_request(ec_slave_config_t *sc, |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
536 |
ec_sdo_request_t *req) |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
537 |
{ |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
538 |
if (sc->first_sdo_request) { |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
539 |
ec_sdo_request_t *r = sc->first_sdo_request; |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
540 |
while (r->next) { |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
541 |
r = r->next; |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
542 |
} |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
543 |
r->next = req; |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
544 |
} else { |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
545 |
sc->first_sdo_request = req; |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
546 |
} |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
547 |
} |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
548 |
|
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
549 |
/*****************************************************************************/ |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
550 |
|
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
551 |
ec_sdo_request_t *ecrt_slave_config_create_sdo_request(ec_slave_config_t *sc, |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
552 |
uint16_t index, uint8_t subindex, size_t size) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
553 |
{ |
1352
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
554 |
ec_ioctl_sdo_request_t data; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
555 |
ec_sdo_request_t *req; |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
556 |
int ret; |
1352
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
557 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
558 |
req = malloc(sizeof(ec_sdo_request_t)); |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
559 |
if (!req) { |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
560 |
fprintf(stderr, "Failed to allocate memory.\n"); |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
561 |
return 0; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
562 |
} |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
563 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
564 |
if (size) { |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
565 |
req->data = malloc(size); |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
566 |
if (!req->data) { |
2480 | 567 |
fprintf(stderr, "Failed to allocate %zu bytes of SDO data" |
1352
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
568 |
" memory.\n", size); |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
569 |
free(req); |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
570 |
return 0; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
571 |
} |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
572 |
} else { |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
573 |
req->data = NULL; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
574 |
} |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
575 |
|
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
576 |
data.config_index = sc->index; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
577 |
data.sdo_index = index; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
578 |
data.sdo_subindex = subindex; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
579 |
data.size = size; |
2421 | 580 |
|
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
581 |
ret = ioctl(sc->master->fd, EC_IOCTL_SC_SDO_REQUEST, &data); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
582 |
if (EC_IOCTL_IS_ERROR(ret)) { |
1352
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
583 |
fprintf(stderr, "Failed to create SDO request: %s\n", |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
584 |
strerror(EC_IOCTL_ERRNO(ret))); |
1959
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
585 |
ec_sdo_request_clear(req); |
1352
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
586 |
free(req); |
2421 | 587 |
return NULL; |
1352
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
588 |
} |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
589 |
|
1959
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
590 |
req->next = NULL; |
1352
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
591 |
req->config = sc; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
592 |
req->index = data.request_index; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
593 |
req->sdo_index = data.sdo_index; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
594 |
req->sdo_subindex = data.sdo_subindex; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
595 |
req->data_size = size; |
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
596 |
req->mem_size = size; |
1959
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
597 |
|
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
598 |
ec_slave_config_add_sdo_request(sc, req); |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
599 |
|
1352
275d2fdeab48
Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
600 |
return req; |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
601 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
602 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
603 |
/*****************************************************************************/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
604 |
|
2443
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
605 |
void ec_slave_config_add_reg_request(ec_slave_config_t *sc, |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
606 |
ec_reg_request_t *reg) |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
607 |
{ |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
608 |
if (sc->first_reg_request) { |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
609 |
ec_reg_request_t *r = sc->first_reg_request; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
610 |
while (r->next) { |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
611 |
r = r->next; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
612 |
} |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
613 |
r->next = reg; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
614 |
} else { |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
615 |
sc->first_reg_request = reg; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
616 |
} |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
617 |
} |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
618 |
|
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
619 |
/*****************************************************************************/ |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
620 |
|
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
621 |
ec_reg_request_t *ecrt_slave_config_create_reg_request(ec_slave_config_t *sc, |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
622 |
size_t size) |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
623 |
{ |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
624 |
ec_ioctl_reg_request_t io; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
625 |
ec_reg_request_t *reg; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
626 |
int ret; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
627 |
|
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
628 |
reg = malloc(sizeof(ec_reg_request_t)); |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
629 |
if (!reg) { |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
630 |
fprintf(stderr, "Failed to allocate memory.\n"); |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
631 |
return NULL; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
632 |
} |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
633 |
|
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
634 |
if (size) { |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
635 |
reg->data = malloc(size); |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
636 |
if (!reg->data) { |
2480 | 637 |
fprintf(stderr, "Failed to allocate %zu bytes of register data" |
2443
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
638 |
" memory.\n", size); |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
639 |
free(reg); |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
640 |
return 0; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
641 |
} |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
642 |
} else { |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
643 |
reg->data = NULL; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
644 |
} |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
645 |
|
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
646 |
io.config_index = sc->index; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
647 |
io.mem_size = size; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
648 |
|
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
649 |
ret = ioctl(sc->master->fd, EC_IOCTL_SC_REG_REQUEST, &io); |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
650 |
if (EC_IOCTL_IS_ERROR(ret)) { |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
651 |
fprintf(stderr, "Failed to create register request: %s\n", |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
652 |
strerror(EC_IOCTL_ERRNO(ret))); |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
653 |
ec_reg_request_clear(reg); |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
654 |
free(reg); |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
655 |
return NULL; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
656 |
} |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
657 |
|
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
658 |
reg->next = NULL; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
659 |
reg->config = sc; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
660 |
reg->index = io.request_index; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
661 |
reg->mem_size = size; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
662 |
|
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
663 |
ec_slave_config_add_reg_request(sc, reg); |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
664 |
|
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
665 |
return reg; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
666 |
} |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
667 |
|
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
668 |
/*****************************************************************************/ |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2438
diff
changeset
|
669 |
|
1959
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
670 |
void ec_slave_config_add_voe_handler(ec_slave_config_t *sc, |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
671 |
ec_voe_handler_t *voe) |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
672 |
{ |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
673 |
if (sc->first_voe_handler) { |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
674 |
ec_voe_handler_t *v = sc->first_voe_handler; |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
675 |
while (v->next) { |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
676 |
v = v->next; |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
677 |
} |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
678 |
v->next = voe; |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
679 |
} else { |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
680 |
sc->first_voe_handler = voe; |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
681 |
} |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
682 |
} |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
683 |
|
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
684 |
/*****************************************************************************/ |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
685 |
|
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
686 |
ec_voe_handler_t *ecrt_slave_config_create_voe_handler(ec_slave_config_t *sc, |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
687 |
size_t size) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
688 |
{ |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
689 |
ec_ioctl_voe_t data; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
690 |
ec_voe_handler_t *voe; |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
691 |
int ret; |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
692 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
693 |
voe = malloc(sizeof(ec_voe_handler_t)); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
694 |
if (!voe) { |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
695 |
fprintf(stderr, "Failed to allocate memory.\n"); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
696 |
return 0; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
697 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
698 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
699 |
if (size) { |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
700 |
voe->data = malloc(size); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
701 |
if (!voe->data) { |
2480 | 702 |
fprintf(stderr, "Failed to allocate %zu bytes of VoE data" |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
703 |
" memory.\n", size); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
704 |
free(voe); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
705 |
return 0; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
706 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
707 |
} else { |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
708 |
voe->data = NULL; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
709 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
710 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
711 |
data.config_index = sc->index; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
712 |
data.size = size; |
2421 | 713 |
|
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
714 |
ret = ioctl(sc->master->fd, EC_IOCTL_SC_VOE, &data); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
715 |
if (EC_IOCTL_IS_ERROR(ret)) { |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
716 |
fprintf(stderr, "Failed to create VoE handler: %s\n", |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
717 |
strerror(EC_IOCTL_ERRNO(ret))); |
1959
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
718 |
ec_voe_handler_clear(voe); |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
719 |
free(voe); |
2421 | 720 |
return NULL; |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
721 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
722 |
|
1959
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
723 |
voe->next = NULL; |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
724 |
voe->config = sc; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
725 |
voe->index = data.voe_index; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
726 |
voe->data_size = size; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
727 |
voe->mem_size = size; |
1959
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
728 |
|
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
729 |
ec_slave_config_add_voe_handler(sc, voe); |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
730 |
|
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1259
diff
changeset
|
731 |
return voe; |
1255
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
732 |
} |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
733 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
734 |
/*****************************************************************************/ |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
735 |
|
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
736 |
void ecrt_slave_config_state(const ec_slave_config_t *sc, |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
737 |
ec_slave_config_state_t *state) |
38b7e05b20c1
Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
738 |
{ |
1259
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
739 |
ec_ioctl_sc_state_t data; |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
740 |
int ret; |
1259
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
741 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
742 |
data.config_index = sc->index; |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
743 |
data.state = state; |
2421 | 744 |
|
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
745 |
ret = ioctl(sc->master->fd, EC_IOCTL_SC_STATE, &data); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
746 |
if (EC_IOCTL_IS_ERROR(ret)) { |
1259
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
747 |
fprintf(stderr, "Failed to get slave configuration state: %s\n", |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
748 |
strerror(EC_IOCTL_ERRNO(ret))); |
1259
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
749 |
} |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
750 |
} |
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
751 |
|
5f9d1abbee71
Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents:
1255
diff
changeset
|
752 |
/*****************************************************************************/ |
1862
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1526
diff
changeset
|
753 |
|
1952
7d9fb723fc4b
Added drive_no parameter to SoE layer.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
754 |
int ecrt_slave_config_idn(ec_slave_config_t *sc, uint8_t drive_no, |
7d9fb723fc4b
Added drive_no parameter to SoE layer.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
755 |
uint16_t idn, ec_al_state_t al_state, const uint8_t *data, size_t size) |
1862
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1526
diff
changeset
|
756 |
{ |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1526
diff
changeset
|
757 |
ec_ioctl_sc_idn_t io; |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
758 |
int ret; |
1862
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1526
diff
changeset
|
759 |
|
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1526
diff
changeset
|
760 |
io.config_index = sc->index; |
1952
7d9fb723fc4b
Added drive_no parameter to SoE layer.
Florian Pose <fp@igh-essen.com>
parents:
1945
diff
changeset
|
761 |
io.drive_no = drive_no; |
1862
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1526
diff
changeset
|
762 |
io.idn = idn; |
1945
f9204699e799
Incremented ioctl interface version; Minor changes.
Florian Pose <fp@igh-essen.com>
parents:
1944
diff
changeset
|
763 |
io.al_state = al_state; |
1862
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1526
diff
changeset
|
764 |
io.data = data; |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1526
diff
changeset
|
765 |
io.size = size; |
05d224a66270
Implemented ecrt_slave_config_idn() for user-space library.
Florian Pose <fp@igh-essen.com>
parents:
1526
diff
changeset
|
766 |
|
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
767 |
ret = ioctl(sc->master->fd, EC_IOCTL_SC_IDN, &io); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
768 |
if (EC_IOCTL_IS_ERROR(ret)) { |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
769 |
fprintf(stderr, "Failed to configure IDN: %s\n", |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
770 |
strerror(EC_IOCTL_ERRNO(ret))); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
771 |
return -EC_IOCTL_ERRNO(ret); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
772 |
} |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
773 |
|
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
774 |
return 0; |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
775 |
} |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
776 |
|
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2428
diff
changeset
|
777 |
/*****************************************************************************/ |