author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Fri, 05 Oct 2018 23:47:07 +0200 | |
branch | stable-1.5 |
changeset 2722 | 5e5bec5ee9c1 |
parent 2479 | b7f84bebd965 |
permissions | -rw-r--r-- |
1264
e7882f246d7a
Implemented VoE handler in userspace.
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:
1314
diff
changeset
|
3 |
* $Id$ |
2421 | 4 |
* |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
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:
1314
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:
1314
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:
1314
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:
1314
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:
1314
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:
1314
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:
1314
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:
1314
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:
1314
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:
1314
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:
1314
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:
1314
diff
changeset
|
21 |
* <http://www.gnu.org/licenses/>. |
2421 | 22 |
* |
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
23 |
* --- |
2421 | 24 |
* |
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1350
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:
1350
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:
1350
diff
changeset
|
27 |
* industrial property and similar rights of Beckhoff Automation GmbH. |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
* |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
30 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
31 |
/** \file |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
32 |
* Vendor specific over EtherCAT protocol handler functions. |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
*/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
/*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
|
1271
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
37 |
#include <stdlib.h> |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
#include <stdio.h> |
1271
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
39 |
#include <string.h> |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
|
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
41 |
#include "ioctl.h" |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
#include "voe_handler.h" |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
#include "slave_config.h" |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
#include "master.h" |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
45 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
46 |
/*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
47 |
|
1959
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
48 |
void ec_voe_handler_clear(ec_voe_handler_t *voe) |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
49 |
{ |
2430 | 50 |
if (voe->data) { |
1959
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
51 |
free(voe->data); |
2430 | 52 |
} |
1959
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
53 |
} |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
54 |
|
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
55 |
/*****************************************************************************/ |
656f114153c2
Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
56 |
|
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
57 |
void ecrt_voe_handler_send_header(ec_voe_handler_t *voe, uint32_t vendor_id, |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
58 |
uint16_t vendor_type) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
59 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
60 |
ec_ioctl_voe_t data; |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
61 |
int ret; |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
62 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
63 |
data.config_index = voe->config->index; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
64 |
data.voe_index = voe->index; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
65 |
data.vendor_id = &vendor_id; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
66 |
data.vendor_type = &vendor_type; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
67 |
|
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
68 |
ret = ioctl(voe->config->master->fd, EC_IOCTL_VOE_SEND_HEADER, &data); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
69 |
if (EC_IOCTL_IS_ERROR(ret)) { |
1271
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
70 |
fprintf(stderr, "Failed to set VoE send header: %s\n", |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
71 |
strerror(EC_IOCTL_ERRNO(ret))); |
2429 | 72 |
} |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
73 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
74 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
75 |
/*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
76 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
77 |
void ecrt_voe_handler_received_header(const ec_voe_handler_t *voe, |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
78 |
uint32_t *vendor_id, uint16_t *vendor_type) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
79 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
80 |
ec_ioctl_voe_t data; |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
81 |
int ret; |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
82 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
83 |
data.config_index = voe->config->index; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
84 |
data.voe_index = voe->index; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
85 |
data.vendor_id = vendor_id; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
86 |
data.vendor_type = vendor_type; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
87 |
|
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
88 |
ret = ioctl(voe->config->master->fd, EC_IOCTL_VOE_REC_HEADER, &data); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
89 |
if (EC_IOCTL_IS_ERROR(ret)) { |
1271
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
90 |
fprintf(stderr, "Failed to get received VoE header: %s\n", |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
91 |
strerror(EC_IOCTL_ERRNO(ret))); |
2429 | 92 |
} |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
93 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
94 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
95 |
/*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
96 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
97 |
uint8_t *ecrt_voe_handler_data(ec_voe_handler_t *voe) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
98 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
99 |
return voe->data; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
100 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
101 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
102 |
/*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
103 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
104 |
size_t ecrt_voe_handler_data_size(const ec_voe_handler_t *voe) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
105 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
106 |
return voe->data_size; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
107 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
108 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
109 |
/*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
110 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
111 |
void ecrt_voe_handler_read(ec_voe_handler_t *voe) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
112 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
113 |
ec_ioctl_voe_t data; |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
114 |
int ret; |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
115 |
|
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
116 |
data.config_index = voe->config->index; |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
117 |
data.voe_index = voe->index; |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
118 |
|
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
119 |
ret = ioctl(voe->config->master->fd, EC_IOCTL_VOE_READ, &data); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
120 |
if (EC_IOCTL_IS_ERROR(ret)) { |
1271
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
121 |
fprintf(stderr, "Failed to initiate VoE reading: %s\n", |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
122 |
strerror(EC_IOCTL_ERRNO(ret))); |
2429 | 123 |
} |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
124 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
125 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
126 |
/*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
127 |
|
1314
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
128 |
void ecrt_voe_handler_read_nosync(ec_voe_handler_t *voe) |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
129 |
{ |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
130 |
ec_ioctl_voe_t data; |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
131 |
int ret; |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
132 |
|
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
133 |
data.config_index = voe->config->index; |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
134 |
data.voe_index = voe->index; |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
135 |
|
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
136 |
ret = ioctl(voe->config->master->fd, EC_IOCTL_VOE_READ_NOSYNC, &data); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
137 |
if (EC_IOCTL_IS_ERROR(ret)) { |
1314
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
138 |
fprintf(stderr, "Failed to initiate VoE reading: %s\n", |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
139 |
strerror(EC_IOCTL_ERRNO(ret))); |
2429 | 140 |
} |
1314
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
141 |
} |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
142 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
143 |
/*****************************************************************************/ |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
144 |
|
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
145 |
void ecrt_voe_handler_write(ec_voe_handler_t *voe, size_t size) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
146 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
147 |
ec_ioctl_voe_t data; |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
148 |
int ret; |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
149 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
150 |
data.config_index = voe->config->index; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
151 |
data.voe_index = voe->index; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
152 |
data.size = size; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
153 |
data.data = voe->data; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
154 |
|
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
155 |
ret = ioctl(voe->config->master->fd, EC_IOCTL_VOE_WRITE, &data); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
156 |
if (EC_IOCTL_IS_ERROR(ret)) { |
1271
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
157 |
fprintf(stderr, "Failed to initiate VoE writing: %s\n", |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
158 |
strerror(EC_IOCTL_ERRNO(ret))); |
2429 | 159 |
} |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
160 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
161 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
162 |
/*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
163 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
164 |
ec_request_state_t ecrt_voe_handler_execute(ec_voe_handler_t *voe) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
165 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
166 |
ec_ioctl_voe_t data; |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
167 |
int ret; |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
168 |
|
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
169 |
data.config_index = voe->config->index; |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
170 |
data.voe_index = voe->index; |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
171 |
|
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
172 |
ret = ioctl(voe->config->master->fd, EC_IOCTL_VOE_EXEC, &data); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
173 |
if (EC_IOCTL_IS_ERROR(ret)) { |
1271
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
174 |
fprintf(stderr, "Failed to execute VoE handler: %s\n", |
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
175 |
strerror(EC_IOCTL_ERRNO(ret))); |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
176 |
return EC_REQUEST_ERROR; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
177 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
178 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
179 |
if (data.size) { // new data waiting to be copied |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
180 |
if (voe->mem_size < data.size) { |
2479 | 181 |
fprintf(stderr, "Received %zu bytes do not fit info VoE data" |
182 |
" memory (%zu bytes)!\n", data.size, voe->mem_size); |
|
2432
f4313f5aba88
Do not re-allocate memory in VoE handler.
Florian Pose <fp@igh-essen.com>
parents:
2430
diff
changeset
|
183 |
return EC_REQUEST_ERROR; |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
184 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
185 |
|
1271
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
186 |
data.data = voe->data; |
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
187 |
|
2433
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
188 |
ret = ioctl(voe->config->master->fd, EC_IOCTL_VOE_DATA, &data); |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
189 |
if (EC_IOCTL_IS_ERROR(ret)) { |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
190 |
fprintf(stderr, "Failed to get VoE data: %s\n", |
3bdd7a747fae
Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents:
2432
diff
changeset
|
191 |
strerror(EC_IOCTL_ERRNO(ret))); |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
192 |
return EC_REQUEST_ERROR; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
193 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
194 |
voe->data_size = data.size; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
195 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
196 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
197 |
return data.state; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
198 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
199 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
200 |
/*****************************************************************************/ |