author | Florian Pose <fp@igh-essen.com> |
Fri, 03 Mar 2017 13:33:17 +0100 | |
changeset 2669 | 878a657d920a |
parent 2610 | f0fdcce9874b |
permissions | -rw-r--r-- |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
3 |
* $Id$ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
* |
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
5 |
* Copyright (C) 2008 Olav Zarges, imc Messsysteme GmbH |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
6 |
* 2013 Florian Pose <fp@igh-essen.com> |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
* |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
8 |
* This file is part of the IgH EtherCAT Master. |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
9 |
* |
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
10 |
* The IgH EtherCAT Master is free software; you can redistribute it and/or |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
11 |
* modify it under the terms of the GNU General Public License version 2, as |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
12 |
* published by the Free Software Foundation. |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
13 |
* |
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
14 |
* The IgH EtherCAT Master is distributed in the hope that it will be useful, |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
17 |
* Public License for more details. |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
18 |
* |
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
19 |
* You should have received a copy of the GNU General Public License along |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
20 |
* with the IgH EtherCAT Master; if not, write to the Free Software |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
21 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
22 |
* |
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
23 |
* --- |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
24 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
25 |
* The license mentioned above concerns the source code only. Using the |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
26 |
* EtherCAT technology and brand is only permitted in compliance with the |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
27 |
* industrial property and similar rights of Beckhoff Automation GmbH. |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
* |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
30 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
31 |
/** \file |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
32 |
* EtherCAT FoE state machines. |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
33 |
*/ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
#include "globals.h" |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
#include "master.h" |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
#include "mailbox.h" |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
#include "fsm_foe.h" |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
#include "foe.h" |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
|
2601
9b36a16271e6
Fix spurious FoE write timeout
Dave Page <dave.page@gleeble.com>
parents:
2594
diff
changeset
|
45 |
/** Maximum time in jiffies to wait for responses when reading out the |
9b36a16271e6
Fix spurious FoE write timeout
Dave Page <dave.page@gleeble.com>
parents:
2594
diff
changeset
|
46 |
* dictionary. |
9b36a16271e6
Fix spurious FoE write timeout
Dave Page <dave.page@gleeble.com>
parents:
2594
diff
changeset
|
47 |
*/ |
9b36a16271e6
Fix spurious FoE write timeout
Dave Page <dave.page@gleeble.com>
parents:
2594
diff
changeset
|
48 |
#define EC_FSM_FOE_TIMEOUT_JIFFIES (3 * HZ) |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
49 |
|
1465 | 50 |
/** Size of the FoE header. |
51 |
*/ |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
52 |
#define EC_FOE_HEADER_SIZE 6 |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
53 |
// uint8_t OpCode |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
54 |
// uint8_t reserved |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
55 |
// uint32_t PacketNo, Password, ErrorCode |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
56 |
|
2610
f0fdcce9874b
Refactor fmmu->logical_start_address to fmmu->logical_domain_offset
Dave Page <dave.page@gleeble.com>
parents:
2608
diff
changeset
|
57 |
//#define DEBUG_FOE |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
58 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
59 |
/*****************************************************************************/ |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
60 |
|
1416 | 61 |
/** FoE OpCodes. |
62 |
*/ |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
63 |
enum { |
1416 | 64 |
EC_FOE_OPCODE_RRQ = 1, /**< Read request. */ |
65 |
EC_FOE_OPCODE_WRQ = 2, /**< Write request. */ |
|
66 |
EC_FOE_OPCODE_DATA = 3, /**< Data. */ |
|
67 |
EC_FOE_OPCODE_ACK = 4, /**< Acknowledge. */ |
|
68 |
EC_FOE_OPCODE_ERR = 5, /**< Error. */ |
|
69 |
EC_FOE_OPCODE_BUSY = 6 /**< Busy. */ |
|
2594
9b33888de6c3
Removed obsolete FoE type name.
Florian Pose <fp@igh-essen.com>
parents:
2591
diff
changeset
|
70 |
}; |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
71 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
72 |
/*****************************************************************************/ |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
73 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
74 |
int ec_foe_prepare_data_send(ec_fsm_foe_t *, ec_datagram_t *); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
75 |
int ec_foe_prepare_wrq_send(ec_fsm_foe_t *, ec_datagram_t *); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
76 |
int ec_foe_prepare_rrq_send(ec_fsm_foe_t *, ec_datagram_t *); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
77 |
int ec_foe_prepare_send_ack(ec_fsm_foe_t *, ec_datagram_t *); |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
78 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
79 |
void ec_foe_set_tx_error(ec_fsm_foe_t *, uint32_t); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
80 |
void ec_foe_set_rx_error(ec_fsm_foe_t *, uint32_t); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
81 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
82 |
void ec_fsm_foe_end(ec_fsm_foe_t *, ec_datagram_t *); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
83 |
void ec_fsm_foe_error(ec_fsm_foe_t *, ec_datagram_t *); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
84 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
85 |
void ec_fsm_foe_state_wrq_sent(ec_fsm_foe_t *, ec_datagram_t *); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
86 |
void ec_fsm_foe_state_rrq_sent(ec_fsm_foe_t *, ec_datagram_t *); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
87 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
88 |
void ec_fsm_foe_state_ack_check(ec_fsm_foe_t *, ec_datagram_t *); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
89 |
void ec_fsm_foe_state_ack_read(ec_fsm_foe_t *, ec_datagram_t *); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
90 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
91 |
void ec_fsm_foe_state_data_sent(ec_fsm_foe_t *, ec_datagram_t *); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
92 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
93 |
void ec_fsm_foe_state_data_check(ec_fsm_foe_t *, ec_datagram_t *); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
94 |
void ec_fsm_foe_state_data_read(ec_fsm_foe_t *, ec_datagram_t *); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
95 |
void ec_fsm_foe_state_sent_ack(ec_fsm_foe_t *, ec_datagram_t *); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
96 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
97 |
void ec_fsm_foe_write_start(ec_fsm_foe_t *, ec_datagram_t *); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
98 |
void ec_fsm_foe_read_start(ec_fsm_foe_t *, ec_datagram_t *); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
99 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
100 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
101 |
|
1901
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
102 |
/** Constructor. |
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
103 |
*/ |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
104 |
void ec_fsm_foe_init( |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
105 |
ec_fsm_foe_t *fsm /**< finite state machine */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
106 |
) |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
107 |
{ |
2045
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
108 |
fsm->state = NULL; |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
109 |
fsm->datagram = NULL; |
1901
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
110 |
} |
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
111 |
|
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
112 |
/*****************************************************************************/ |
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
113 |
|
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
114 |
/** Destructor. |
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
115 |
*/ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
116 |
void ec_fsm_foe_clear(ec_fsm_foe_t *fsm /**< finite state machine */) |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
117 |
{ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
118 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
119 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
120 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
121 |
|
1901
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
122 |
/** Executes the current state of the state machine. |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
123 |
* |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
124 |
* \return 1, if the datagram was used, else 0. |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
125 |
*/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
126 |
int ec_fsm_foe_exec( |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
127 |
ec_fsm_foe_t *fsm, /**< finite state machine */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
128 |
ec_datagram_t *datagram /**< Datagram to use. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
129 |
) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
130 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
131 |
int datagram_used = 0; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
132 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
133 |
if (fsm->datagram && |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
134 |
(fsm->datagram->state == EC_DATAGRAM_INIT || |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
135 |
fsm->datagram->state == EC_DATAGRAM_QUEUED || |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
136 |
fsm->datagram->state == EC_DATAGRAM_SENT)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
137 |
// datagram not received yet |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
138 |
return datagram_used; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
139 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
140 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
141 |
fsm->state(fsm, datagram); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
142 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
143 |
datagram_used = |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
144 |
fsm->state != ec_fsm_foe_end && fsm->state != ec_fsm_foe_error; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
145 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
146 |
if (datagram_used) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
147 |
fsm->datagram = datagram; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
148 |
} else { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
149 |
fsm->datagram = NULL; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
150 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
151 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
152 |
return datagram_used; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
153 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
154 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
155 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
156 |
|
1901
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
157 |
/** Returns, if the state machine terminated with success. |
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
158 |
* \return non-zero if successful. |
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
159 |
*/ |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
160 |
int ec_fsm_foe_success(const ec_fsm_foe_t *fsm /**< Finite state machine */) |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
161 |
{ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
162 |
return fsm->state == ec_fsm_foe_end; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
163 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
164 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
165 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
166 |
|
1465 | 167 |
/** Prepares an FoE transfer. |
168 |
*/ |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
169 |
void ec_fsm_foe_transfer( |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
170 |
ec_fsm_foe_t *fsm, /**< State machine. */ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
171 |
ec_slave_t *slave, /**< EtherCAT slave. */ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
172 |
ec_foe_request_t *request /**< Sdo request. */ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
173 |
) |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
174 |
{ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
175 |
fsm->slave = slave; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
176 |
fsm->request = request; |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
177 |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
178 |
if (request->dir == EC_DIR_OUTPUT) { |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
179 |
fsm->tx_buffer = fsm->request->buffer; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
180 |
fsm->tx_buffer_size = fsm->request->data_size; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
181 |
fsm->tx_buffer_offset = 0; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
182 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
183 |
fsm->tx_filename = fsm->request->file_name; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
184 |
fsm->tx_filename_len = strlen(fsm->tx_filename); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
185 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
186 |
fsm->state = ec_fsm_foe_write_start; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
187 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
188 |
else { |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
189 |
fsm->rx_buffer = fsm->request->buffer; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
190 |
fsm->rx_buffer_size = fsm->request->buffer_size; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
191 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
192 |
fsm->rx_filename = fsm->request->file_name; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
193 |
fsm->rx_filename_len = strlen(fsm->rx_filename); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
194 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
195 |
fsm->state = ec_fsm_foe_read_start; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
196 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
197 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
198 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
199 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
200 |
|
1901
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
201 |
/** State: ERROR. |
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
202 |
*/ |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
203 |
void ec_fsm_foe_error( |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
204 |
ec_fsm_foe_t *fsm, /**< finite state machine */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
205 |
ec_datagram_t *datagram /**< Datagram to use. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
206 |
) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
207 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
208 |
#ifdef DEBUG_FOE |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
209 |
EC_SLAVE_DBG(fsm->slave, 0, "%s()\n", __func__); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
210 |
#endif |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
211 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
212 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
213 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
214 |
|
1901
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
215 |
/** State: END. |
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
216 |
*/ |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
217 |
void ec_fsm_foe_end( |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
218 |
ec_fsm_foe_t *fsm, /**< finite state machine */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
219 |
ec_datagram_t *datagram /**< Datagram to use. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
220 |
) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
221 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
222 |
#ifdef DEBUG_FOE |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
223 |
EC_SLAVE_DBG(fsm->slave, 0, "%s()\n", __func__); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
224 |
#endif |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
225 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
226 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
227 |
/*****************************************************************************/ |
1901
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
228 |
|
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
229 |
/** Sends a file or the next fragment. |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
230 |
* |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
231 |
* \return Zero on success, otherwise a negative error code. |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
232 |
*/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
233 |
int ec_foe_prepare_data_send( |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
234 |
ec_fsm_foe_t *fsm, /**< Finite state machine. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
235 |
ec_datagram_t *datagram /**< Datagram to use. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
236 |
) |
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
237 |
{ |
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
238 |
size_t remaining_size, current_size; |
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
239 |
uint8_t *data; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
240 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
241 |
remaining_size = fsm->tx_buffer_size - fsm->tx_buffer_offset; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
242 |
|
1338
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
243 |
if (remaining_size < fsm->slave->configured_tx_mailbox_size |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1336
diff
changeset
|
244 |
- EC_MBOX_HEADER_SIZE - EC_FOE_HEADER_SIZE) { |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
245 |
current_size = remaining_size; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
246 |
fsm->tx_last_packet = 1; |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1336
diff
changeset
|
247 |
} else { |
1338
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
248 |
current_size = fsm->slave->configured_tx_mailbox_size |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1336
diff
changeset
|
249 |
- EC_MBOX_HEADER_SIZE - EC_FOE_HEADER_SIZE; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
250 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
251 |
|
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
252 |
data = ec_slave_mbox_prepare_send(fsm->slave, |
2591
23b360e4a530
Centrally defined mailbox types.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
253 |
datagram, EC_MBOX_TYPE_FOE, current_size + EC_FOE_HEADER_SIZE); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
254 |
if (IS_ERR(data)) { |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
255 |
return -1; |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
256 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
257 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
258 |
EC_WRITE_U16(data, EC_FOE_OPCODE_DATA); // OpCode = DataBlock req. |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
259 |
EC_WRITE_U32(data + 2, fsm->tx_packet_no); // PacketNo, Password |
2606
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
260 |
#ifdef DEBUG_FOE |
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
261 |
EC_SLAVE_DBG(fsm->slave, 0, "sending opcode %u packet %u\n", |
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
262 |
EC_FOE_OPCODE_DATA, fsm->tx_packet_no); |
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
263 |
#endif |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
264 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
265 |
memcpy(data + EC_FOE_HEADER_SIZE, |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
266 |
fsm->tx_buffer + fsm->tx_buffer_offset, current_size); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
267 |
fsm->tx_current_size = current_size; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
268 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
269 |
return 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
270 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
271 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
272 |
/*****************************************************************************/ |
1901
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
273 |
|
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
274 |
/** Prepare a write request (WRQ) with filename |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
275 |
* |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
276 |
* \return Zero on success, otherwise a negative error code. |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
277 |
*/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
278 |
int ec_foe_prepare_wrq_send( |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
279 |
ec_fsm_foe_t *fsm, /**< Finite state machine. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
280 |
ec_datagram_t *datagram /**< Datagram to use. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
281 |
) |
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
282 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
283 |
size_t current_size; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
284 |
uint8_t *data; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
285 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
286 |
fsm->tx_buffer_offset = 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
287 |
fsm->tx_current_size = 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
288 |
fsm->tx_packet_no = 0; |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
289 |
fsm->tx_last_packet = 0; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
290 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
291 |
current_size = fsm->tx_filename_len; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
292 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
293 |
data = ec_slave_mbox_prepare_send(fsm->slave, datagram, |
2591
23b360e4a530
Centrally defined mailbox types.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
294 |
EC_MBOX_TYPE_FOE, current_size + EC_FOE_HEADER_SIZE); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
295 |
if (IS_ERR(data)) { |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
296 |
return -1; |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
297 |
} |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
298 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
299 |
EC_WRITE_U16( data, EC_FOE_OPCODE_WRQ); // fsm write request |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
300 |
EC_WRITE_U32( data + 2, fsm->tx_packet_no ); |
2606
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
301 |
#ifdef DEBUG_FOE |
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
302 |
EC_SLAVE_DBG(fsm->slave, 0, "sending opcode %u packet %u\n", |
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
303 |
EC_FOE_OPCODE_WRQ, fsm->tx_packet_no); |
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
304 |
#endif |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
305 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
306 |
memcpy(data + EC_FOE_HEADER_SIZE, fsm->tx_filename, current_size); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
307 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
308 |
return 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
309 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
310 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
311 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
312 |
|
1465 | 313 |
/** Initializes the FoE write state machine. |
314 |
*/ |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
315 |
void ec_fsm_foe_write_start( |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
316 |
ec_fsm_foe_t *fsm, /**< finite state machine */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
317 |
ec_datagram_t *datagram /**< Datagram to use. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
318 |
) |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
319 |
{ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
320 |
ec_slave_t *slave = fsm->slave; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
321 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
322 |
fsm->tx_buffer_offset = 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
323 |
fsm->tx_current_size = 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
324 |
fsm->tx_packet_no = 0; |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
325 |
fsm->tx_last_packet = 0; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
326 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
327 |
#ifdef DEBUG_FOE |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
328 |
EC_SLAVE_DBG(fsm->slave, 0, "%s()\n", __func__); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
329 |
#endif |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
330 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
331 |
if (!(slave->sii.mailbox_protocols & EC_MBOX_FOE)) { |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
332 |
ec_foe_set_tx_error(fsm, FOE_MBOX_PROT_ERROR); |
1921 | 333 |
EC_SLAVE_ERR(slave, "Slave does not support FoE!\n"); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
334 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
335 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
336 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
337 |
if (ec_foe_prepare_wrq_send(fsm, datagram)) { |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
338 |
ec_foe_set_tx_error(fsm, FOE_PROT_ERROR); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
339 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
340 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
341 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
342 |
fsm->state = ec_fsm_foe_state_wrq_sent; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
343 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
344 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
345 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
346 |
|
1465 | 347 |
/** Check for acknowledge. |
348 |
*/ |
|
349 |
void ec_fsm_foe_state_ack_check( |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
350 |
ec_fsm_foe_t *fsm, /**< FoE statemachine. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
351 |
ec_datagram_t *datagram /**< Datagram to use. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
352 |
) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
353 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
354 |
ec_slave_t *slave = fsm->slave; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
355 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
356 |
#ifdef DEBUG_FOE |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
357 |
EC_SLAVE_DBG(fsm->slave, 0, "%s()\n", __func__); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
358 |
#endif |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
359 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
360 |
if (fsm->datagram->state != EC_DATAGRAM_RECEIVED) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
361 |
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
1921 | 362 |
EC_SLAVE_ERR(slave, "Failed to receive FoE mailbox check datagram: "); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
363 |
ec_datagram_print_state(fsm->datagram); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
364 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
365 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
366 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
367 |
if (fsm->datagram->working_counter != 1) { |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
368 |
ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
1921 | 369 |
EC_SLAVE_ERR(slave, "Reception of FoE mailbox check datagram" |
370 |
" failed: "); |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
371 |
ec_datagram_print_wc_error(fsm->datagram); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
372 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
373 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
374 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
375 |
if (!ec_slave_mbox_check(fsm->datagram)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
376 |
// slave did not put anything in the mailbox yet |
2607
b59d6aecdbaa
Fix fsm_foe timeout regression
"Dave Page <dave.page@gleeble.com>"
parents:
2606
diff
changeset
|
377 |
if (time_after(fsm->datagram->jiffies_received, |
2601
9b36a16271e6
Fix spurious FoE write timeout
Dave Page <dave.page@gleeble.com>
parents:
2594
diff
changeset
|
378 |
fsm->jiffies_start + EC_FSM_FOE_TIMEOUT_JIFFIES)) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
379 |
ec_foe_set_tx_error(fsm, FOE_TIMEOUT_ERROR); |
1921 | 380 |
EC_SLAVE_ERR(slave, "Timeout while waiting for ack response.\n"); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
381 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
382 |
} |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
383 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
384 |
ec_slave_mbox_prepare_check(slave, datagram); // can not fail. |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
385 |
fsm->retries = EC_FSM_RETRIES; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
386 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
387 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
388 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
389 |
// Fetch response |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
390 |
ec_slave_mbox_prepare_fetch(slave, datagram); // can not fail. |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
391 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
392 |
fsm->retries = EC_FSM_RETRIES; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
393 |
fsm->state = ec_fsm_foe_state_ack_read; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
394 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
395 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
396 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
397 |
|
1465 | 398 |
/** Acknowledge a read operation. |
399 |
*/ |
|
400 |
void ec_fsm_foe_state_ack_read( |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
401 |
ec_fsm_foe_t *fsm, /**< FoE statemachine. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
402 |
ec_datagram_t *datagram /**< Datagram to use. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
403 |
) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
404 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
405 |
ec_slave_t *slave = fsm->slave; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
406 |
uint8_t *data, mbox_prot; |
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
407 |
uint8_t opCode; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
408 |
size_t rec_size; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
409 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
410 |
#ifdef DEBUG_FOE |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
411 |
EC_SLAVE_DBG(fsm->slave, 0, "%s()\n", __func__); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
412 |
#endif |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
413 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
414 |
if (fsm->datagram->state != EC_DATAGRAM_RECEIVED) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
415 |
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
1921 | 416 |
EC_SLAVE_ERR(slave, "Failed to receive FoE ack response datagram: "); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
417 |
ec_datagram_print_state(fsm->datagram); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
418 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
419 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
420 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
421 |
if (fsm->datagram->working_counter != 1) { |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
422 |
ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
1921 | 423 |
EC_SLAVE_ERR(slave, "Reception of FoE ack response failed: "); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
424 |
ec_datagram_print_wc_error(fsm->datagram); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
425 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
426 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
427 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
428 |
data = ec_slave_mbox_fetch(slave, fsm->datagram, &mbox_prot, &rec_size); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
429 |
if (IS_ERR(data)) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
430 |
ec_foe_set_tx_error(fsm, FOE_PROT_ERROR); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
431 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
432 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
433 |
|
2591
23b360e4a530
Centrally defined mailbox types.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
434 |
if (mbox_prot != EC_MBOX_TYPE_FOE) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
435 |
ec_foe_set_tx_error(fsm, FOE_MBOX_PROT_ERROR); |
1921 | 436 |
EC_SLAVE_ERR(slave, "Received mailbox protocol 0x%02X as response.\n", |
437 |
mbox_prot); |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
438 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
439 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
440 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
441 |
opCode = EC_READ_U8(data); |
2606
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
442 |
#ifdef DEBUG_FOE |
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
443 |
EC_SLAVE_DBG(fsm->slave, 0, "received opcode %u\n", opCode); |
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
444 |
#endif |
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
445 |
|
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
446 |
if (opCode == EC_FOE_OPCODE_BUSY) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
447 |
// slave not ready |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
448 |
if (ec_foe_prepare_data_send(fsm, datagram)) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
449 |
ec_foe_set_tx_error(fsm, FOE_PROT_ERROR); |
1921 | 450 |
EC_SLAVE_ERR(slave, "Slave is busy.\n"); |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
451 |
return; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
452 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
453 |
fsm->state = ec_fsm_foe_state_data_sent; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
454 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
455 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
456 |
|
2606
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
457 |
if (opCode == EC_FOE_OPCODE_ERR) { |
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
458 |
fsm->request->error_code = EC_READ_U32(data + 2); |
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
459 |
EC_SLAVE_ERR(slave, "Received FoE Error Request (code 0x%08x).\n", |
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
460 |
fsm->request->error_code); |
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
461 |
if (rec_size > 6 && data[6]) { |
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
462 |
uint8_t text[256]; |
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
463 |
strncpy(text, data + 6, min(rec_size - 6, sizeof(text))); |
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
464 |
text[sizeof(text)-1] = 0; |
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
465 |
EC_SLAVE_ERR(slave, "FoE Error Text: %s\n", text); |
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
466 |
} |
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
467 |
ec_foe_set_tx_error(fsm, FOE_OPCODE_ERROR); |
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
468 |
return; |
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
469 |
} |
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
470 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
471 |
if (opCode == EC_FOE_OPCODE_ACK) { |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
472 |
fsm->tx_packet_no++; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
473 |
fsm->tx_buffer_offset += fsm->tx_current_size; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
474 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
475 |
if (fsm->tx_last_packet) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
476 |
fsm->state = ec_fsm_foe_end; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
477 |
return; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
478 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
479 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
480 |
if (ec_foe_prepare_data_send(fsm, datagram)) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
481 |
ec_foe_set_tx_error(fsm, FOE_PROT_ERROR); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
482 |
return; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
483 |
} |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
484 |
fsm->state = ec_fsm_foe_state_data_sent; |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
485 |
return; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
486 |
} |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
487 |
ec_foe_set_tx_error(fsm, FOE_ACK_ERROR); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
488 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
489 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
490 |
/*****************************************************************************/ |
1465 | 491 |
|
492 |
/** State: WRQ SENT. |
|
493 |
* |
|
494 |
* Checks is the previous transmit datagram succeded and sends the next |
|
495 |
* fragment, if necessary. |
|
496 |
*/ |
|
497 |
void ec_fsm_foe_state_wrq_sent( |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
498 |
ec_fsm_foe_t *fsm, /**< FoE statemachine. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
499 |
ec_datagram_t *datagram /**< Datagram to use. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
500 |
) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
501 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
502 |
ec_slave_t *slave = fsm->slave; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
503 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
504 |
#ifdef DEBUG_FOE |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
505 |
EC_SLAVE_DBG(fsm->slave, 0, "%s()\n", __func__); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
506 |
#endif |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
507 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
508 |
if (fsm->datagram->state != EC_DATAGRAM_RECEIVED) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
509 |
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
1921 | 510 |
EC_SLAVE_ERR(slave, "Failed to send FoE WRQ: "); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
511 |
ec_datagram_print_state(fsm->datagram); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
512 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
513 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
514 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
515 |
if (fsm->datagram->working_counter != 1) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
516 |
// slave did not put anything in the mailbox yet |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
517 |
ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
1921 | 518 |
EC_SLAVE_ERR(slave, "Reception of FoE WRQ failed: "); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
519 |
ec_datagram_print_wc_error(fsm->datagram); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
520 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
521 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
522 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
523 |
fsm->jiffies_start = fsm->datagram->jiffies_sent; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
524 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
525 |
ec_slave_mbox_prepare_check(slave, datagram); // can not fail. |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
526 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
527 |
fsm->retries = EC_FSM_RETRIES; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
528 |
fsm->state = ec_fsm_foe_state_ack_check; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
529 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
530 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
531 |
/*****************************************************************************/ |
1465 | 532 |
|
533 |
/** State: WRQ SENT. |
|
534 |
* |
|
535 |
* Checks is the previous transmit datagram succeded and sends the next |
|
536 |
* fragment, if necessary. |
|
537 |
*/ |
|
538 |
void ec_fsm_foe_state_data_sent( |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
539 |
ec_fsm_foe_t *fsm, /**< Foe statemachine. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
540 |
ec_datagram_t *datagram /**< Datagram to use. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
541 |
) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
542 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
543 |
ec_slave_t *slave = fsm->slave; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
544 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
545 |
#ifdef DEBUG_FOE |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
546 |
EC_SLAVE_DBG(fsm->slave, 0, "%s()\n", __func__); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
547 |
#endif |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
548 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
549 |
if (fsm->datagram->state != EC_DATAGRAM_RECEIVED) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
550 |
ec_foe_set_tx_error(fsm, FOE_RECEIVE_ERROR); |
1921 | 551 |
EC_SLAVE_ERR(slave, "Failed to receive FoE ack response datagram: "); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
552 |
ec_datagram_print_state(fsm->datagram); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
553 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
554 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
555 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
556 |
if (fsm->datagram->working_counter != 1) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
557 |
ec_foe_set_tx_error(fsm, FOE_WC_ERROR); |
1921 | 558 |
EC_SLAVE_ERR(slave, "Reception of FoE data send failed: "); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
559 |
ec_datagram_print_wc_error(fsm->datagram); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
560 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
561 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
562 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
563 |
ec_slave_mbox_prepare_check(slave, datagram); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
564 |
fsm->jiffies_start = jiffies; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
565 |
fsm->retries = EC_FSM_RETRIES; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
566 |
fsm->state = ec_fsm_foe_state_ack_check; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
567 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
568 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
569 |
/*****************************************************************************/ |
1901
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
570 |
|
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
571 |
/** Prepare a read request (RRQ) with filename |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
572 |
* |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
573 |
* \return Zero on success, otherwise a negative error code. |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
574 |
*/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
575 |
int ec_foe_prepare_rrq_send( |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
576 |
ec_fsm_foe_t *fsm, /**< Finite state machine. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
577 |
ec_datagram_t *datagram /**< Datagram to use. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
578 |
) |
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
579 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
580 |
size_t current_size; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
581 |
uint8_t *data; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
582 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
583 |
current_size = fsm->rx_filename_len; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
584 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
585 |
data = ec_slave_mbox_prepare_send(fsm->slave, datagram, |
2591
23b360e4a530
Centrally defined mailbox types.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
586 |
EC_MBOX_TYPE_FOE, current_size + EC_FOE_HEADER_SIZE); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
587 |
if (IS_ERR(data)) { |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
588 |
return -1; |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
589 |
} |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
590 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
591 |
EC_WRITE_U16(data, EC_FOE_OPCODE_RRQ); // fsm read request |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
592 |
EC_WRITE_U32(data + 2, 0x00000000); // no passwd |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
593 |
memcpy(data + EC_FOE_HEADER_SIZE, fsm->rx_filename, current_size); |
2606
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
594 |
#ifdef DEBUG_FOE |
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
595 |
EC_SLAVE_DBG(fsm->slave, 0, "sending opcode %u\n", EC_FOE_OPCODE_RRQ); |
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
596 |
#endif |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
597 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
598 |
if (fsm->slave->master->debug_level) { |
1921 | 599 |
EC_SLAVE_DBG(fsm->slave, 1, "FoE Read Request:\n"); |
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
600 |
ec_print_data(data, current_size + EC_FOE_HEADER_SIZE); |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
601 |
} |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
602 |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
603 |
return 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
604 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
605 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
606 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
607 |
|
1465 | 608 |
/** Prepare to send an acknowledge. |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
609 |
* |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
610 |
* \return Zero on success, otherwise a negative error code. |
1465 | 611 |
*/ |
612 |
int ec_foe_prepare_send_ack( |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
613 |
ec_fsm_foe_t *fsm, /**< FoE statemachine. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
614 |
ec_datagram_t *datagram /**< Datagram to use. */ |
1465 | 615 |
) |
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
616 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
617 |
uint8_t *data; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
618 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
619 |
data = ec_slave_mbox_prepare_send(fsm->slave, datagram, |
2591
23b360e4a530
Centrally defined mailbox types.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
620 |
EC_MBOX_TYPE_FOE, EC_FOE_HEADER_SIZE); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
621 |
if (IS_ERR(data)) { |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
622 |
return -1; |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
623 |
} |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
624 |
|
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
625 |
EC_WRITE_U16(data, EC_FOE_OPCODE_ACK); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
626 |
EC_WRITE_U32(data + 2, fsm->rx_expected_packet_no); |
2606
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
627 |
#ifdef DEBUG_FOE |
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
628 |
EC_SLAVE_DBG(fsm->slave, 0, "sending opcode %u packet %u\n", |
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
629 |
EC_FOE_OPCODE_ACK, fsm->rx_expected_packet_no); |
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
630 |
#endif |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
631 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
632 |
return 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
633 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
634 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
635 |
/*****************************************************************************/ |
1465 | 636 |
|
637 |
/** State: RRQ SENT. |
|
638 |
* |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
639 |
* Checks is the previous transmit datagram succeeded and sends the next |
1465 | 640 |
* fragment, if necessary. |
641 |
*/ |
|
642 |
void ec_fsm_foe_state_rrq_sent( |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
643 |
ec_fsm_foe_t *fsm, /**< FoE statemachine. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
644 |
ec_datagram_t *datagram /**< Datagram to use. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
645 |
) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
646 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
647 |
ec_slave_t *slave = fsm->slave; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
648 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
649 |
#ifdef DEBUG_FOE |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
650 |
EC_SLAVE_DBG(fsm->slave, 0, "%s()\n", __func__); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
651 |
#endif |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
652 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
653 |
if (fsm->datagram->state != EC_DATAGRAM_RECEIVED) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
654 |
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
1921 | 655 |
EC_SLAVE_ERR(slave, "Failed to send FoE RRQ: "); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
656 |
ec_datagram_print_state(fsm->datagram); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
657 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
658 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
659 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
660 |
if (fsm->datagram->working_counter != 1) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
661 |
// slave did not put anything in the mailbox yet |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
662 |
ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
1921 | 663 |
EC_SLAVE_ERR(slave, "Reception of FoE RRQ failed: "); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
664 |
ec_datagram_print_wc_error(fsm->datagram); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
665 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
666 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
667 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
668 |
fsm->jiffies_start = fsm->datagram->jiffies_sent; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
669 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
670 |
ec_slave_mbox_prepare_check(slave, datagram); // can not fail. |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
671 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
672 |
fsm->retries = EC_FSM_RETRIES; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
673 |
fsm->state = ec_fsm_foe_state_data_check; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
674 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
675 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
676 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
677 |
|
1465 | 678 |
/** Starting state for read operations. |
679 |
*/ |
|
680 |
void ec_fsm_foe_read_start( |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
681 |
ec_fsm_foe_t *fsm, /**< FoE statemachine. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
682 |
ec_datagram_t *datagram /**< Datagram to use. */ |
1465 | 683 |
) |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
684 |
{ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
685 |
ec_slave_t *slave = fsm->slave; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
686 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
687 |
fsm->rx_buffer_offset = 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
688 |
fsm->rx_expected_packet_no = 1; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
689 |
fsm->rx_last_packet = 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
690 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
691 |
#ifdef DEBUG_FOE |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
692 |
EC_SLAVE_DBG(fsm->slave, 0, "%s()\n", __func__); |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
693 |
#endif |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
694 |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
695 |
if (!(slave->sii.mailbox_protocols & EC_MBOX_FOE)) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
696 |
ec_foe_set_tx_error(fsm, FOE_MBOX_PROT_ERROR); |
1921 | 697 |
EC_SLAVE_ERR(slave, "Slave does not support FoE!\n"); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
698 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
699 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
700 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
701 |
if (ec_foe_prepare_rrq_send(fsm, datagram)) { |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
702 |
ec_foe_set_rx_error(fsm, FOE_PROT_ERROR); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
703 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
704 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
705 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
706 |
fsm->state = ec_fsm_foe_state_rrq_sent; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
707 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
708 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
709 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
710 |
|
1465 | 711 |
/** Check for data. |
712 |
*/ |
|
713 |
void ec_fsm_foe_state_data_check( |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
714 |
ec_fsm_foe_t *fsm, /**< FoE statemachine. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
715 |
ec_datagram_t *datagram /**< Datagram to use. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
716 |
) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
717 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
718 |
ec_slave_t *slave = fsm->slave; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
719 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
720 |
#ifdef DEBUG_FOE |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
721 |
EC_SLAVE_DBG(fsm->slave, 0, "%s()\n", __func__); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
722 |
#endif |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
723 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
724 |
if (fsm->datagram->state != EC_DATAGRAM_RECEIVED) { |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
725 |
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
1921 | 726 |
EC_SLAVE_ERR(slave, "Failed to send FoE DATA READ: "); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
727 |
ec_datagram_print_state(fsm->datagram); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
728 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
729 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
730 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
731 |
if (fsm->datagram->working_counter != 1) { |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
732 |
ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
1921 | 733 |
EC_SLAVE_ERR(slave, "Reception of FoE DATA READ: "); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
734 |
ec_datagram_print_wc_error(fsm->datagram); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
735 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
736 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
737 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
738 |
if (!ec_slave_mbox_check(fsm->datagram)) { |
2607
b59d6aecdbaa
Fix fsm_foe timeout regression
"Dave Page <dave.page@gleeble.com>"
parents:
2606
diff
changeset
|
739 |
if (time_after(fsm->datagram->jiffies_received, |
2601
9b36a16271e6
Fix spurious FoE write timeout
Dave Page <dave.page@gleeble.com>
parents:
2594
diff
changeset
|
740 |
fsm->jiffies_start + EC_FSM_FOE_TIMEOUT_JIFFIES)) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
741 |
ec_foe_set_tx_error(fsm, FOE_TIMEOUT_ERROR); |
1921 | 742 |
EC_SLAVE_ERR(slave, "Timeout while waiting for ack response.\n"); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
743 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
744 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
745 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
746 |
ec_slave_mbox_prepare_check(slave, datagram); // can not fail. |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
747 |
fsm->retries = EC_FSM_RETRIES; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
748 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
749 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
750 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
751 |
// Fetch response |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
752 |
ec_slave_mbox_prepare_fetch(slave, datagram); // can not fail. |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
753 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
754 |
fsm->retries = EC_FSM_RETRIES; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
755 |
fsm->state = ec_fsm_foe_state_data_read; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
756 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
757 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
758 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
759 |
|
1465 | 760 |
/** Start reading data. |
761 |
*/ |
|
762 |
void ec_fsm_foe_state_data_read( |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
763 |
ec_fsm_foe_t *fsm, /**< FoE statemachine. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
764 |
ec_datagram_t *datagram /**< Datagram to use. */ |
1465 | 765 |
) |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
766 |
{ |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
767 |
size_t rec_size; |
2604
8476f196755b
[etherlab-dev] [PATCH] FoE: fix read packet number check
"Dave Page <dave.page@gleeble.com>"
parents:
2603
diff
changeset
|
768 |
uint32_t packet_no; |
8476f196755b
[etherlab-dev] [PATCH] FoE: fix read packet number check
"Dave Page <dave.page@gleeble.com>"
parents:
2603
diff
changeset
|
769 |
uint8_t *data, opCode, mbox_prot; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
770 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
771 |
ec_slave_t *slave = fsm->slave; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
772 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
773 |
#ifdef DEBUG_FOE |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
774 |
EC_SLAVE_DBG(fsm->slave, 0, "%s()\n", __func__); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
775 |
#endif |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
776 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
777 |
if (fsm->datagram->state != EC_DATAGRAM_RECEIVED) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
778 |
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
1921 | 779 |
EC_SLAVE_ERR(slave, "Failed to receive FoE DATA READ datagram: "); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
780 |
ec_datagram_print_state(fsm->datagram); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
781 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
782 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
783 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
784 |
if (fsm->datagram->working_counter != 1) { |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
785 |
ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
1921 | 786 |
EC_SLAVE_ERR(slave, "Reception of FoE DATA READ failed: "); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
787 |
ec_datagram_print_wc_error(fsm->datagram); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
788 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
789 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
790 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
791 |
data = ec_slave_mbox_fetch(slave, fsm->datagram, &mbox_prot, &rec_size); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
792 |
if (IS_ERR(data)) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
793 |
ec_foe_set_rx_error(fsm, FOE_MBOX_FETCH_ERROR); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
794 |
return; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
795 |
} |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
796 |
|
2591
23b360e4a530
Centrally defined mailbox types.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
797 |
if (mbox_prot != EC_MBOX_TYPE_FOE) { |
1921 | 798 |
EC_SLAVE_ERR(slave, "Received mailbox protocol 0x%02X as response.\n", |
799 |
mbox_prot); |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
800 |
ec_foe_set_rx_error(fsm, FOE_PROT_ERROR); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
801 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
802 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
803 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
804 |
opCode = EC_READ_U8(data); |
2606
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
805 |
#ifdef DEBUG_FOE |
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
806 |
EC_SLAVE_DBG(fsm->slave, 0, "received opcode %u\n", opCode); |
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
807 |
#endif |
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
808 |
|
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
809 |
if (opCode == EC_FOE_OPCODE_BUSY) { |
2605
f3843f68644f
FoE: Fix expected packet number when busy
"Dave Page <dave.page@gleeble.com>"
parents:
2604
diff
changeset
|
810 |
fsm->rx_expected_packet_no--; |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
811 |
if (ec_foe_prepare_send_ack(fsm, datagram)) { |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
812 |
ec_foe_set_rx_error(fsm, FOE_PROT_ERROR); |
2606
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
813 |
} else { |
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
814 |
fsm->state = ec_fsm_foe_state_sent_ack; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
815 |
} |
2605
f3843f68644f
FoE: Fix expected packet number when busy
"Dave Page <dave.page@gleeble.com>"
parents:
2604
diff
changeset
|
816 |
#ifdef DEBUG_FOE |
f3843f68644f
FoE: Fix expected packet number when busy
"Dave Page <dave.page@gleeble.com>"
parents:
2604
diff
changeset
|
817 |
EC_SLAVE_DBG(fsm->slave, 0, "%s() busy. Next pkt %u\n", __func__, |
f3843f68644f
FoE: Fix expected packet number when busy
"Dave Page <dave.page@gleeble.com>"
parents:
2604
diff
changeset
|
818 |
fsm->rx_expected_packet_no); |
f3843f68644f
FoE: Fix expected packet number when busy
"Dave Page <dave.page@gleeble.com>"
parents:
2604
diff
changeset
|
819 |
#endif |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
820 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
821 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
822 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
823 |
if (opCode == EC_FOE_OPCODE_ERR) { |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
824 |
fsm->request->error_code = EC_READ_U32(data + 2); |
1921 | 825 |
EC_SLAVE_ERR(slave, "Received FoE Error Request (code 0x%08x).\n", |
826 |
fsm->request->error_code); |
|
2606
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
827 |
if (rec_size > 6 && data[6]) { |
2259
5538f60ea32c
Decreased maximum length of error message to avoid stack warning.
Florian Pose <fp@igh-essen.com>
parents:
2240
diff
changeset
|
828 |
uint8_t text[256]; |
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
829 |
strncpy(text, data + 6, min(rec_size - 6, sizeof(text))); |
2606
764801a0f2aa
Gavin Lambert FoE Patches
"Dave Page <dave.page@gleeble.com>"
parents:
2605
diff
changeset
|
830 |
text[sizeof(text)-1] = 0; |
1921 | 831 |
EC_SLAVE_ERR(slave, "FoE Error Text: %s\n", text); |
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
832 |
} |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
833 |
ec_foe_set_rx_error(fsm, FOE_OPCODE_ERROR); |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
834 |
return; |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
835 |
} |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
836 |
|
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
837 |
if (opCode != EC_FOE_OPCODE_DATA) { |
1921 | 838 |
EC_SLAVE_ERR(slave, "Received OPCODE %x, expected %x.\n", |
839 |
opCode, EC_FOE_OPCODE_DATA); |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
840 |
fsm->request->error_code = 0x00000000; |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
841 |
ec_foe_set_rx_error(fsm, FOE_OPCODE_ERROR); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
842 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
843 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
844 |
|
2604
8476f196755b
[etherlab-dev] [PATCH] FoE: fix read packet number check
"Dave Page <dave.page@gleeble.com>"
parents:
2603
diff
changeset
|
845 |
packet_no = EC_READ_U32(data + 2); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
846 |
if (packet_no != fsm->rx_expected_packet_no) { |
2604
8476f196755b
[etherlab-dev] [PATCH] FoE: fix read packet number check
"Dave Page <dave.page@gleeble.com>"
parents:
2603
diff
changeset
|
847 |
EC_SLAVE_ERR(slave, "Received packet number %u, expected %u.\n", |
8476f196755b
[etherlab-dev] [PATCH] FoE: fix read packet number check
"Dave Page <dave.page@gleeble.com>"
parents:
2603
diff
changeset
|
848 |
packet_no, fsm->rx_expected_packet_no); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
849 |
ec_foe_set_rx_error(fsm, FOE_PACKETNO_ERROR); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
850 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
851 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
852 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
853 |
rec_size -= EC_FOE_HEADER_SIZE; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
854 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
855 |
if (fsm->rx_buffer_size >= fsm->rx_buffer_offset + rec_size) { |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
856 |
memcpy(fsm->rx_buffer + fsm->rx_buffer_offset, |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
857 |
data + EC_FOE_HEADER_SIZE, rec_size); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
858 |
fsm->rx_buffer_offset += rec_size; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
859 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
860 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
861 |
fsm->rx_last_packet = |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
862 |
(rec_size + EC_MBOX_HEADER_SIZE + EC_FOE_HEADER_SIZE |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
863 |
!= slave->configured_rx_mailbox_size); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
864 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
865 |
if (fsm->rx_last_packet || |
1338
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
866 |
(slave->configured_rx_mailbox_size - EC_MBOX_HEADER_SIZE |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
867 |
- EC_FOE_HEADER_SIZE + fsm->rx_buffer_offset) |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
868 |
<= fsm->rx_buffer_size) { |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
869 |
// either it was the last packet or a new packet will fit into the |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
870 |
// delivered buffer |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
871 |
#ifdef DEBUG_FOE |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
872 |
EC_SLAVE_DBG(fsm->slave, 0, "last_packet=true\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
873 |
#endif |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
874 |
if (ec_foe_prepare_send_ack(fsm, datagram)) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
875 |
ec_foe_set_rx_error(fsm, FOE_RX_DATA_ACK_ERROR); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
876 |
return; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
877 |
} |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
878 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
879 |
fsm->state = ec_fsm_foe_state_sent_ack; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
880 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
881 |
else { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
882 |
// no more data fits into the delivered buffer |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
883 |
// ... wait for new read request |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
884 |
EC_SLAVE_ERR(slave, "Data do not fit in receive buffer!\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
885 |
printk(" rx_buffer_size = %d\n", fsm->rx_buffer_size); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
886 |
printk("rx_buffer_offset = %d\n", fsm->rx_buffer_offset); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
887 |
printk(" rec_size = %zd\n", rec_size); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
888 |
printk(" rx_mailbox_size = %d\n", slave->configured_rx_mailbox_size); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
889 |
printk(" rx_last_packet = %d\n", fsm->rx_last_packet); |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
890 |
fsm->request->result = FOE_READY; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
891 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
892 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
893 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
894 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
895 |
|
1465 | 896 |
/** Sent an acknowledge. |
897 |
*/ |
|
898 |
void ec_fsm_foe_state_sent_ack( |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
899 |
ec_fsm_foe_t *fsm, /**< FoE statemachine. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
900 |
ec_datagram_t *datagram /**< Datagram to use. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
901 |
) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
902 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
903 |
ec_slave_t *slave = fsm->slave; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
904 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
905 |
#ifdef DEBUG_FOE |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
906 |
EC_SLAVE_DBG(fsm->slave, 0, "%s()\n", __func__); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
907 |
#endif |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
908 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
909 |
if (fsm->datagram->state != EC_DATAGRAM_RECEIVED) { |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
910 |
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
1921 | 911 |
EC_SLAVE_ERR(slave, "Failed to send FoE ACK: "); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
912 |
ec_datagram_print_state(fsm->datagram); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
913 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
914 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
915 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
916 |
if (fsm->datagram->working_counter != 1) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
917 |
// slave did not put anything into the mailbox yet |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
918 |
ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
1921 | 919 |
EC_SLAVE_ERR(slave, "Reception of FoE ACK failed: "); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
920 |
ec_datagram_print_wc_error(fsm->datagram); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
921 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
922 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
923 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
924 |
fsm->jiffies_start = fsm->datagram->jiffies_sent; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
925 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2259
diff
changeset
|
926 |
ec_slave_mbox_prepare_check(slave, datagram); // can not fail. |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
927 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
928 |
if (fsm->rx_last_packet) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
929 |
fsm->rx_expected_packet_no = 0; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
930 |
fsm->request->data_size = fsm->rx_buffer_offset; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
931 |
fsm->state = ec_fsm_foe_end; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
932 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
933 |
else { |
2603 | 934 |
fsm->rx_expected_packet_no++; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
935 |
fsm->retries = EC_FSM_RETRIES; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
936 |
fsm->state = ec_fsm_foe_state_data_check; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
937 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
938 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
939 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
940 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
941 |
|
1465 | 942 |
/** Set an error code and go to the send error state. |
943 |
*/ |
|
944 |
void ec_foe_set_tx_error( |
|
945 |
ec_fsm_foe_t *fsm, /**< FoE statemachine. */ |
|
946 |
uint32_t errorcode /**< FoE error code. */ |
|
947 |
) |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
948 |
{ |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
949 |
fsm->request->result = errorcode; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
950 |
fsm->state = ec_fsm_foe_error; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
951 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
952 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
953 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
954 |
|
1465 | 955 |
/** Set an error code and go to the receive error state. |
956 |
*/ |
|
957 |
void ec_foe_set_rx_error( |
|
958 |
ec_fsm_foe_t *fsm, /**< FoE statemachine. */ |
|
959 |
uint32_t errorcode /**< FoE error code. */ |
|
960 |
) |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
961 |
{ |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
962 |
fsm->request->result = errorcode; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
963 |
fsm->state = ec_fsm_foe_error; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
964 |
} |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
965 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
966 |
/*****************************************************************************/ |