author | Florian Pose <fp@igh-essen.com> |
Mon, 26 Jan 2009 10:30:17 +0000 | |
changeset 1323 | 10fbef0a3ac5 |
parent 1315 | 26b4f94cfdfb |
child 1326 | ef907b0b5125 |
permissions | -rw-r--r-- |
1209 | 1 |
/****************************************************************************** |
2 |
* |
|
3 |
* $Id$ |
|
4 |
* |
|
5 |
* Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
|
6 |
* |
|
7 |
* This file is part of the IgH EtherCAT Master. |
|
8 |
* |
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it |
|
10 |
* and/or modify it under the terms of the GNU General Public License |
|
11 |
* as published by the Free Software Foundation; either version 2 of the |
|
12 |
* License, or (at your option) any later version. |
|
13 |
* |
|
14 |
* The IgH EtherCAT Master is distributed in the hope that it will be |
|
15 |
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17 |
* GNU General Public License for more details. |
|
18 |
* |
|
19 |
* You should have received a copy of the GNU General Public License |
|
20 |
* along with the IgH EtherCAT Master; if not, write to the Free Software |
|
21 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
22 |
* |
|
23 |
* The right to use EtherCAT Technology is granted and comes free of |
|
24 |
* charge under condition of compatibility of product made by |
|
25 |
* Licensee. People intending to distribute/sell products based on the |
|
26 |
* code, have to sign an agreement to guarantee that products using |
|
27 |
* software based on IgH EtherCAT master stay compatible with the actual |
|
28 |
* EtherCAT specification (which are released themselves as an open |
|
29 |
* standard) as the (only) precondition to have the right to use EtherCAT |
|
30 |
* Technology, IP and trade marks. |
|
31 |
* |
|
32 |
*****************************************************************************/ |
|
33 |
||
34 |
/** \file |
|
35 |
* Vendor-specific-over-EtherCAT protocol handler functions. |
|
36 |
*/ |
|
37 |
||
38 |
/*****************************************************************************/ |
|
39 |
||
40 |
#include <linux/module.h> |
|
41 |
||
42 |
#include "master.h" |
|
43 |
#include "slave_config.h" |
|
44 |
#include "mailbox.h" |
|
45 |
#include "voe_handler.h" |
|
46 |
||
1216
e70c4d71cebd
Changed VoE mailbox type to 0xff.
Florian Pose <fp@igh-essen.com>
parents:
1209
diff
changeset
|
47 |
/** VoE mailbox type. |
e70c4d71cebd
Changed VoE mailbox type to 0xff.
Florian Pose <fp@igh-essen.com>
parents:
1209
diff
changeset
|
48 |
*/ |
1224 | 49 |
#define EC_MBOX_TYPE_VOE 0x0f |
1216
e70c4d71cebd
Changed VoE mailbox type to 0xff.
Florian Pose <fp@igh-essen.com>
parents:
1209
diff
changeset
|
50 |
|
1218 | 51 |
/** VoE header size. |
52 |
*/ |
|
53 |
#define EC_VOE_HEADER_SIZE 6 |
|
54 |
||
1209 | 55 |
/** VoE response timeout in [ms]. |
56 |
*/ |
|
57 |
#define EC_VOE_RESPONSE_TIMEOUT 500 |
|
58 |
||
59 |
/*****************************************************************************/ |
|
60 |
||
61 |
void ec_voe_handler_state_write_start(ec_voe_handler_t *); |
|
62 |
void ec_voe_handler_state_write_response(ec_voe_handler_t *); |
|
63 |
||
64 |
void ec_voe_handler_state_read_start(ec_voe_handler_t *); |
|
65 |
void ec_voe_handler_state_read_check(ec_voe_handler_t *); |
|
66 |
void ec_voe_handler_state_read_response(ec_voe_handler_t *); |
|
67 |
||
1314
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
68 |
void ec_voe_handler_state_read_nosync_start(ec_voe_handler_t *); |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
69 |
void ec_voe_handler_state_read_nosync_response(ec_voe_handler_t *); |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
70 |
|
1209 | 71 |
void ec_voe_handler_state_end(ec_voe_handler_t *); |
72 |
void ec_voe_handler_state_error(ec_voe_handler_t *); |
|
73 |
||
74 |
/*****************************************************************************/ |
|
75 |
||
76 |
/** VoE handler constructor. |
|
1312
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
77 |
* |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
78 |
* \return Return value of ec_datagram_prealloc(). |
1209 | 79 |
*/ |
80 |
int ec_voe_handler_init( |
|
81 |
ec_voe_handler_t *voe, /**< VoE handler. */ |
|
82 |
ec_slave_config_t *sc, /**< Parent slave configuration. */ |
|
83 |
size_t size /**< Size of memory to reserve. */ |
|
84 |
) |
|
85 |
{ |
|
86 |
voe->config = sc; |
|
1218 | 87 |
voe->vendor_id = 0x00000000; |
88 |
voe->vendor_type = 0x0000; |
|
1209 | 89 |
voe->data_size = 0; |
90 |
voe->dir = EC_DIR_INVALID; |
|
91 |
voe->state = ec_voe_handler_state_error; |
|
92 |
voe->request_state = EC_INT_REQUEST_INIT; |
|
93 |
||
94 |
ec_datagram_init(&voe->datagram); |
|
1312
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
95 |
return ec_datagram_prealloc(&voe->datagram, |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
96 |
size + EC_MBOX_HEADER_SIZE + EC_VOE_HEADER_SIZE); |
1209 | 97 |
} |
98 |
||
99 |
/*****************************************************************************/ |
|
100 |
||
101 |
/** VoE handler destructor. |
|
102 |
*/ |
|
103 |
void ec_voe_handler_clear( |
|
104 |
ec_voe_handler_t *voe /**< VoE handler. */ |
|
105 |
) |
|
106 |
{ |
|
107 |
ec_datagram_clear(&voe->datagram); |
|
108 |
} |
|
109 |
||
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1226
diff
changeset
|
110 |
/*****************************************************************************/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1226
diff
changeset
|
111 |
|
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1226
diff
changeset
|
112 |
/** Get usable memory size. |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1226
diff
changeset
|
113 |
*/ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1226
diff
changeset
|
114 |
size_t ec_voe_handler_mem_size( |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1226
diff
changeset
|
115 |
const ec_voe_handler_t *voe /**< VoE handler. */ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1226
diff
changeset
|
116 |
) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1226
diff
changeset
|
117 |
{ |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1226
diff
changeset
|
118 |
if (voe->datagram.mem_size >= EC_MBOX_HEADER_SIZE + EC_VOE_HEADER_SIZE) |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1226
diff
changeset
|
119 |
return voe->datagram.mem_size - |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1226
diff
changeset
|
120 |
(EC_MBOX_HEADER_SIZE + EC_VOE_HEADER_SIZE); |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1226
diff
changeset
|
121 |
else |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1226
diff
changeset
|
122 |
return 0; |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1226
diff
changeset
|
123 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1226
diff
changeset
|
124 |
|
1209 | 125 |
/***************************************************************************** |
126 |
* Application interface. |
|
127 |
****************************************************************************/ |
|
128 |
||
1226
afb189516fcf
Introduced ecrt_voe_handler_received_header(); renamed
Florian Pose <fp@igh-essen.com>
parents:
1224
diff
changeset
|
129 |
void ecrt_voe_handler_send_header(ec_voe_handler_t *voe, uint32_t vendor_id, |
1218 | 130 |
uint16_t vendor_type) |
131 |
{ |
|
132 |
voe->vendor_id = vendor_id; |
|
133 |
voe->vendor_type = vendor_type; |
|
134 |
} |
|
135 |
||
136 |
/*****************************************************************************/ |
|
137 |
||
1226
afb189516fcf
Introduced ecrt_voe_handler_received_header(); renamed
Florian Pose <fp@igh-essen.com>
parents:
1224
diff
changeset
|
138 |
void ecrt_voe_handler_received_header(const ec_voe_handler_t *voe, |
afb189516fcf
Introduced ecrt_voe_handler_received_header(); renamed
Florian Pose <fp@igh-essen.com>
parents:
1224
diff
changeset
|
139 |
uint32_t *vendor_id, uint16_t *vendor_type) |
afb189516fcf
Introduced ecrt_voe_handler_received_header(); renamed
Florian Pose <fp@igh-essen.com>
parents:
1224
diff
changeset
|
140 |
{ |
afb189516fcf
Introduced ecrt_voe_handler_received_header(); renamed
Florian Pose <fp@igh-essen.com>
parents:
1224
diff
changeset
|
141 |
uint8_t *header = voe->datagram.data + EC_MBOX_HEADER_SIZE; |
afb189516fcf
Introduced ecrt_voe_handler_received_header(); renamed
Florian Pose <fp@igh-essen.com>
parents:
1224
diff
changeset
|
142 |
|
afb189516fcf
Introduced ecrt_voe_handler_received_header(); renamed
Florian Pose <fp@igh-essen.com>
parents:
1224
diff
changeset
|
143 |
if (vendor_id) |
afb189516fcf
Introduced ecrt_voe_handler_received_header(); renamed
Florian Pose <fp@igh-essen.com>
parents:
1224
diff
changeset
|
144 |
*vendor_id = EC_READ_U32(header); |
afb189516fcf
Introduced ecrt_voe_handler_received_header(); renamed
Florian Pose <fp@igh-essen.com>
parents:
1224
diff
changeset
|
145 |
if (vendor_type) |
afb189516fcf
Introduced ecrt_voe_handler_received_header(); renamed
Florian Pose <fp@igh-essen.com>
parents:
1224
diff
changeset
|
146 |
*vendor_type = EC_READ_U16(header + 4); |
afb189516fcf
Introduced ecrt_voe_handler_received_header(); renamed
Florian Pose <fp@igh-essen.com>
parents:
1224
diff
changeset
|
147 |
} |
afb189516fcf
Introduced ecrt_voe_handler_received_header(); renamed
Florian Pose <fp@igh-essen.com>
parents:
1224
diff
changeset
|
148 |
|
afb189516fcf
Introduced ecrt_voe_handler_received_header(); renamed
Florian Pose <fp@igh-essen.com>
parents:
1224
diff
changeset
|
149 |
/*****************************************************************************/ |
afb189516fcf
Introduced ecrt_voe_handler_received_header(); renamed
Florian Pose <fp@igh-essen.com>
parents:
1224
diff
changeset
|
150 |
|
1209 | 151 |
uint8_t *ecrt_voe_handler_data(ec_voe_handler_t *voe) |
152 |
{ |
|
1218 | 153 |
return voe->datagram.data + EC_MBOX_HEADER_SIZE + EC_VOE_HEADER_SIZE; |
1209 | 154 |
} |
155 |
||
156 |
/*****************************************************************************/ |
|
157 |
||
158 |
size_t ecrt_voe_handler_data_size(const ec_voe_handler_t *voe) |
|
159 |
{ |
|
160 |
return voe->data_size; |
|
161 |
} |
|
162 |
||
163 |
/*****************************************************************************/ |
|
164 |
||
165 |
void ecrt_voe_handler_read(ec_voe_handler_t *voe) |
|
166 |
{ |
|
167 |
voe->dir = EC_DIR_INPUT; |
|
168 |
voe->state = ec_voe_handler_state_read_start; |
|
169 |
voe->request_state = EC_INT_REQUEST_QUEUED; |
|
170 |
} |
|
171 |
||
172 |
/*****************************************************************************/ |
|
173 |
||
1314
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
174 |
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:
1313
diff
changeset
|
175 |
{ |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
176 |
voe->dir = EC_DIR_INPUT; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
177 |
voe->state = ec_voe_handler_state_read_nosync_start; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
178 |
voe->request_state = EC_INT_REQUEST_QUEUED; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
179 |
} |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
180 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
181 |
/*****************************************************************************/ |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
182 |
|
1209 | 183 |
void ecrt_voe_handler_write(ec_voe_handler_t *voe, size_t size) |
184 |
{ |
|
185 |
voe->dir = EC_DIR_OUTPUT; |
|
1218 | 186 |
voe->data_size = size; |
1209 | 187 |
voe->state = ec_voe_handler_state_write_start; |
188 |
voe->request_state = EC_INT_REQUEST_QUEUED; |
|
189 |
} |
|
190 |
||
191 |
/*****************************************************************************/ |
|
192 |
||
193 |
ec_request_state_t ecrt_voe_handler_execute(ec_voe_handler_t *voe) |
|
194 |
{ |
|
195 |
if (voe->config->slave) { |
|
196 |
voe->state(voe); |
|
197 |
if (voe->request_state == EC_REQUEST_BUSY) |
|
198 |
ec_master_queue_datagram(voe->config->master, &voe->datagram); |
|
199 |
} else { |
|
200 |
voe->state = ec_voe_handler_state_error; |
|
201 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
|
202 |
} |
|
203 |
||
204 |
return ec_request_state_translation_table[voe->request_state]; |
|
205 |
} |
|
206 |
||
207 |
/****************************************************************************** |
|
208 |
* State functions. |
|
209 |
*****************************************************************************/ |
|
210 |
||
1268 | 211 |
/** Start writing VoE data. |
212 |
*/ |
|
1209 | 213 |
void ec_voe_handler_state_write_start(ec_voe_handler_t *voe) |
214 |
{ |
|
215 |
ec_slave_t *slave = voe->config->slave; |
|
216 |
uint8_t *data; |
|
217 |
||
218 |
if (slave->master->debug_level) { |
|
219 |
EC_DBG("Writing %u bytes of VoE data to slave %u.\n", |
|
220 |
voe->data_size, slave->ring_position); |
|
221 |
ec_print_data(ecrt_voe_handler_data(voe), voe->data_size); |
|
222 |
} |
|
223 |
||
224 |
if (!(slave->sii.mailbox_protocols & EC_MBOX_VOE)) { |
|
225 |
EC_ERR("Slave %u does not support VoE!\n", slave->ring_position); |
|
226 |
voe->state = ec_voe_handler_state_error; |
|
227 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
|
228 |
return; |
|
229 |
} |
|
230 |
||
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
231 |
data = ec_slave_mbox_prepare_send(slave, &voe->datagram, |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
232 |
EC_MBOX_TYPE_VOE, EC_VOE_HEADER_SIZE + voe->data_size); |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
233 |
if (IS_ERR(data)) { |
1218 | 234 |
voe->state = ec_voe_handler_state_error; |
235 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
|
236 |
return; |
|
237 |
} |
|
238 |
||
239 |
EC_WRITE_U32(data, voe->vendor_id); |
|
240 |
EC_WRITE_U16(data + 4, voe->vendor_type); |
|
1209 | 241 |
|
242 |
voe->retries = EC_FSM_RETRIES; |
|
243 |
voe->jiffies_start = jiffies; |
|
244 |
voe->state = ec_voe_handler_state_write_response; |
|
245 |
} |
|
246 |
||
247 |
/*****************************************************************************/ |
|
248 |
||
1268 | 249 |
/** Wait for the mailbox response. |
250 |
*/ |
|
1209 | 251 |
void ec_voe_handler_state_write_response(ec_voe_handler_t *voe) |
252 |
{ |
|
253 |
ec_datagram_t *datagram = &voe->datagram; |
|
254 |
ec_slave_t *slave = voe->config->slave; |
|
255 |
||
256 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && voe->retries--) |
|
257 |
return; |
|
258 |
||
259 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
|
260 |
voe->state = ec_voe_handler_state_error; |
|
261 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
|
262 |
EC_ERR("Failed to receive VoE write request datagram for" |
|
263 |
" slave %u (datagram state %u).\n", |
|
264 |
slave->ring_position, datagram->state); |
|
265 |
return; |
|
266 |
} |
|
267 |
||
268 |
if (datagram->working_counter != 1) { |
|
269 |
if (!datagram->working_counter) { |
|
270 |
unsigned long diff_ms = |
|
271 |
(jiffies - voe->jiffies_start) * 1000 / HZ; |
|
272 |
if (diff_ms < EC_VOE_RESPONSE_TIMEOUT) { |
|
273 |
if (slave->master->debug_level) { |
|
274 |
EC_DBG("Slave %u did not respond to VoE write request. " |
|
275 |
"Retrying after %u ms...\n", |
|
276 |
slave->ring_position, (u32) diff_ms); |
|
277 |
} |
|
278 |
// no response; send request datagram again |
|
279 |
return; |
|
280 |
} |
|
281 |
} |
|
282 |
voe->state = ec_voe_handler_state_error; |
|
283 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
|
284 |
EC_ERR("Reception of VoE write request failed on slave %u: ", |
|
285 |
slave->ring_position); |
|
286 |
ec_datagram_print_wc_error(datagram); |
|
287 |
return; |
|
288 |
} |
|
289 |
||
290 |
if (voe->config->master->debug_level) |
|
291 |
EC_DBG("VoE write request successful.\n"); |
|
292 |
||
293 |
voe->request_state = EC_INT_REQUEST_SUCCESS; |
|
294 |
voe->state = ec_voe_handler_state_end; |
|
295 |
} |
|
296 |
||
297 |
/*****************************************************************************/ |
|
298 |
||
1268 | 299 |
/** Start reading VoE data. |
300 |
*/ |
|
1209 | 301 |
void ec_voe_handler_state_read_start(ec_voe_handler_t *voe) |
302 |
{ |
|
303 |
ec_datagram_t *datagram = &voe->datagram; |
|
304 |
ec_slave_t *slave = voe->config->slave; |
|
305 |
||
306 |
if (slave->master->debug_level) |
|
307 |
EC_DBG("Reading VoE data to slave %u.\n", slave->ring_position); |
|
308 |
||
309 |
if (!(slave->sii.mailbox_protocols & EC_MBOX_VOE)) { |
|
310 |
EC_ERR("Slave %u does not support VoE!\n", slave->ring_position); |
|
311 |
voe->state = ec_voe_handler_state_error; |
|
312 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
|
313 |
return; |
|
314 |
} |
|
315 |
||
316 |
ec_slave_mbox_prepare_check(slave, datagram); // can not fail. |
|
317 |
||
318 |
voe->jiffies_start = jiffies; |
|
319 |
voe->retries = EC_FSM_RETRIES; |
|
320 |
voe->state = ec_voe_handler_state_read_check; |
|
321 |
} |
|
322 |
||
323 |
/*****************************************************************************/ |
|
324 |
||
1268 | 325 |
/** Check for new data in the mailbox. |
326 |
*/ |
|
1209 | 327 |
void ec_voe_handler_state_read_check(ec_voe_handler_t *voe) |
328 |
{ |
|
329 |
ec_datagram_t *datagram = &voe->datagram; |
|
330 |
ec_slave_t *slave = voe->config->slave; |
|
331 |
||
332 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && voe->retries--) |
|
333 |
return; |
|
334 |
||
335 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
|
336 |
voe->state = ec_voe_handler_state_error; |
|
337 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
|
338 |
EC_ERR("Failed to receive VoE mailbox check datagram from slave %u" |
|
339 |
" (datagram state %u).\n", |
|
340 |
slave->ring_position, datagram->state); |
|
341 |
return; |
|
342 |
} |
|
343 |
||
344 |
if (datagram->working_counter != 1) { |
|
345 |
voe->state = ec_voe_handler_state_error; |
|
346 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
|
347 |
EC_ERR("Reception of VoE mailbox check" |
|
348 |
" datagram failed on slave %u: ", slave->ring_position); |
|
349 |
ec_datagram_print_wc_error(datagram); |
|
350 |
return; |
|
351 |
} |
|
352 |
||
353 |
if (!ec_slave_mbox_check(datagram)) { |
|
354 |
unsigned long diff_ms = |
|
355 |
(datagram->jiffies_received - voe->jiffies_start) * 1000 / HZ; |
|
356 |
if (diff_ms >= EC_VOE_RESPONSE_TIMEOUT) { |
|
357 |
voe->state = ec_voe_handler_state_error; |
|
358 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
|
359 |
EC_ERR("Timeout while waiting for VoE data on " |
|
360 |
"slave %u.\n", slave->ring_position); |
|
361 |
return; |
|
362 |
} |
|
363 |
||
364 |
ec_slave_mbox_prepare_check(slave, datagram); // can not fail. |
|
365 |
voe->retries = EC_FSM_RETRIES; |
|
366 |
return; |
|
367 |
} |
|
368 |
||
369 |
// Fetch response |
|
370 |
ec_slave_mbox_prepare_fetch(slave, datagram); // can not fail. |
|
371 |
voe->retries = EC_FSM_RETRIES; |
|
372 |
voe->state = ec_voe_handler_state_read_response; |
|
373 |
} |
|
374 |
||
375 |
/*****************************************************************************/ |
|
376 |
||
1268 | 377 |
/** Read the pending mailbox data. |
378 |
*/ |
|
1209 | 379 |
void ec_voe_handler_state_read_response(ec_voe_handler_t *voe) |
380 |
{ |
|
381 |
ec_datagram_t *datagram = &voe->datagram; |
|
382 |
ec_slave_t *slave = voe->config->slave; |
|
383 |
ec_master_t *master = voe->config->master; |
|
384 |
uint8_t *data, mbox_prot; |
|
385 |
size_t rec_size; |
|
386 |
||
387 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && voe->retries--) |
|
388 |
return; |
|
389 |
||
390 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
|
391 |
voe->state = ec_voe_handler_state_error; |
|
392 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
|
393 |
EC_ERR("Failed to receive VoE read datagram for" |
|
394 |
" slave %u (datagram state %u).\n", |
|
395 |
slave->ring_position, datagram->state); |
|
396 |
return; |
|
397 |
} |
|
398 |
||
399 |
if (datagram->working_counter != 1) { |
|
400 |
voe->state = ec_voe_handler_state_error; |
|
401 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
|
402 |
EC_ERR("Reception of VoE read response failed on slave %u: ", |
|
403 |
slave->ring_position); |
|
404 |
ec_datagram_print_wc_error(datagram); |
|
405 |
return; |
|
406 |
} |
|
407 |
||
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
408 |
data = ec_slave_mbox_fetch(slave, datagram, &mbox_prot, &rec_size); |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
409 |
if (IS_ERR(data)) { |
1209 | 410 |
voe->state = ec_voe_handler_state_error; |
411 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
|
412 |
return; |
|
413 |
} |
|
414 |
||
1216
e70c4d71cebd
Changed VoE mailbox type to 0xff.
Florian Pose <fp@igh-essen.com>
parents:
1209
diff
changeset
|
415 |
if (mbox_prot != EC_MBOX_TYPE_VOE) { |
1209 | 416 |
voe->state = ec_voe_handler_state_error; |
417 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
|
418 |
EC_WARN("Received mailbox protocol 0x%02X as response.\n", mbox_prot); |
|
419 |
ec_print_data(data, rec_size); |
|
420 |
return; |
|
421 |
} |
|
422 |
||
1218 | 423 |
if (rec_size < EC_VOE_HEADER_SIZE) { |
424 |
voe->state = ec_voe_handler_state_error; |
|
425 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
|
426 |
EC_ERR("Received VoE header is incomplete (%u bytes)!\n", rec_size); |
|
427 |
return; |
|
428 |
} |
|
429 |
||
1209 | 430 |
if (master->debug_level) { |
431 |
EC_DBG("VoE data:\n"); |
|
432 |
ec_print_data(data, rec_size); |
|
433 |
} |
|
434 |
||
1218 | 435 |
voe->data_size = rec_size - EC_VOE_HEADER_SIZE; |
1209 | 436 |
voe->request_state = EC_INT_REQUEST_SUCCESS; |
437 |
voe->state = ec_voe_handler_state_end; // success |
|
438 |
} |
|
439 |
||
440 |
/*****************************************************************************/ |
|
441 |
||
1314
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
442 |
/** Start reading VoE data without sending a sync message before. |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
443 |
*/ |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
444 |
void ec_voe_handler_state_read_nosync_start(ec_voe_handler_t *voe) |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
445 |
{ |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
446 |
ec_datagram_t *datagram = &voe->datagram; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
447 |
ec_slave_t *slave = voe->config->slave; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
448 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
449 |
if (slave->master->debug_level) |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
450 |
EC_DBG("Reading VoE data to slave %u.\n", slave->ring_position); |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
451 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
452 |
if (!(slave->sii.mailbox_protocols & EC_MBOX_VOE)) { |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
453 |
EC_ERR("Slave %u does not support VoE!\n", slave->ring_position); |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
454 |
voe->state = ec_voe_handler_state_error; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
455 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
456 |
return; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
457 |
} |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
458 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
459 |
ec_slave_mbox_prepare_fetch(slave, datagram); // can not fail. |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
460 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
461 |
voe->jiffies_start = jiffies; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
462 |
voe->retries = EC_FSM_RETRIES; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
463 |
voe->state = ec_voe_handler_state_read_nosync_response; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
464 |
} |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
465 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
466 |
/*****************************************************************************/ |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
467 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
468 |
/** Read the pending mailbox data without sending a sync message before. This |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
469 |
* might lead to an empty reponse from the client. |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
470 |
*/ |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
471 |
void ec_voe_handler_state_read_nosync_response(ec_voe_handler_t *voe) |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
472 |
{ |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
473 |
ec_datagram_t *datagram = &voe->datagram; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
474 |
ec_slave_t *slave = voe->config->slave; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
475 |
ec_master_t *master = voe->config->master; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
476 |
uint8_t *data, mbox_prot; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
477 |
size_t rec_size; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
478 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
479 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && voe->retries--) |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
480 |
return; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
481 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
482 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
483 |
voe->state = ec_voe_handler_state_error; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
484 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
485 |
EC_ERR("Failed to receive VoE read datagram for" |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
486 |
" slave %u (datagram state %u).\n", |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
487 |
slave->ring_position, datagram->state); |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
488 |
return; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
489 |
} |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
490 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
491 |
if (datagram->working_counter == 0) { |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
492 |
voe->state = ec_voe_handler_state_error; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
493 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
1315
26b4f94cfdfb
Output debug message only on debug level > 0.
Florian Pose <fp@igh-essen.com>
parents:
1314
diff
changeset
|
494 |
if (master->debug_level) |
26b4f94cfdfb
Output debug message only on debug level > 0.
Florian Pose <fp@igh-essen.com>
parents:
1314
diff
changeset
|
495 |
EC_DBG("Slave %u did not send VoE data.", slave->ring_position); |
1314
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
496 |
return; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
497 |
} |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
498 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
499 |
if (datagram->working_counter != 1) { |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
500 |
voe->state = ec_voe_handler_state_error; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
501 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
502 |
EC_WARN("Reception of VoE read response failed on slave %u: ", |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
503 |
slave->ring_position); |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
504 |
ec_datagram_print_wc_error(datagram); |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
505 |
return; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
506 |
} |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
507 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
508 |
if (!(data = ec_slave_mbox_fetch(slave, datagram, |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
509 |
&mbox_prot, &rec_size))) { |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
510 |
voe->state = ec_voe_handler_state_error; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
511 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
512 |
return; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
513 |
} |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
514 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
515 |
if (mbox_prot != EC_MBOX_TYPE_VOE) { |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
516 |
voe->state = ec_voe_handler_state_error; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
517 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
518 |
EC_WARN("Received mailbox protocol 0x%02X as response.\n", mbox_prot); |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
519 |
ec_print_data(data, rec_size); |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
520 |
return; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
521 |
} |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
522 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
523 |
if (rec_size < EC_VOE_HEADER_SIZE) { |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
524 |
voe->state = ec_voe_handler_state_error; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
525 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
526 |
EC_ERR("Received VoE header is incomplete (%u bytes)!\n", rec_size); |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
527 |
return; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
528 |
} |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
529 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
530 |
if (master->debug_level) { |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
531 |
EC_DBG("VoE data:\n"); |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
532 |
ec_print_data(data, rec_size); |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
533 |
} |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
534 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
535 |
voe->data_size = rec_size - EC_VOE_HEADER_SIZE; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
536 |
voe->request_state = EC_INT_REQUEST_SUCCESS; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
537 |
voe->state = ec_voe_handler_state_end; // success |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
538 |
} |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
539 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
540 |
/*****************************************************************************/ |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
541 |
|
1268 | 542 |
/** Successful termination state function. |
543 |
*/ |
|
1209 | 544 |
void ec_voe_handler_state_end(ec_voe_handler_t *voe) |
545 |
{ |
|
546 |
} |
|
547 |
||
548 |
/*****************************************************************************/ |
|
549 |
||
1268 | 550 |
/** Failure termination state function. |
551 |
*/ |
|
1209 | 552 |
void ec_voe_handler_state_error(ec_voe_handler_t *voe) |
553 |
{ |
|
554 |
} |
|
555 |
||
556 |
/*****************************************************************************/ |
|
557 |
||
558 |
/** \cond */ |
|
559 |
||
1226
afb189516fcf
Introduced ecrt_voe_handler_received_header(); renamed
Florian Pose <fp@igh-essen.com>
parents:
1224
diff
changeset
|
560 |
EXPORT_SYMBOL(ecrt_voe_handler_send_header); |
afb189516fcf
Introduced ecrt_voe_handler_received_header(); renamed
Florian Pose <fp@igh-essen.com>
parents:
1224
diff
changeset
|
561 |
EXPORT_SYMBOL(ecrt_voe_handler_received_header); |
1209 | 562 |
EXPORT_SYMBOL(ecrt_voe_handler_data); |
563 |
EXPORT_SYMBOL(ecrt_voe_handler_data_size); |
|
564 |
EXPORT_SYMBOL(ecrt_voe_handler_read); |
|
565 |
EXPORT_SYMBOL(ecrt_voe_handler_write); |
|
566 |
EXPORT_SYMBOL(ecrt_voe_handler_execute); |
|
567 |
||
568 |
/** \endcond */ |
|
569 |
||
570 |
/*****************************************************************************/ |