author | Gavin Lambert <gavinl@compacsort.com> |
Tue, 14 Apr 2015 09:35:15 -0400 | |
changeset 2620 | 0e4d098db815 |
parent 2591 | 23b360e4a530 |
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 |
||
1218 | 43 |
/** VoE header size. |
44 |
*/ |
|
45 |
#define EC_VOE_HEADER_SIZE 6 |
|
46 |
||
1209 | 47 |
/** VoE response timeout in [ms]. |
48 |
*/ |
|
49 |
#define EC_VOE_RESPONSE_TIMEOUT 500 |
|
50 |
||
51 |
/*****************************************************************************/ |
|
52 |
||
53 |
void ec_voe_handler_state_write_start(ec_voe_handler_t *); |
|
54 |
void ec_voe_handler_state_write_response(ec_voe_handler_t *); |
|
55 |
||
56 |
void ec_voe_handler_state_read_start(ec_voe_handler_t *); |
|
57 |
void ec_voe_handler_state_read_check(ec_voe_handler_t *); |
|
58 |
void ec_voe_handler_state_read_response(ec_voe_handler_t *); |
|
59 |
||
1314
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
60 |
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
|
61 |
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
|
62 |
|
1209 | 63 |
void ec_voe_handler_state_end(ec_voe_handler_t *); |
64 |
void ec_voe_handler_state_error(ec_voe_handler_t *); |
|
65 |
||
66 |
/*****************************************************************************/ |
|
67 |
||
68 |
/** 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
|
69 |
* |
74853e018898
Created backend versions of all API functions returing a pointer; using
Florian Pose <fp@igh-essen.com>
parents:
1268
diff
changeset
|
70 |
* \return Return value of ec_datagram_prealloc(). |
1209 | 71 |
*/ |
72 |
int ec_voe_handler_init( |
|
73 |
ec_voe_handler_t *voe, /**< VoE handler. */ |
|
74 |
ec_slave_config_t *sc, /**< Parent slave configuration. */ |
|
75 |
size_t size /**< Size of memory to reserve. */ |
|
76 |
) |
|
77 |
{ |
|
78 |
voe->config = sc; |
|
1218 | 79 |
voe->vendor_id = 0x00000000; |
80 |
voe->vendor_type = 0x0000; |
|
1209 | 81 |
voe->data_size = 0; |
82 |
voe->dir = EC_DIR_INVALID; |
|
83 |
voe->state = ec_voe_handler_state_error; |
|
84 |
voe->request_state = EC_INT_REQUEST_INIT; |
|
85 |
||
86 |
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
|
87 |
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
|
88 |
size + EC_MBOX_HEADER_SIZE + EC_VOE_HEADER_SIZE); |
1209 | 89 |
} |
90 |
||
91 |
/*****************************************************************************/ |
|
92 |
||
93 |
/** VoE handler destructor. |
|
94 |
*/ |
|
95 |
void ec_voe_handler_clear( |
|
96 |
ec_voe_handler_t *voe /**< VoE handler. */ |
|
97 |
) |
|
98 |
{ |
|
99 |
ec_datagram_clear(&voe->datagram); |
|
100 |
} |
|
101 |
||
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1226
diff
changeset
|
102 |
/*****************************************************************************/ |
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 |
/** Get usable memory size. |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
105 |
* |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
106 |
* \return Memory size. |
1264
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 |
size_t ec_voe_handler_mem_size( |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
109 |
const ec_voe_handler_t *voe /**< VoE handler. */ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
110 |
) |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
111 |
{ |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
112 |
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
|
113 |
return voe->datagram.mem_size - |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
114 |
(EC_MBOX_HEADER_SIZE + EC_VOE_HEADER_SIZE); |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
115 |
else |
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
116 |
return 0; |
1264
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1226
diff
changeset
|
117 |
} |
e7882f246d7a
Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents:
1226
diff
changeset
|
118 |
|
1209 | 119 |
/***************************************************************************** |
120 |
* Application interface. |
|
121 |
****************************************************************************/ |
|
122 |
||
1226
afb189516fcf
Introduced ecrt_voe_handler_received_header(); renamed
Florian Pose <fp@igh-essen.com>
parents:
1224
diff
changeset
|
123 |
void ecrt_voe_handler_send_header(ec_voe_handler_t *voe, uint32_t vendor_id, |
1218 | 124 |
uint16_t vendor_type) |
125 |
{ |
|
126 |
voe->vendor_id = vendor_id; |
|
127 |
voe->vendor_type = vendor_type; |
|
128 |
} |
|
129 |
||
130 |
/*****************************************************************************/ |
|
131 |
||
1226
afb189516fcf
Introduced ecrt_voe_handler_received_header(); renamed
Florian Pose <fp@igh-essen.com>
parents:
1224
diff
changeset
|
132 |
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
|
133 |
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
|
134 |
{ |
afb189516fcf
Introduced ecrt_voe_handler_received_header(); renamed
Florian Pose <fp@igh-essen.com>
parents:
1224
diff
changeset
|
135 |
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
|
136 |
|
afb189516fcf
Introduced ecrt_voe_handler_received_header(); renamed
Florian Pose <fp@igh-essen.com>
parents:
1224
diff
changeset
|
137 |
if (vendor_id) |
afb189516fcf
Introduced ecrt_voe_handler_received_header(); renamed
Florian Pose <fp@igh-essen.com>
parents:
1224
diff
changeset
|
138 |
*vendor_id = EC_READ_U32(header); |
afb189516fcf
Introduced ecrt_voe_handler_received_header(); renamed
Florian Pose <fp@igh-essen.com>
parents:
1224
diff
changeset
|
139 |
if (vendor_type) |
afb189516fcf
Introduced ecrt_voe_handler_received_header(); renamed
Florian Pose <fp@igh-essen.com>
parents:
1224
diff
changeset
|
140 |
*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
|
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 |
/*****************************************************************************/ |
afb189516fcf
Introduced ecrt_voe_handler_received_header(); renamed
Florian Pose <fp@igh-essen.com>
parents:
1224
diff
changeset
|
144 |
|
1209 | 145 |
uint8_t *ecrt_voe_handler_data(ec_voe_handler_t *voe) |
146 |
{ |
|
1218 | 147 |
return voe->datagram.data + EC_MBOX_HEADER_SIZE + EC_VOE_HEADER_SIZE; |
1209 | 148 |
} |
149 |
||
150 |
/*****************************************************************************/ |
|
151 |
||
152 |
size_t ecrt_voe_handler_data_size(const ec_voe_handler_t *voe) |
|
153 |
{ |
|
154 |
return voe->data_size; |
|
155 |
} |
|
156 |
||
157 |
/*****************************************************************************/ |
|
158 |
||
159 |
void ecrt_voe_handler_read(ec_voe_handler_t *voe) |
|
160 |
{ |
|
161 |
voe->dir = EC_DIR_INPUT; |
|
162 |
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
|
163 |
voe->request_state = EC_INT_REQUEST_BUSY; |
1209 | 164 |
} |
165 |
||
166 |
/*****************************************************************************/ |
|
167 |
||
1314
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
168 |
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
|
169 |
{ |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
170 |
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
|
171 |
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
|
172 |
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
|
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 |
/*****************************************************************************/ |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
176 |
|
1209 | 177 |
void ecrt_voe_handler_write(ec_voe_handler_t *voe, size_t size) |
178 |
{ |
|
179 |
voe->dir = EC_DIR_OUTPUT; |
|
1218 | 180 |
voe->data_size = size; |
1209 | 181 |
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
|
182 |
voe->request_state = EC_INT_REQUEST_BUSY; |
1209 | 183 |
} |
184 |
||
185 |
/*****************************************************************************/ |
|
186 |
||
187 |
ec_request_state_t ecrt_voe_handler_execute(ec_voe_handler_t *voe) |
|
188 |
{ |
|
1348
8db0f72ace11
Fixed usage of internal request states.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
189 |
if (voe->config->slave) { // FIXME locking? |
1209 | 190 |
voe->state(voe); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
191 |
if (voe->request_state == EC_INT_REQUEST_BUSY) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
192 |
ec_master_queue_datagram(voe->config->master, &voe->datagram); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
193 |
} |
1209 | 194 |
} else { |
195 |
voe->state = ec_voe_handler_state_error; |
|
196 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
|
197 |
} |
|
198 |
||
199 |
return ec_request_state_translation_table[voe->request_state]; |
|
200 |
} |
|
201 |
||
202 |
/****************************************************************************** |
|
203 |
* State functions. |
|
204 |
*****************************************************************************/ |
|
205 |
||
1268 | 206 |
/** Start writing VoE data. |
207 |
*/ |
|
1209 | 208 |
void ec_voe_handler_state_write_start(ec_voe_handler_t *voe) |
209 |
{ |
|
210 |
ec_slave_t *slave = voe->config->slave; |
|
211 |
uint8_t *data; |
|
212 |
||
213 |
if (slave->master->debug_level) { |
|
1921 | 214 |
EC_SLAVE_DBG(slave, 0, "Writing %zu bytes of VoE data.\n", |
215 |
voe->data_size); |
|
1209 | 216 |
ec_print_data(ecrt_voe_handler_data(voe), voe->data_size); |
217 |
} |
|
218 |
||
219 |
if (!(slave->sii.mailbox_protocols & EC_MBOX_VOE)) { |
|
1921 | 220 |
EC_SLAVE_ERR(slave, "Slave does not support VoE!\n"); |
1209 | 221 |
voe->state = ec_voe_handler_state_error; |
222 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
|
223 |
return; |
|
224 |
} |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
225 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
226 |
data = ec_slave_mbox_prepare_send(slave, &voe->datagram, |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
227 |
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
|
228 |
if (IS_ERR(data)) { |
1218 | 229 |
voe->state = ec_voe_handler_state_error; |
230 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
|
231 |
return; |
|
232 |
} |
|
233 |
||
234 |
EC_WRITE_U32(data, voe->vendor_id); |
|
235 |
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
|
236 |
/* data already in datagram */ |
1209 | 237 |
|
238 |
voe->retries = EC_FSM_RETRIES; |
|
239 |
voe->jiffies_start = jiffies; |
|
240 |
voe->state = ec_voe_handler_state_write_response; |
|
241 |
} |
|
242 |
||
243 |
/*****************************************************************************/ |
|
244 |
||
1268 | 245 |
/** Wait for the mailbox response. |
246 |
*/ |
|
1209 | 247 |
void ec_voe_handler_state_write_response(ec_voe_handler_t *voe) |
248 |
{ |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
249 |
ec_datagram_t *datagram = &voe->datagram; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
250 |
ec_slave_t *slave = voe->config->slave; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
251 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
252 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && voe->retries--) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
253 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
254 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
255 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
1209 | 256 |
voe->state = ec_voe_handler_state_error; |
257 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
|
1921 | 258 |
EC_SLAVE_ERR(slave, "Failed to receive VoE write request datagram: "); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
259 |
ec_datagram_print_state(datagram); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
260 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
261 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
262 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
263 |
if (datagram->working_counter != 1) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
264 |
if (!datagram->working_counter) { |
1209 | 265 |
unsigned long diff_ms = |
266 |
(jiffies - voe->jiffies_start) * 1000 / HZ; |
|
267 |
if (diff_ms < EC_VOE_RESPONSE_TIMEOUT) { |
|
1921 | 268 |
EC_SLAVE_DBG(slave, 1, "Slave did not respond to" |
1931 | 269 |
" VoE write request. Retrying after %lu ms...\n", |
270 |
diff_ms); |
|
1209 | 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; |
|
1921 | 277 |
EC_SLAVE_ERR(slave, "Reception of VoE write request failed: "); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
278 |
ec_datagram_print_wc_error(datagram); |
1209 | 279 |
return; |
280 |
} |
|
281 |
||
1921 | 282 |
EC_CONFIG_DBG(voe->config, 1, "VoE write request successful.\n"); |
1209 | 283 |
|
284 |
voe->request_state = EC_INT_REQUEST_SUCCESS; |
|
285 |
voe->state = ec_voe_handler_state_end; |
|
286 |
} |
|
287 |
||
288 |
/*****************************************************************************/ |
|
289 |
||
1268 | 290 |
/** Start reading VoE data. |
291 |
*/ |
|
1209 | 292 |
void ec_voe_handler_state_read_start(ec_voe_handler_t *voe) |
293 |
{ |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
294 |
ec_datagram_t *datagram = &voe->datagram; |
1209 | 295 |
ec_slave_t *slave = voe->config->slave; |
296 |
||
1921 | 297 |
EC_SLAVE_DBG(slave, 1, "Reading VoE data.\n"); |
1209 | 298 |
|
299 |
if (!(slave->sii.mailbox_protocols & EC_MBOX_VOE)) { |
|
1921 | 300 |
EC_SLAVE_ERR(slave, "Slave does not support VoE!\n"); |
1209 | 301 |
voe->state = ec_voe_handler_state_error; |
302 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
|
303 |
return; |
|
304 |
} |
|
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
305 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
306 |
ec_slave_mbox_prepare_check(slave, datagram); // can not fail. |
1209 | 307 |
|
308 |
voe->jiffies_start = jiffies; |
|
309 |
voe->retries = EC_FSM_RETRIES; |
|
310 |
voe->state = ec_voe_handler_state_read_check; |
|
311 |
} |
|
312 |
||
313 |
/*****************************************************************************/ |
|
314 |
||
1268 | 315 |
/** Check for new data in the mailbox. |
316 |
*/ |
|
1209 | 317 |
void ec_voe_handler_state_read_check(ec_voe_handler_t *voe) |
318 |
{ |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
319 |
ec_datagram_t *datagram = &voe->datagram; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
320 |
ec_slave_t *slave = voe->config->slave; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
321 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
322 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && voe->retries--) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
323 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
324 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
325 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
1209 | 326 |
voe->state = ec_voe_handler_state_error; |
327 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
|
1921 | 328 |
EC_SLAVE_ERR(slave, "Failed to receive VoE mailbox check datagram: "); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
329 |
ec_datagram_print_state(datagram); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
330 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
331 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
332 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
333 |
if (datagram->working_counter != 1) { |
1209 | 334 |
voe->state = ec_voe_handler_state_error; |
335 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
|
1921 | 336 |
EC_SLAVE_ERR(slave, "Reception of VoE mailbox check" |
337 |
" datagram failed: "); |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
338 |
ec_datagram_print_wc_error(datagram); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
339 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
340 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
341 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
342 |
if (!ec_slave_mbox_check(datagram)) { |
1209 | 343 |
unsigned long diff_ms = |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
344 |
(datagram->jiffies_received - voe->jiffies_start) * 1000 / HZ; |
1209 | 345 |
if (diff_ms >= EC_VOE_RESPONSE_TIMEOUT) { |
346 |
voe->state = ec_voe_handler_state_error; |
|
347 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
|
1921 | 348 |
EC_SLAVE_ERR(slave, "Timeout while waiting for VoE data.\n"); |
1209 | 349 |
return; |
350 |
} |
|
351 |
||
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
352 |
ec_slave_mbox_prepare_check(slave, datagram); // can not fail. |
1209 | 353 |
voe->retries = EC_FSM_RETRIES; |
354 |
return; |
|
355 |
} |
|
356 |
||
357 |
// Fetch response |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
358 |
ec_slave_mbox_prepare_fetch(slave, datagram); // can not fail. |
1209 | 359 |
voe->retries = EC_FSM_RETRIES; |
360 |
voe->state = ec_voe_handler_state_read_response; |
|
361 |
} |
|
362 |
||
363 |
/*****************************************************************************/ |
|
364 |
||
1268 | 365 |
/** Read the pending mailbox data. |
366 |
*/ |
|
1209 | 367 |
void ec_voe_handler_state_read_response(ec_voe_handler_t *voe) |
368 |
{ |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
369 |
ec_datagram_t *datagram = &voe->datagram; |
1209 | 370 |
ec_slave_t *slave = voe->config->slave; |
371 |
ec_master_t *master = voe->config->master; |
|
372 |
uint8_t *data, mbox_prot; |
|
373 |
size_t rec_size; |
|
374 |
||
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
375 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && voe->retries--) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
376 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
377 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
378 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
1209 | 379 |
voe->state = ec_voe_handler_state_error; |
380 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
|
1921 | 381 |
EC_SLAVE_ERR(slave, "Failed to receive VoE read datagram: "); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
382 |
ec_datagram_print_state(datagram); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
383 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
384 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
385 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
386 |
if (datagram->working_counter != 1) { |
1209 | 387 |
voe->state = ec_voe_handler_state_error; |
388 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
|
1921 | 389 |
EC_SLAVE_ERR(slave, "Reception of VoE read response failed: "); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
390 |
ec_datagram_print_wc_error(datagram); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
391 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
392 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
393 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
394 |
data = ec_slave_mbox_fetch(slave, datagram, &mbox_prot, &rec_size); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1312
diff
changeset
|
395 |
if (IS_ERR(data)) { |
1209 | 396 |
voe->state = ec_voe_handler_state_error; |
397 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
|
398 |
return; |
|
399 |
} |
|
400 |
||
1216
e70c4d71cebd
Changed VoE mailbox type to 0xff.
Florian Pose <fp@igh-essen.com>
parents:
1209
diff
changeset
|
401 |
if (mbox_prot != EC_MBOX_TYPE_VOE) { |
1209 | 402 |
voe->state = ec_voe_handler_state_error; |
403 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
|
1921 | 404 |
EC_SLAVE_WARN(slave, "Received mailbox protocol 0x%02X" |
405 |
" as response.\n", mbox_prot); |
|
1209 | 406 |
ec_print_data(data, rec_size); |
407 |
return; |
|
408 |
} |
|
409 |
||
1218 | 410 |
if (rec_size < EC_VOE_HEADER_SIZE) { |
411 |
voe->state = ec_voe_handler_state_error; |
|
412 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
|
1921 | 413 |
EC_SLAVE_ERR(slave, "Received VoE header is" |
414 |
" incomplete (%zu bytes)!\n", rec_size); |
|
1218 | 415 |
return; |
416 |
} |
|
417 |
||
1209 | 418 |
if (master->debug_level) { |
1921 | 419 |
EC_CONFIG_DBG(voe->config, 0, "VoE data:\n"); |
1209 | 420 |
ec_print_data(data, rec_size); |
421 |
} |
|
422 |
||
1218 | 423 |
voe->data_size = rec_size - EC_VOE_HEADER_SIZE; |
1209 | 424 |
voe->request_state = EC_INT_REQUEST_SUCCESS; |
425 |
voe->state = ec_voe_handler_state_end; // success |
|
426 |
} |
|
427 |
||
428 |
/*****************************************************************************/ |
|
429 |
||
1314
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
430 |
/** 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
|
431 |
*/ |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
432 |
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
|
433 |
{ |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
434 |
ec_datagram_t *datagram = &voe->datagram; |
1314
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
435 |
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
|
436 |
|
1921 | 437 |
EC_SLAVE_DBG(slave, 1, "Reading VoE data.\n"); |
1314
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 |
if (!(slave->sii.mailbox_protocols & EC_MBOX_VOE)) { |
1921 | 440 |
EC_SLAVE_ERR(slave, "Slave does not support VoE!\n"); |
1314
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
441 |
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
|
442 |
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
|
443 |
return; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
444 |
} |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
445 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
446 |
ec_slave_mbox_prepare_fetch(slave, datagram); // can not fail. |
1314
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
447 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
448 |
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
|
449 |
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
|
450 |
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
|
451 |
} |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
452 |
|
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 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
455 |
/** 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
|
456 |
* 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
|
457 |
*/ |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
458 |
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
|
459 |
{ |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
460 |
ec_datagram_t *datagram = &voe->datagram; |
1314
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
461 |
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
|
462 |
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
|
463 |
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
|
464 |
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
|
465 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
466 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && voe->retries--) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
467 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
468 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
469 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
1314
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
470 |
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
|
471 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
1921 | 472 |
EC_SLAVE_ERR(slave, "Failed to receive VoE read datagram: "); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
473 |
ec_datagram_print_state(datagram); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
474 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
475 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
476 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
477 |
if (datagram->working_counter == 0) { |
1314
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
478 |
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
|
479 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
1921 | 480 |
EC_SLAVE_DBG(slave, 1, "Slave did not send VoE data.\n"); |
1314
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 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
484 |
if (datagram->working_counter != 1) { |
1314
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; |
1921 | 487 |
EC_SLAVE_WARN(slave, "Reception of VoE read response failed: "); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
488 |
ec_datagram_print_wc_error(datagram); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
489 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
490 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
491 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
492 |
if (!(data = ec_slave_mbox_fetch(slave, datagram, |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
493 |
&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
|
494 |
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
|
495 |
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
|
496 |
return; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
497 |
} |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
498 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
499 |
if (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
|
500 |
voe->state = ec_voe_handler_state_error; |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
501 |
voe->request_state = EC_INT_REQUEST_FAILURE; |
1921 | 502 |
EC_SLAVE_WARN(slave, "Received mailbox protocol 0x%02X" |
503 |
" as response.\n", mbox_prot); |
|
1314
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
504 |
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
|
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 (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
|
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; |
1921 | 511 |
EC_SLAVE_ERR(slave, "Received VoE header is" |
512 |
" 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
|
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 (master->debug_level) { |
1921 | 517 |
EC_CONFIG_DBG(voe->config, 1, "VoE data:\n"); |
1314
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
518 |
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
|
519 |
} |
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
520 |
|
b3d06a8807b3
Included ecrt_voe_handler_read_nosync()-Patch by Mathias Weber.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
521 |
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
|
522 |
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
|
523 |
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
|
524 |
} |
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 |
|
1268 | 528 |
/** Successful termination state function. |
529 |
*/ |
|
1209 | 530 |
void ec_voe_handler_state_end(ec_voe_handler_t *voe) |
531 |
{ |
|
532 |
} |
|
533 |
||
534 |
/*****************************************************************************/ |
|
535 |
||
1268 | 536 |
/** Failure termination state function. |
537 |
*/ |
|
1209 | 538 |
void ec_voe_handler_state_error(ec_voe_handler_t *voe) |
539 |
{ |
|
540 |
} |
|
541 |
||
542 |
/*****************************************************************************/ |
|
543 |
||
544 |
/** \cond */ |
|
545 |
||
1226
afb189516fcf
Introduced ecrt_voe_handler_received_header(); renamed
Florian Pose <fp@igh-essen.com>
parents:
1224
diff
changeset
|
546 |
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
|
547 |
EXPORT_SYMBOL(ecrt_voe_handler_received_header); |
1209 | 548 |
EXPORT_SYMBOL(ecrt_voe_handler_data); |
549 |
EXPORT_SYMBOL(ecrt_voe_handler_data_size); |
|
550 |
EXPORT_SYMBOL(ecrt_voe_handler_read); |
|
551 |
EXPORT_SYMBOL(ecrt_voe_handler_write); |
|
552 |
EXPORT_SYMBOL(ecrt_voe_handler_execute); |
|
553 |
||
554 |
/** \endcond */ |
|
555 |
||
556 |
/*****************************************************************************/ |