author | Florian Pose <fp@igh-essen.com> |
Wed, 05 Nov 2008 15:05:40 +0000 | |
changeset 1305 | de3fcbb6773e |
parent 1287 | cc7b679c74e9 |
child 1314 | b3d06a8807b3 |
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 |
* |
dd1f501c4070
Added LGPL licence headers to userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1264
diff
changeset
|
3 |
* $Id$ |
dd1f501c4070
Added LGPL licence headers to userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1264
diff
changeset
|
4 |
* |
dd1f501c4070
Added LGPL licence headers to userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1264
diff
changeset
|
5 |
* Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH |
dd1f501c4070
Added LGPL licence headers to userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1264
diff
changeset
|
6 |
* |
dd1f501c4070
Added LGPL licence headers to userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1264
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT master userspace library. |
dd1f501c4070
Added LGPL licence headers to userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1264
diff
changeset
|
8 |
* |
1287 | 9 |
* The IgH EtherCAT master userspace library is free software; you can |
1266
dd1f501c4070
Added LGPL licence headers to userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1264
diff
changeset
|
10 |
* redistribute it and/or modify it under the terms of the GNU Lesser General |
1287 | 11 |
* Public License as published by the Free Software Foundation; version 2.1 of |
1266
dd1f501c4070
Added LGPL licence headers to userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1264
diff
changeset
|
12 |
* the License. |
1287 | 13 |
* |
1266
dd1f501c4070
Added LGPL licence headers to userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1264
diff
changeset
|
14 |
* The IgH EtherCAT master userspace library is distributed in the hope that |
dd1f501c4070
Added LGPL licence headers to userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1264
diff
changeset
|
15 |
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
dd1f501c4070
Added LGPL licence headers to userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1264
diff
changeset
|
16 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
dd1f501c4070
Added LGPL licence headers to userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1264
diff
changeset
|
17 |
* GNU Lesser General Public License for more details. |
1287 | 18 |
* |
1266
dd1f501c4070
Added LGPL licence headers to userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1264
diff
changeset
|
19 |
* You should have received a copy of the GNU Lesser General Public License |
dd1f501c4070
Added LGPL licence headers to userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1264
diff
changeset
|
20 |
* along with the IgH EtherCAT master userspace library. If not, see |
dd1f501c4070
Added LGPL licence headers to userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1264
diff
changeset
|
21 |
* <http://www.gnu.org/licenses/>. |
dd1f501c4070
Added LGPL licence headers to userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1264
diff
changeset
|
22 |
* |
dd1f501c4070
Added LGPL licence headers to userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1264
diff
changeset
|
23 |
* The right to use EtherCAT Technology is granted and comes free of charge |
dd1f501c4070
Added LGPL licence headers to userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1264
diff
changeset
|
24 |
* under condition of compatibility of product made by Licensee. People |
dd1f501c4070
Added LGPL licence headers to userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1264
diff
changeset
|
25 |
* intending to distribute/sell products based on the code, have to sign an |
dd1f501c4070
Added LGPL licence headers to userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1264
diff
changeset
|
26 |
* agreement to guarantee that products using software based on IgH EtherCAT |
dd1f501c4070
Added LGPL licence headers to userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1264
diff
changeset
|
27 |
* master stay compatible with the actual EtherCAT specification (which are |
dd1f501c4070
Added LGPL licence headers to userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1264
diff
changeset
|
28 |
* released themselves as an open standard) as the (only) precondition to have |
dd1f501c4070
Added LGPL licence headers to userspace library.
Florian Pose <fp@igh-essen.com>
parents:
1264
diff
changeset
|
29 |
* the right to use EtherCAT Technology, IP and trade marks. |
1264
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 |
*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
/** \file |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
* Vendor-specific-over-EtherCAT protocol handler functions. |
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 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
/*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
|
1271
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
39 |
#include <stdlib.h> |
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
40 |
#include <sys/ioctl.h> |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
#include <stdio.h> |
1271
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
42 |
#include <errno.h> |
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
43 |
#include <string.h> |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
45 |
#include "voe_handler.h" |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
46 |
#include "slave_config.h" |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
47 |
#include "master.h" |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
48 |
#include "master/ioctl.h" |
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 |
/*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
51 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
52 |
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
|
53 |
uint16_t vendor_type) |
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 |
ec_ioctl_voe_t data; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
56 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
57 |
data.config_index = voe->config->index; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
58 |
data.voe_index = voe->index; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
59 |
data.vendor_id = &vendor_id; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
60 |
data.vendor_type = &vendor_type; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
61 |
|
1271
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
62 |
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
|
63 |
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
|
64 |
strerror(errno)); |
1264
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 |
/*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
68 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
69 |
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
|
70 |
uint32_t *vendor_id, uint16_t *vendor_type) |
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 |
ec_ioctl_voe_t data; |
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 |
data.config_index = voe->config->index; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
75 |
data.voe_index = voe->index; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
76 |
data.vendor_id = vendor_id; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
77 |
data.vendor_type = vendor_type; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
78 |
|
1271
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
79 |
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
|
80 |
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
|
81 |
strerror(errno)); |
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 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
84 |
/*****************************************************************************/ |
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 |
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
|
87 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
88 |
return voe->data; |
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 |
/*****************************************************************************/ |
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 |
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
|
94 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
95 |
return voe->data_size; |
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 |
/*****************************************************************************/ |
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 |
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
|
101 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
102 |
ec_ioctl_voe_t data; |
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 |
data.config_index = voe->config->index; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
105 |
data.voe_index = voe->index; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
106 |
|
1271
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
107 |
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
|
108 |
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
|
109 |
strerror(errno)); |
1264
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 |
|
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 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
114 |
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
|
115 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
116 |
ec_ioctl_voe_t data; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
117 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
118 |
data.config_index = voe->config->index; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
119 |
data.voe_index = voe->index; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
120 |
data.size = size; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
121 |
data.data = voe->data; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
122 |
|
1271
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
123 |
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
|
124 |
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
|
125 |
strerror(errno)); |
1264
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 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
128 |
/*****************************************************************************/ |
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 |
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
|
131 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
132 |
ec_ioctl_voe_t data; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
133 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
134 |
data.config_index = voe->config->index; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
135 |
data.voe_index = voe->index; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
136 |
data.size = 0; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
137 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
138 |
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
|
139 |
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
|
140 |
strerror(errno)); |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
141 |
return EC_REQUEST_ERROR; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
142 |
} |
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 |
if (data.size) { // new data waiting to be copied |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
145 |
if (voe->mem_size < data.size) { |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
146 |
if (voe->data) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
147 |
free(voe->data); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
148 |
voe->data = malloc(data.size); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
149 |
if (!voe->data) { |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
150 |
voe->mem_size = 0; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
151 |
fprintf(stderr, "Failed to allocate VoE data memory!"); |
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 |
voe->mem_size = data.size; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
155 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
156 |
|
1271
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
157 |
data.data = voe->data; |
19f9e9b6cf2c
Fixed VoE data reading in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1266
diff
changeset
|
158 |
|
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
159 |
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
|
160 |
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
|
161 |
return EC_REQUEST_ERROR; |
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 |
voe->data_size = data.size; |
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 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
166 |
return data.state; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
167 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
168 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
169 |
/*****************************************************************************/ |