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