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