author | Florian Pose <fp@igh-essen.com> |
Fri, 19 Jun 2009 14:41:06 +0000 | |
changeset 1480 | 72f8adf4205a |
parent 1363 | 11c0b2caa253 |
child 1959 | 656f114153c2 |
permissions | -rw-r--r-- |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
1266
dd1f501c4070
Added LGPL licence headers to userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1264
diff
changeset
|
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$ |
1266
dd1f501c4070
Added LGPL licence headers to userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1264
diff
changeset
|
4 |
* |
1326
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1314
diff
changeset
|
5 |
* Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH |
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
|
6 |
* |
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. |
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
|
8 |
* |
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/>. |
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
|
22 |
* |
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
23 |
* --- |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1350
diff
changeset
|
24 |
* |
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> |
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
38 |
#include <sys/ioctl.h> |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
#include <stdio.h> |
1271
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
40 |
#include <errno.h> |
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
41 |
#include <string.h> |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
#include "voe_handler.h" |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
#include "slave_config.h" |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
45 |
#include "master.h" |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
46 |
#include "master/ioctl.h" |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
47 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
48 |
/*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
49 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
50 |
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
|
51 |
uint16_t vendor_type) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
52 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
53 |
ec_ioctl_voe_t data; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
54 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
55 |
data.config_index = voe->config->index; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
56 |
data.voe_index = voe->index; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
57 |
data.vendor_id = &vendor_id; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
58 |
data.vendor_type = &vendor_type; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
59 |
|
1271
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
60 |
if (ioctl(voe->config->master->fd, EC_IOCTL_VOE_SEND_HEADER, &data) == -1) |
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
61 |
fprintf(stderr, "Failed to set VoE send header: %s\n", |
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
62 |
strerror(errno)); |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
63 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
64 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
65 |
/*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
66 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
67 |
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
|
68 |
uint32_t *vendor_id, uint16_t *vendor_type) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
69 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
70 |
ec_ioctl_voe_t data; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
71 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
72 |
data.config_index = voe->config->index; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
73 |
data.voe_index = voe->index; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
74 |
data.vendor_id = vendor_id; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
75 |
data.vendor_type = vendor_type; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
76 |
|
1271
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
77 |
if (ioctl(voe->config->master->fd, EC_IOCTL_VOE_REC_HEADER, &data) == -1) |
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
78 |
fprintf(stderr, "Failed to get received VoE header: %s\n", |
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
79 |
strerror(errno)); |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
80 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
81 |
|
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 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
84 |
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
|
85 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
86 |
return voe->data; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
87 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
88 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
89 |
/*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
90 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
91 |
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
|
92 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
93 |
return voe->data_size; |
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 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
98 |
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
|
99 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
100 |
ec_ioctl_voe_t data; |
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 |
data.config_index = voe->config->index; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
103 |
data.voe_index = voe->index; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
104 |
|
1271
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
105 |
if (ioctl(voe->config->master->fd, EC_IOCTL_VOE_READ, &data) == -1) |
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
106 |
fprintf(stderr, "Failed to initiate VoE reading: %s\n", |
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
107 |
strerror(errno)); |
1264
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 |
|
1314
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
112 |
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
|
113 |
{ |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
114 |
ec_ioctl_voe_t data; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
115 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
116 |
data.config_index = voe->config->index; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
117 |
data.voe_index = voe->index; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
118 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
119 |
if (ioctl(voe->config->master->fd, EC_IOCTL_VOE_READ_NOSYNC, &data) == -1) |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
120 |
fprintf(stderr, "Failed to initiate VoE reading: %s\n", |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
121 |
strerror(errno)); |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
122 |
} |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
123 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
124 |
/*****************************************************************************/ |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1287
diff
changeset
|
125 |
|
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
126 |
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
|
127 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
128 |
ec_ioctl_voe_t data; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
129 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
130 |
data.config_index = voe->config->index; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
131 |
data.voe_index = voe->index; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
132 |
data.size = size; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
133 |
data.data = voe->data; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
134 |
|
1271
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
135 |
if (ioctl(voe->config->master->fd, EC_IOCTL_VOE_WRITE, &data) == -1) |
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
136 |
fprintf(stderr, "Failed to initiate VoE writing: %s\n", |
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
137 |
strerror(errno)); |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
138 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
139 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
140 |
/*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
141 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
142 |
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
|
143 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
144 |
ec_ioctl_voe_t data; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
145 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
146 |
data.config_index = voe->config->index; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
147 |
data.voe_index = voe->index; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
148 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
149 |
if (ioctl(voe->config->master->fd, EC_IOCTL_VOE_EXEC, &data) == -1) { |
1271
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
150 |
fprintf(stderr, "Failed to execute VoE handler: %s\n", |
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
151 |
strerror(errno)); |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
152 |
return EC_REQUEST_ERROR; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
153 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
154 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
155 |
if (data.size) { // new data waiting to be copied |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
156 |
if (voe->mem_size < data.size) { |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
157 |
if (voe->data) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
158 |
free(voe->data); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
159 |
voe->data = malloc(data.size); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
160 |
if (!voe->data) { |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
161 |
voe->mem_size = 0; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
162 |
fprintf(stderr, "Failed to allocate VoE data memory!"); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
163 |
return EC_REQUEST_ERROR; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
164 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
165 |
voe->mem_size = data.size; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
166 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
167 |
|
1271
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
168 |
data.data = voe->data; |
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
169 |
|
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
170 |
if (ioctl(voe->config->master->fd, EC_IOCTL_VOE_DATA, &data) == -1) { |
1271
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
171 |
fprintf(stderr, "Failed to get VoE data: %s\n", strerror(errno)); |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
172 |
return EC_REQUEST_ERROR; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
173 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
174 |
voe->data_size = data.size; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
175 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
176 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
177 |
return data.state; |
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 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
180 |
/*****************************************************************************/ |