author | Florian Pose <fp@igh-essen.com> |
Fri, 08 Feb 2013 20:00:16 +0100 | |
branch | stable-1.5 |
changeset 2512 | a01947bc9ab6 |
parent 2502 | 906ef8b1c0ec |
child 2522 | ec403cf308eb |
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 |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
* |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
* 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
|
8 |
* |
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
9 |
* 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
|
10 |
* 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
|
11 |
* 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
|
12 |
* |
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
13 |
* 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
|
14 |
* 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
|
15 |
* 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
|
16 |
* 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
|
17 |
* |
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
18 |
* 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
|
19 |
* 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
|
20 |
* 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
|
21 |
* |
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
22 |
* --- |
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 |
* 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
|
25 |
* EtherCAT technology and brand is only permitted in compliance with the |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1343
diff
changeset
|
26 |
* 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
|
27 |
* |
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 |
/** |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
31 |
\file |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
EtherCAT FoE state machines. |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
*/ |
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 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
45 |
/** Maximum time in ms to wait for responses when reading out the dictionary. |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
46 |
*/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
47 |
#define EC_FSM_FOE_TIMEOUT 3000 |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
48 |
|
1465 | 49 |
/** Mailbox type FoE. |
50 |
*/ |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
51 |
#define EC_MBOX_TYPE_FILEACCESS 0x04 |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
52 |
|
1465 | 53 |
/** Size of the FoE header. |
54 |
*/ |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
55 |
#define EC_FOE_HEADER_SIZE 6 |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
56 |
// uint8_t OpCode |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
57 |
// uint8_t reserved |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
58 |
// uint32_t PacketNo, Password, ErrorCode |
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 |
//#define DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
61 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
62 |
/*****************************************************************************/ |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
63 |
|
1416 | 64 |
/** FoE OpCodes. |
65 |
*/ |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
66 |
enum { |
1416 | 67 |
EC_FOE_OPCODE_RRQ = 1, /**< Read request. */ |
68 |
EC_FOE_OPCODE_WRQ = 2, /**< Write request. */ |
|
69 |
EC_FOE_OPCODE_DATA = 3, /**< Data. */ |
|
70 |
EC_FOE_OPCODE_ACK = 4, /**< Acknowledge. */ |
|
71 |
EC_FOE_OPCODE_ERR = 5, /**< Error. */ |
|
72 |
EC_FOE_OPCODE_BUSY = 6 /**< Busy. */ |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
73 |
} ec_foe_opcode_t; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
74 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
75 |
/*****************************************************************************/ |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
76 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
77 |
int ec_foe_prepare_data_send(ec_fsm_foe_t *, ec_datagram_t *); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
78 |
int ec_foe_prepare_wrq_send(ec_fsm_foe_t *, ec_datagram_t *); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
79 |
int ec_foe_prepare_rrq_send(ec_fsm_foe_t *, ec_datagram_t *); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
80 |
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
|
81 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
82 |
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
|
83 |
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
|
84 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
85 |
void ec_fsm_foe_end(ec_fsm_foe_t *, ec_datagram_t *); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
86 |
void ec_fsm_foe_error(ec_fsm_foe_t *, ec_datagram_t *); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
87 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
88 |
void ec_fsm_foe_state_wrq_sent(ec_fsm_foe_t *, ec_datagram_t *); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
89 |
void ec_fsm_foe_state_rrq_sent(ec_fsm_foe_t *, ec_datagram_t *); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
90 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
91 |
void ec_fsm_foe_state_ack_check(ec_fsm_foe_t *, ec_datagram_t *); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
92 |
void ec_fsm_foe_state_ack_read(ec_fsm_foe_t *, ec_datagram_t *); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
93 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
94 |
void ec_fsm_foe_state_data_sent(ec_fsm_foe_t *, ec_datagram_t *); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
95 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
96 |
void ec_fsm_foe_state_data_check(ec_fsm_foe_t *, ec_datagram_t *); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
97 |
void ec_fsm_foe_state_data_read(ec_fsm_foe_t *, ec_datagram_t *); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
98 |
void ec_fsm_foe_state_sent_ack(ec_fsm_foe_t *, ec_datagram_t *); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
99 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
100 |
void ec_fsm_foe_write_start(ec_fsm_foe_t *, ec_datagram_t *); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
101 |
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
|
102 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
103 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
104 |
|
1901
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
105 |
/** Constructor. |
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
106 |
*/ |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
107 |
void ec_fsm_foe_init( |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
108 |
ec_fsm_foe_t *fsm /**< finite state machine */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
109 |
) |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
110 |
{ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
111 |
fsm->state = NULL; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
112 |
fsm->datagram = NULL; |
1901
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 |
|
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
115 |
/*****************************************************************************/ |
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
116 |
|
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
117 |
/** Destructor. |
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
118 |
*/ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
119 |
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
|
120 |
{ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
121 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
122 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
123 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
124 |
|
1901
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
125 |
/** Executes the current state of the state machine. |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
126 |
* |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
127 |
* \return 1, if the datagram was used, else 0. |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
128 |
*/ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
129 |
int ec_fsm_foe_exec( |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
130 |
ec_fsm_foe_t *fsm, /**< finite state machine */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
131 |
ec_datagram_t *datagram /**< Datagram to use. */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
132 |
) |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
133 |
{ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
134 |
int datagram_used = 0; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
135 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
136 |
if (fsm->datagram && |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
137 |
(fsm->datagram->state == EC_DATAGRAM_INIT || |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
138 |
fsm->datagram->state == EC_DATAGRAM_QUEUED || |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
139 |
fsm->datagram->state == EC_DATAGRAM_SENT)) { |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
140 |
// datagram not received yet |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
141 |
return datagram_used; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
142 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
143 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
144 |
fsm->state(fsm, datagram); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
145 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
146 |
datagram_used = |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
147 |
fsm->state != ec_fsm_foe_end && fsm->state != ec_fsm_foe_error; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
148 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
149 |
if (datagram_used) { |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
150 |
fsm->datagram = datagram; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
151 |
} else { |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
152 |
fsm->datagram = NULL; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
153 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
154 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
155 |
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
|
156 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
157 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
158 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
159 |
|
1901
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
160 |
/** 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
|
161 |
* \return non-zero if successful. |
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
162 |
*/ |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
163 |
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
|
164 |
{ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
165 |
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
|
166 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
167 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
168 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
169 |
|
1465 | 170 |
/** Prepares an FoE transfer. |
171 |
*/ |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
172 |
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
|
173 |
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
|
174 |
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
|
175 |
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
|
176 |
) |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
177 |
{ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
178 |
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
|
179 |
fsm->request = request; |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
180 |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
181 |
if (request->dir == EC_DIR_OUTPUT) { |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
182 |
fsm->tx_buffer = fsm->request->buffer; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
183 |
fsm->tx_buffer_size = fsm->request->data_size; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
184 |
fsm->tx_buffer_offset = 0; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
185 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
186 |
fsm->tx_filename = fsm->request->file_name; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
187 |
fsm->tx_filename_len = strlen(fsm->tx_filename); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
188 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
189 |
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
|
190 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
191 |
else { |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
192 |
fsm->rx_buffer = fsm->request->buffer; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
193 |
fsm->rx_buffer_size = fsm->request->buffer_size; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
194 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
195 |
fsm->rx_filename = fsm->request->file_name; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
196 |
fsm->rx_filename_len = strlen(fsm->rx_filename); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
197 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
198 |
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
|
199 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
200 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
201 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
202 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
203 |
|
1901
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
204 |
/** State: ERROR. |
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
205 |
*/ |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
206 |
void ec_fsm_foe_error( |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
207 |
ec_fsm_foe_t *fsm, /**< finite state machine */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
208 |
ec_datagram_t *datagram /**< Datagram to use. */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
209 |
) |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
210 |
{ |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
211 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
212 |
printk("ec_fsm_foe_error()\n"); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
213 |
#endif |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
214 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
215 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
216 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
217 |
|
1901
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
218 |
/** State: END. |
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
219 |
*/ |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
220 |
void ec_fsm_foe_end( |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
221 |
ec_fsm_foe_t *fsm, /**< finite state machine */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
222 |
ec_datagram_t *datagram /**< Datagram to use. */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
223 |
) |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
224 |
{ |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
225 |
#ifdef DEBUG_FOE |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
226 |
printk("ec_fsm_foe_end\n"); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
227 |
#endif |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
228 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
229 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
230 |
/*****************************************************************************/ |
1901
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
231 |
|
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
232 |
/** Sends a file or the next fragment. |
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
233 |
*/ |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
234 |
int ec_foe_prepare_data_send( |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
235 |
ec_fsm_foe_t *fsm, |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
236 |
ec_datagram_t *datagram /**< Datagram to use. */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
237 |
) |
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
238 |
{ |
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
239 |
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
|
240 |
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
|
241 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
242 |
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
|
243 |
|
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
|
244 |
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
|
245 |
- 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
|
246 |
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
|
247 |
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
|
248 |
} 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
|
249 |
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
|
250 |
- 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
|
251 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
252 |
|
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
253 |
data = ec_slave_mbox_prepare_send(fsm->slave, |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
254 |
datagram, EC_MBOX_TYPE_FILEACCESS, |
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
255 |
current_size + EC_FOE_HEADER_SIZE); |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
256 |
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
|
257 |
return -1; |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
258 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
259 |
|
2501
64cdc3b59d25
Fixed FoE data opcode, thanks to R. Roesch.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
260 |
EC_WRITE_U16(data, EC_FOE_OPCODE_DATA); // OpCode = DataBlock req. |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
261 |
EC_WRITE_U32(data + 2, fsm->tx_packet_no); // PacketNo, Password |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
262 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
263 |
memcpy(data + EC_FOE_HEADER_SIZE, |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
264 |
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
|
265 |
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
|
266 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
267 |
return 0; |
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 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
270 |
/*****************************************************************************/ |
1901
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
271 |
|
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
272 |
/** Prepare a write request (WRQ) with filename |
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
273 |
*/ |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
274 |
int ec_foe_prepare_wrq_send( |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
275 |
ec_fsm_foe_t *fsm, /**< Finite state machine. */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
276 |
ec_datagram_t *datagram /**< Datagram to use. */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
277 |
) |
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
278 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
279 |
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
|
280 |
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
|
281 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
282 |
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
|
283 |
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
|
284 |
fsm->tx_packet_no = 0; |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
285 |
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
|
286 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
287 |
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
|
288 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
289 |
data = ec_slave_mbox_prepare_send(fsm->slave, datagram, |
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
290 |
EC_MBOX_TYPE_FILEACCESS, current_size + EC_FOE_HEADER_SIZE); |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
291 |
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
|
292 |
return -1; |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
293 |
} |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
294 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
295 |
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
|
296 |
EC_WRITE_U32( data + 2, 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
|
297 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
298 |
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
|
299 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
300 |
return 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
301 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
302 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
303 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
304 |
|
1465 | 305 |
/** Initializes the FoE write state machine. |
306 |
*/ |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
307 |
void ec_fsm_foe_write_start( |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
308 |
ec_fsm_foe_t *fsm, /**< finite state machine */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
309 |
ec_datagram_t *datagram /**< Datagram to use. */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
310 |
) |
1335
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 |
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
|
313 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
314 |
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
|
315 |
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
|
316 |
fsm->tx_packet_no = 0; |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
317 |
fsm->tx_last_packet = 0; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
318 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
319 |
#ifdef DEBUG_FOE |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
320 |
printk("ec_fsm_foe_write_start()\n"); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
321 |
#endif |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
322 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
323 |
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
|
324 |
ec_foe_set_tx_error(fsm, FOE_MBOX_PROT_ERROR); |
1921 | 325 |
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
|
326 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
327 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
328 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
329 |
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
|
330 |
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
|
331 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
332 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
333 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
334 |
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
|
335 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
336 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
337 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
338 |
|
1465 | 339 |
/** Check for acknowledge. |
340 |
*/ |
|
341 |
void ec_fsm_foe_state_ack_check( |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
342 |
ec_fsm_foe_t *fsm, /**< FoE statemachine. */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
343 |
ec_datagram_t *datagram /**< Datagram to use. */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
344 |
) |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
345 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
346 |
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
|
347 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
348 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
349 |
printk("ec_fsm_foe_ack_check()\n"); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
350 |
#endif |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
351 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
352 |
if (fsm->datagram->state != EC_DATAGRAM_RECEIVED) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
353 |
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
1921 | 354 |
EC_SLAVE_ERR(slave, "Failed to receive FoE mailbox check datagram: "); |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
355 |
ec_datagram_print_state(fsm->datagram); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
356 |
return; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
357 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
358 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
359 |
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
|
360 |
ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
1921 | 361 |
EC_SLAVE_ERR(slave, "Reception of FoE mailbox check datagram" |
362 |
" failed: "); |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
363 |
ec_datagram_print_wc_error(fsm->datagram); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
364 |
return; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
365 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
366 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
367 |
if (!ec_slave_mbox_check(fsm->datagram)) { |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
368 |
// 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
|
369 |
unsigned long diff_ms = |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
370 |
(datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
371 |
if (diff_ms >= EC_FSM_FOE_TIMEOUT) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
372 |
ec_foe_set_tx_error(fsm, FOE_TIMEOUT_ERROR); |
1921 | 373 |
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
|
374 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
375 |
} |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
376 |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
377 |
ec_slave_mbox_prepare_check(slave, datagram); // can not fail. |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
378 |
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
|
379 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
380 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
381 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
382 |
// Fetch response |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
383 |
ec_slave_mbox_prepare_fetch(slave, datagram); // can not fail. |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
384 |
|
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 |
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
|
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 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
390 |
|
1465 | 391 |
/** Acknowledge a read operation. |
392 |
*/ |
|
393 |
void ec_fsm_foe_state_ack_read( |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
394 |
ec_fsm_foe_t *fsm, /**< FoE statemachine. */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
395 |
ec_datagram_t *datagram /**< Datagram to use. */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
396 |
) |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
397 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
398 |
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
|
399 |
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
|
400 |
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
|
401 |
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
|
402 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
403 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
404 |
printk("ec_fsm_foe_ack_read()\n"); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
405 |
#endif |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
406 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
407 |
if (fsm->datagram->state != EC_DATAGRAM_RECEIVED) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
408 |
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
1921 | 409 |
EC_SLAVE_ERR(slave, "Failed to receive FoE ack response datagram: "); |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
410 |
ec_datagram_print_state(fsm->datagram); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
411 |
return; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
412 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
413 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
414 |
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
|
415 |
ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
1921 | 416 |
EC_SLAVE_ERR(slave, "Reception of FoE ack response failed: "); |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
417 |
ec_datagram_print_wc_error(fsm->datagram); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
418 |
return; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
419 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
420 |
|
2502
906ef8b1c0ec
FoE datagram / fsm->datagram bugfix, thanks to R. Roesch.
Florian Pose <fp@igh-essen.com>
parents:
2501
diff
changeset
|
421 |
data = ec_slave_mbox_fetch(slave, fsm->datagram, &mbox_prot, &rec_size); |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
422 |
if (IS_ERR(data)) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
423 |
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
|
424 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
425 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
426 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
427 |
if (mbox_prot != EC_MBOX_TYPE_FILEACCESS) { // FoE |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
428 |
ec_foe_set_tx_error(fsm, FOE_MBOX_PROT_ERROR); |
1921 | 429 |
EC_SLAVE_ERR(slave, "Received mailbox protocol 0x%02X as response.\n", |
430 |
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
|
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 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
434 |
opCode = EC_READ_U8(data); |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
435 |
|
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
436 |
if (opCode == EC_FOE_OPCODE_BUSY) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
437 |
// slave not ready |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
438 |
if (ec_foe_prepare_data_send(fsm, datagram)) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
439 |
ec_foe_set_tx_error(fsm, FOE_PROT_ERROR); |
1921 | 440 |
EC_SLAVE_ERR(slave, "Slave is busy.\n"); |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
441 |
return; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
442 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
443 |
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
|
444 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
445 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
446 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
447 |
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
|
448 |
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
|
449 |
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
|
450 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
451 |
if (fsm->tx_last_packet) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
452 |
fsm->state = ec_fsm_foe_end; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
453 |
return; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
454 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
455 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
456 |
if (ec_foe_prepare_data_send(fsm, datagram)) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
457 |
ec_foe_set_tx_error(fsm, FOE_PROT_ERROR); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
458 |
return; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
459 |
} |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
460 |
fsm->state = ec_fsm_foe_state_data_sent; |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
461 |
return; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
462 |
} |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
463 |
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
|
464 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
465 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
466 |
/*****************************************************************************/ |
1465 | 467 |
|
468 |
/** State: WRQ SENT. |
|
469 |
* |
|
470 |
* Checks is the previous transmit datagram succeded and sends the next |
|
471 |
* fragment, if necessary. |
|
472 |
*/ |
|
473 |
void ec_fsm_foe_state_wrq_sent( |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
474 |
ec_fsm_foe_t *fsm, /**< FoE statemachine. */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
475 |
ec_datagram_t *datagram /**< Datagram to use. */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
476 |
) |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
477 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
478 |
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
|
479 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
480 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
481 |
printk("ec_foe_state_sent_wrq()\n"); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
482 |
#endif |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
483 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
484 |
if (fsm->datagram->state != EC_DATAGRAM_RECEIVED) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
485 |
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
1921 | 486 |
EC_SLAVE_ERR(slave, "Failed to send FoE WRQ: "); |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
487 |
ec_datagram_print_state(fsm->datagram); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
488 |
return; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
489 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
490 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
491 |
if (fsm->datagram->working_counter != 1) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
492 |
// 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
|
493 |
ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
1921 | 494 |
EC_SLAVE_ERR(slave, "Reception of FoE WRQ failed: "); |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
495 |
ec_datagram_print_wc_error(fsm->datagram); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
496 |
return; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
497 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
498 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
499 |
fsm->jiffies_start = fsm->datagram->jiffies_sent; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
500 |
|
2502
906ef8b1c0ec
FoE datagram / fsm->datagram bugfix, thanks to R. Roesch.
Florian Pose <fp@igh-essen.com>
parents:
2501
diff
changeset
|
501 |
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
|
502 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
503 |
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
|
504 |
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
|
505 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
506 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
507 |
/*****************************************************************************/ |
1465 | 508 |
|
509 |
/** State: WRQ SENT. |
|
510 |
* |
|
511 |
* Checks is the previous transmit datagram succeded and sends the next |
|
512 |
* fragment, if necessary. |
|
513 |
*/ |
|
514 |
void ec_fsm_foe_state_data_sent( |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
515 |
ec_fsm_foe_t *fsm, /**< Foe statemachine. */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
516 |
ec_datagram_t *datagram /**< Datagram to use. */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
517 |
) |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
518 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
519 |
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
|
520 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
521 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
522 |
printk("ec_fsm_foe_state_data_sent()\n"); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
523 |
#endif |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
524 |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
525 |
if (fsm->datagram->state != EC_DATAGRAM_RECEIVED) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
526 |
ec_foe_set_tx_error(fsm, FOE_RECEIVE_ERROR); |
1921 | 527 |
EC_SLAVE_ERR(slave, "Failed to receive FoE ack response datagram: "); |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
528 |
ec_datagram_print_state(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
|
529 |
return; |
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 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
532 |
if (fsm->datagram->working_counter != 1) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
533 |
ec_foe_set_tx_error(fsm, FOE_WC_ERROR); |
1921 | 534 |
EC_SLAVE_ERR(slave, "Reception of FoE data send failed: "); |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
535 |
ec_datagram_print_wc_error(fsm->datagram); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
536 |
return; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
537 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
538 |
|
2502
906ef8b1c0ec
FoE datagram / fsm->datagram bugfix, thanks to R. Roesch.
Florian Pose <fp@igh-essen.com>
parents:
2501
diff
changeset
|
539 |
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
|
540 |
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
|
541 |
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
|
542 |
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
|
543 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
544 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
545 |
/*****************************************************************************/ |
1901
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
546 |
|
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
547 |
/** Prepare a read request (RRQ) with filename |
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
548 |
*/ |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
549 |
int ec_foe_prepare_rrq_send( |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
550 |
ec_fsm_foe_t *fsm, /**< Finite state machine. */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
551 |
ec_datagram_t *datagram /**< Datagram to use. */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
552 |
) |
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
553 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
554 |
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
|
555 |
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
|
556 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
557 |
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
|
558 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
559 |
data = ec_slave_mbox_prepare_send(fsm->slave, datagram, |
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
560 |
EC_MBOX_TYPE_FILEACCESS, current_size + EC_FOE_HEADER_SIZE); |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
561 |
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
|
562 |
return -1; |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
563 |
} |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
564 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
565 |
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
|
566 |
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
|
567 |
memcpy(data + EC_FOE_HEADER_SIZE, fsm->rx_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
|
568 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
569 |
if (fsm->slave->master->debug_level) { |
1921 | 570 |
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
|
571 |
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
|
572 |
} |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
573 |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
574 |
return 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
575 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
576 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
577 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
578 |
|
1465 | 579 |
/** Prepare to send an acknowledge. |
580 |
*/ |
|
581 |
int ec_foe_prepare_send_ack( |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
582 |
ec_fsm_foe_t *fsm, /**< FoE statemachine. */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
583 |
ec_datagram_t *datagram /**< Datagram to use. */ |
1465 | 584 |
) |
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
585 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
586 |
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
|
587 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
588 |
data = ec_slave_mbox_prepare_send(fsm->slave, datagram, |
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
589 |
EC_MBOX_TYPE_FILEACCESS, EC_FOE_HEADER_SIZE); |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
590 |
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
|
591 |
return -1; |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
592 |
} |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
593 |
|
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
594 |
EC_WRITE_U16(data, EC_FOE_OPCODE_ACK); |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
595 |
EC_WRITE_U32(data + 2, 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
|
596 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
597 |
return 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
598 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
599 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
600 |
/*****************************************************************************/ |
1465 | 601 |
|
602 |
/** State: RRQ SENT. |
|
603 |
* |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
604 |
* Checks is the previous transmit datagram succeeded and sends the next |
1465 | 605 |
* fragment, if necessary. |
606 |
*/ |
|
607 |
void ec_fsm_foe_state_rrq_sent( |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
608 |
ec_fsm_foe_t *fsm, /**< FoE statemachine. */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
609 |
ec_datagram_t *datagram /**< Datagram to use. */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
610 |
) |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
611 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
612 |
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
|
613 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
614 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
615 |
printk("ec_foe_state_rrq_sent()\n"); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
616 |
#endif |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
617 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
618 |
if (fsm->datagram->state != EC_DATAGRAM_RECEIVED) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
619 |
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
1921 | 620 |
EC_SLAVE_ERR(slave, "Failed to send FoE RRQ: "); |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
621 |
ec_datagram_print_state(fsm->datagram); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
622 |
return; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
623 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
624 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
625 |
if (fsm->datagram->working_counter != 1) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
626 |
// 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
|
627 |
ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
1921 | 628 |
EC_SLAVE_ERR(slave, "Reception of FoE RRQ failed: "); |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
629 |
ec_datagram_print_wc_error(fsm->datagram); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
630 |
return; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
631 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
632 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
633 |
fsm->jiffies_start = fsm->datagram->jiffies_sent; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
634 |
|
2502
906ef8b1c0ec
FoE datagram / fsm->datagram bugfix, thanks to R. Roesch.
Florian Pose <fp@igh-essen.com>
parents:
2501
diff
changeset
|
635 |
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
|
636 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
637 |
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
|
638 |
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
|
639 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
640 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
641 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
642 |
|
1465 | 643 |
/** Starting state for read operations. |
644 |
*/ |
|
645 |
void ec_fsm_foe_read_start( |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
646 |
ec_fsm_foe_t *fsm, /**< FoE statemachine. */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
647 |
ec_datagram_t *datagram /**< Datagram to use. */ |
1465 | 648 |
) |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
649 |
{ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
650 |
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
|
651 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
652 |
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
|
653 |
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
|
654 |
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
|
655 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
656 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
657 |
printk("ec_fsm_foe_read_start()\n"); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
658 |
#endif |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
659 |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
660 |
if (!(slave->sii.mailbox_protocols & EC_MBOX_FOE)) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
661 |
ec_foe_set_tx_error(fsm, FOE_MBOX_PROT_ERROR); |
1921 | 662 |
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
|
663 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
664 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
665 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
666 |
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
|
667 |
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
|
668 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
669 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
670 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
671 |
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
|
672 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
673 |
|
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 |
|
1465 | 676 |
/** Check for data. |
677 |
*/ |
|
678 |
void ec_fsm_foe_state_data_check( |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
679 |
ec_fsm_foe_t *fsm, /**< FoE statemachine. */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
680 |
ec_datagram_t *datagram /**< Datagram to use. */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
681 |
) |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
682 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
683 |
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
|
684 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
685 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
686 |
printk("ec_fsm_foe_state_data_check()\n"); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
687 |
#endif |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
688 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
689 |
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
|
690 |
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
1921 | 691 |
EC_SLAVE_ERR(slave, "Failed to send FoE DATA READ: "); |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
692 |
ec_datagram_print_state(fsm->datagram); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
693 |
return; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
694 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
695 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
696 |
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
|
697 |
ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
1921 | 698 |
EC_SLAVE_ERR(slave, "Reception of FoE DATA READ: "); |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
699 |
ec_datagram_print_wc_error(fsm->datagram); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
700 |
return; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
701 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
702 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
703 |
if (!ec_slave_mbox_check(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
|
704 |
unsigned long diff_ms = |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
705 |
(fsm->datagram->jiffies_received - fsm->jiffies_start) * |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
706 |
1000 / HZ; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
707 |
if (diff_ms >= EC_FSM_FOE_TIMEOUT) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
708 |
ec_foe_set_tx_error(fsm, FOE_TIMEOUT_ERROR); |
1921 | 709 |
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
|
710 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
711 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
712 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
713 |
ec_slave_mbox_prepare_check(slave, datagram); // can not fail. |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
714 |
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
|
715 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
716 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
717 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
718 |
// Fetch response |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
719 |
ec_slave_mbox_prepare_fetch(slave, datagram); // can not fail. |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
720 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
721 |
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
|
722 |
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
|
723 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
724 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
725 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
726 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
727 |
|
1465 | 728 |
/** Start reading data. |
729 |
*/ |
|
730 |
void ec_fsm_foe_state_data_read( |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
731 |
ec_fsm_foe_t *fsm, /**< FoE statemachine. */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
732 |
ec_datagram_t *datagram /**< Datagram to use. */ |
1465 | 733 |
) |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
734 |
{ |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
735 |
size_t rec_size; |
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
736 |
uint8_t *data, opCode, packet_no, 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
|
737 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
738 |
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
|
739 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
740 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
741 |
printk("ec_fsm_foe_state_data_read()\n"); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
742 |
#endif |
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
743 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
744 |
if (fsm->datagram->state != EC_DATAGRAM_RECEIVED) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
745 |
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
1921 | 746 |
EC_SLAVE_ERR(slave, "Failed to receive FoE DATA READ datagram: "); |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
747 |
ec_datagram_print_state(fsm->datagram); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
748 |
return; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
749 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
750 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
751 |
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
|
752 |
ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
1921 | 753 |
EC_SLAVE_ERR(slave, "Reception of FoE DATA READ failed: "); |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
754 |
ec_datagram_print_wc_error(fsm->datagram); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
755 |
return; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
756 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
757 |
|
2502
906ef8b1c0ec
FoE datagram / fsm->datagram bugfix, thanks to R. Roesch.
Florian Pose <fp@igh-essen.com>
parents:
2501
diff
changeset
|
758 |
data = ec_slave_mbox_fetch(slave, fsm->datagram, &mbox_prot, &rec_size); |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
759 |
if (IS_ERR(data)) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
760 |
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
|
761 |
return; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
762 |
} |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
763 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
764 |
if (mbox_prot != EC_MBOX_TYPE_FILEACCESS) { // FoE |
1921 | 765 |
EC_SLAVE_ERR(slave, "Received mailbox protocol 0x%02X as response.\n", |
766 |
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
|
767 |
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
|
768 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
769 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
770 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
771 |
opCode = EC_READ_U8(data); |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
772 |
|
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
773 |
if (opCode == EC_FOE_OPCODE_BUSY) { |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
774 |
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
|
775 |
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
|
776 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
777 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
778 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
779 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
780 |
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
|
781 |
fsm->request->error_code = EC_READ_U32(data + 2); |
1921 | 782 |
EC_SLAVE_ERR(slave, "Received FoE Error Request (code 0x%08x).\n", |
783 |
fsm->request->error_code); |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
784 |
if (rec_size > 6) { |
2257
a2a675601c98
Decreased maximum length of error message to avoid stack warning.
Florian Pose <fp@igh-essen.com>
parents:
2235
diff
changeset
|
785 |
uint8_t text[256]; |
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
786 |
strncpy(text, data + 6, min(rec_size - 6, sizeof(text))); |
1921 | 787 |
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
|
788 |
} |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
789 |
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
|
790 |
return; |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
791 |
} |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
792 |
|
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
793 |
if (opCode != EC_FOE_OPCODE_DATA) { |
1921 | 794 |
EC_SLAVE_ERR(slave, "Received OPCODE %x, expected %x.\n", |
795 |
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
|
796 |
fsm->request->error_code = 0x00000000; |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
797 |
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
|
798 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
799 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
800 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
801 |
packet_no = EC_READ_U16(data + 2); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
802 |
if (packet_no != fsm->rx_expected_packet_no) { |
1921 | 803 |
EC_SLAVE_ERR(slave, "Received unexpected packet number.\n"); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
804 |
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
|
805 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
806 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
807 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
808 |
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
|
809 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
810 |
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
|
811 |
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
|
812 |
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
|
813 |
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
|
814 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
815 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
816 |
fsm->rx_last_packet = |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
817 |
(rec_size + EC_MBOX_HEADER_SIZE + EC_FOE_HEADER_SIZE |
2502
906ef8b1c0ec
FoE datagram / fsm->datagram bugfix, thanks to R. Roesch.
Florian Pose <fp@igh-essen.com>
parents:
2501
diff
changeset
|
818 |
!= 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
|
819 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
820 |
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
|
821 |
(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
|
822 |
- EC_FOE_HEADER_SIZE + fsm->rx_buffer_offset) |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
823 |
<= fsm->rx_buffer_size) { |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
824 |
// 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
|
825 |
// delivered buffer |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
826 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
827 |
printk ("last_packet=true\n"); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
828 |
#endif |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
829 |
if (ec_foe_prepare_send_ack(fsm, datagram)) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
830 |
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
|
831 |
return; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
832 |
} |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
833 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
834 |
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
|
835 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
836 |
else { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
837 |
// no more data fits into the delivered buffer |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
838 |
// ... wait for new read request |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
839 |
printk ("ERROR: data doesn't fit in receive buffer\n"); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
840 |
printk (" rx_buffer_size = %d\n", fsm->rx_buffer_size); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
841 |
printk (" rx_buffer_offset= %d\n", fsm->rx_buffer_offset); |
1543
373cd456dc26
Avoid warnings on x86_64 platform. Thanks to Thomas Elste.
Florian Pose <fp@igh-essen.com>
parents:
1465
diff
changeset
|
842 |
printk (" rec_size = %zd\n", rec_size); |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
843 |
printk (" rx_mailbox_size = %d\n", |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
844 |
slave->configured_rx_mailbox_size); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
845 |
printk (" rx_last_packet = %d\n", fsm->rx_last_packet); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
846 |
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
|
847 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
848 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
849 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
850 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
851 |
|
1465 | 852 |
/** Sent an acknowledge. |
853 |
*/ |
|
854 |
void ec_fsm_foe_state_sent_ack( |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
855 |
ec_fsm_foe_t *fsm, /**< FoE statemachine. */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
856 |
ec_datagram_t *datagram /**< Datagram to use. */ |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
857 |
) |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
858 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
859 |
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
|
860 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
861 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
862 |
printk("ec_foe_state_sent_ack()\n"); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
863 |
#endif |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
864 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
865 |
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
|
866 |
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
1921 | 867 |
EC_SLAVE_ERR(slave, "Failed to send FoE ACK: "); |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
868 |
ec_datagram_print_state(fsm->datagram); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
869 |
return; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
870 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
871 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
872 |
if (fsm->datagram->working_counter != 1) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
873 |
// 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
|
874 |
ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
1921 | 875 |
EC_SLAVE_ERR(slave, "Reception of FoE ACK failed: "); |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
876 |
ec_datagram_print_wc_error(fsm->datagram); |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
877 |
return; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
878 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
879 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
880 |
fsm->jiffies_start = fsm->datagram->jiffies_sent; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
881 |
|
2502
906ef8b1c0ec
FoE datagram / fsm->datagram bugfix, thanks to R. Roesch.
Florian Pose <fp@igh-essen.com>
parents:
2501
diff
changeset
|
882 |
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
|
883 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
884 |
if (fsm->rx_last_packet) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
885 |
fsm->rx_expected_packet_no = 0; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
886 |
fsm->request->data_size = fsm->rx_buffer_offset; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
887 |
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
|
888 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
889 |
else { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
890 |
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
|
891 |
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
|
892 |
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
|
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 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
896 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
897 |
|
1465 | 898 |
/** Set an error code and go to the send error state. |
899 |
*/ |
|
900 |
void ec_foe_set_tx_error( |
|
901 |
ec_fsm_foe_t *fsm, /**< FoE statemachine. */ |
|
902 |
uint32_t errorcode /**< FoE error code. */ |
|
903 |
) |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
904 |
{ |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
905 |
fsm->request->result = errorcode; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
906 |
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
|
907 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
908 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
909 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
910 |
|
1465 | 911 |
/** Set an error code and go to the receive error state. |
912 |
*/ |
|
913 |
void ec_foe_set_rx_error( |
|
914 |
ec_fsm_foe_t *fsm, /**< FoE statemachine. */ |
|
915 |
uint32_t errorcode /**< FoE error code. */ |
|
916 |
) |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
917 |
{ |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
918 |
fsm->request->result = errorcode; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
919 |
fsm->state = ec_fsm_foe_error; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
920 |
} |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
921 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
922 |
/*****************************************************************************/ |