author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Fri, 05 Oct 2018 18:01:39 +0200 | |
branch | stable-1.5 |
changeset 2721 | d3855a6b0a9f |
parent 2510 | 1e8d9fcb5100 |
permissions | -rw-r--r-- |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
* $Id$ |
d83d92e1a919
Separated slave state machines.
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:
1225
diff
changeset
|
5 |
* Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
* |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
d83d92e1a919
Separated slave state machines.
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:
1225
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:
1225
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:
1225
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:
1225
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:
1225
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:
1225
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:
1225
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:
1225
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:
1225
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:
1225
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:
1225
diff
changeset
|
19 |
* with the IgH EtherCAT Master; if not, write to the Free Software |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
20 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
21 |
* |
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
22 |
* --- |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
23 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1338
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:
1338
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:
1338
diff
changeset
|
26 |
* industrial property and similar rights of Beckhoff Automation GmbH. |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
27 |
* |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
30 |
/** |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
31 |
\file |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
EtherCAT slave state machines. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
*/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
#include "globals.h" |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
#include "master.h" |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
#include "mailbox.h" |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
#include "slave_config.h" |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
#include "fsm_slave_scan.h" |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
45 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
46 |
void ec_fsm_slave_scan_state_start(ec_fsm_slave_scan_t *); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
47 |
void ec_fsm_slave_scan_state_address(ec_fsm_slave_scan_t *); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
48 |
void ec_fsm_slave_scan_state_state(ec_fsm_slave_scan_t *); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
49 |
void ec_fsm_slave_scan_state_base(ec_fsm_slave_scan_t *); |
1419
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
50 |
void ec_fsm_slave_scan_state_dc_cap(ec_fsm_slave_scan_t *); |
1420
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
51 |
void ec_fsm_slave_scan_state_dc_times(ec_fsm_slave_scan_t *); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
52 |
void ec_fsm_slave_scan_state_datalink(ec_fsm_slave_scan_t *); |
2508
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
53 |
#ifdef EC_SII_ASSIGN |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
54 |
void ec_fsm_slave_scan_state_assign_sii(ec_fsm_slave_scan_t *); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
55 |
#endif |
872 | 56 |
void ec_fsm_slave_scan_state_sii_size(ec_fsm_slave_scan_t *); |
57 |
void ec_fsm_slave_scan_state_sii_data(ec_fsm_slave_scan_t *); |
|
1934
f00951ab7399
Introduced configure switch --enable-regalias for enabling reading alias
Florian Pose <fp@igh-essen.com>
parents:
1924
diff
changeset
|
58 |
#ifdef EC_REGALIAS |
1579
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
59 |
void ec_fsm_slave_scan_state_regalias(ec_fsm_slave_scan_t *); |
1934
f00951ab7399
Introduced configure switch --enable-regalias for enabling reading alias
Florian Pose <fp@igh-essen.com>
parents:
1924
diff
changeset
|
60 |
#endif |
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
61 |
void ec_fsm_slave_scan_state_preop(ec_fsm_slave_scan_t *); |
1338
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
62 |
void ec_fsm_slave_scan_state_sync(ec_fsm_slave_scan_t *); |
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
63 |
void ec_fsm_slave_scan_state_pdos(ec_fsm_slave_scan_t *); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
64 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
65 |
void ec_fsm_slave_scan_state_end(ec_fsm_slave_scan_t *); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
66 |
void ec_fsm_slave_scan_state_error(ec_fsm_slave_scan_t *); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
67 |
|
1419
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
68 |
void ec_fsm_slave_scan_enter_datalink(ec_fsm_slave_scan_t *); |
1934
f00951ab7399
Introduced configure switch --enable-regalias for enabling reading alias
Florian Pose <fp@igh-essen.com>
parents:
1924
diff
changeset
|
69 |
#ifdef EC_REGALIAS |
1579
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
70 |
void ec_fsm_slave_scan_enter_regalias(ec_fsm_slave_scan_t *); |
1934
f00951ab7399
Introduced configure switch --enable-regalias for enabling reading alias
Florian Pose <fp@igh-essen.com>
parents:
1924
diff
changeset
|
71 |
#endif |
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
72 |
void ec_fsm_slave_scan_enter_preop(ec_fsm_slave_scan_t *); |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
73 |
void ec_fsm_slave_scan_enter_pdos(ec_fsm_slave_scan_t *); |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
74 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
75 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
76 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
77 |
/** Constructor. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
78 |
*/ |
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
79 |
void ec_fsm_slave_scan_init( |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
80 |
ec_fsm_slave_scan_t *fsm, /**< Slave scanning state machine. */ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
81 |
ec_datagram_t *datagram, /**< Datagram to use. */ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
82 |
ec_fsm_slave_config_t *fsm_slave_config, /**< Slave configuration |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
83 |
state machine to use. */ |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
84 |
ec_fsm_pdo_t *fsm_pdo /**< PDO configuration machine to use. */ |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
85 |
) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
86 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
87 |
fsm->datagram = datagram; |
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
88 |
fsm->fsm_slave_config = fsm_slave_config; |
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
89 |
fsm->fsm_pdo = fsm_pdo; |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
90 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
91 |
// init sub state machines |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
92 |
ec_fsm_sii_init(&fsm->fsm_sii, fsm->datagram); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
93 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
94 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
95 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
96 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
97 |
/** Destructor. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
98 |
*/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
99 |
void ec_fsm_slave_scan_clear(ec_fsm_slave_scan_t *fsm /**< slave state machine */) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
100 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
101 |
// clear sub state machines |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
102 |
ec_fsm_sii_clear(&fsm->fsm_sii); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
103 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
104 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
105 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
106 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
107 |
/** |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
108 |
* Start slave scan state machine. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
109 |
*/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
110 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
111 |
void ec_fsm_slave_scan_start( |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
112 |
ec_fsm_slave_scan_t *fsm, /**< slave state machine */ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
113 |
ec_slave_t *slave /**< slave to configure */ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
114 |
) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
115 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
116 |
fsm->slave = slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
117 |
fsm->state = ec_fsm_slave_scan_state_start; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
118 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
119 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
120 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
121 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
122 |
/** |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
123 |
\return false, if state machine has terminated |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
124 |
*/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
125 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
126 |
int ec_fsm_slave_scan_running(const ec_fsm_slave_scan_t *fsm /**< slave state machine */) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
127 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
128 |
return fsm->state != ec_fsm_slave_scan_state_end |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
129 |
&& fsm->state != ec_fsm_slave_scan_state_error; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
130 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
131 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
132 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
133 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
134 |
/** |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
135 |
Executes the current state of the state machine. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
136 |
If the state machine's datagram is not sent or received yet, the execution |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
137 |
of the state machine is delayed to the next cycle. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
138 |
\return false, if state machine has terminated |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
139 |
*/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
140 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
141 |
int ec_fsm_slave_scan_exec(ec_fsm_slave_scan_t *fsm /**< slave state machine */) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
142 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
143 |
if (fsm->datagram->state == EC_DATAGRAM_SENT |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
144 |
|| fsm->datagram->state == EC_DATAGRAM_QUEUED) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
145 |
// datagram was not sent or received yet. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
146 |
return ec_fsm_slave_scan_running(fsm); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
147 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
148 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
149 |
fsm->state(fsm); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
150 |
return ec_fsm_slave_scan_running(fsm); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
151 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
152 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
153 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
154 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
155 |
/** |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
156 |
\return true, if the state machine terminated gracefully |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
157 |
*/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
158 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
159 |
int ec_fsm_slave_scan_success(const ec_fsm_slave_scan_t *fsm /**< slave state machine */) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
160 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
161 |
return fsm->state == ec_fsm_slave_scan_state_end; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
162 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
163 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
164 |
/****************************************************************************** |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
165 |
* slave scan state machine |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
166 |
*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
167 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
168 |
/** |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
169 |
Slave scan state: START. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
170 |
First state of the slave state machine. Writes the station address to the |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
171 |
slave, according to its ring position. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
172 |
*/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
173 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
174 |
void ec_fsm_slave_scan_state_start(ec_fsm_slave_scan_t *fsm /**< slave state machine */) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
175 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
176 |
// write station address |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
177 |
ec_datagram_apwr(fsm->datagram, fsm->slave->ring_position, 0x0010, 2); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
178 |
EC_WRITE_U16(fsm->datagram->data, fsm->slave->station_address); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
179 |
fsm->retries = EC_FSM_RETRIES; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
180 |
fsm->state = ec_fsm_slave_scan_state_address; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
181 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
182 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
183 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
184 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
185 |
/** |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
186 |
Slave scan state: ADDRESS. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
187 |
*/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
188 |
|
1822
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
189 |
void ec_fsm_slave_scan_state_address( |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
190 |
ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
191 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
192 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
193 |
ec_datagram_t *datagram = fsm->datagram; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
194 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
195 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
196 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
197 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
198 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
199 |
fsm->state = ec_fsm_slave_scan_state_error; |
1921 | 200 |
EC_SLAVE_ERR(fsm->slave, |
201 |
"Failed to receive station address datagram: "); |
|
1822
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
202 |
ec_datagram_print_state(datagram); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
203 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
204 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
205 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
206 |
if (datagram->working_counter != 1) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
207 |
fsm->slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
208 |
fsm->state = ec_fsm_slave_scan_state_error; |
1921 | 209 |
EC_SLAVE_ERR(fsm->slave, "Failed to write station address: "); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
210 |
ec_datagram_print_wc_error(datagram); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
211 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
212 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
213 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
214 |
// Read AL state |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
215 |
ec_datagram_fprd(datagram, fsm->slave->station_address, 0x0130, 2); |
1225
4d5b739edcb5
Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
216 |
ec_datagram_zero(datagram); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
217 |
fsm->retries = EC_FSM_RETRIES; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
218 |
fsm->state = ec_fsm_slave_scan_state_state; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
219 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
220 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
221 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
222 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
223 |
/** |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
224 |
Slave scan state: STATE. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
225 |
*/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
226 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
227 |
void ec_fsm_slave_scan_state_state( |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
228 |
ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
229 |
) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
230 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
231 |
ec_datagram_t *datagram = fsm->datagram; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
232 |
ec_slave_t *slave = fsm->slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
233 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
234 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
235 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
236 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
237 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
238 |
fsm->state = ec_fsm_slave_scan_state_error; |
1921 | 239 |
EC_SLAVE_ERR(slave, "Failed to receive AL state datagram: "); |
1822
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
240 |
ec_datagram_print_state(datagram); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
241 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
242 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
243 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
244 |
if (datagram->working_counter != 1) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
245 |
fsm->slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
246 |
fsm->state = ec_fsm_slave_scan_state_error; |
1921 | 247 |
EC_SLAVE_ERR(slave, "Failed to read AL state: "); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
248 |
ec_datagram_print_wc_error(datagram); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
249 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
250 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
251 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
252 |
slave->current_state = EC_READ_U8(datagram->data); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
253 |
if (slave->current_state & EC_SLAVE_STATE_ACK_ERR) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
254 |
char state_str[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:
1327
diff
changeset
|
255 |
ec_state_string(slave->current_state, state_str, 0); |
1921 | 256 |
EC_SLAVE_WARN(slave, "Slave has state error bit set (%s)!\n", |
257 |
state_str); |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
258 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
259 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
260 |
// read base data |
1379
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
261 |
ec_datagram_fprd(datagram, fsm->slave->station_address, 0x0000, 12); |
1225
4d5b739edcb5
Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
262 |
ec_datagram_zero(datagram); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
263 |
fsm->retries = EC_FSM_RETRIES; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
264 |
fsm->state = ec_fsm_slave_scan_state_base; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
265 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
266 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
267 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
268 |
|
1420
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
269 |
/** Slave scan state: BASE. |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
270 |
*/ |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
271 |
void ec_fsm_slave_scan_state_base( |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
272 |
ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
273 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
274 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
275 |
ec_datagram_t *datagram = fsm->datagram; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
276 |
ec_slave_t *slave = fsm->slave; |
1379
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
277 |
u8 octet; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
278 |
int i; |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
279 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
280 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
281 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
282 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
283 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
284 |
fsm->state = ec_fsm_slave_scan_state_error; |
1921 | 285 |
EC_SLAVE_ERR(slave, "Failed to receive base data datagram: "); |
1822
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
286 |
ec_datagram_print_state(datagram); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
287 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
288 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
289 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
290 |
if (datagram->working_counter != 1) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
291 |
fsm->slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
292 |
fsm->state = ec_fsm_slave_scan_state_error; |
1921 | 293 |
EC_SLAVE_ERR(slave, "Failed to read base data: "); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
294 |
ec_datagram_print_wc_error(datagram); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
295 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
296 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
297 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
298 |
slave->base_type = EC_READ_U8 (datagram->data); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
299 |
slave->base_revision = EC_READ_U8 (datagram->data + 1); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
300 |
slave->base_build = EC_READ_U16(datagram->data + 2); |
1379
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
301 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
302 |
slave->base_fmmu_count = EC_READ_U8 (datagram->data + 4); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
303 |
if (slave->base_fmmu_count > EC_MAX_FMMUS) { |
1921 | 304 |
EC_SLAVE_WARN(slave, "Slave has more FMMUs (%u) than the master can" |
305 |
" handle (%u).\n", slave->base_fmmu_count, EC_MAX_FMMUS); |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
306 |
slave->base_fmmu_count = EC_MAX_FMMUS; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
307 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
308 |
|
1470 | 309 |
slave->base_sync_count = EC_READ_U8(datagram->data + 5); |
1379
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
310 |
if (slave->base_sync_count > EC_MAX_SYNC_MANAGERS) { |
1921 | 311 |
EC_SLAVE_WARN(slave, "Slave provides more sync managers (%u)" |
312 |
" than the master can handle (%u).\n", |
|
1379
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
313 |
slave->base_sync_count, EC_MAX_SYNC_MANAGERS); |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
314 |
slave->base_sync_count = EC_MAX_SYNC_MANAGERS; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
315 |
} |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
316 |
|
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
317 |
octet = EC_READ_U8(datagram->data + 7); |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
318 |
for (i = 0; i < EC_MAX_PORTS; i++) { |
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1420
diff
changeset
|
319 |
slave->ports[i].desc = (octet >> (2 * i)) & 0x03; |
1379
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
320 |
} |
1579
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
321 |
|
1379
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
322 |
octet = EC_READ_U8(datagram->data + 8); |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
323 |
slave->base_fmmu_bit_operation = octet & 0x01; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
324 |
slave->base_dc_supported = (octet >> 2) & 0x01; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
325 |
slave->base_dc_range = ((octet >> 3) & 0x01) ? EC_DC_64 : EC_DC_32; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
326 |
|
1419
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
327 |
if (slave->base_dc_supported) { |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
328 |
// read DC capabilities |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
329 |
ec_datagram_fprd(datagram, slave->station_address, 0x0910, |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
330 |
slave->base_dc_range == EC_DC_64 ? 8 : 4); |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
331 |
ec_datagram_zero(datagram); |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
332 |
fsm->retries = EC_FSM_RETRIES; |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
333 |
fsm->state = ec_fsm_slave_scan_state_dc_cap; |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
334 |
} else { |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
335 |
ec_fsm_slave_scan_enter_datalink(fsm); |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
336 |
} |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
337 |
} |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
338 |
|
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
339 |
/*****************************************************************************/ |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
340 |
|
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
341 |
/** |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
342 |
Slave scan state: DC CAPABILITIES. |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
343 |
*/ |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
344 |
|
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
345 |
void ec_fsm_slave_scan_state_dc_cap( |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
346 |
ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
347 |
) |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
348 |
{ |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
349 |
ec_datagram_t *datagram = fsm->datagram; |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
350 |
ec_slave_t *slave = fsm->slave; |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
351 |
|
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
352 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
353 |
return; |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
354 |
|
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
355 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
356 |
fsm->state = ec_fsm_slave_scan_state_error; |
1921 | 357 |
EC_SLAVE_ERR(slave, "Failed to receive system time datagram: "); |
1822
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
358 |
ec_datagram_print_state(datagram); |
1419
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
359 |
return; |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
360 |
} |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
361 |
|
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
362 |
if (datagram->working_counter == 1) { |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
363 |
slave->has_dc_system_time = 1; |
1921 | 364 |
EC_SLAVE_DBG(slave, 1, "Slave has the System Time register.\n"); |
1419
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
365 |
} else if (datagram->working_counter == 0) { |
1921 | 366 |
EC_SLAVE_DBG(slave, 1, "Slave has no System Time register; delay " |
367 |
"measurement only.\n"); |
|
1419
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
368 |
} else { |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
369 |
fsm->slave->error_flag = 1; |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
370 |
fsm->state = ec_fsm_slave_scan_state_error; |
1921 | 371 |
EC_SLAVE_ERR(slave, "Failed to determine, if system time register is " |
372 |
"supported: "); |
|
1419
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
373 |
ec_datagram_print_wc_error(datagram); |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
374 |
return; |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
375 |
} |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
376 |
|
1420
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
377 |
// read DC port receive times |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
378 |
ec_datagram_fprd(datagram, slave->station_address, 0x0900, 16); |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
379 |
ec_datagram_zero(datagram); |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
380 |
fsm->retries = EC_FSM_RETRIES; |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
381 |
fsm->state = ec_fsm_slave_scan_state_dc_times; |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
382 |
} |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
383 |
|
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
384 |
/*****************************************************************************/ |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
385 |
|
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
386 |
/** |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
387 |
Slave scan state: DC TIMES. |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
388 |
*/ |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
389 |
|
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
390 |
void ec_fsm_slave_scan_state_dc_times( |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
391 |
ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
392 |
) |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
393 |
{ |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
394 |
ec_datagram_t *datagram = fsm->datagram; |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
395 |
ec_slave_t *slave = fsm->slave; |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
396 |
int i; |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
397 |
|
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
398 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
399 |
return; |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
400 |
|
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
401 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
402 |
fsm->state = ec_fsm_slave_scan_state_error; |
1921 | 403 |
EC_SLAVE_ERR(slave, "Failed to receive system time datagram: "); |
1822
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
404 |
ec_datagram_print_state(datagram); |
1420
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
405 |
return; |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
406 |
} |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
407 |
|
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
408 |
if (datagram->working_counter != 1) { |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
409 |
fsm->slave->error_flag = 1; |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
410 |
fsm->state = ec_fsm_slave_scan_state_error; |
1921 | 411 |
EC_SLAVE_ERR(slave, "Failed to get DC receive times: "); |
1420
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
412 |
ec_datagram_print_wc_error(datagram); |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
413 |
return; |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
414 |
} |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
415 |
|
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
416 |
for (i = 0; i < EC_MAX_PORTS; i++) { |
1425
c1322a8793c0
Transition delay calculation. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1420
diff
changeset
|
417 |
slave->ports[i].receive_time = EC_READ_U32(datagram->data + 4 * i); |
1420
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
418 |
} |
5eb814732c46
Measure port receive times.
Florian Pose <fp@igh-essen.com>
parents:
1419
diff
changeset
|
419 |
|
1419
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
420 |
ec_fsm_slave_scan_enter_datalink(fsm); |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
421 |
} |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
422 |
|
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
423 |
/*****************************************************************************/ |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
424 |
|
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
425 |
/** |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
426 |
Slave scan entry function: DATALINK. |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
427 |
*/ |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
428 |
|
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
429 |
void ec_fsm_slave_scan_enter_datalink( |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
430 |
ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
431 |
) |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
432 |
{ |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
433 |
ec_datagram_t *datagram = fsm->datagram; |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
434 |
ec_slave_t *slave = fsm->slave; |
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1379
diff
changeset
|
435 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
436 |
// read data link status |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
437 |
ec_datagram_fprd(datagram, slave->station_address, 0x0110, 2); |
1225
4d5b739edcb5
Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
438 |
ec_datagram_zero(datagram); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
439 |
fsm->retries = EC_FSM_RETRIES; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
440 |
fsm->state = ec_fsm_slave_scan_state_datalink; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
441 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
442 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
443 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
444 |
|
2508
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
445 |
/** Enter slave scan state SII_SIZE. |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
446 |
*/ |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
447 |
void ec_fsm_slave_scan_enter_sii_size( |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
448 |
ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
449 |
) |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
450 |
{ |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
451 |
// Start fetching SII size |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
452 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
453 |
fsm->sii_offset = EC_FIRST_SII_CATEGORY_OFFSET; // first category header |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
454 |
ec_fsm_sii_read(&fsm->fsm_sii, fsm->slave, fsm->sii_offset, |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
455 |
EC_FSM_SII_USE_CONFIGURED_ADDRESS); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
456 |
fsm->state = ec_fsm_slave_scan_state_sii_size; |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
457 |
fsm->state(fsm); // execute state immediately |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
458 |
} |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
459 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
460 |
/*****************************************************************************/ |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
461 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
462 |
#ifdef EC_SII_ASSIGN |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
463 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
464 |
/** Enter slave scan state ASSIGN_SII. |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
465 |
*/ |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
466 |
void ec_fsm_slave_scan_enter_assign_sii( |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
467 |
ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
468 |
) |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
469 |
{ |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
470 |
ec_datagram_t *datagram = fsm->datagram; |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
471 |
ec_slave_t *slave = fsm->slave; |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
472 |
|
2510 | 473 |
EC_SLAVE_DBG(slave, 1, "Assigning SII access to EtherCAT.\n"); |
474 |
||
2508
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
475 |
// assign SII to ECAT |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
476 |
ec_datagram_fpwr(datagram, slave->station_address, 0x0500, 1); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
477 |
EC_WRITE_U8(datagram->data, 0x00); // EtherCAT |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
478 |
fsm->retries = EC_FSM_RETRIES; |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
479 |
fsm->state = ec_fsm_slave_scan_state_assign_sii; |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
480 |
} |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
481 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
482 |
#endif |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
483 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
484 |
/*****************************************************************************/ |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
485 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
486 |
/** |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
487 |
Slave scan state: DATALINK. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
488 |
*/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
489 |
|
2508
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
490 |
void ec_fsm_slave_scan_state_datalink( |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
491 |
ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
492 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
493 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
494 |
ec_datagram_t *datagram = fsm->datagram; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
495 |
ec_slave_t *slave = fsm->slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
496 |
uint16_t dl_status; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
497 |
unsigned int i; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
498 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
499 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
500 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
501 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
502 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
503 |
fsm->state = ec_fsm_slave_scan_state_error; |
1921 | 504 |
EC_SLAVE_ERR(slave, "Failed to receive DL status datagram: "); |
1822
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
505 |
ec_datagram_print_state(datagram); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
506 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
507 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
508 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
509 |
if (datagram->working_counter != 1) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
510 |
fsm->slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
511 |
fsm->state = ec_fsm_slave_scan_state_error; |
1921 | 512 |
EC_SLAVE_ERR(slave, "Failed to read DL status: "); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
513 |
ec_datagram_print_wc_error(datagram); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
514 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
515 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
516 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
517 |
dl_status = EC_READ_U16(datagram->data); |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
518 |
for (i = 0; i < EC_MAX_PORTS; i++) { |
1921 | 519 |
slave->ports[i].link.link_up = |
520 |
dl_status & (1 << (4 + i)) ? 1 : 0; |
|
521 |
slave->ports[i].link.loop_closed = |
|
522 |
dl_status & (1 << (8 + i * 2)) ? 1 : 0; |
|
523 |
slave->ports[i].link.signal_detected = |
|
524 |
dl_status & (1 << (9 + i * 2)) ? 1 : 0; |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
525 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
526 |
|
2508
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
527 |
#ifdef EC_SII_ASSIGN |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
528 |
ec_fsm_slave_scan_enter_assign_sii(fsm); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
529 |
#else |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
530 |
ec_fsm_slave_scan_enter_sii_size(fsm); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
531 |
#endif |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
532 |
} |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
533 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
534 |
/*****************************************************************************/ |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
535 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
536 |
#ifdef EC_SII_ASSIGN |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
537 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
538 |
/** |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
539 |
Slave scan state: ASSIGN_SII. |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
540 |
*/ |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
541 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
542 |
void ec_fsm_slave_scan_state_assign_sii( |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
543 |
ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
544 |
) |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
545 |
{ |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
546 |
ec_datagram_t *datagram = fsm->datagram; |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
547 |
ec_slave_t *slave = fsm->slave; |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
548 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
549 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) { |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
550 |
return; |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
551 |
} |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
552 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
553 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
554 |
EC_SLAVE_WARN(slave, "Failed to receive SII assignment datagram: "); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
555 |
ec_datagram_print_state(datagram); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
556 |
// Try to go on, probably assignment is correct |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
557 |
goto continue_with_sii_size; |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
558 |
} |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
559 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
560 |
if (datagram->working_counter != 1) { |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
561 |
EC_SLAVE_WARN(slave, "Failed to assign SII to EtherCAT: "); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
562 |
ec_datagram_print_wc_error(datagram); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
563 |
// Try to go on, probably assignment is correct |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
564 |
} |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
565 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
566 |
continue_with_sii_size: |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
567 |
ec_fsm_slave_scan_enter_sii_size(fsm); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
568 |
} |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
569 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
570 |
#endif |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
571 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
572 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
573 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
574 |
/** |
872 | 575 |
Slave scan state: SII SIZE. |
576 |
*/ |
|
577 |
||
2508
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
578 |
void ec_fsm_slave_scan_state_sii_size( |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
579 |
ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
580 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
581 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
582 |
ec_slave_t *slave = fsm->slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
583 |
uint16_t cat_type, cat_size; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
584 |
|
1951 | 585 |
if (ec_fsm_sii_exec(&fsm->fsm_sii)) |
586 |
return; |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
587 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
588 |
if (!ec_fsm_sii_success(&fsm->fsm_sii)) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
589 |
fsm->slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
590 |
fsm->state = ec_fsm_slave_scan_state_error; |
1951 | 591 |
EC_SLAVE_ERR(slave, "Failed to determine SII content size:" |
1958
7dceb43bd855
Read at least 64 words, when SII size determination failed.
Florian Pose <fp@igh-essen.com>
parents:
1951
diff
changeset
|
592 |
" Reading word offset 0x%04x failed. Assuming %u words.\n", |
7dceb43bd855
Read at least 64 words, when SII size determination failed.
Florian Pose <fp@igh-essen.com>
parents:
1951
diff
changeset
|
593 |
fsm->sii_offset, EC_FIRST_SII_CATEGORY_OFFSET); |
7dceb43bd855
Read at least 64 words, when SII size determination failed.
Florian Pose <fp@igh-essen.com>
parents:
1951
diff
changeset
|
594 |
slave->sii_nwords = EC_FIRST_SII_CATEGORY_OFFSET; |
7dceb43bd855
Read at least 64 words, when SII size determination failed.
Florian Pose <fp@igh-essen.com>
parents:
1951
diff
changeset
|
595 |
goto alloc_sii; |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
596 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
597 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
598 |
cat_type = EC_READ_U16(fsm->fsm_sii.value); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
599 |
cat_size = EC_READ_U16(fsm->fsm_sii.value + 2); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
600 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
601 |
if (cat_type != 0xFFFF) { // not the last category |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
602 |
off_t next_offset = 2UL + fsm->sii_offset + cat_size; |
872 | 603 |
if (next_offset >= EC_MAX_SII_SIZE) { |
1921 | 604 |
EC_SLAVE_WARN(slave, "SII size exceeds %u words" |
605 |
" (0xffff limiter missing?).\n", EC_MAX_SII_SIZE); |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
606 |
// cut off category data... |
977 | 607 |
slave->sii_nwords = EC_FIRST_SII_CATEGORY_OFFSET; |
872 | 608 |
goto alloc_sii; |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
609 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
610 |
fsm->sii_offset = next_offset; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
611 |
ec_fsm_sii_read(&fsm->fsm_sii, slave, fsm->sii_offset, |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
612 |
EC_FSM_SII_USE_CONFIGURED_ADDRESS); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
613 |
ec_fsm_sii_exec(&fsm->fsm_sii); // execute state immediately |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
614 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
615 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
616 |
|
977 | 617 |
slave->sii_nwords = fsm->sii_offset + 1; |
872 | 618 |
|
619 |
alloc_sii: |
|
977 | 620 |
if (slave->sii_words) { |
1921 | 621 |
EC_SLAVE_WARN(slave, "Freeing old SII data...\n"); |
977 | 622 |
kfree(slave->sii_words); |
623 |
} |
|
624 |
||
625 |
if (!(slave->sii_words = |
|
998
05a24788f3b2
Replaced a few GFP_ATOMIC allocations with GFP_KERNEL ones.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
626 |
(uint16_t *) kmalloc(slave->sii_nwords * 2, GFP_KERNEL))) { |
1921 | 627 |
EC_SLAVE_ERR(slave, "Failed to allocate %zu words of SII data.\n", |
628 |
slave->sii_nwords); |
|
977 | 629 |
slave->sii_nwords = 0; |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
630 |
slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
631 |
fsm->state = ec_fsm_slave_scan_state_error; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
632 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
633 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
634 |
|
872 | 635 |
// Start fetching SII contents |
636 |
||
637 |
fsm->state = ec_fsm_slave_scan_state_sii_data; |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
638 |
fsm->sii_offset = 0x0000; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
639 |
ec_fsm_sii_read(&fsm->fsm_sii, slave, fsm->sii_offset, |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
640 |
EC_FSM_SII_USE_CONFIGURED_ADDRESS); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
641 |
ec_fsm_sii_exec(&fsm->fsm_sii); // execute state immediately |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
642 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
643 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
644 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
645 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
646 |
/** |
872 | 647 |
Slave scan state: SII DATA. |
648 |
*/ |
|
649 |
||
650 |
void ec_fsm_slave_scan_state_sii_data(ec_fsm_slave_scan_t *fsm /**< slave state machine */) |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
651 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
652 |
ec_slave_t *slave = fsm->slave; |
977 | 653 |
uint16_t *cat_word, cat_type, cat_size; |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
654 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
655 |
if (ec_fsm_sii_exec(&fsm->fsm_sii)) return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
656 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
657 |
if (!ec_fsm_sii_success(&fsm->fsm_sii)) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
658 |
fsm->slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
659 |
fsm->state = ec_fsm_slave_scan_state_error; |
1921 | 660 |
EC_SLAVE_ERR(slave, "Failed to fetch SII contents.\n"); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
661 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
662 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
663 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
664 |
// 2 words fetched |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
665 |
|
977 | 666 |
if (fsm->sii_offset + 2 <= slave->sii_nwords) { // 2 words fit |
667 |
memcpy(slave->sii_words + fsm->sii_offset, fsm->fsm_sii.value, 4); |
|
668 |
} else { // copy the last word |
|
669 |
memcpy(slave->sii_words + fsm->sii_offset, fsm->fsm_sii.value, 2); |
|
670 |
} |
|
671 |
||
672 |
if (fsm->sii_offset + 2 < slave->sii_nwords) { |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
673 |
// fetch the next 2 words |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
674 |
fsm->sii_offset += 2; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
675 |
ec_fsm_sii_read(&fsm->fsm_sii, slave, fsm->sii_offset, |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
676 |
EC_FSM_SII_USE_CONFIGURED_ADDRESS); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
677 |
ec_fsm_sii_exec(&fsm->fsm_sii); // execute state immediately |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
678 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
679 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
680 |
|
872 | 681 |
// Evaluate SII contents |
1579
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
682 |
|
870
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
841
diff
changeset
|
683 |
ec_slave_clear_sync_managers(slave); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
684 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
685 |
slave->sii.alias = |
977 | 686 |
EC_READ_U16(slave->sii_words + 0x0004); |
1909
ea3eb4c74c1b
Introduced effective_alias variable to separate reg12 alias from SII alias.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
687 |
slave->effective_alias = slave->sii.alias; |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
688 |
slave->sii.vendor_id = |
977 | 689 |
EC_READ_U32(slave->sii_words + 0x0008); |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
690 |
slave->sii.product_code = |
977 | 691 |
EC_READ_U32(slave->sii_words + 0x000A); |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
692 |
slave->sii.revision_number = |
977 | 693 |
EC_READ_U32(slave->sii_words + 0x000C); |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
694 |
slave->sii.serial_number = |
977 | 695 |
EC_READ_U32(slave->sii_words + 0x000E); |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
696 |
slave->sii.boot_rx_mailbox_offset = |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
697 |
EC_READ_U16(slave->sii_words + 0x0014); |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
698 |
slave->sii.boot_rx_mailbox_size = |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
699 |
EC_READ_U16(slave->sii_words + 0x0015); |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
700 |
slave->sii.boot_tx_mailbox_offset = |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
701 |
EC_READ_U16(slave->sii_words + 0x0016); |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
702 |
slave->sii.boot_tx_mailbox_size = |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
703 |
EC_READ_U16(slave->sii_words + 0x0017); |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
704 |
slave->sii.std_rx_mailbox_offset = |
977 | 705 |
EC_READ_U16(slave->sii_words + 0x0018); |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
706 |
slave->sii.std_rx_mailbox_size = |
977 | 707 |
EC_READ_U16(slave->sii_words + 0x0019); |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
708 |
slave->sii.std_tx_mailbox_offset = |
977 | 709 |
EC_READ_U16(slave->sii_words + 0x001A); |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
710 |
slave->sii.std_tx_mailbox_size = |
977 | 711 |
EC_READ_U16(slave->sii_words + 0x001B); |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
712 |
slave->sii.mailbox_protocols = |
977 | 713 |
EC_READ_U16(slave->sii_words + 0x001C); |
714 |
||
715 |
if (slave->sii_nwords == EC_FIRST_SII_CATEGORY_OFFSET) { |
|
872 | 716 |
// sii does not contain category data |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
717 |
fsm->state = ec_fsm_slave_scan_state_end; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
718 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
719 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
720 |
|
977 | 721 |
if (slave->sii_nwords < EC_FIRST_SII_CATEGORY_OFFSET + 1) { |
1921 | 722 |
EC_SLAVE_ERR(slave, "Unexpected end of SII data:" |
723 |
" First category header missing.\n"); |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
724 |
goto end; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
725 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
726 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
727 |
// evaluate category data |
977 | 728 |
cat_word = slave->sii_words + EC_FIRST_SII_CATEGORY_OFFSET; |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
729 |
while (EC_READ_U16(cat_word) != 0xFFFF) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
730 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
731 |
// type and size words must fit |
977 | 732 |
if (cat_word + 2 - slave->sii_words > slave->sii_nwords) { |
1921 | 733 |
EC_SLAVE_ERR(slave, "Unexpected end of SII data:" |
734 |
" Category header incomplete.\n"); |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
735 |
goto end; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
736 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
737 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
738 |
cat_type = EC_READ_U16(cat_word) & 0x7FFF; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
739 |
cat_size = EC_READ_U16(cat_word + 1); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
740 |
cat_word += 2; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
741 |
|
977 | 742 |
if (cat_word + cat_size - slave->sii_words > slave->sii_nwords) { |
1921 | 743 |
EC_SLAVE_WARN(slave, "Unexpected end of SII data:" |
744 |
" Category data incomplete.\n"); |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
745 |
goto end; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
746 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
747 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
748 |
switch (cat_type) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
749 |
case 0x000A: |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
750 |
if (ec_slave_fetch_sii_strings(slave, (uint8_t *) cat_word, |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
751 |
cat_size * 2)) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
752 |
goto end; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
753 |
break; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
754 |
case 0x001E: |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
755 |
if (ec_slave_fetch_sii_general(slave, (uint8_t *) cat_word, |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
756 |
cat_size * 2)) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
757 |
goto end; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
758 |
break; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
759 |
case 0x0028: |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
760 |
break; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
761 |
case 0x0029: |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
762 |
if (ec_slave_fetch_sii_syncs(slave, (uint8_t *) cat_word, |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
763 |
cat_size * 2)) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
764 |
goto end; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
765 |
break; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
766 |
case 0x0032: |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
767 |
if (ec_slave_fetch_sii_pdos( slave, (uint8_t *) cat_word, |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
768 |
cat_size * 2, EC_DIR_INPUT)) // TxPDO |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
769 |
goto end; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
770 |
break; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
771 |
case 0x0033: |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
772 |
if (ec_slave_fetch_sii_pdos( slave, (uint8_t *) cat_word, |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
773 |
cat_size * 2, EC_DIR_OUTPUT)) // RxPDO |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
774 |
goto end; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
775 |
break; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
776 |
default: |
1924 | 777 |
EC_SLAVE_DBG(slave, 1, "Unknown category type 0x%04X.\n", |
778 |
cat_type); |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
779 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
780 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
781 |
cat_word += cat_size; |
977 | 782 |
if (cat_word - slave->sii_words >= slave->sii_nwords) { |
1921 | 783 |
EC_SLAVE_WARN(slave, "Unexpected end of SII data:" |
784 |
" Next category header missing.\n"); |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
785 |
goto end; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
786 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
787 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
788 |
|
1934
f00951ab7399
Introduced configure switch --enable-regalias for enabling reading alias
Florian Pose <fp@igh-essen.com>
parents:
1924
diff
changeset
|
789 |
#ifdef EC_REGALIAS |
1579
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
790 |
ec_fsm_slave_scan_enter_regalias(fsm); |
1934
f00951ab7399
Introduced configure switch --enable-regalias for enabling reading alias
Florian Pose <fp@igh-essen.com>
parents:
1924
diff
changeset
|
791 |
#else |
f00951ab7399
Introduced configure switch --enable-regalias for enabling reading alias
Florian Pose <fp@igh-essen.com>
parents:
1924
diff
changeset
|
792 |
if (slave->sii.mailbox_protocols & EC_MBOX_COE) { |
f00951ab7399
Introduced configure switch --enable-regalias for enabling reading alias
Florian Pose <fp@igh-essen.com>
parents:
1924
diff
changeset
|
793 |
ec_fsm_slave_scan_enter_preop(fsm); |
f00951ab7399
Introduced configure switch --enable-regalias for enabling reading alias
Florian Pose <fp@igh-essen.com>
parents:
1924
diff
changeset
|
794 |
} else { |
f00951ab7399
Introduced configure switch --enable-regalias for enabling reading alias
Florian Pose <fp@igh-essen.com>
parents:
1924
diff
changeset
|
795 |
fsm->state = ec_fsm_slave_scan_state_end; |
f00951ab7399
Introduced configure switch --enable-regalias for enabling reading alias
Florian Pose <fp@igh-essen.com>
parents:
1924
diff
changeset
|
796 |
} |
f00951ab7399
Introduced configure switch --enable-regalias for enabling reading alias
Florian Pose <fp@igh-essen.com>
parents:
1924
diff
changeset
|
797 |
#endif |
1579
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
798 |
return; |
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
799 |
|
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
800 |
end: |
1921 | 801 |
EC_SLAVE_ERR(slave, "Failed to analyze category data.\n"); |
1579
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
802 |
fsm->slave->error_flag = 1; |
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
803 |
fsm->state = ec_fsm_slave_scan_state_error; |
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
804 |
} |
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
805 |
|
1934
f00951ab7399
Introduced configure switch --enable-regalias for enabling reading alias
Florian Pose <fp@igh-essen.com>
parents:
1924
diff
changeset
|
806 |
/*****************************************************************************/ |
f00951ab7399
Introduced configure switch --enable-regalias for enabling reading alias
Florian Pose <fp@igh-essen.com>
parents:
1924
diff
changeset
|
807 |
|
f00951ab7399
Introduced configure switch --enable-regalias for enabling reading alias
Florian Pose <fp@igh-essen.com>
parents:
1924
diff
changeset
|
808 |
#ifdef EC_REGALIAS |
f00951ab7399
Introduced configure switch --enable-regalias for enabling reading alias
Florian Pose <fp@igh-essen.com>
parents:
1924
diff
changeset
|
809 |
|
f00951ab7399
Introduced configure switch --enable-regalias for enabling reading alias
Florian Pose <fp@igh-essen.com>
parents:
1924
diff
changeset
|
810 |
/** Slave scan entry function: REGALIAS. |
f00951ab7399
Introduced configure switch --enable-regalias for enabling reading alias
Florian Pose <fp@igh-essen.com>
parents:
1924
diff
changeset
|
811 |
*/ |
1579
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
812 |
void ec_fsm_slave_scan_enter_regalias( |
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
813 |
ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
814 |
) |
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
815 |
{ |
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
816 |
ec_datagram_t *datagram = fsm->datagram; |
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
817 |
ec_slave_t *slave = fsm->slave; |
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
818 |
|
1909
ea3eb4c74c1b
Introduced effective_alias variable to separate reg12 alias from SII alias.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
819 |
// read alias from register |
1921 | 820 |
EC_SLAVE_DBG(slave, 1, "Reading alias from register.\n"); |
1579
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
821 |
ec_datagram_fprd(datagram, slave->station_address, 0x0012, 2); |
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
822 |
ec_datagram_zero(datagram); |
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
823 |
fsm->retries = EC_FSM_RETRIES; |
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
824 |
fsm->state = ec_fsm_slave_scan_state_regalias; |
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
825 |
} |
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
826 |
|
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
827 |
/*****************************************************************************/ |
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
828 |
|
1934
f00951ab7399
Introduced configure switch --enable-regalias for enabling reading alias
Florian Pose <fp@igh-essen.com>
parents:
1924
diff
changeset
|
829 |
/** Slave scan state: REGALIAS. |
f00951ab7399
Introduced configure switch --enable-regalias for enabling reading alias
Florian Pose <fp@igh-essen.com>
parents:
1924
diff
changeset
|
830 |
*/ |
1579
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
831 |
void ec_fsm_slave_scan_state_regalias( |
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
832 |
ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
1804 | 833 |
) |
1579
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
834 |
{ |
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
835 |
ec_datagram_t *datagram = fsm->datagram; |
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
836 |
ec_slave_t *slave = fsm->slave; |
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
837 |
|
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
838 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
839 |
return; |
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
840 |
|
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
841 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
842 |
fsm->state = ec_fsm_slave_scan_state_error; |
1921 | 843 |
EC_SLAVE_ERR(slave, "Failed to receive register alias datagram: "); |
1822
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
844 |
ec_datagram_print_state(datagram); |
1579
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
845 |
return; |
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
846 |
} |
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1470
diff
changeset
|
847 |
|
1776 | 848 |
if (datagram->working_counter != 1) { |
1921 | 849 |
EC_SLAVE_DBG(slave, 1, "Failed to read register alias.\n"); |
1776 | 850 |
} else { |
1909
ea3eb4c74c1b
Introduced effective_alias variable to separate reg12 alias from SII alias.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
851 |
slave->effective_alias = EC_READ_U16(datagram->data); |
1921 | 852 |
EC_SLAVE_DBG(slave, 1, "Read alias %u from register.\n", |
853 |
slave->effective_alias); |
|
1776 | 854 |
} |
1934
f00951ab7399
Introduced configure switch --enable-regalias for enabling reading alias
Florian Pose <fp@igh-essen.com>
parents:
1924
diff
changeset
|
855 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
856 |
if (slave->sii.mailbox_protocols & EC_MBOX_COE) { |
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
857 |
ec_fsm_slave_scan_enter_preop(fsm); |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
858 |
} else { |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
859 |
fsm->state = ec_fsm_slave_scan_state_end; |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
860 |
} |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
861 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
862 |
|
1934
f00951ab7399
Introduced configure switch --enable-regalias for enabling reading alias
Florian Pose <fp@igh-essen.com>
parents:
1924
diff
changeset
|
863 |
#endif // defined EC_REGALIAS |
f00951ab7399
Introduced configure switch --enable-regalias for enabling reading alias
Florian Pose <fp@igh-essen.com>
parents:
1924
diff
changeset
|
864 |
|
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
865 |
/*****************************************************************************/ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
866 |
|
841 | 867 |
/** Enter slave scan state PREOP. |
868 |
*/ |
|
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
869 |
void ec_fsm_slave_scan_enter_preop( |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
870 |
ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
871 |
) |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
872 |
{ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
873 |
ec_slave_t *slave = fsm->slave; |
1338
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
874 |
uint8_t current_state = slave->current_state & EC_SLAVE_STATE_MASK; |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
875 |
|
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
876 |
if (current_state != EC_SLAVE_STATE_PREOP |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
877 |
&& current_state != EC_SLAVE_STATE_SAFEOP |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
878 |
&& current_state != EC_SLAVE_STATE_OP) { |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
879 |
if (slave->master->debug_level) { |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
880 |
char str[EC_STATE_STRING_SIZE]; |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
881 |
ec_state_string(current_state, str, 0); |
1921 | 882 |
EC_SLAVE_DBG(slave, 0, "Slave is not in the state" |
883 |
" to do mailbox com (%s), setting to PREOP.\n", str); |
|
1338
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
884 |
} |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
885 |
|
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
886 |
fsm->state = ec_fsm_slave_scan_state_preop; |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
887 |
ec_slave_request_state(slave, EC_SLAVE_STATE_PREOP); |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
888 |
ec_fsm_slave_config_start(fsm->fsm_slave_config, slave); |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
889 |
ec_fsm_slave_config_exec(fsm->fsm_slave_config); |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
890 |
} else { |
1921 | 891 |
EC_SLAVE_DBG(slave, 1, "Reading mailbox" |
892 |
" sync manager configuration.\n"); |
|
1338
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
893 |
|
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
894 |
/* Scan current sync manager configuration to get configured mailbox |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
895 |
* sizes. */ |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
896 |
ec_datagram_fprd(fsm->datagram, slave->station_address, 0x0800, |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
897 |
EC_SYNC_PAGE_SIZE * 2); |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
898 |
fsm->retries = EC_FSM_RETRIES; |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
899 |
fsm->state = ec_fsm_slave_scan_state_sync; |
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
900 |
} |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
901 |
} |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
902 |
|
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
903 |
/*****************************************************************************/ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
904 |
|
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
905 |
/** Slave scan state: PREOP. |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
906 |
*/ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
907 |
void ec_fsm_slave_scan_state_preop( |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
908 |
ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
909 |
) |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
910 |
{ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
911 |
if (ec_fsm_slave_config_exec(fsm->fsm_slave_config)) |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
912 |
return; |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
913 |
|
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
914 |
if (!ec_fsm_slave_config_success(fsm->fsm_slave_config)) { |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
915 |
fsm->state = ec_fsm_slave_scan_state_error; |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
916 |
return; |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
917 |
} |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
918 |
|
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
919 |
ec_fsm_slave_scan_enter_pdos(fsm); |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
920 |
} |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
921 |
|
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
922 |
/*****************************************************************************/ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
923 |
|
1338
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
924 |
/** Slave scan state: SYNC. |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
925 |
*/ |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
926 |
void ec_fsm_slave_scan_state_sync( |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
927 |
ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
928 |
) |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
929 |
{ |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
930 |
ec_datagram_t *datagram = fsm->datagram; |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
931 |
ec_slave_t *slave = fsm->slave; |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
932 |
|
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
933 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
934 |
return; |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
935 |
|
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
936 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
937 |
fsm->state = ec_fsm_slave_scan_state_error; |
1921 | 938 |
EC_SLAVE_ERR(slave, "Failed to receive sync manager" |
939 |
" configuration datagram: "); |
|
1822
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
940 |
ec_datagram_print_state(datagram); |
1338
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
941 |
return; |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
942 |
} |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
943 |
|
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
944 |
if (datagram->working_counter != 1) { |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
945 |
fsm->slave->error_flag = 1; |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
946 |
fsm->state = ec_fsm_slave_scan_state_error; |
1921 | 947 |
EC_SLAVE_ERR(slave, "Failed to read DL status: "); |
1338
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
948 |
ec_datagram_print_wc_error(datagram); |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
949 |
return; |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
950 |
} |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
951 |
|
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
952 |
slave->configured_rx_mailbox_offset = EC_READ_U16(datagram->data); |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
953 |
slave->configured_rx_mailbox_size = EC_READ_U16(datagram->data + 2); |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
954 |
slave->configured_tx_mailbox_offset = EC_READ_U16(datagram->data + 8); |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
955 |
slave->configured_tx_mailbox_size = EC_READ_U16(datagram->data + 10); |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
956 |
|
1921 | 957 |
EC_SLAVE_DBG(slave, 1, "Mailbox configuration:\n"); |
958 |
EC_SLAVE_DBG(slave, 1, " RX offset=0x%04x size=%u\n", |
|
959 |
slave->configured_rx_mailbox_offset, |
|
960 |
slave->configured_rx_mailbox_size); |
|
961 |
EC_SLAVE_DBG(slave, 1, " TX offset=0x%04x size=%u\n", |
|
962 |
slave->configured_tx_mailbox_offset, |
|
963 |
slave->configured_tx_mailbox_size); |
|
1338
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
964 |
|
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
965 |
ec_fsm_slave_scan_enter_pdos(fsm); |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
966 |
} |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
967 |
|
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
968 |
/*****************************************************************************/ |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
969 |
|
841 | 970 |
/** Enter slave scan state PDOS. |
971 |
*/ |
|
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
972 |
void ec_fsm_slave_scan_enter_pdos( |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
973 |
ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
974 |
) |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
975 |
{ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
976 |
ec_slave_t *slave = fsm->slave; |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
977 |
|
1921 | 978 |
EC_SLAVE_DBG(slave, 1, "Scanning PDO assignment and mapping.\n"); |
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
979 |
fsm->state = ec_fsm_slave_scan_state_pdos; |
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
980 |
ec_fsm_pdo_start_reading(fsm->fsm_pdo, slave); |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
1958
diff
changeset
|
981 |
ec_fsm_pdo_exec(fsm->fsm_pdo, fsm->datagram); // execute immediately |
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
982 |
} |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
983 |
|
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
984 |
/*****************************************************************************/ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
985 |
|
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
986 |
/** Slave scan state: PDOS. |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
987 |
*/ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
988 |
void ec_fsm_slave_scan_state_pdos( |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
989 |
ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
990 |
) |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
991 |
{ |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
1958
diff
changeset
|
992 |
if (ec_fsm_pdo_exec(fsm->fsm_pdo, fsm->datagram)) { |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
1958
diff
changeset
|
993 |
return; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
1958
diff
changeset
|
994 |
} |
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
995 |
|
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
996 |
if (!ec_fsm_pdo_success(fsm->fsm_pdo)) { |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
997 |
fsm->state = ec_fsm_slave_scan_state_error; |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
998 |
return; |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
999 |
} |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1000 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
1001 |
// reading PDO configuration finished |
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
1002 |
fsm->state = ec_fsm_slave_scan_state_end; |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
1003 |
} |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
1004 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1005 |
/****************************************************************************** |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1006 |
* Common state functions |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1007 |
*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1008 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1009 |
/** State: ERROR. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1010 |
*/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1011 |
void ec_fsm_slave_scan_state_error( |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1012 |
ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1013 |
) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1014 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1015 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1016 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1017 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1018 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1019 |
/** State: END. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1020 |
*/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1021 |
void ec_fsm_slave_scan_state_end( |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1022 |
ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1023 |
) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1024 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1025 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1026 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1027 |
/*****************************************************************************/ |