author | Martin Troxler <martin.troxler@komaxgroup.com> |
Tue, 15 Dec 2009 10:53:28 +0100 | |
changeset 1599 | fe338fe37923 |
parent 1597 | 491dea6f4fd7 |
child 1601 | a784812c787f |
permissions | -rw-r--r-- |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
* $Id$ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
* |
1326
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
5 |
* Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
* |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
8 |
* |
1326
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it and/or |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
10 |
* modify it under the terms of the GNU General Public License version 2, as |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
11 |
* published by the Free Software Foundation. |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
12 |
* |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
13 |
* The IgH EtherCAT Master is distributed in the hope that it will be useful, |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
16 |
* Public License for more details. |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
17 |
* |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
18 |
* You should have received a copy of the GNU General Public License along |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
19 |
* with the IgH EtherCAT Master; if not, write to the Free Software |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
20 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
21 |
* |
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1349
diff
changeset
|
22 |
* --- |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1349
diff
changeset
|
23 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1349
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:
1349
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:
1349
diff
changeset
|
26 |
* industrial property and similar rights of Beckhoff Automation GmbH. |
246
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
27 |
* |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
*****************************************************************************/ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
|
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
30 |
/** \file |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
31 |
* EtherCAT master state machine. |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
32 |
*/ |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
/*****************************************************************************/ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
#include "globals.h" |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
#include "master.h" |
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
38 |
#include "mailbox.h" |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
853
diff
changeset
|
39 |
#include "slave_config.h" |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
713
diff
changeset
|
40 |
#ifdef EC_EOE |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
41 |
#include "ethernet.h" |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
713
diff
changeset
|
42 |
#endif |
849
4b712ec8929d
Removed slave pointer from ec_sdo_request_t class.
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
43 |
|
528
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
523
diff
changeset
|
44 |
#include "fsm_master.h" |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
45 |
#include "fsm_foe.h" |
528
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
523
diff
changeset
|
46 |
|
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
523
diff
changeset
|
47 |
/*****************************************************************************/ |
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
523
diff
changeset
|
48 |
|
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
523
diff
changeset
|
49 |
void ec_fsm_master_state_start(ec_fsm_master_t *); |
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
523
diff
changeset
|
50 |
void ec_fsm_master_state_broadcast(ec_fsm_master_t *); |
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
51 |
void ec_fsm_master_state_read_state(ec_fsm_master_t *); |
528
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
523
diff
changeset
|
52 |
void ec_fsm_master_state_acknowledge(ec_fsm_master_t *); |
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
523
diff
changeset
|
53 |
void ec_fsm_master_state_configure_slave(ec_fsm_master_t *); |
717
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
54 |
void ec_fsm_master_state_clear_addresses(ec_fsm_master_t *); |
1420
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
55 |
void ec_fsm_master_state_dc_measure_delays(ec_fsm_master_t *); |
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
56 |
void ec_fsm_master_state_scan_slave(ec_fsm_master_t *); |
872 | 57 |
void ec_fsm_master_state_write_sii(ec_fsm_master_t *); |
905
6d74ebc603ee
Renamed state sdodict to sdo_dictionary.
Florian Pose <fp@igh-essen.com>
parents:
904
diff
changeset
|
58 |
void ec_fsm_master_state_sdo_dictionary(ec_fsm_master_t *); |
528
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
523
diff
changeset
|
59 |
void ec_fsm_master_state_sdo_request(ec_fsm_master_t *); |
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
60 |
void ec_fsm_master_state_reg_request(ec_fsm_master_t *); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
61 |
|
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1579
diff
changeset
|
62 |
|
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
63 |
/*****************************************************************************/ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
64 |
|
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
65 |
/** Constructor. |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
66 |
*/ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
67 |
void ec_fsm_master_init( |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
68 |
ec_fsm_master_t *fsm, /**< Master state machine. */ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
69 |
ec_master_t *master, /**< EtherCAT master. */ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
70 |
ec_datagram_t *datagram /**< Datagram object to use. */ |
528
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
523
diff
changeset
|
71 |
) |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
72 |
{ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
73 |
fsm->master = master; |
528
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
523
diff
changeset
|
74 |
fsm->datagram = datagram; |
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
523
diff
changeset
|
75 |
fsm->state = ec_fsm_master_state_start; |
650
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
649
diff
changeset
|
76 |
fsm->idle = 0; |
1400
3c4923051e43
Clear slave list on link down.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
77 |
fsm->link_state = 0; |
528
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
523
diff
changeset
|
78 |
fsm->slaves_responding = 0; |
553
a4e0267825e3
Introduced topology_change_pending to delay bus scanning until IDLE mode
Florian Pose <fp@igh-essen.com>
parents:
538
diff
changeset
|
79 |
fsm->topology_change_pending = 0; |
528
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
523
diff
changeset
|
80 |
fsm->slave_states = EC_SLAVE_STATE_UNKNOWN; |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
81 |
|
436
63214beb641d
Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
435
diff
changeset
|
82 |
// init sub-state-machines |
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
83 |
ec_fsm_coe_init(&fsm->fsm_coe, fsm->datagram); |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
84 |
ec_fsm_pdo_init(&fsm->fsm_pdo, &fsm->fsm_coe); |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
85 |
ec_fsm_change_init(&fsm->fsm_change, fsm->datagram); |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
86 |
ec_fsm_slave_config_init(&fsm->fsm_slave_config, fsm->datagram, |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
87 |
&fsm->fsm_change, &fsm->fsm_coe, &fsm->fsm_pdo); |
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
88 |
ec_fsm_slave_scan_init(&fsm->fsm_slave_scan, fsm->datagram, |
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
89 |
&fsm->fsm_slave_config, &fsm->fsm_pdo); |
528
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
523
diff
changeset
|
90 |
ec_fsm_sii_init(&fsm->fsm_sii, fsm->datagram); |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
91 |
} |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
92 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
93 |
/*****************************************************************************/ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
94 |
|
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
95 |
/** Destructor. |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
96 |
*/ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
97 |
void ec_fsm_master_clear( |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
98 |
ec_fsm_master_t *fsm /**< Master state machine. */ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
99 |
) |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
100 |
{ |
436
63214beb641d
Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
435
diff
changeset
|
101 |
// clear sub-state machines |
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
102 |
ec_fsm_coe_clear(&fsm->fsm_coe); |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
103 |
ec_fsm_pdo_clear(&fsm->fsm_pdo); |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
104 |
ec_fsm_change_clear(&fsm->fsm_change); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
105 |
ec_fsm_slave_config_clear(&fsm->fsm_slave_config); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
106 |
ec_fsm_slave_scan_clear(&fsm->fsm_slave_scan); |
433
100f51f28cf2
Layed out SII state machine.
Florian Pose <fp@igh-essen.com>
parents:
430
diff
changeset
|
107 |
ec_fsm_sii_clear(&fsm->fsm_sii); |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
108 |
} |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
109 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
110 |
/*****************************************************************************/ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
111 |
|
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
112 |
/** Executes the current state of the state machine. |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
113 |
* |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
114 |
* If the state machine's datagram is not sent or received yet, the execution |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
115 |
* of the state machine is delayed to the next cycle. |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1579
diff
changeset
|
116 |
* |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1579
diff
changeset
|
117 |
* \return true, if the state machine was executed |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1579
diff
changeset
|
118 |
*/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1579
diff
changeset
|
119 |
int ec_fsm_master_exec( |
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
120 |
ec_fsm_master_t *fsm /**< Master state machine. */ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
121 |
) |
528
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
523
diff
changeset
|
122 |
{ |
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
523
diff
changeset
|
123 |
if (fsm->datagram->state == EC_DATAGRAM_SENT |
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
523
diff
changeset
|
124 |
|| fsm->datagram->state == EC_DATAGRAM_QUEUED) { |
505
bc443ca0077f
State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents:
484
diff
changeset
|
125 |
// datagram was not sent or received yet. |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1579
diff
changeset
|
126 |
return 0; |
528
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
523
diff
changeset
|
127 |
} |
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
523
diff
changeset
|
128 |
|
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
523
diff
changeset
|
129 |
fsm->state(fsm); |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1579
diff
changeset
|
130 |
return 1; |
446 | 131 |
} |
132 |
||
650
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
649
diff
changeset
|
133 |
/*****************************************************************************/ |
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
649
diff
changeset
|
134 |
|
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
649
diff
changeset
|
135 |
/** |
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
649
diff
changeset
|
136 |
* \return true, if the state machine is in an idle phase |
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
649
diff
changeset
|
137 |
*/ |
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
649
diff
changeset
|
138 |
int ec_fsm_master_idle( |
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
139 |
const ec_fsm_master_t *fsm /**< Master state machine. */ |
650
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
649
diff
changeset
|
140 |
) |
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
649
diff
changeset
|
141 |
{ |
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
649
diff
changeset
|
142 |
return fsm->idle; |
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
649
diff
changeset
|
143 |
} |
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
649
diff
changeset
|
144 |
|
1031
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
145 |
/*****************************************************************************/ |
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
146 |
|
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
147 |
/** Restarts the master state machine. |
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
148 |
*/ |
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
149 |
void ec_fsm_master_restart( |
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
150 |
ec_fsm_master_t *fsm /**< Master state machine. */ |
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
151 |
) |
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
152 |
{ |
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
153 |
fsm->state = ec_fsm_master_state_start; |
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
154 |
fsm->state(fsm); // execute immediately |
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
155 |
} |
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
156 |
|
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
157 |
/****************************************************************************** |
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
158 |
* Master state machine |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
159 |
*****************************************************************************/ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
160 |
|
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
161 |
/** Master state: START. |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
162 |
* |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
163 |
* Starts with getting slave count and slave states. |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
164 |
*/ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
165 |
void ec_fsm_master_state_start( |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
166 |
ec_fsm_master_t *fsm /**< Master state machine. */ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
167 |
) |
528
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
523
diff
changeset
|
168 |
{ |
650
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
649
diff
changeset
|
169 |
fsm->idle = 1; |
528
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
523
diff
changeset
|
170 |
ec_datagram_brd(fsm->datagram, 0x0130, 2); |
1225
4d5b739edcb5
Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents:
1219
diff
changeset
|
171 |
ec_datagram_zero(fsm->datagram); |
528
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
523
diff
changeset
|
172 |
fsm->state = ec_fsm_master_state_broadcast; |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
173 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
174 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
175 |
/*****************************************************************************/ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
176 |
|
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
177 |
/** Master state: BROADCAST. |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
178 |
* |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
179 |
* Processes the broadcast read slave count and slaves states. |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
180 |
*/ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
181 |
void ec_fsm_master_state_broadcast( |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
182 |
ec_fsm_master_t *fsm /**< Master state machine. */ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
183 |
) |
528
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
523
diff
changeset
|
184 |
{ |
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
523
diff
changeset
|
185 |
ec_datagram_t *datagram = fsm->datagram; |
1005 | 186 |
unsigned int i, size; |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
187 |
ec_slave_t *slave; |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
188 |
ec_master_t *master = fsm->master; |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
189 |
|
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
190 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT) |
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
191 |
return; // always retry |
505
bc443ca0077f
State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents:
484
diff
changeset
|
192 |
|
553
a4e0267825e3
Introduced topology_change_pending to delay bus scanning until IDLE mode
Florian Pose <fp@igh-essen.com>
parents:
538
diff
changeset
|
193 |
// bus topology change? |
a4e0267825e3
Introduced topology_change_pending to delay bus scanning until IDLE mode
Florian Pose <fp@igh-essen.com>
parents:
538
diff
changeset
|
194 |
if (datagram->working_counter != fsm->slaves_responding) { |
a4e0267825e3
Introduced topology_change_pending to delay bus scanning until IDLE mode
Florian Pose <fp@igh-essen.com>
parents:
538
diff
changeset
|
195 |
fsm->topology_change_pending = 1; |
a4e0267825e3
Introduced topology_change_pending to delay bus scanning until IDLE mode
Florian Pose <fp@igh-essen.com>
parents:
538
diff
changeset
|
196 |
fsm->slaves_responding = datagram->working_counter; |
906 | 197 |
EC_INFO("%u slave(s) responding.\n", fsm->slaves_responding); |
198 |
} |
|
199 |
||
1400
3c4923051e43
Clear slave list on link down.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
200 |
if (fsm->link_state && !master->main_device.link_state) { // link went down |
1402
4c1203ec569d
Tested clearing slave list after link down; minor changes.
Florian Pose <fp@igh-essen.com>
parents:
1400
diff
changeset
|
201 |
if (master->debug_level) { |
4c1203ec569d
Tested clearing slave list after link down; minor changes.
Florian Pose <fp@igh-essen.com>
parents:
1400
diff
changeset
|
202 |
EC_DBG("Master state machine detected " |
4c1203ec569d
Tested clearing slave list after link down; minor changes.
Florian Pose <fp@igh-essen.com>
parents:
1400
diff
changeset
|
203 |
"link down. Clearing slave list.\n"); |
4c1203ec569d
Tested clearing slave list after link down; minor changes.
Florian Pose <fp@igh-essen.com>
parents:
1400
diff
changeset
|
204 |
} |
4c1203ec569d
Tested clearing slave list after link down; minor changes.
Florian Pose <fp@igh-essen.com>
parents:
1400
diff
changeset
|
205 |
|
1400
3c4923051e43
Clear slave list on link down.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
206 |
#ifdef EC_EOE |
3c4923051e43
Clear slave list on link down.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
207 |
ec_master_eoe_stop(master); |
3c4923051e43
Clear slave list on link down.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
208 |
ec_master_clear_eoe_handlers(master); |
3c4923051e43
Clear slave list on link down.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
209 |
#endif |
3c4923051e43
Clear slave list on link down.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
210 |
ec_master_clear_slaves(master); |
3c4923051e43
Clear slave list on link down.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
211 |
} |
3c4923051e43
Clear slave list on link down.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
212 |
fsm->link_state = master->main_device.link_state; |
3c4923051e43
Clear slave list on link down.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
213 |
|
1402
4c1203ec569d
Tested clearing slave list after link down; minor changes.
Florian Pose <fp@igh-essen.com>
parents:
1400
diff
changeset
|
214 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
1031
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
215 |
ec_fsm_master_restart(fsm); |
906 | 216 |
return; |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
217 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
218 |
|
1021
fa5cf205f4f0
Set slave_states to 0x00 when no slaves are present.
Florian Pose <fp@igh-essen.com>
parents:
1005
diff
changeset
|
219 |
if (fsm->slaves_responding) { |
fa5cf205f4f0
Set slave_states to 0x00 when no slaves are present.
Florian Pose <fp@igh-essen.com>
parents:
1005
diff
changeset
|
220 |
uint8_t states = EC_READ_U8(datagram->data); |
fa5cf205f4f0
Set slave_states to 0x00 when no slaves are present.
Florian Pose <fp@igh-essen.com>
parents:
1005
diff
changeset
|
221 |
if (states != fsm->slave_states) { // slave states changed? |
fa5cf205f4f0
Set slave_states to 0x00 when no slaves are present.
Florian Pose <fp@igh-essen.com>
parents:
1005
diff
changeset
|
222 |
char state_str[EC_STATE_STRING_SIZE]; |
fa5cf205f4f0
Set slave_states to 0x00 when no slaves are present.
Florian Pose <fp@igh-essen.com>
parents:
1005
diff
changeset
|
223 |
fsm->slave_states = states; |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1336
diff
changeset
|
224 |
ec_state_string(fsm->slave_states, state_str, 1); |
1021
fa5cf205f4f0
Set slave_states to 0x00 when no slaves are present.
Florian Pose <fp@igh-essen.com>
parents:
1005
diff
changeset
|
225 |
EC_INFO("Slave states: %s.\n", state_str); |
fa5cf205f4f0
Set slave_states to 0x00 when no slaves are present.
Florian Pose <fp@igh-essen.com>
parents:
1005
diff
changeset
|
226 |
} |
fa5cf205f4f0
Set slave_states to 0x00 when no slaves are present.
Florian Pose <fp@igh-essen.com>
parents:
1005
diff
changeset
|
227 |
} else { |
fa5cf205f4f0
Set slave_states to 0x00 when no slaves are present.
Florian Pose <fp@igh-essen.com>
parents:
1005
diff
changeset
|
228 |
fsm->slave_states = 0x00; |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
229 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
230 |
|
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
652
diff
changeset
|
231 |
if (fsm->topology_change_pending) { |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
652
diff
changeset
|
232 |
down(&master->scan_sem); |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
652
diff
changeset
|
233 |
if (!master->allow_scan) { |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
652
diff
changeset
|
234 |
up(&master->scan_sem); |
900
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
880
diff
changeset
|
235 |
} else { |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
880
diff
changeset
|
236 |
master->scan_busy = 1; |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
652
diff
changeset
|
237 |
up(&master->scan_sem); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
238 |
|
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
652
diff
changeset
|
239 |
// topology change when scan is allowed: |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
652
diff
changeset
|
240 |
// clear all slaves and scan the bus |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
652
diff
changeset
|
241 |
fsm->topology_change_pending = 0; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
652
diff
changeset
|
242 |
fsm->idle = 0; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
652
diff
changeset
|
243 |
fsm->scan_jiffies = jiffies; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
652
diff
changeset
|
244 |
|
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
713
diff
changeset
|
245 |
#ifdef EC_EOE |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
652
diff
changeset
|
246 |
ec_master_eoe_stop(master); |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
247 |
ec_master_clear_eoe_handlers(master); |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
713
diff
changeset
|
248 |
#endif |
992
50a44cbd30af
Removed kobjects from sdo and slave.
Florian Pose <fp@igh-essen.com>
parents:
987
diff
changeset
|
249 |
ec_master_clear_slaves(master); |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
652
diff
changeset
|
250 |
|
1003 | 251 |
master->slave_count = fsm->slaves_responding; |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
652
diff
changeset
|
252 |
|
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
652
diff
changeset
|
253 |
if (!master->slave_count) { |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
652
diff
changeset
|
254 |
// no slaves present -> finish state machine. |
900
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
880
diff
changeset
|
255 |
master->scan_busy = 0; |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
652
diff
changeset
|
256 |
wake_up_interruptible(&master->scan_queue); |
1031
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
257 |
ec_fsm_master_restart(fsm); |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
258 |
return; |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
259 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
260 |
|
1005 | 261 |
size = sizeof(ec_slave_t) * master->slave_count; |
262 |
if (!(master->slaves = (ec_slave_t *) kmalloc(size, GFP_KERNEL))) { |
|
263 |
EC_ERR("Failed to allocate %u bytes of slave memory!\n", |
|
264 |
size); |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1031
diff
changeset
|
265 |
master->slave_count = 0; // TODO avoid retrying scan! |
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
998
diff
changeset
|
266 |
master->scan_busy = 0; |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
998
diff
changeset
|
267 |
wake_up_interruptible(&master->scan_queue); |
1031
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
268 |
ec_fsm_master_restart(fsm); |
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
998
diff
changeset
|
269 |
return; |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
998
diff
changeset
|
270 |
} |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
998
diff
changeset
|
271 |
|
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
652
diff
changeset
|
272 |
// init slaves |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
652
diff
changeset
|
273 |
for (i = 0; i < master->slave_count; i++) { |
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
998
diff
changeset
|
274 |
slave = master->slaves + i; |
992
50a44cbd30af
Removed kobjects from sdo and slave.
Florian Pose <fp@igh-essen.com>
parents:
987
diff
changeset
|
275 |
ec_slave_init(slave, master, i, i + 1); |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
652
diff
changeset
|
276 |
|
1029
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
277 |
// do not force reconfiguration in operation phase to avoid |
908
386b908033be
Replaced self_configured flag with force_config flag.
Florian Pose <fp@igh-essen.com>
parents:
907
diff
changeset
|
278 |
// unnecesssary process data interruptions |
1029
61ffe5f22306
Renamed master 'mode' to 'phase'.
Florian Pose <fp@igh-essen.com>
parents:
1028
diff
changeset
|
279 |
if (master->phase != EC_OPERATION) |
908
386b908033be
Replaced self_configured flag with force_config flag.
Florian Pose <fp@igh-essen.com>
parents:
907
diff
changeset
|
280 |
slave->force_config = 1; |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
281 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
282 |
|
904 | 283 |
// broadcast clear all station addresses |
717
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
284 |
ec_datagram_bwr(datagram, 0x0010, 2); |
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
285 |
EC_WRITE_U16(datagram->data, 0x0000); |
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
286 |
fsm->retries = EC_FSM_RETRIES; |
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
287 |
fsm->state = ec_fsm_master_state_clear_addresses; |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
652
diff
changeset
|
288 |
return; |
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
652
diff
changeset
|
289 |
} |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
290 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
291 |
|
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
998
diff
changeset
|
292 |
if (master->slave_count) { |
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
293 |
// fetch state from first slave |
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
998
diff
changeset
|
294 |
fsm->slave = master->slaves; |
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
295 |
ec_datagram_fprd(fsm->datagram, fsm->slave->station_address, |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
296 |
0x0130, 2); |
1225
4d5b739edcb5
Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents:
1219
diff
changeset
|
297 |
ec_datagram_zero(datagram); |
853
726326d0aef4
Fixed bug if scanning is not allowed when link goes up.
Florian Pose <fp@igh-essen.com>
parents:
849
diff
changeset
|
298 |
fsm->retries = EC_FSM_RETRIES; |
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
299 |
fsm->state = ec_fsm_master_state_read_state; |
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
998
diff
changeset
|
300 |
} else { |
1031
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
301 |
ec_fsm_master_restart(fsm); |
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
302 |
} |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
303 |
} |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
304 |
|
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
305 |
/*****************************************************************************/ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
306 |
|
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
307 |
/** Check for pending SII write requests and process one. |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
308 |
* |
872 | 309 |
* \return non-zero, if an SII write request is processed. |
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
594
diff
changeset
|
310 |
*/ |
872 | 311 |
int ec_fsm_master_action_process_sii( |
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
312 |
ec_fsm_master_t *fsm /**< Master state machine. */ |
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
594
diff
changeset
|
313 |
) |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
594
diff
changeset
|
314 |
{ |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
594
diff
changeset
|
315 |
ec_master_t *master = fsm->master; |
872 | 316 |
ec_sii_write_request_t *request; |
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
594
diff
changeset
|
317 |
|
604
74ceacf42710
Fixed possible race with next request pointer again.
Florian Pose <fp@igh-essen.com>
parents:
603
diff
changeset
|
318 |
// search the first request to be processed |
74ceacf42710
Fixed possible race with next request pointer again.
Florian Pose <fp@igh-essen.com>
parents:
603
diff
changeset
|
319 |
while (1) { |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1064
diff
changeset
|
320 |
if (list_empty(&master->sii_requests)) |
604
74ceacf42710
Fixed possible race with next request pointer again.
Florian Pose <fp@igh-essen.com>
parents:
603
diff
changeset
|
321 |
break; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1064
diff
changeset
|
322 |
|
604
74ceacf42710
Fixed possible race with next request pointer again.
Florian Pose <fp@igh-essen.com>
parents:
603
diff
changeset
|
323 |
// get first request |
872 | 324 |
request = list_entry(master->sii_requests.next, |
325 |
ec_sii_write_request_t, list); |
|
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
594
diff
changeset
|
326 |
list_del_init(&request->list); // dequeue |
1209 | 327 |
request->state = EC_INT_REQUEST_BUSY; |
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
594
diff
changeset
|
328 |
|
872 | 329 |
// found pending SII write operation. execute it! |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
605
diff
changeset
|
330 |
if (master->debug_level) |
906 | 331 |
EC_DBG("Writing SII data to slave %u...\n", |
332 |
request->slave->ring_position); |
|
872 | 333 |
fsm->sii_request = request; |
334 |
fsm->sii_index = 0; |
|
979
405cc2d033e0
Renamed some fields in ec_sii_request_t to word addressing.
Florian Pose <fp@igh-essen.com>
parents:
969
diff
changeset
|
335 |
ec_fsm_sii_write(&fsm->fsm_sii, request->slave, request->offset, |
405cc2d033e0
Renamed some fields in ec_sii_request_t to word addressing.
Florian Pose <fp@igh-essen.com>
parents:
969
diff
changeset
|
336 |
request->words, EC_FSM_SII_USE_CONFIGURED_ADDRESS); |
872 | 337 |
fsm->state = ec_fsm_master_state_write_sii; |
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
594
diff
changeset
|
338 |
fsm->state(fsm); // execute immediately |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
594
diff
changeset
|
339 |
return 1; |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
594
diff
changeset
|
340 |
} |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
594
diff
changeset
|
341 |
|
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
594
diff
changeset
|
342 |
return 0; |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
594
diff
changeset
|
343 |
} |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
594
diff
changeset
|
344 |
|
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
594
diff
changeset
|
345 |
/*****************************************************************************/ |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
594
diff
changeset
|
346 |
|
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
347 |
/** Check for pending register requests and process one. |
1579
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1507
diff
changeset
|
348 |
* |
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
349 |
* \return non-zero, if a register request is processed. |
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
350 |
*/ |
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
351 |
int ec_fsm_master_action_process_register( |
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
352 |
ec_fsm_master_t *fsm /**< Master state machine. */ |
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
353 |
) |
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
354 |
{ |
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
355 |
ec_master_t *master = fsm->master; |
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
356 |
ec_reg_request_t *request; |
1200 | 357 |
|
358 |
// search the first request to be processed |
|
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
359 |
while (!list_empty(&master->reg_requests)) { |
1200 | 360 |
|
361 |
// get first request |
|
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
362 |
request = list_entry(master->reg_requests.next, |
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
363 |
ec_reg_request_t, list); |
1200 | 364 |
list_del_init(&request->list); // dequeue |
1209 | 365 |
request->state = EC_INT_REQUEST_BUSY; |
1200 | 366 |
|
367 |
// found pending request; process it! |
|
368 |
if (master->debug_level) |
|
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
369 |
EC_DBG("Processing register request for slave %u, " |
1380 | 370 |
"offset 0x%04x, length %u...\n", |
371 |
request->slave->ring_position, |
|
372 |
request->offset, request->length); |
|
1386
95ec1e9bcb53
Check phy_request length for read operations, too!
Florian Pose <fp@igh-essen.com>
parents:
1385
diff
changeset
|
373 |
|
95ec1e9bcb53
Check phy_request length for read operations, too!
Florian Pose <fp@igh-essen.com>
parents:
1385
diff
changeset
|
374 |
if (request->length > fsm->datagram->mem_size) { |
95ec1e9bcb53
Check phy_request length for read operations, too!
Florian Pose <fp@igh-essen.com>
parents:
1385
diff
changeset
|
375 |
EC_ERR("Request length (%u) exceeds maximum " |
95ec1e9bcb53
Check phy_request length for read operations, too!
Florian Pose <fp@igh-essen.com>
parents:
1385
diff
changeset
|
376 |
"datagram size (%u)!\n", request->length, |
95ec1e9bcb53
Check phy_request length for read operations, too!
Florian Pose <fp@igh-essen.com>
parents:
1385
diff
changeset
|
377 |
fsm->datagram->mem_size); |
95ec1e9bcb53
Check phy_request length for read operations, too!
Florian Pose <fp@igh-essen.com>
parents:
1385
diff
changeset
|
378 |
request->state = EC_INT_REQUEST_FAILURE; |
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
379 |
wake_up(&master->reg_queue); |
1386
95ec1e9bcb53
Check phy_request length for read operations, too!
Florian Pose <fp@igh-essen.com>
parents:
1385
diff
changeset
|
380 |
continue; |
95ec1e9bcb53
Check phy_request length for read operations, too!
Florian Pose <fp@igh-essen.com>
parents:
1385
diff
changeset
|
381 |
} |
95ec1e9bcb53
Check phy_request length for read operations, too!
Florian Pose <fp@igh-essen.com>
parents:
1385
diff
changeset
|
382 |
|
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
383 |
fsm->reg_request = request; |
1200 | 384 |
|
385 |
if (request->dir == EC_DIR_INPUT) { |
|
386 |
ec_datagram_fprd(fsm->datagram, request->slave->station_address, |
|
387 |
request->offset, request->length); |
|
1225
4d5b739edcb5
Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents:
1219
diff
changeset
|
388 |
ec_datagram_zero(fsm->datagram); |
1200 | 389 |
} else { |
390 |
ec_datagram_fpwr(fsm->datagram, request->slave->station_address, |
|
391 |
request->offset, request->length); |
|
392 |
memcpy(fsm->datagram->data, request->data, request->length); |
|
393 |
} |
|
394 |
fsm->retries = EC_FSM_RETRIES; |
|
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
395 |
fsm->state = ec_fsm_master_state_reg_request; |
1200 | 396 |
return 1; |
397 |
} |
|
398 |
||
399 |
return 0; |
|
400 |
} |
|
401 |
||
402 |
/*****************************************************************************/ |
|
403 |
||
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
404 |
/** Check for pending SDO requests and process one. |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
405 |
* |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
406 |
* \return non-zero, if an SDO request is processed. |
646
fbbd4e54e031
Implemented SDO reading with wait queues.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
407 |
*/ |
fbbd4e54e031
Implemented SDO reading with wait queues.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
408 |
int ec_fsm_master_action_process_sdo( |
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
409 |
ec_fsm_master_t *fsm /**< Master state machine. */ |
646
fbbd4e54e031
Implemented SDO reading with wait queues.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
410 |
) |
fbbd4e54e031
Implemented SDO reading with wait queues.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
411 |
{ |
fbbd4e54e031
Implemented SDO reading with wait queues.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
412 |
ec_master_t *master = fsm->master; |
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
998
diff
changeset
|
413 |
ec_slave_t *slave; |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
998
diff
changeset
|
414 |
ec_sdo_request_t *req; |
646
fbbd4e54e031
Implemented SDO reading with wait queues.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
415 |
|
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
853
diff
changeset
|
416 |
// search for internal requests to be processed |
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
998
diff
changeset
|
417 |
for (slave = master->slaves; |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
998
diff
changeset
|
418 |
slave < master->slaves + master->slave_count; |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
998
diff
changeset
|
419 |
slave++) { |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
853
diff
changeset
|
420 |
if (!slave->config) |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
853
diff
changeset
|
421 |
continue; |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
853
diff
changeset
|
422 |
list_for_each_entry(req, &slave->config->sdo_requests, list) { |
1209 | 423 |
if (req->state == EC_INT_REQUEST_QUEUED) { |
880 | 424 |
|
425 |
if (ec_sdo_request_timed_out(req)) { |
|
1209 | 426 |
req->state = EC_INT_REQUEST_FAILURE; |
880 | 427 |
if (master->debug_level) |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1579
diff
changeset
|
428 |
EC_DBG("Internal SDO request for slave %u timed out...\n", |
880 | 429 |
slave->ring_position); |
430 |
continue; |
|
431 |
} |
|
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
853
diff
changeset
|
432 |
|
987
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
433 |
if (slave->current_state == EC_SLAVE_STATE_INIT) { |
1209 | 434 |
req->state = EC_INT_REQUEST_FAILURE; |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
853
diff
changeset
|
435 |
continue; |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
853
diff
changeset
|
436 |
} |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
853
diff
changeset
|
437 |
|
1209 | 438 |
req->state = EC_INT_REQUEST_BUSY; |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
853
diff
changeset
|
439 |
if (master->debug_level) |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1579
diff
changeset
|
440 |
EC_DBG("Processing internal SDO request for slave %u...\n", |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
853
diff
changeset
|
441 |
slave->ring_position); |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
853
diff
changeset
|
442 |
|
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
853
diff
changeset
|
443 |
fsm->idle = 0; |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
853
diff
changeset
|
444 |
fsm->sdo_request = req; |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
853
diff
changeset
|
445 |
fsm->slave = slave; |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
853
diff
changeset
|
446 |
fsm->state = ec_fsm_master_state_sdo_request; |
859
233e32f428e1
Replaced ec_fsm_coe_\(upload\|download\)() with ec_fsm_coe_transfer();
Florian Pose <fp@igh-essen.com>
parents:
858
diff
changeset
|
447 |
ec_fsm_coe_transfer(&fsm->fsm_coe, slave, req); |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
853
diff
changeset
|
448 |
ec_fsm_coe_exec(&fsm->fsm_coe); // execute immediately |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
853
diff
changeset
|
449 |
return 1; |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
853
diff
changeset
|
450 |
} |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
853
diff
changeset
|
451 |
} |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
853
diff
changeset
|
452 |
} |
646
fbbd4e54e031
Implemented SDO reading with wait queues.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
453 |
return 0; |
fbbd4e54e031
Implemented SDO reading with wait queues.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
454 |
} |
fbbd4e54e031
Implemented SDO reading with wait queues.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
455 |
|
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
456 |
|
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
457 |
/*****************************************************************************/ |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
458 |
|
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
459 |
/** Master action: IDLE. |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
460 |
* |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
461 |
* Does secondary work. |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
462 |
*/ |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
463 |
void ec_fsm_master_action_idle( |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
464 |
ec_fsm_master_t *fsm /**< Master state machine. */ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
465 |
) |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
466 |
{ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
467 |
ec_master_t *master = fsm->master; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
468 |
ec_slave_t *slave; |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
469 |
|
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
470 |
// Check for pending internal SDO requests |
646
fbbd4e54e031
Implemented SDO reading with wait queues.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
471 |
if (ec_fsm_master_action_process_sdo(fsm)) |
fbbd4e54e031
Implemented SDO reading with wait queues.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
472 |
return; |
fbbd4e54e031
Implemented SDO reading with wait queues.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
473 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
474 |
// check, if slaves have an SDO dictionary to read out. |
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
998
diff
changeset
|
475 |
for (slave = master->slaves; |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
998
diff
changeset
|
476 |
slave < master->slaves + master->slave_count; |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
998
diff
changeset
|
477 |
slave++) { |
910
9fd31755f576
Fetch Sdo dictionaries and process SII requests in operation mode.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
478 |
if (!(slave->sii.mailbox_protocols & EC_MBOX_COE) |
1219
aa030fb1e980
Only query Sdo information service, if slave supports it.
Florian Pose <fp@igh-essen.com>
parents:
1209
diff
changeset
|
479 |
|| (slave->sii.has_general |
aa030fb1e980
Only query Sdo information service, if slave supports it.
Florian Pose <fp@igh-essen.com>
parents:
1209
diff
changeset
|
480 |
&& !slave->sii.coe_details.enable_sdo_info) |
442
6607875255d9
SDO dictionary and SDO access only in IDLE mode, because of kmalloc()s.
Florian Pose <fp@igh-essen.com>
parents:
441
diff
changeset
|
481 |
|| slave->sdo_dictionary_fetched |
6607875255d9
SDO dictionary and SDO access only in IDLE mode, because of kmalloc()s.
Florian Pose <fp@igh-essen.com>
parents:
441
diff
changeset
|
482 |
|| slave->current_state == EC_SLAVE_STATE_INIT |
1219
aa030fb1e980
Only query Sdo information service, if slave supports it.
Florian Pose <fp@igh-essen.com>
parents:
1209
diff
changeset
|
483 |
|| slave->current_state == EC_SLAVE_STATE_UNKNOWN |
442
6607875255d9
SDO dictionary and SDO access only in IDLE mode, because of kmalloc()s.
Florian Pose <fp@igh-essen.com>
parents:
441
diff
changeset
|
484 |
|| jiffies - slave->jiffies_preop < EC_WAIT_SDO_DICT * HZ |
987
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
485 |
) continue; |
442
6607875255d9
SDO dictionary and SDO access only in IDLE mode, because of kmalloc()s.
Florian Pose <fp@igh-essen.com>
parents:
441
diff
changeset
|
486 |
|
910
9fd31755f576
Fetch Sdo dictionaries and process SII requests in operation mode.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
487 |
if (master->debug_level) { |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
488 |
EC_DBG("Fetching SDO dictionary from slave %u.\n", |
910
9fd31755f576
Fetch Sdo dictionaries and process SII requests in operation mode.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
489 |
slave->ring_position); |
441
ffa13db95e10
SDO uploading via Sysfs without master FSM calling wake_up().
Florian Pose <fp@igh-essen.com>
parents:
437
diff
changeset
|
490 |
} |
442
6607875255d9
SDO dictionary and SDO access only in IDLE mode, because of kmalloc()s.
Florian Pose <fp@igh-essen.com>
parents:
441
diff
changeset
|
491 |
|
910
9fd31755f576
Fetch Sdo dictionaries and process SII requests in operation mode.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
492 |
slave->sdo_dictionary_fetched = 1; |
9fd31755f576
Fetch Sdo dictionaries and process SII requests in operation mode.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
493 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
494 |
// start fetching SDO dictionary |
910
9fd31755f576
Fetch Sdo dictionaries and process SII requests in operation mode.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
495 |
fsm->idle = 0; |
9fd31755f576
Fetch Sdo dictionaries and process SII requests in operation mode.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
496 |
fsm->slave = slave; |
9fd31755f576
Fetch Sdo dictionaries and process SII requests in operation mode.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
497 |
fsm->state = ec_fsm_master_state_sdo_dictionary; |
9fd31755f576
Fetch Sdo dictionaries and process SII requests in operation mode.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
498 |
ec_fsm_coe_dictionary(&fsm->fsm_coe, slave); |
9fd31755f576
Fetch Sdo dictionaries and process SII requests in operation mode.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
499 |
ec_fsm_coe_exec(&fsm->fsm_coe); // execute immediately |
9fd31755f576
Fetch Sdo dictionaries and process SII requests in operation mode.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
500 |
return; |
9fd31755f576
Fetch Sdo dictionaries and process SII requests in operation mode.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
501 |
} |
9fd31755f576
Fetch Sdo dictionaries and process SII requests in operation mode.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
502 |
|
9fd31755f576
Fetch Sdo dictionaries and process SII requests in operation mode.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
503 |
// check for pending SII write operations. |
9fd31755f576
Fetch Sdo dictionaries and process SII requests in operation mode.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
504 |
if (ec_fsm_master_action_process_sii(fsm)) |
9fd31755f576
Fetch Sdo dictionaries and process SII requests in operation mode.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
505 |
return; // SII write request found |
304
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
506 |
|
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
507 |
// check for pending register requests. |
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
508 |
if (ec_fsm_master_action_process_register(fsm)) |
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
509 |
return; // register request processing |
1200 | 510 |
|
1031
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
511 |
ec_fsm_master_restart(fsm); |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
512 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
513 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
514 |
/*****************************************************************************/ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
515 |
|
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
516 |
/** Master action: Get state of next slave. |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
517 |
*/ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
518 |
void ec_fsm_master_action_next_slave_state( |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
519 |
ec_fsm_master_t *fsm /**< Master state machine. */ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
520 |
) |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
521 |
{ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
522 |
ec_master_t *master = fsm->master; |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
523 |
|
304
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
524 |
// is there another slave to query? |
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
998
diff
changeset
|
525 |
fsm->slave++; |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
998
diff
changeset
|
526 |
if (fsm->slave < master->slaves + master->slave_count) { |
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
527 |
// fetch state from next slave |
650
c68995623e94
Introduced idle flag in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
649
diff
changeset
|
528 |
fsm->idle = 1; |
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
998
diff
changeset
|
529 |
ec_datagram_fprd(fsm->datagram, |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
998
diff
changeset
|
530 |
fsm->slave->station_address, 0x0130, 2); |
1225
4d5b739edcb5
Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents:
1219
diff
changeset
|
531 |
ec_datagram_zero(fsm->datagram); |
505
bc443ca0077f
State machines re-send datagrams on timeout.
Florian Pose <fp@igh-essen.com>
parents:
484
diff
changeset
|
532 |
fsm->retries = EC_FSM_RETRIES; |
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
533 |
fsm->state = ec_fsm_master_state_read_state; |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
534 |
return; |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
535 |
} |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
536 |
|
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
537 |
// all slaves processed |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
538 |
ec_fsm_master_action_idle(fsm); |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
539 |
} |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
540 |
|
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
541 |
/*****************************************************************************/ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
542 |
|
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
543 |
/** Master action: Configure. |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
544 |
*/ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
545 |
void ec_fsm_master_action_configure( |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
546 |
ec_fsm_master_t *fsm /**< Master state machine. */ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
547 |
) |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
548 |
{ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
549 |
ec_master_t *master = fsm->master; |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
550 |
ec_slave_t *slave = fsm->slave; |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
551 |
|
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
552 |
// Does the slave have to be configured? |
987
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
553 |
if ((slave->current_state != slave->requested_state |
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
554 |
|| slave->force_config) && !slave->error_flag) { |
1177 | 555 |
|
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
556 |
// Start slave configuration, if it is allowed. |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
557 |
down(&master->config_sem); |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
558 |
if (!master->allow_config) { |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
559 |
up(&master->config_sem); |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
560 |
} else { |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
561 |
master->config_busy = 1; |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
562 |
up(&master->config_sem); |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
563 |
|
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
564 |
if (master->debug_level) { |
908
386b908033be
Replaced self_configured flag with force_config flag.
Florian Pose <fp@igh-essen.com>
parents:
907
diff
changeset
|
565 |
char old_state[EC_STATE_STRING_SIZE], |
386b908033be
Replaced self_configured flag with force_config flag.
Florian Pose <fp@igh-essen.com>
parents:
907
diff
changeset
|
566 |
new_state[EC_STATE_STRING_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
|
567 |
ec_state_string(slave->current_state, old_state, 0); |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1336
diff
changeset
|
568 |
ec_state_string(slave->requested_state, new_state, 0); |
908
386b908033be
Replaced self_configured flag with force_config flag.
Florian Pose <fp@igh-essen.com>
parents:
907
diff
changeset
|
569 |
EC_DBG("Changing state of slave %u from %s to %s%s.\n", |
386b908033be
Replaced self_configured flag with force_config flag.
Florian Pose <fp@igh-essen.com>
parents:
907
diff
changeset
|
570 |
slave->ring_position, old_state, new_state, |
386b908033be
Replaced self_configured flag with force_config flag.
Florian Pose <fp@igh-essen.com>
parents:
907
diff
changeset
|
571 |
slave->force_config ? " (forced)" : ""); |
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
572 |
} |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
573 |
|
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
574 |
fsm->idle = 0; |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
575 |
fsm->state = ec_fsm_master_state_configure_slave; |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
576 |
ec_fsm_slave_config_start(&fsm->fsm_slave_config, slave); |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
577 |
fsm->state(fsm); // execute immediately |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
578 |
return; |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
579 |
} |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
580 |
} |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
581 |
|
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
582 |
// slave has error flag set; process next one |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
583 |
ec_fsm_master_action_next_slave_state(fsm); |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
584 |
} |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
585 |
|
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
586 |
/*****************************************************************************/ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
587 |
|
987
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
588 |
/** Master state: READ STATE. |
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
589 |
* |
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
590 |
* Fetches the AL state of a slave. |
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
591 |
*/ |
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
592 |
void ec_fsm_master_state_read_state( |
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
593 |
ec_fsm_master_t *fsm /**< Master state machine. */ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
594 |
) |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
595 |
{ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
596 |
ec_slave_t *slave = fsm->slave; |
987
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
597 |
ec_datagram_t *datagram = fsm->datagram; |
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
598 |
|
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
599 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
600 |
return; |
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
601 |
|
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
602 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
603 |
EC_ERR("Failed to receive AL state datagram for slave %u" |
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
604 |
" (datagram state %u)\n", |
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
605 |
slave->ring_position, datagram->state); |
1031
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
606 |
ec_fsm_master_restart(fsm); |
987
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
607 |
return; |
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
608 |
} |
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
609 |
|
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
610 |
// did the slave not respond to its station address? |
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
611 |
if (datagram->working_counter != 1) { |
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
612 |
if (!slave->error_flag) { |
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
613 |
slave->error_flag = 1; |
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
614 |
if (fsm->master->debug_level) |
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
615 |
EC_DBG("Slave %u did not respond to state query.\n", |
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
616 |
fsm->slave->ring_position); |
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
617 |
} |
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
618 |
fsm->topology_change_pending = 1; |
1031
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
619 |
ec_fsm_master_restart(fsm); |
987
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
620 |
return; |
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
621 |
} |
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
622 |
|
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
623 |
// A single slave responded |
3c9090138140
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
624 |
ec_slave_set_state(slave, EC_READ_U8(datagram->data)); |
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
625 |
|
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
626 |
if (!slave->error_flag) { |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
627 |
// Check, if new slave state has to be acknowledged |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
628 |
if (slave->current_state & EC_SLAVE_STATE_ACK_ERR) { |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
629 |
fsm->idle = 0; |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
630 |
fsm->state = ec_fsm_master_state_acknowledge; |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
631 |
ec_fsm_change_ack(&fsm->fsm_change, slave); |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
632 |
fsm->state(fsm); // execute immediately |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
633 |
return; |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
634 |
} |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
635 |
|
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
636 |
// No acknowlegde necessary; check for configuration |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
637 |
ec_fsm_master_action_configure(fsm); |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
638 |
return; |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
639 |
} |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
640 |
|
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
641 |
// slave has error flag set; process next one |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
642 |
ec_fsm_master_action_next_slave_state(fsm); |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
643 |
} |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
644 |
|
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
645 |
/*****************************************************************************/ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
646 |
|
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
647 |
/** Master state: ACKNOWLEDGE. |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
648 |
*/ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
649 |
void ec_fsm_master_state_acknowledge( |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
650 |
ec_fsm_master_t *fsm /**< Master state machine. */ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
651 |
) |
454
25cc4a3b9e0a
State acknowledgement in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
448
diff
changeset
|
652 |
{ |
25cc4a3b9e0a
State acknowledgement in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
448
diff
changeset
|
653 |
ec_slave_t *slave = fsm->slave; |
25cc4a3b9e0a
State acknowledgement in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
448
diff
changeset
|
654 |
|
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
655 |
if (ec_fsm_change_exec(&fsm->fsm_change)) |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
656 |
return; |
454
25cc4a3b9e0a
State acknowledgement in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
448
diff
changeset
|
657 |
|
25cc4a3b9e0a
State acknowledgement in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
448
diff
changeset
|
658 |
if (!ec_fsm_change_success(&fsm->fsm_change)) { |
25cc4a3b9e0a
State acknowledgement in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
448
diff
changeset
|
659 |
fsm->slave->error_flag = 1; |
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
660 |
EC_ERR("Failed to acknowledge state change on slave %u.\n", |
454
25cc4a3b9e0a
State acknowledgement in master state machine.
Florian Pose <fp@igh-essen.com>
parents:
448
diff
changeset
|
661 |
slave->ring_position); |
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
662 |
} |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
663 |
|
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
664 |
ec_fsm_master_action_configure(fsm); |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
665 |
} |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
666 |
|
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
667 |
/*****************************************************************************/ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
668 |
|
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
669 |
/** Master state: CLEAR ADDRESSES. |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
670 |
*/ |
717
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
671 |
void ec_fsm_master_state_clear_addresses( |
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
672 |
ec_fsm_master_t *fsm /**< Master state machine. */ |
717
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
673 |
) |
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
674 |
{ |
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
675 |
ec_master_t *master = fsm->master; |
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
676 |
ec_datagram_t *datagram = fsm->datagram; |
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
677 |
|
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
678 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
679 |
return; |
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
680 |
|
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
681 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
979
diff
changeset
|
682 |
EC_ERR("Failed to receive address clearing datagram (state %u).\n", |
717
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
683 |
datagram->state); |
900
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
880
diff
changeset
|
684 |
master->scan_busy = 0; |
794
684dea874956
Allow bus configuration when link is down.
Florian Pose <fp@igh-essen.com>
parents:
792
diff
changeset
|
685 |
wake_up_interruptible(&master->scan_queue); |
1031
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
686 |
ec_fsm_master_restart(fsm); |
717
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
687 |
return; |
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
688 |
} |
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
689 |
|
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
690 |
if (datagram->working_counter != master->slave_count) { |
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
691 |
EC_WARN("Failed to clear all station addresses: Cleared %u of %u", |
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
692 |
datagram->working_counter, master->slave_count); |
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
693 |
} |
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
694 |
|
1420
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
695 |
if (master->debug_level) |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
696 |
EC_DBG("Sending broadcast-write to measure transmission delays.\n"); |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
697 |
|
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
698 |
ec_datagram_bwr(datagram, 0x0900, 1); |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
699 |
ec_datagram_zero(datagram); |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
700 |
fsm->retries = EC_FSM_RETRIES; |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
701 |
fsm->state = ec_fsm_master_state_dc_measure_delays; |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
702 |
} |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
703 |
|
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
704 |
/*****************************************************************************/ |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
705 |
|
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
706 |
/** Master state: DC MEASURE DELAYS. |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
707 |
*/ |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
708 |
void ec_fsm_master_state_dc_measure_delays( |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
709 |
ec_fsm_master_t *fsm /**< Master state machine. */ |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
710 |
) |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
711 |
{ |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
712 |
ec_master_t *master = fsm->master; |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
713 |
ec_datagram_t *datagram = fsm->datagram; |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
714 |
|
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
715 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
716 |
return; |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
717 |
|
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
718 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
719 |
EC_ERR("Failed to receive delay measuring datagram (state %u).\n", |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
720 |
datagram->state); |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
721 |
master->scan_busy = 0; |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
722 |
wake_up_interruptible(&master->scan_queue); |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
723 |
ec_fsm_master_restart(fsm); |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
724 |
return; |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
725 |
} |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
726 |
|
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
727 |
if (master->debug_level) |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
728 |
EC_DBG("%u slaves responded to delay measuring.\n", |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
729 |
datagram->working_counter); |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1408
diff
changeset
|
730 |
|
717
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
731 |
EC_INFO("Scanning bus.\n"); |
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
732 |
|
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
733 |
// begin scanning of slaves |
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
998
diff
changeset
|
734 |
fsm->slave = master->slaves; |
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
735 |
fsm->state = ec_fsm_master_state_scan_slave; |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
736 |
ec_fsm_slave_scan_start(&fsm->fsm_slave_scan, fsm->slave); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
737 |
ec_fsm_slave_scan_exec(&fsm->fsm_slave_scan); // execute immediately |
717
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
738 |
} |
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
739 |
|
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
740 |
/*****************************************************************************/ |
87abf1166e88
Clear station addresses with broadcast before setting them.
Florian Pose <fp@igh-essen.com>
parents:
716
diff
changeset
|
741 |
|
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
742 |
/** Master state: SCAN SLAVE. |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
743 |
* |
652 | 744 |
* Executes the sub-statemachine for the scanning of a slave. |
745 |
*/ |
|
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
746 |
void ec_fsm_master_state_scan_slave( |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
747 |
ec_fsm_master_t *fsm /**< Master state machine. */ |
652 | 748 |
) |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
749 |
{ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
750 |
ec_master_t *master = fsm->master; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
751 |
#ifdef EC_EOE |
637
d5d04c868e0e
Removed ecrt_master_run(), removed datagram queueing from state
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
752 |
ec_slave_t *slave = fsm->slave; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
753 |
#endif |
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
754 |
if (ec_fsm_slave_scan_exec(&fsm->fsm_slave_scan)) |
528
f789bdd78b54
Layed out slave state machines in own files fsm_slave.[ch]; renamed fsm.[ch] to fsm_master.[ch]
Florian Pose <fp@igh-essen.com>
parents:
523
diff
changeset
|
755 |
return; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
756 |
|
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
713
diff
changeset
|
757 |
#ifdef EC_EOE |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
758 |
if (slave->sii.mailbox_protocols & EC_MBOX_EOE) { |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
759 |
// create EoE handler for this slave |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
760 |
ec_eoe_t *eoe; |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
761 |
if (!(eoe = kmalloc(sizeof(ec_eoe_t), GFP_KERNEL))) { |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
762 |
EC_ERR("Failed to allocate EoE handler memory for slave %u!\n", |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
763 |
slave->ring_position); |
900
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
880
diff
changeset
|
764 |
} else if (ec_eoe_init(eoe, slave)) { |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
765 |
EC_ERR("Failed to init EoE handler for slave %u!\n", |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
766 |
slave->ring_position); |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
767 |
kfree(eoe); |
900
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
880
diff
changeset
|
768 |
} else { |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
769 |
list_add_tail(&eoe->list, &master->eoe_handlers); |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
770 |
} |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
771 |
} |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
713
diff
changeset
|
772 |
#endif |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
773 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
774 |
// another slave to fetch? |
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
998
diff
changeset
|
775 |
fsm->slave++; |
1002
0e1aaeb3540d
Fixed bug in slave scanning, causing a segmentation fault.
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
776 |
if (fsm->slave < master->slaves + master->slave_count) { |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
777 |
ec_fsm_slave_scan_start(&fsm->fsm_slave_scan, fsm->slave); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
778 |
ec_fsm_slave_scan_exec(&fsm->fsm_slave_scan); // execute immediately |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
779 |
return; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
780 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
781 |
|
652 | 782 |
EC_INFO("Bus scanning completed in %u ms.\n", |
783 |
(u32) (jiffies - fsm->scan_jiffies) * 1000 / HZ); |
|
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
784 |
|
900
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
880
diff
changeset
|
785 |
master->scan_busy = 0; |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
880
diff
changeset
|
786 |
wake_up_interruptible(&master->scan_queue); |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
880
diff
changeset
|
787 |
|
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1421
diff
changeset
|
788 |
ec_master_calc_dc(master); |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1444
diff
changeset
|
789 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
790 |
// Attach slave configurations |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
791 |
ec_master_attach_slave_configs(master); |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
758
diff
changeset
|
792 |
|
716 | 793 |
#ifdef EC_EOE |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
794 |
// check if EoE processing has to be started |
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
795 |
ec_master_eoe_start(master); |
715
f12ff7c08623
Added --enable-eoe conditional.
Florian Pose <fp@igh-essen.com>
parents:
713
diff
changeset
|
796 |
#endif |
661
bc1de1362efb
Dynamic creation of EoE handlers.
Florian Pose <fp@igh-essen.com>
parents:
656
diff
changeset
|
797 |
|
1031
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
798 |
ec_fsm_master_restart(fsm); |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
799 |
} |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
800 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
801 |
/*****************************************************************************/ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
802 |
|
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
803 |
/** Master state: CONFIGURE SLAVE. |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
804 |
* |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
805 |
* Starts configuring a slave. |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
806 |
*/ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
807 |
void ec_fsm_master_state_configure_slave( |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
808 |
ec_fsm_master_t *fsm /**< Master state machine. */ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
809 |
) |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
810 |
{ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
811 |
ec_master_t *master = fsm->master; |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
812 |
|
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
813 |
if (ec_fsm_slave_config_exec(&fsm->fsm_slave_config)) |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
814 |
return; |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
815 |
|
1277
1189e040fe12
merge -c1521 branches/stable-1.4: Fixed race concerning ec_slave_config_state->operational.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
816 |
fsm->slave->force_config = 0; |
1189e040fe12
merge -c1521 branches/stable-1.4: Fixed race concerning ec_slave_config_state->operational.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
817 |
|
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
818 |
// configuration finished |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
819 |
master->config_busy = 0; |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
820 |
wake_up_interruptible(&master->config_queue); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
821 |
|
900
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
880
diff
changeset
|
822 |
if (!ec_fsm_slave_config_success(&fsm->fsm_slave_config)) { |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
880
diff
changeset
|
823 |
// TODO: mark slave_config as failed. |
f8b5c6d21705
Removed bus validation; slave configuration during realtime operation;
Florian Pose <fp@igh-essen.com>
parents:
880
diff
changeset
|
824 |
} |
656
370aa8c2d1b1
Slave configuration exclusively from master thread; removed
Florian Pose <fp@igh-essen.com>
parents:
652
diff
changeset
|
825 |
|
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
826 |
fsm->idle = 1; |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
827 |
ec_fsm_master_action_next_slave_state(fsm); |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
828 |
} |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
829 |
|
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
830 |
/*****************************************************************************/ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
831 |
|
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
832 |
/** Master state: WRITE SII. |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
833 |
*/ |
872 | 834 |
void ec_fsm_master_state_write_sii( |
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
835 |
ec_fsm_master_t *fsm /**< Master state machine. */ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
836 |
) |
269 | 837 |
{ |
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
594
diff
changeset
|
838 |
ec_master_t *master = fsm->master; |
872 | 839 |
ec_sii_write_request_t *request = fsm->sii_request; |
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
594
diff
changeset
|
840 |
ec_slave_t *slave = request->slave; |
269 | 841 |
|
435
779a18d12e6c
Removed state machine running() methods.
Florian Pose <fp@igh-essen.com>
parents:
434
diff
changeset
|
842 |
if (ec_fsm_sii_exec(&fsm->fsm_sii)) return; |
433
100f51f28cf2
Layed out SII state machine.
Florian Pose <fp@igh-essen.com>
parents:
430
diff
changeset
|
843 |
|
100f51f28cf2
Layed out SII state machine.
Florian Pose <fp@igh-essen.com>
parents:
430
diff
changeset
|
844 |
if (!ec_fsm_sii_success(&fsm->fsm_sii)) { |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
979
diff
changeset
|
845 |
EC_ERR("Failed to write SII data to slave %u.\n", |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
605
diff
changeset
|
846 |
slave->ring_position); |
1209 | 847 |
request->state = EC_INT_REQUEST_FAILURE; |
872 | 848 |
wake_up(&master->sii_queue); |
1031
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
849 |
ec_fsm_master_restart(fsm); |
872 | 850 |
return; |
851 |
} |
|
852 |
||
853 |
fsm->sii_index++; |
|
979
405cc2d033e0
Renamed some fields in ec_sii_request_t to word addressing.
Florian Pose <fp@igh-essen.com>
parents:
969
diff
changeset
|
854 |
if (fsm->sii_index < request->nwords) { |
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
594
diff
changeset
|
855 |
ec_fsm_sii_write(&fsm->fsm_sii, slave, |
979
405cc2d033e0
Renamed some fields in ec_sii_request_t to word addressing.
Florian Pose <fp@igh-essen.com>
parents:
969
diff
changeset
|
856 |
request->offset + fsm->sii_index, |
405cc2d033e0
Renamed some fields in ec_sii_request_t to word addressing.
Florian Pose <fp@igh-essen.com>
parents:
969
diff
changeset
|
857 |
request->words + fsm->sii_index, |
815
002fe9ec778f
Implemented missing datagram types.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
858 |
EC_FSM_SII_USE_CONFIGURED_ADDRESS); |
433
100f51f28cf2
Layed out SII state machine.
Florian Pose <fp@igh-essen.com>
parents:
430
diff
changeset
|
859 |
ec_fsm_sii_exec(&fsm->fsm_sii); // execute immediately |
269 | 860 |
return; |
861 |
} |
|
862 |
||
872 | 863 |
// finished writing SII |
607
7b1daa325c5f
Implemented alias reading/writing via sysfs.
Florian Pose <fp@igh-essen.com>
parents:
605
diff
changeset
|
864 |
if (master->debug_level) |
872 | 865 |
EC_DBG("Finished writing %u words of SII data to slave %u.\n", |
979
405cc2d033e0
Renamed some fields in ec_sii_request_t to word addressing.
Florian Pose <fp@igh-essen.com>
parents:
969
diff
changeset
|
866 |
request->nwords, slave->ring_position); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1064
diff
changeset
|
867 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1064
diff
changeset
|
868 |
if (request->offset <= 4 && request->offset + request->nwords > 4) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1064
diff
changeset
|
869 |
// alias was written |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1064
diff
changeset
|
870 |
slave->sii.alias = EC_READ_U16(request->words + 4); |
1579
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1507
diff
changeset
|
871 |
// TODO: read alias from register 0x0012 |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1064
diff
changeset
|
872 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1064
diff
changeset
|
873 |
// TODO: Evaluate other SII contents! |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
874 |
|
1209 | 875 |
request->state = EC_INT_REQUEST_SUCCESS; |
872 | 876 |
wake_up(&master->sii_queue); |
877 |
||
878 |
// check for another SII write request |
|
879 |
if (ec_fsm_master_action_process_sii(fsm)) |
|
601
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
594
diff
changeset
|
880 |
return; // processing another request |
d6d951b766e3
Introduced EEPROM write requests: EEPROM write operations from user
Florian Pose <fp@igh-essen.com>
parents:
594
diff
changeset
|
881 |
|
1031
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
882 |
ec_fsm_master_restart(fsm); |
419
cf724fc82a00
Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents:
411
diff
changeset
|
883 |
} |
cf724fc82a00
Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents:
411
diff
changeset
|
884 |
|
cf724fc82a00
Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents:
411
diff
changeset
|
885 |
/*****************************************************************************/ |
cf724fc82a00
Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents:
411
diff
changeset
|
886 |
|
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
887 |
/** Master state: SDO DICTIONARY. |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
888 |
*/ |
905
6d74ebc603ee
Renamed state sdodict to sdo_dictionary.
Florian Pose <fp@igh-essen.com>
parents:
904
diff
changeset
|
889 |
void ec_fsm_master_state_sdo_dictionary( |
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
890 |
ec_fsm_master_t *fsm /**< Master state machine. */ |
905
6d74ebc603ee
Renamed state sdodict to sdo_dictionary.
Florian Pose <fp@igh-essen.com>
parents:
904
diff
changeset
|
891 |
) |
419
cf724fc82a00
Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents:
411
diff
changeset
|
892 |
{ |
cf724fc82a00
Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents:
411
diff
changeset
|
893 |
ec_slave_t *slave = fsm->slave; |
cf724fc82a00
Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents:
411
diff
changeset
|
894 |
ec_master_t *master = fsm->master; |
cf724fc82a00
Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents:
411
diff
changeset
|
895 |
|
436
63214beb641d
Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
435
diff
changeset
|
896 |
if (ec_fsm_coe_exec(&fsm->fsm_coe)) return; |
63214beb641d
Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
435
diff
changeset
|
897 |
|
63214beb641d
Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
435
diff
changeset
|
898 |
if (!ec_fsm_coe_success(&fsm->fsm_coe)) { |
1031
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
899 |
ec_fsm_master_restart(fsm); |
419
cf724fc82a00
Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents:
411
diff
changeset
|
900 |
return; |
cf724fc82a00
Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents:
411
diff
changeset
|
901 |
} |
cf724fc82a00
Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents:
411
diff
changeset
|
902 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
903 |
// SDO dictionary fetching finished |
419
cf724fc82a00
Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents:
411
diff
changeset
|
904 |
|
cf724fc82a00
Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents:
411
diff
changeset
|
905 |
if (master->debug_level) { |
423
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
422
diff
changeset
|
906 |
unsigned int sdo_count, entry_count; |
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
422
diff
changeset
|
907 |
ec_slave_sdo_dict_info(slave, &sdo_count, &entry_count); |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
908 |
EC_DBG("Fetched %u SDOs and %u entries from slave %u.\n", |
423
862ff892cf18
Better debugging output for SDO dictionaries.
Florian Pose <fp@igh-essen.com>
parents:
422
diff
changeset
|
909 |
sdo_count, entry_count, slave->ring_position); |
419
cf724fc82a00
Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents:
411
diff
changeset
|
910 |
} |
cf724fc82a00
Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents:
411
diff
changeset
|
911 |
|
1186
ff481f097c97
Attach Pdo names from dictionary.
Florian Pose <fp@igh-essen.com>
parents:
1177
diff
changeset
|
912 |
// attach pdo names from dictionary |
ff481f097c97
Attach Pdo names from dictionary.
Florian Pose <fp@igh-essen.com>
parents:
1177
diff
changeset
|
913 |
ec_slave_attach_pdo_names(slave); |
ff481f097c97
Attach Pdo names from dictionary.
Florian Pose <fp@igh-essen.com>
parents:
1177
diff
changeset
|
914 |
|
1031
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
915 |
ec_fsm_master_restart(fsm); |
269 | 916 |
} |
917 |
||
430
74754f45d5fa
Implemented SDO reading via Sysfs.
Florian Pose <fp@igh-essen.com>
parents:
429
diff
changeset
|
918 |
/*****************************************************************************/ |
74754f45d5fa
Implemented SDO reading via Sysfs.
Florian Pose <fp@igh-essen.com>
parents:
429
diff
changeset
|
919 |
|
907
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
920 |
/** Master state: SDO REQUEST. |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
921 |
*/ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
922 |
void ec_fsm_master_state_sdo_request( |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
923 |
ec_fsm_master_t *fsm /**< Master state machine. */ |
570ae1c64465
Improved master state machine.
Florian Pose <fp@igh-essen.com>
parents:
906
diff
changeset
|
924 |
) |
430
74754f45d5fa
Implemented SDO reading via Sysfs.
Florian Pose <fp@igh-essen.com>
parents:
429
diff
changeset
|
925 |
{ |
74754f45d5fa
Implemented SDO reading via Sysfs.
Florian Pose <fp@igh-essen.com>
parents:
429
diff
changeset
|
926 |
ec_master_t *master = fsm->master; |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
853
diff
changeset
|
927 |
ec_sdo_request_t *request = fsm->sdo_request; |
436
63214beb641d
Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
435
diff
changeset
|
928 |
|
63214beb641d
Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
435
diff
changeset
|
929 |
if (ec_fsm_coe_exec(&fsm->fsm_coe)) return; |
63214beb641d
Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
435
diff
changeset
|
930 |
|
63214beb641d
Layed out CoE state machine.
Florian Pose <fp@igh-essen.com>
parents:
435
diff
changeset
|
931 |
if (!ec_fsm_coe_success(&fsm->fsm_coe)) { |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1579
diff
changeset
|
932 |
EC_DBG("Failed to process internal SDO request for slave %u.\n", |
646
fbbd4e54e031
Implemented SDO reading with wait queues.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
933 |
fsm->slave->ring_position); |
1209 | 934 |
request->state = EC_INT_REQUEST_FAILURE; |
1596
ea8d2b4ee742
Moved sdo request queue to slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
935 |
wake_up(&fsm->slave->sdo_queue); |
1031
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
936 |
ec_fsm_master_restart(fsm); |
646
fbbd4e54e031
Implemented SDO reading with wait queues.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
937 |
return; |
fbbd4e54e031
Implemented SDO reading with wait queues.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
938 |
} |
fbbd4e54e031
Implemented SDO reading with wait queues.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
939 |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
940 |
// SDO request finished |
1209 | 941 |
request->state = EC_INT_REQUEST_SUCCESS; |
1596
ea8d2b4ee742
Moved sdo request queue to slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
942 |
wake_up(&fsm->slave->sdo_queue); |
646
fbbd4e54e031
Implemented SDO reading with wait queues.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
943 |
|
fbbd4e54e031
Implemented SDO reading with wait queues.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
944 |
if (master->debug_level) |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1579
diff
changeset
|
945 |
EC_DBG("Finished internal SDO request for slave %u.\n", |
646
fbbd4e54e031
Implemented SDO reading with wait queues.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
946 |
fsm->slave->ring_position); |
fbbd4e54e031
Implemented SDO reading with wait queues.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
947 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
948 |
// check for another SDO request |
646
fbbd4e54e031
Implemented SDO reading with wait queues.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
949 |
if (ec_fsm_master_action_process_sdo(fsm)) |
fbbd4e54e031
Implemented SDO reading with wait queues.
Florian Pose <fp@igh-essen.com>
parents:
645
diff
changeset
|
950 |
return; // processing another request |
430
74754f45d5fa
Implemented SDO reading via Sysfs.
Florian Pose <fp@igh-essen.com>
parents:
429
diff
changeset
|
951 |
|
1031
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
952 |
ec_fsm_master_restart(fsm); |
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
953 |
} |
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
954 |
|
000593b576dd
Removed 'end' and 'error' states from master state machine.
Florian Pose <fp@igh-essen.com>
parents:
1029
diff
changeset
|
955 |
/*****************************************************************************/ |
1200 | 956 |
|
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
957 |
/** Master state: REG REQUEST. |
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
958 |
*/ |
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
959 |
void ec_fsm_master_state_reg_request( |
1200 | 960 |
ec_fsm_master_t *fsm /**< Master state machine. */ |
961 |
) |
|
962 |
{ |
|
963 |
ec_master_t *master = fsm->master; |
|
964 |
ec_datagram_t *datagram = fsm->datagram; |
|
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
965 |
ec_reg_request_t *request = fsm->reg_request; |
1200 | 966 |
|
967 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
|
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
968 |
EC_ERR("Failed to receive register request datagram (state %u).\n", |
1200 | 969 |
datagram->state); |
1209 | 970 |
request->state = EC_INT_REQUEST_FAILURE; |
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
971 |
wake_up(&master->reg_queue); |
1200 | 972 |
ec_fsm_master_restart(fsm); |
973 |
return; |
|
974 |
} |
|
1579
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1507
diff
changeset
|
975 |
|
1385
241a7511eee9
Process working counter of phy_* commands.
Florian Pose <fp@igh-essen.com>
parents:
1380
diff
changeset
|
976 |
if (datagram->working_counter == 1) { |
241a7511eee9
Process working counter of phy_* commands.
Florian Pose <fp@igh-essen.com>
parents:
1380
diff
changeset
|
977 |
if (request->dir == EC_DIR_INPUT) { // read request |
241a7511eee9
Process working counter of phy_* commands.
Florian Pose <fp@igh-essen.com>
parents:
1380
diff
changeset
|
978 |
if (request->data) |
241a7511eee9
Process working counter of phy_* commands.
Florian Pose <fp@igh-essen.com>
parents:
1380
diff
changeset
|
979 |
kfree(request->data); |
241a7511eee9
Process working counter of phy_* commands.
Florian Pose <fp@igh-essen.com>
parents:
1380
diff
changeset
|
980 |
request->data = kmalloc(request->length, GFP_KERNEL); |
241a7511eee9
Process working counter of phy_* commands.
Florian Pose <fp@igh-essen.com>
parents:
1380
diff
changeset
|
981 |
if (!request->data) { |
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
982 |
EC_ERR("Failed to allocate %u bytes of memory for" |
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
983 |
" register data.\n", request->length); |
1385
241a7511eee9
Process working counter of phy_* commands.
Florian Pose <fp@igh-essen.com>
parents:
1380
diff
changeset
|
984 |
request->state = EC_INT_REQUEST_FAILURE; |
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
985 |
wake_up(&master->reg_queue); |
1385
241a7511eee9
Process working counter of phy_* commands.
Florian Pose <fp@igh-essen.com>
parents:
1380
diff
changeset
|
986 |
ec_fsm_master_restart(fsm); |
241a7511eee9
Process working counter of phy_* commands.
Florian Pose <fp@igh-essen.com>
parents:
1380
diff
changeset
|
987 |
return; |
241a7511eee9
Process working counter of phy_* commands.
Florian Pose <fp@igh-essen.com>
parents:
1380
diff
changeset
|
988 |
} |
241a7511eee9
Process working counter of phy_* commands.
Florian Pose <fp@igh-essen.com>
parents:
1380
diff
changeset
|
989 |
memcpy(request->data, datagram->data, request->length); |
1200 | 990 |
} |
1385
241a7511eee9
Process working counter of phy_* commands.
Florian Pose <fp@igh-essen.com>
parents:
1380
diff
changeset
|
991 |
|
241a7511eee9
Process working counter of phy_* commands.
Florian Pose <fp@igh-essen.com>
parents:
1380
diff
changeset
|
992 |
request->state = EC_INT_REQUEST_SUCCESS; |
241a7511eee9
Process working counter of phy_* commands.
Florian Pose <fp@igh-essen.com>
parents:
1380
diff
changeset
|
993 |
} else { |
241a7511eee9
Process working counter of phy_* commands.
Florian Pose <fp@igh-essen.com>
parents:
1380
diff
changeset
|
994 |
request->state = EC_INT_REQUEST_FAILURE; |
241a7511eee9
Process working counter of phy_* commands.
Florian Pose <fp@igh-essen.com>
parents:
1380
diff
changeset
|
995 |
} |
241a7511eee9
Process working counter of phy_* commands.
Florian Pose <fp@igh-essen.com>
parents:
1380
diff
changeset
|
996 |
|
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
997 |
wake_up(&master->reg_queue); |
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
998 |
|
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
999 |
// check for another register request |
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1386
diff
changeset
|
1000 |
if (ec_fsm_master_action_process_register(fsm)) |
1200 | 1001 |
return; // processing another request |
1002 |
||
1003 |
ec_fsm_master_restart(fsm); |
|
1004 |
} |
|
1005 |
||
1006 |
/*****************************************************************************/ |