author | Patrick Bruenn <p.bruenn@beckhoff.com> |
Wed, 23 Apr 2014 13:15:10 +0200 | |
branch | stable-1.5 |
changeset 2552 | 6e419c23b1b3 |
parent 2522 | ec403cf308eb |
child 2527 | f51f3ef3260d |
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. |
2522
ec403cf308eb
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2502
diff
changeset
|
233 |
* |
ec403cf308eb
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2502
diff
changeset
|
234 |
* \return Zero on success, otherwise a negative error code. |
1901
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
235 |
*/ |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
236 |
int ec_foe_prepare_data_send( |
2522
ec403cf308eb
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2502
diff
changeset
|
237 |
ec_fsm_foe_t *fsm, /**< Finite state machine. */ |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
238 |
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
|
239 |
) |
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
240 |
{ |
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
241 |
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
|
242 |
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
|
243 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
244 |
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
|
245 |
|
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
|
246 |
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
|
247 |
- 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
|
248 |
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
|
249 |
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
|
250 |
} 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
|
251 |
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
|
252 |
- 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
|
253 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
254 |
|
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
255 |
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
|
256 |
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
|
257 |
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
|
258 |
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
|
259 |
return -1; |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
260 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
261 |
|
2501
64cdc3b59d25
Fixed FoE data opcode, thanks to R. Roesch.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
262 |
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
|
263 |
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
|
264 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
265 |
memcpy(data + EC_FOE_HEADER_SIZE, |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
266 |
fsm->tx_buffer + fsm->tx_buffer_offset, current_size); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
267 |
fsm->tx_current_size = current_size; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
268 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
269 |
return 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
270 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
271 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
272 |
/*****************************************************************************/ |
1901
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
273 |
|
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
274 |
/** Prepare a write request (WRQ) with filename |
2522
ec403cf308eb
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2502
diff
changeset
|
275 |
* |
ec403cf308eb
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2502
diff
changeset
|
276 |
* \return Zero on success, otherwise a negative error code. |
1901
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
277 |
*/ |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
278 |
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
|
279 |
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
|
280 |
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
|
281 |
) |
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
282 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
283 |
size_t current_size; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
284 |
uint8_t *data; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
285 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
286 |
fsm->tx_buffer_offset = 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
287 |
fsm->tx_current_size = 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
288 |
fsm->tx_packet_no = 0; |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
289 |
fsm->tx_last_packet = 0; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
290 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
291 |
current_size = fsm->tx_filename_len; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
292 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
293 |
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
|
294 |
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
|
295 |
if (IS_ERR(data)) { |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
296 |
return -1; |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
297 |
} |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
298 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
299 |
EC_WRITE_U16( data, EC_FOE_OPCODE_WRQ); // fsm write request |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
300 |
EC_WRITE_U32( data + 2, fsm->tx_packet_no ); |
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 |
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
|
303 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
304 |
return 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
305 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
306 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
307 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
308 |
|
1465 | 309 |
/** Initializes the FoE write state machine. |
310 |
*/ |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
311 |
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
|
312 |
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
|
313 |
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
|
314 |
) |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
315 |
{ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
316 |
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
|
317 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
318 |
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
|
319 |
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
|
320 |
fsm->tx_packet_no = 0; |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
321 |
fsm->tx_last_packet = 0; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
322 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
323 |
#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
|
324 |
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
|
325 |
#endif |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
326 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
327 |
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
|
328 |
ec_foe_set_tx_error(fsm, FOE_MBOX_PROT_ERROR); |
1921 | 329 |
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
|
330 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
331 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
332 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
333 |
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
|
334 |
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
|
335 |
return; |
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 |
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
|
339 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
340 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
341 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
342 |
|
1465 | 343 |
/** Check for acknowledge. |
344 |
*/ |
|
345 |
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
|
346 |
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
|
347 |
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
|
348 |
) |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
349 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
350 |
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
|
351 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
352 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
353 |
printk("ec_fsm_foe_ack_check()\n"); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
354 |
#endif |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
355 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
356 |
if (fsm->datagram->state != EC_DATAGRAM_RECEIVED) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
357 |
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
1921 | 358 |
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
|
359 |
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
|
360 |
return; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
361 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
362 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
363 |
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
|
364 |
ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
1921 | 365 |
EC_SLAVE_ERR(slave, "Reception of FoE mailbox check datagram" |
366 |
" failed: "); |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
367 |
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
|
368 |
return; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
369 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
370 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
371 |
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
|
372 |
// 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
|
373 |
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
|
374 |
(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
|
375 |
if (diff_ms >= EC_FSM_FOE_TIMEOUT) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
376 |
ec_foe_set_tx_error(fsm, FOE_TIMEOUT_ERROR); |
1921 | 377 |
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
|
378 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
379 |
} |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
380 |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
381 |
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
|
382 |
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
|
383 |
return; |
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 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
386 |
// Fetch response |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
387 |
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
|
388 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
389 |
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
|
390 |
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
|
391 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
392 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
393 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
394 |
|
1465 | 395 |
/** Acknowledge a read operation. |
396 |
*/ |
|
397 |
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
|
398 |
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
|
399 |
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
|
400 |
) |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
401 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
402 |
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
|
403 |
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
|
404 |
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
|
405 |
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
|
406 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
407 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
408 |
printk("ec_fsm_foe_ack_read()\n"); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
409 |
#endif |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
410 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
411 |
if (fsm->datagram->state != EC_DATAGRAM_RECEIVED) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
412 |
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
1921 | 413 |
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
|
414 |
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
|
415 |
return; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
416 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
417 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
418 |
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
|
419 |
ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
1921 | 420 |
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
|
421 |
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
|
422 |
return; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
423 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
424 |
|
2502
906ef8b1c0ec
FoE datagram / fsm->datagram bugfix, thanks to R. Roesch.
Florian Pose <fp@igh-essen.com>
parents:
2501
diff
changeset
|
425 |
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
|
426 |
if (IS_ERR(data)) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
427 |
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
|
428 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
429 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
430 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
431 |
if (mbox_prot != EC_MBOX_TYPE_FILEACCESS) { // FoE |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
432 |
ec_foe_set_tx_error(fsm, FOE_MBOX_PROT_ERROR); |
1921 | 433 |
EC_SLAVE_ERR(slave, "Received mailbox protocol 0x%02X as response.\n", |
434 |
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
|
435 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
436 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
437 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
438 |
opCode = EC_READ_U8(data); |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
439 |
|
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
440 |
if (opCode == EC_FOE_OPCODE_BUSY) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
441 |
// slave not ready |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
442 |
if (ec_foe_prepare_data_send(fsm, datagram)) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
443 |
ec_foe_set_tx_error(fsm, FOE_PROT_ERROR); |
1921 | 444 |
EC_SLAVE_ERR(slave, "Slave is busy.\n"); |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
445 |
return; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
446 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
447 |
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
|
448 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
449 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
450 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
451 |
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
|
452 |
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
|
453 |
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
|
454 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
455 |
if (fsm->tx_last_packet) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
456 |
fsm->state = ec_fsm_foe_end; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
457 |
return; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
458 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
459 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
460 |
if (ec_foe_prepare_data_send(fsm, datagram)) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
461 |
ec_foe_set_tx_error(fsm, FOE_PROT_ERROR); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
462 |
return; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
463 |
} |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
464 |
fsm->state = ec_fsm_foe_state_data_sent; |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
465 |
return; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
466 |
} |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
467 |
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
|
468 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
469 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
470 |
/*****************************************************************************/ |
1465 | 471 |
|
472 |
/** State: WRQ SENT. |
|
473 |
* |
|
474 |
* Checks is the previous transmit datagram succeded and sends the next |
|
475 |
* fragment, if necessary. |
|
476 |
*/ |
|
477 |
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
|
478 |
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
|
479 |
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
|
480 |
) |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
481 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
482 |
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
|
483 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
484 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
485 |
printk("ec_foe_state_sent_wrq()\n"); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
486 |
#endif |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
487 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
488 |
if (fsm->datagram->state != EC_DATAGRAM_RECEIVED) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
489 |
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
1921 | 490 |
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
|
491 |
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
|
492 |
return; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
493 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
494 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
495 |
if (fsm->datagram->working_counter != 1) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
496 |
// 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
|
497 |
ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
1921 | 498 |
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
|
499 |
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
|
500 |
return; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
501 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
502 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
503 |
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
|
504 |
|
2502
906ef8b1c0ec
FoE datagram / fsm->datagram bugfix, thanks to R. Roesch.
Florian Pose <fp@igh-essen.com>
parents:
2501
diff
changeset
|
505 |
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
|
506 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
507 |
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
|
508 |
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
|
509 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
510 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
511 |
/*****************************************************************************/ |
1465 | 512 |
|
513 |
/** State: WRQ SENT. |
|
514 |
* |
|
515 |
* Checks is the previous transmit datagram succeded and sends the next |
|
516 |
* fragment, if necessary. |
|
517 |
*/ |
|
518 |
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
|
519 |
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
|
520 |
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
|
521 |
) |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
522 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
523 |
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
|
524 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
525 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
526 |
printk("ec_fsm_foe_state_data_sent()\n"); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
527 |
#endif |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
528 |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
529 |
if (fsm->datagram->state != EC_DATAGRAM_RECEIVED) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
530 |
ec_foe_set_tx_error(fsm, FOE_RECEIVE_ERROR); |
1921 | 531 |
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
|
532 |
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
|
533 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
534 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
535 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
536 |
if (fsm->datagram->working_counter != 1) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
537 |
ec_foe_set_tx_error(fsm, FOE_WC_ERROR); |
1921 | 538 |
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
|
539 |
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
|
540 |
return; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
541 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
542 |
|
2502
906ef8b1c0ec
FoE datagram / fsm->datagram bugfix, thanks to R. Roesch.
Florian Pose <fp@igh-essen.com>
parents:
2501
diff
changeset
|
543 |
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
|
544 |
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
|
545 |
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
|
546 |
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
|
547 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
548 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
549 |
/*****************************************************************************/ |
1901
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
550 |
|
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
551 |
/** Prepare a read request (RRQ) with filename |
2522
ec403cf308eb
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2502
diff
changeset
|
552 |
* |
ec403cf308eb
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2502
diff
changeset
|
553 |
* \return Zero on success, otherwise a negative error code. |
1901
2a1106b1d863
Documented fsm_foe members and removed unused variables.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
554 |
*/ |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
555 |
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
|
556 |
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
|
557 |
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
|
558 |
) |
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
559 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
560 |
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
|
561 |
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
|
562 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
563 |
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
|
564 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
565 |
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
|
566 |
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
|
567 |
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
|
568 |
return -1; |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
569 |
} |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
570 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
571 |
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
|
572 |
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
|
573 |
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
|
574 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
575 |
if (fsm->slave->master->debug_level) { |
1921 | 576 |
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
|
577 |
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
|
578 |
} |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
579 |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
580 |
return 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
581 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
582 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
583 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
584 |
|
1465 | 585 |
/** Prepare to send an acknowledge. |
2522
ec403cf308eb
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2502
diff
changeset
|
586 |
* |
ec403cf308eb
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
2502
diff
changeset
|
587 |
* \return Zero on success, otherwise a negative error code. |
1465 | 588 |
*/ |
589 |
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
|
590 |
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
|
591 |
ec_datagram_t *datagram /**< Datagram to use. */ |
1465 | 592 |
) |
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
593 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
594 |
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
|
595 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
596 |
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
|
597 |
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
|
598 |
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
|
599 |
return -1; |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
600 |
} |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
601 |
|
1446
85ea5af50175
Fixed usage of IS_ERR() in FoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
1416
diff
changeset
|
602 |
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
|
603 |
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
|
604 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
605 |
return 0; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
606 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
607 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
608 |
/*****************************************************************************/ |
1465 | 609 |
|
610 |
/** State: RRQ SENT. |
|
611 |
* |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
612 |
* Checks is the previous transmit datagram succeeded and sends the next |
1465 | 613 |
* fragment, if necessary. |
614 |
*/ |
|
615 |
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
|
616 |
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
|
617 |
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
|
618 |
) |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
619 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
620 |
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
|
621 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
622 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
623 |
printk("ec_foe_state_rrq_sent()\n"); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
624 |
#endif |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
625 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
626 |
if (fsm->datagram->state != EC_DATAGRAM_RECEIVED) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
627 |
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
1921 | 628 |
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
|
629 |
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
|
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 |
if (fsm->datagram->working_counter != 1) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
634 |
// 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
|
635 |
ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
1921 | 636 |
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
|
637 |
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
|
638 |
return; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
639 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
640 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
641 |
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
|
642 |
|
2502
906ef8b1c0ec
FoE datagram / fsm->datagram bugfix, thanks to R. Roesch.
Florian Pose <fp@igh-essen.com>
parents:
2501
diff
changeset
|
643 |
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
|
644 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
645 |
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
|
646 |
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
|
647 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
648 |
|
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 |
|
1465 | 651 |
/** Starting state for read operations. |
652 |
*/ |
|
653 |
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
|
654 |
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
|
655 |
ec_datagram_t *datagram /**< Datagram to use. */ |
1465 | 656 |
) |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
657 |
{ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
658 |
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
|
659 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
660 |
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
|
661 |
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
|
662 |
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
|
663 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
664 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
665 |
printk("ec_fsm_foe_read_start()\n"); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
666 |
#endif |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
667 |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
668 |
if (!(slave->sii.mailbox_protocols & EC_MBOX_FOE)) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
669 |
ec_foe_set_tx_error(fsm, FOE_MBOX_PROT_ERROR); |
1921 | 670 |
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
|
671 |
return; |
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 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
674 |
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
|
675 |
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
|
676 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
677 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
678 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
679 |
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
|
680 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
681 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
682 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
683 |
|
1465 | 684 |
/** Check for data. |
685 |
*/ |
|
686 |
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
|
687 |
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
|
688 |
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
|
689 |
) |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
690 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
691 |
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
|
692 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
693 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
694 |
printk("ec_fsm_foe_state_data_check()\n"); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
695 |
#endif |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
696 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
697 |
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
|
698 |
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
1921 | 699 |
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
|
700 |
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
|
701 |
return; |
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 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
704 |
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
|
705 |
ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
1921 | 706 |
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
|
707 |
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
|
708 |
return; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
709 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
710 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
711 |
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
|
712 |
unsigned long diff_ms = |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
713 |
(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
|
714 |
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
|
715 |
if (diff_ms >= EC_FSM_FOE_TIMEOUT) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
716 |
ec_foe_set_tx_error(fsm, FOE_TIMEOUT_ERROR); |
1921 | 717 |
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
|
718 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
719 |
} |
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 |
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
|
722 |
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
|
723 |
return; |
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 |
// Fetch response |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
727 |
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
|
728 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
729 |
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
|
730 |
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
|
731 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
732 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
733 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
734 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
735 |
|
1465 | 736 |
/** Start reading data. |
737 |
*/ |
|
738 |
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
|
739 |
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
|
740 |
ec_datagram_t *datagram /**< Datagram to use. */ |
1465 | 741 |
) |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
742 |
{ |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
743 |
size_t rec_size; |
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
744 |
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
|
745 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
746 |
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
|
747 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
748 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
749 |
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
|
750 |
#endif |
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
751 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
752 |
if (fsm->datagram->state != EC_DATAGRAM_RECEIVED) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
753 |
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
1921 | 754 |
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
|
755 |
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
|
756 |
return; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
757 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
758 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
759 |
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
|
760 |
ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
1921 | 761 |
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
|
762 |
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
|
763 |
return; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
764 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
765 |
|
2502
906ef8b1c0ec
FoE datagram / fsm->datagram bugfix, thanks to R. Roesch.
Florian Pose <fp@igh-essen.com>
parents:
2501
diff
changeset
|
766 |
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
|
767 |
if (IS_ERR(data)) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
768 |
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
|
769 |
return; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
770 |
} |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
771 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
772 |
if (mbox_prot != EC_MBOX_TYPE_FILEACCESS) { // FoE |
1921 | 773 |
EC_SLAVE_ERR(slave, "Received mailbox protocol 0x%02X as response.\n", |
774 |
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
|
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 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
777 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
778 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
779 |
opCode = EC_READ_U8(data); |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
780 |
|
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
781 |
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
|
782 |
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
|
783 |
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
|
784 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
785 |
return; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
786 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
787 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
788 |
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
|
789 |
fsm->request->error_code = EC_READ_U32(data + 2); |
1921 | 790 |
EC_SLAVE_ERR(slave, "Received FoE Error Request (code 0x%08x).\n", |
791 |
fsm->request->error_code); |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
792 |
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
|
793 |
uint8_t text[256]; |
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
794 |
strncpy(text, data + 6, min(rec_size - 6, sizeof(text))); |
1921 | 795 |
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
|
796 |
} |
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); |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
798 |
return; |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
799 |
} |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
800 |
|
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
801 |
if (opCode != EC_FOE_OPCODE_DATA) { |
1921 | 802 |
EC_SLAVE_ERR(slave, "Received OPCODE %x, expected %x.\n", |
803 |
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
|
804 |
fsm->request->error_code = 0x00000000; |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
805 |
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
|
806 |
return; |
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 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
809 |
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
|
810 |
if (packet_no != fsm->rx_expected_packet_no) { |
1921 | 811 |
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
|
812 |
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
|
813 |
return; |
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 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
816 |
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
|
817 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
818 |
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
|
819 |
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
|
820 |
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
|
821 |
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
|
822 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
823 |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
824 |
fsm->rx_last_packet = |
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
825 |
(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
|
826 |
!= 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
|
827 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
828 |
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
|
829 |
(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
|
830 |
- EC_FOE_HEADER_SIZE + fsm->rx_buffer_offset) |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
831 |
<= fsm->rx_buffer_size) { |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
832 |
// 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
|
833 |
// delivered buffer |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
834 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
835 |
printk ("last_packet=true\n"); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
836 |
#endif |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
837 |
if (ec_foe_prepare_send_ack(fsm, datagram)) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
838 |
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
|
839 |
return; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
840 |
} |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
841 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
842 |
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
|
843 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
844 |
else { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
845 |
// no more data fits into the delivered buffer |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
846 |
// ... wait for new read request |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
847 |
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
|
848 |
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
|
849 |
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
|
850 |
printk (" rec_size = %zd\n", rec_size); |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
851 |
printk (" rx_mailbox_size = %d\n", |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
852 |
slave->configured_rx_mailbox_size); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
853 |
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
|
854 |
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
|
855 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
856 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
857 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
858 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
859 |
|
1465 | 860 |
/** Sent an acknowledge. |
861 |
*/ |
|
862 |
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
|
863 |
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
|
864 |
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
|
865 |
) |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
866 |
{ |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
867 |
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
|
868 |
|
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
869 |
#ifdef DEBUG_FOE |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
870 |
printk("ec_foe_state_sent_ack()\n"); |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
871 |
#endif |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
872 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
873 |
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
|
874 |
ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR); |
1921 | 875 |
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
|
876 |
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
|
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 |
if (fsm->datagram->working_counter != 1) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
881 |
// 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
|
882 |
ec_foe_set_rx_error(fsm, FOE_WC_ERROR); |
1921 | 883 |
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
|
884 |
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
|
885 |
return; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
886 |
} |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
887 |
|
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2257
diff
changeset
|
888 |
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
|
889 |
|
2502
906ef8b1c0ec
FoE datagram / fsm->datagram bugfix, thanks to R. Roesch.
Florian Pose <fp@igh-essen.com>
parents:
2501
diff
changeset
|
890 |
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
|
891 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
892 |
if (fsm->rx_last_packet) { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
893 |
fsm->rx_expected_packet_no = 0; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
894 |
fsm->request->data_size = fsm->rx_buffer_offset; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
895 |
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
|
896 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
897 |
else { |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
898 |
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
|
899 |
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
|
900 |
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
|
901 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
902 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
903 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
904 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
905 |
|
1465 | 906 |
/** Set an error code and go to the send error state. |
907 |
*/ |
|
908 |
void ec_foe_set_tx_error( |
|
909 |
ec_fsm_foe_t *fsm, /**< FoE statemachine. */ |
|
910 |
uint32_t errorcode /**< FoE error code. */ |
|
911 |
) |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
912 |
{ |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
913 |
fsm->request->result = errorcode; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
914 |
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
|
915 |
} |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
916 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
917 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
918 |
|
1465 | 919 |
/** Set an error code and go to the receive error state. |
920 |
*/ |
|
921 |
void ec_foe_set_rx_error( |
|
922 |
ec_fsm_foe_t *fsm, /**< FoE statemachine. */ |
|
923 |
uint32_t errorcode /**< FoE error code. */ |
|
924 |
) |
|
1336
e27b37e80a99
merge -c1618 branches/1.4-foe: Improved FoE.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
925 |
{ |
1343
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
926 |
fsm->request->result = errorcode; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
927 |
fsm->state = ec_fsm_foe_error; |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
928 |
} |
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
929 |
|
6628cd694cba
Fixed spacing and comments.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
930 |
/*****************************************************************************/ |