author | Florian Pose <fp@igh-essen.com> |
Thu, 06 Dec 2012 18:11:11 +0100 | |
branch | stable-1.5 |
changeset 2485 | 5535603c34a0 |
parent 2467 | 74ede087bc85 |
child 2498 | 9cdd7669dc0b |
permissions | -rw-r--r-- |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
2 |
* |
2099
e485694c6427
Minor: Fixed broken keyword strings.
Florian Pose <fp@igh-essen.com>
parents:
2083
diff
changeset
|
3 |
* $Id$ |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
4 |
* |
2443
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
5 |
* Copyright (C) 2006-2012 Florian Pose, Ingenieurgemeinschaft IgH |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
6 |
* |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
8 |
* |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it and/or |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
10 |
* modify it under the terms of the GNU General Public License version 2, as |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
11 |
* published by the Free Software Foundation. |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
12 |
* |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
13 |
* The IgH EtherCAT Master is distributed in the hope that it will be useful, |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
16 |
* Public License for more details. |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
17 |
* |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
18 |
* You should have received a copy of the GNU General Public License along |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
19 |
* with the IgH EtherCAT Master; if not, write to the Free Software |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
20 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
21 |
* |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
22 |
* --- |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
23 |
* |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
24 |
* The license mentioned above concerns the source code only. Using the |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
25 |
* EtherCAT technology and brand is only permitted in compliance with the |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
26 |
* industrial property and similar rights of Beckhoff Automation GmbH. |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
27 |
* |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
28 |
*****************************************************************************/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
29 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
30 |
/** \file |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
31 |
* EtherCAT slave (SDO) state machine. |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
32 |
*/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
33 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
34 |
/*****************************************************************************/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
35 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
36 |
#include "globals.h" |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
37 |
#include "master.h" |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
38 |
#include "mailbox.h" |
2443
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
39 |
#include "slave_config.h" |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
40 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
41 |
#include "fsm_slave.h" |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
42 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
43 |
/*****************************************************************************/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
44 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
45 |
void ec_fsm_slave_state_idle(ec_fsm_slave_t *); |
1601
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
46 |
void ec_fsm_slave_state_ready(ec_fsm_slave_t *); |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
47 |
int ec_fsm_slave_action_process_sdo(ec_fsm_slave_t *); |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
48 |
void ec_fsm_slave_state_sdo_request(ec_fsm_slave_t *); |
2443
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
49 |
int ec_fsm_slave_action_process_reg(ec_fsm_slave_t *); |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
50 |
void ec_fsm_slave_state_reg_request(ec_fsm_slave_t *); |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
51 |
int ec_fsm_slave_action_process_foe(ec_fsm_slave_t *); |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
52 |
void ec_fsm_slave_state_foe_request(ec_fsm_slave_t *); |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
53 |
int ec_fsm_slave_action_process_soe(ec_fsm_slave_t *); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
54 |
void ec_fsm_slave_state_soe_request(ec_fsm_slave_t *); |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
55 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
56 |
/*****************************************************************************/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
57 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
58 |
/** Constructor. |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
59 |
*/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
60 |
void ec_fsm_slave_init( |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
61 |
ec_fsm_slave_t *fsm, /**< Slave state machine. */ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
62 |
ec_slave_t *slave, /**< EtherCAT slave. */ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
63 |
ec_datagram_t *datagram /**< Datagram object to use. */ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
64 |
) |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
65 |
{ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
66 |
fsm->slave = slave; |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
67 |
fsm->datagram = datagram; |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
68 |
fsm->datagram->data_size = 0; |
1804 | 69 |
|
1921 | 70 |
EC_SLAVE_DBG(slave, 1, "Init FSM.\n"); |
1804 | 71 |
|
72 |
fsm->state = ec_fsm_slave_state_idle; |
|
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
73 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
74 |
// init sub-state-machines |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
75 |
ec_fsm_coe_init(&fsm->fsm_coe, fsm->datagram); |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
76 |
ec_fsm_foe_init(&fsm->fsm_foe, fsm->datagram); |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
77 |
ec_fsm_soe_init(&fsm->fsm_soe, fsm->datagram); |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
78 |
} |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
79 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
80 |
/*****************************************************************************/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
81 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
82 |
/** Destructor. |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
83 |
*/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
84 |
void ec_fsm_slave_clear( |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
85 |
ec_fsm_slave_t *fsm /**< Master state machine. */ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
86 |
) |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
87 |
{ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
88 |
// clear sub-state machines |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
89 |
ec_fsm_coe_clear(&fsm->fsm_coe); |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
90 |
ec_fsm_foe_clear(&fsm->fsm_foe); |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
91 |
ec_fsm_soe_clear(&fsm->fsm_soe); |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
92 |
} |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
93 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
94 |
/*****************************************************************************/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
95 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
96 |
/** Executes the current state of the state machine. |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
97 |
* |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
98 |
* If the state machine's datagram is not sent or received yet, the execution |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
99 |
* of the state machine is delayed to the next cycle. |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
100 |
*/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
101 |
void ec_fsm_slave_exec( |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
102 |
ec_fsm_slave_t *fsm /**< Slave state machine. */ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
103 |
) |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
104 |
{ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
105 |
if (fsm->datagram->state == EC_DATAGRAM_SENT |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
106 |
|| fsm->datagram->state == EC_DATAGRAM_QUEUED) { |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
107 |
// datagram was not sent or received yet. |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
108 |
return; |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
109 |
} |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
110 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
111 |
fsm->state(fsm); |
2440
341d9575745d
Output slave FSM datagram statistics.
Florian Pose <fp@igh-essen.com>
parents:
2419
diff
changeset
|
112 |
|
341d9575745d
Output slave FSM datagram statistics.
Florian Pose <fp@igh-essen.com>
parents:
2419
diff
changeset
|
113 |
ec_datagram_output_stats(fsm->datagram); |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
114 |
} |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
115 |
|
1601
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
116 |
/*****************************************************************************/ |
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
117 |
|
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
118 |
/** Sets the current state of the state machine to READY |
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
119 |
*/ |
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
120 |
void ec_fsm_slave_ready( |
1804 | 121 |
ec_fsm_slave_t *fsm /**< Slave state machine. */ |
122 |
) |
|
123 |
{ |
|
124 |
if (fsm->state == ec_fsm_slave_state_idle) { |
|
1921 | 125 |
EC_SLAVE_DBG(fsm->slave, 1, "Ready for requests.\n"); |
1804 | 126 |
fsm->state = ec_fsm_slave_state_ready; |
127 |
} |
|
1601
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
128 |
} |
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
129 |
|
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
130 |
/****************************************************************************** |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
131 |
* Slave state machine |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
132 |
*****************************************************************************/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
133 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
134 |
/** Slave state: IDLE. |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
135 |
*/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
136 |
void ec_fsm_slave_state_idle( |
1804 | 137 |
ec_fsm_slave_t *fsm /**< Slave state machine. */ |
138 |
) |
|
139 |
{ |
|
140 |
// do nothing |
|
1601
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
141 |
} |
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
142 |
|
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
143 |
/*****************************************************************************/ |
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
144 |
|
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
145 |
/** Slave state: READY. |
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
146 |
*/ |
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
147 |
void ec_fsm_slave_state_ready( |
1804 | 148 |
ec_fsm_slave_t *fsm /**< Slave state machine. */ |
149 |
) |
|
150 |
{ |
|
151 |
// Check for pending external SDO requests |
|
2304 | 152 |
if (ec_fsm_slave_action_process_sdo(fsm)) { |
153 |
return; |
|
154 |
} |
|
1804 | 155 |
|
2443
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
156 |
// Check for pending external register requests |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
157 |
if (ec_fsm_slave_action_process_reg(fsm)) { |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
158 |
return; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
159 |
} |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
160 |
|
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
161 |
// Check for pending FoE requests |
2304 | 162 |
if (ec_fsm_slave_action_process_foe(fsm)) { |
163 |
return; |
|
164 |
} |
|
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
165 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
166 |
// Check for pending SoE requests |
2304 | 167 |
if (ec_fsm_slave_action_process_soe(fsm)) { |
168 |
return; |
|
169 |
} |
|
1804 | 170 |
} |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
171 |
|
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
172 |
/*****************************************************************************/ |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
173 |
|
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
174 |
/** Check for pending SDO requests and process one. |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
175 |
* |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
176 |
* \return non-zero, if an SDO request is processed. |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
177 |
*/ |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
178 |
int ec_fsm_slave_action_process_sdo( |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
179 |
ec_fsm_slave_t *fsm /**< Slave state machine. */ |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
180 |
) |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
181 |
{ |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
182 |
ec_slave_t *slave = fsm->slave; |
2467
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
183 |
ec_sdo_request_t *request; |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
184 |
|
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
185 |
if (list_empty(&slave->sdo_requests)) { |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
186 |
return 0; |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
187 |
} |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
188 |
|
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
189 |
// take the first request to be processed |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
190 |
request = list_entry(slave->sdo_requests.next, ec_sdo_request_t, list); |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
191 |
list_del_init(&request->list); // dequeue |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
192 |
|
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
193 |
if (slave->current_state & EC_SLAVE_STATE_ACK_ERR) { |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
194 |
EC_SLAVE_WARN(slave, "Aborting SDO request," |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
195 |
" slave has error flag set.\n"); |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
196 |
request->state = EC_INT_REQUEST_FAILURE; |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
197 |
wake_up(&slave->master->request_queue); |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
198 |
fsm->state = ec_fsm_slave_state_idle; |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
199 |
return 1; |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
200 |
} |
2467
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
201 |
|
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
202 |
if (slave->current_state == EC_SLAVE_STATE_INIT) { |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
203 |
EC_SLAVE_WARN(slave, "Aborting SDO request, slave is in INIT.\n"); |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
204 |
request->state = EC_INT_REQUEST_FAILURE; |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
205 |
wake_up(&slave->master->request_queue); |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
206 |
fsm->state = ec_fsm_slave_state_idle; |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
207 |
return 1; |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
208 |
} |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
209 |
|
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
210 |
request->state = EC_INT_REQUEST_BUSY; |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
211 |
|
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
212 |
// Found pending SDO request. Execute it! |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
213 |
EC_SLAVE_DBG(slave, 1, "Processing SDO request...\n"); |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
214 |
|
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
215 |
// Start SDO transfer |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
216 |
fsm->sdo_request = request; |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
217 |
fsm->state = ec_fsm_slave_state_sdo_request; |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
218 |
ec_fsm_coe_transfer(&fsm->fsm_coe, slave, request); |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
219 |
ec_fsm_coe_exec(&fsm->fsm_coe); // execute immediately |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
220 |
ec_master_queue_external_datagram(fsm->slave->master, fsm->datagram); |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
221 |
return 1; |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
222 |
} |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
223 |
|
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
224 |
/*****************************************************************************/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
225 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
226 |
/** Slave state: SDO_REQUEST. |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
227 |
*/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
228 |
void ec_fsm_slave_state_sdo_request( |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
229 |
ec_fsm_slave_t *fsm /**< Slave state machine. */ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
230 |
) |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
231 |
{ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
232 |
ec_slave_t *slave = fsm->slave; |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
233 |
ec_sdo_request_t *request = fsm->sdo_request; |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
234 |
|
2268
5e1d3c9430e0
Datagram device_index member.
Florian Pose <fp@igh-essen.com>
parents:
2099
diff
changeset
|
235 |
if (ec_fsm_coe_exec(&fsm->fsm_coe)) { |
2374
e898451c054a
Slave scanning and configuration on all links.
Florian Pose <fp@igh-essen.com>
parents:
2304
diff
changeset
|
236 |
ec_master_queue_external_datagram(fsm->slave->master, fsm->datagram); |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
237 |
return; |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
238 |
} |
2443
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
239 |
|
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
240 |
if (!ec_fsm_coe_success(&fsm->fsm_coe)) { |
1921 | 241 |
EC_SLAVE_ERR(slave, "Failed to process SDO request.\n"); |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
242 |
request->state = EC_INT_REQUEST_FAILURE; |
2467
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
243 |
wake_up(&slave->master->request_queue); |
1804 | 244 |
fsm->sdo_request = NULL; |
2442
86ebf18a029f
Immediately restart slave FSM on several failed requests.
Florian Pose <fp@igh-essen.com>
parents:
2440
diff
changeset
|
245 |
fsm->state = ec_fsm_slave_state_ready; |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
246 |
return; |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
247 |
} |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
248 |
|
1921 | 249 |
EC_SLAVE_DBG(slave, 1, "Finished SDO request.\n"); |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
250 |
|
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
251 |
// SDO request finished |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
252 |
request->state = EC_INT_REQUEST_SUCCESS; |
2467
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
253 |
wake_up(&slave->master->request_queue); |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
254 |
fsm->sdo_request = NULL; |
1804 | 255 |
fsm->state = ec_fsm_slave_state_ready; |
256 |
} |
|
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
257 |
|
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
258 |
/*****************************************************************************/ |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
259 |
|
2443
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
260 |
/** Check for pending register requests and process one. |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
261 |
* |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
262 |
* \return non-zero, if a register request is processed. |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
263 |
*/ |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
264 |
int ec_fsm_slave_action_process_reg( |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
265 |
ec_fsm_slave_t *fsm /**< Slave state machine. */ |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
266 |
) |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
267 |
{ |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
268 |
ec_slave_t *slave = fsm->slave; |
2462
5fc035788a3a
Removed unnecessary loop when dequeuing register requests.
Florian Pose <fp@igh-essen.com>
parents:
2461
diff
changeset
|
269 |
ec_reg_request_t *reg; |
2443
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
270 |
|
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
271 |
fsm->reg_request = NULL; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
272 |
|
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
273 |
if (slave->config) { |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
274 |
// search the first internal register request to be processed |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
275 |
list_for_each_entry(reg, &slave->config->reg_requests, list) { |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
276 |
if (reg->state == EC_INT_REQUEST_QUEUED) { |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
277 |
fsm->reg_request = reg; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
278 |
break; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
279 |
} |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
280 |
} |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
281 |
} |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
282 |
|
2462
5fc035788a3a
Removed unnecessary loop when dequeuing register requests.
Florian Pose <fp@igh-essen.com>
parents:
2461
diff
changeset
|
283 |
if (!fsm->reg_request && !list_empty(&slave->reg_requests)) { |
5fc035788a3a
Removed unnecessary loop when dequeuing register requests.
Florian Pose <fp@igh-essen.com>
parents:
2461
diff
changeset
|
284 |
// take the first external request to be processed |
5fc035788a3a
Removed unnecessary loop when dequeuing register requests.
Florian Pose <fp@igh-essen.com>
parents:
2461
diff
changeset
|
285 |
fsm->reg_request = |
5fc035788a3a
Removed unnecessary loop when dequeuing register requests.
Florian Pose <fp@igh-essen.com>
parents:
2461
diff
changeset
|
286 |
list_entry(slave->reg_requests.next, ec_reg_request_t, list); |
5fc035788a3a
Removed unnecessary loop when dequeuing register requests.
Florian Pose <fp@igh-essen.com>
parents:
2461
diff
changeset
|
287 |
list_del_init(&fsm->reg_request->list); // dequeue |
2443
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
288 |
} |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
289 |
|
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
290 |
if (!fsm->reg_request) { // no register request to process |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
291 |
return 0; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
292 |
} |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
293 |
|
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
294 |
if (slave->current_state & EC_SLAVE_STATE_ACK_ERR) { |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
295 |
EC_SLAVE_WARN(slave, "Aborting register request," |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
296 |
" slave has error flag set.\n"); |
2462
5fc035788a3a
Removed unnecessary loop when dequeuing register requests.
Florian Pose <fp@igh-essen.com>
parents:
2461
diff
changeset
|
297 |
fsm->reg_request->state = EC_INT_REQUEST_FAILURE; |
2467
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
298 |
wake_up(&slave->master->request_queue); |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
299 |
fsm->reg_request = NULL; |
2443
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
300 |
fsm->state = ec_fsm_slave_state_idle; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
301 |
return 1; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
302 |
} |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
303 |
|
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
304 |
// Found pending register request. Execute it! |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
305 |
EC_SLAVE_DBG(slave, 1, "Processing register request...\n"); |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
306 |
|
2462
5fc035788a3a
Removed unnecessary loop when dequeuing register requests.
Florian Pose <fp@igh-essen.com>
parents:
2461
diff
changeset
|
307 |
fsm->reg_request->state = EC_INT_REQUEST_BUSY; |
2443
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
308 |
|
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
309 |
// Start register access |
2462
5fc035788a3a
Removed unnecessary loop when dequeuing register requests.
Florian Pose <fp@igh-essen.com>
parents:
2461
diff
changeset
|
310 |
if (fsm->reg_request->dir == EC_DIR_INPUT) { |
2443
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
311 |
ec_datagram_fprd(fsm->datagram, slave->station_address, |
2462
5fc035788a3a
Removed unnecessary loop when dequeuing register requests.
Florian Pose <fp@igh-essen.com>
parents:
2461
diff
changeset
|
312 |
fsm->reg_request->address, fsm->reg_request->transfer_size); |
2443
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
313 |
ec_datagram_zero(fsm->datagram); |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
314 |
} else { |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
315 |
ec_datagram_fpwr(fsm->datagram, slave->station_address, |
2462
5fc035788a3a
Removed unnecessary loop when dequeuing register requests.
Florian Pose <fp@igh-essen.com>
parents:
2461
diff
changeset
|
316 |
fsm->reg_request->address, fsm->reg_request->transfer_size); |
5fc035788a3a
Removed unnecessary loop when dequeuing register requests.
Florian Pose <fp@igh-essen.com>
parents:
2461
diff
changeset
|
317 |
memcpy(fsm->datagram->data, fsm->reg_request->data, |
5fc035788a3a
Removed unnecessary loop when dequeuing register requests.
Florian Pose <fp@igh-essen.com>
parents:
2461
diff
changeset
|
318 |
fsm->reg_request->transfer_size); |
2443
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
319 |
} |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
320 |
fsm->datagram->device_index = slave->device_index; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
321 |
ec_master_queue_external_datagram(slave->master, fsm->datagram); |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
322 |
fsm->state = ec_fsm_slave_state_reg_request; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
323 |
return 1; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
324 |
} |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
325 |
|
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
326 |
/*****************************************************************************/ |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
327 |
|
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
328 |
/** Slave state: Register request. |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
329 |
*/ |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
330 |
void ec_fsm_slave_state_reg_request( |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
331 |
ec_fsm_slave_t *fsm /**< Slave state machine. */ |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
332 |
) |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
333 |
{ |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
334 |
ec_slave_t *slave = fsm->slave; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
335 |
ec_reg_request_t *reg = fsm->reg_request; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
336 |
|
2459
8c7e674aa5d6
Invalidate processing register requests when clearing configuration.
Florian Pose <fp@igh-essen.com>
parents:
2443
diff
changeset
|
337 |
if (!reg) { |
8c7e674aa5d6
Invalidate processing register requests when clearing configuration.
Florian Pose <fp@igh-essen.com>
parents:
2443
diff
changeset
|
338 |
// configuration was cleared in the meantime |
8c7e674aa5d6
Invalidate processing register requests when clearing configuration.
Florian Pose <fp@igh-essen.com>
parents:
2443
diff
changeset
|
339 |
fsm->state = ec_fsm_slave_state_ready; |
8c7e674aa5d6
Invalidate processing register requests when clearing configuration.
Florian Pose <fp@igh-essen.com>
parents:
2443
diff
changeset
|
340 |
return; |
8c7e674aa5d6
Invalidate processing register requests when clearing configuration.
Florian Pose <fp@igh-essen.com>
parents:
2443
diff
changeset
|
341 |
} |
8c7e674aa5d6
Invalidate processing register requests when clearing configuration.
Florian Pose <fp@igh-essen.com>
parents:
2443
diff
changeset
|
342 |
|
2443
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
343 |
if (fsm->datagram->state != EC_DATAGRAM_RECEIVED) { |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
344 |
EC_SLAVE_ERR(slave, "Failed to receive register" |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
345 |
" request datagram: "); |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
346 |
ec_datagram_print_state(fsm->datagram); |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
347 |
reg->state = EC_INT_REQUEST_FAILURE; |
2467
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
348 |
wake_up(&slave->master->request_queue); |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
349 |
fsm->reg_request = NULL; |
2443
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
350 |
fsm->state = ec_fsm_slave_state_ready; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
351 |
return; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
352 |
} |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
353 |
|
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
354 |
if (fsm->datagram->working_counter == 1) { |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
355 |
if (reg->dir == EC_DIR_INPUT) { // read request |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
356 |
memcpy(reg->data, fsm->datagram->data, reg->transfer_size); |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
357 |
} |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
358 |
|
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
359 |
reg->state = EC_INT_REQUEST_SUCCESS; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
360 |
EC_SLAVE_DBG(slave, 1, "Register request successful.\n"); |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
361 |
} else { |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
362 |
reg->state = EC_INT_REQUEST_FAILURE; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
363 |
ec_datagram_print_state(fsm->datagram); |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
364 |
EC_SLAVE_ERR(slave, "Register request failed" |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
365 |
" (working counter is %u).\n", |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
366 |
fsm->datagram->working_counter); |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
367 |
} |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
368 |
|
2467
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
369 |
wake_up(&slave->master->request_queue); |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
370 |
fsm->reg_request = NULL; |
2443
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
371 |
fsm->state = ec_fsm_slave_state_ready; |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
372 |
} |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
373 |
|
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
374 |
/*****************************************************************************/ |
2c3ccdde3919
Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents:
2442
diff
changeset
|
375 |
|
2442
86ebf18a029f
Immediately restart slave FSM on several failed requests.
Florian Pose <fp@igh-essen.com>
parents:
2440
diff
changeset
|
376 |
/** Check for pending FoE requests and process one. |
86ebf18a029f
Immediately restart slave FSM on several failed requests.
Florian Pose <fp@igh-essen.com>
parents:
2440
diff
changeset
|
377 |
* |
86ebf18a029f
Immediately restart slave FSM on several failed requests.
Florian Pose <fp@igh-essen.com>
parents:
2440
diff
changeset
|
378 |
* \return non-zero, if an FoE request is processed. |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
379 |
*/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
380 |
int ec_fsm_slave_action_process_foe( |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
381 |
ec_fsm_slave_t *fsm /**< Slave state machine. */ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
382 |
) |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
383 |
{ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
384 |
ec_slave_t *slave = fsm->slave; |
2464
e6cc33cac6a2
Removed unnecessary ec_master_foe_request_t; fixed FoE access.
Florian Pose <fp@igh-essen.com>
parents:
2462
diff
changeset
|
385 |
ec_foe_request_t *request; |
e6cc33cac6a2
Removed unnecessary ec_master_foe_request_t; fixed FoE access.
Florian Pose <fp@igh-essen.com>
parents:
2462
diff
changeset
|
386 |
|
e6cc33cac6a2
Removed unnecessary ec_master_foe_request_t; fixed FoE access.
Florian Pose <fp@igh-essen.com>
parents:
2462
diff
changeset
|
387 |
if (list_empty(&slave->foe_requests)) { |
e6cc33cac6a2
Removed unnecessary ec_master_foe_request_t; fixed FoE access.
Florian Pose <fp@igh-essen.com>
parents:
2462
diff
changeset
|
388 |
return 0; |
e6cc33cac6a2
Removed unnecessary ec_master_foe_request_t; fixed FoE access.
Florian Pose <fp@igh-essen.com>
parents:
2462
diff
changeset
|
389 |
} |
e6cc33cac6a2
Removed unnecessary ec_master_foe_request_t; fixed FoE access.
Florian Pose <fp@igh-essen.com>
parents:
2462
diff
changeset
|
390 |
|
e6cc33cac6a2
Removed unnecessary ec_master_foe_request_t; fixed FoE access.
Florian Pose <fp@igh-essen.com>
parents:
2462
diff
changeset
|
391 |
// take the first request to be processed |
e6cc33cac6a2
Removed unnecessary ec_master_foe_request_t; fixed FoE access.
Florian Pose <fp@igh-essen.com>
parents:
2462
diff
changeset
|
392 |
request = list_entry(slave->foe_requests.next, ec_foe_request_t, list); |
e6cc33cac6a2
Removed unnecessary ec_master_foe_request_t; fixed FoE access.
Florian Pose <fp@igh-essen.com>
parents:
2462
diff
changeset
|
393 |
list_del_init(&request->list); // dequeue |
e6cc33cac6a2
Removed unnecessary ec_master_foe_request_t; fixed FoE access.
Florian Pose <fp@igh-essen.com>
parents:
2462
diff
changeset
|
394 |
|
e6cc33cac6a2
Removed unnecessary ec_master_foe_request_t; fixed FoE access.
Florian Pose <fp@igh-essen.com>
parents:
2462
diff
changeset
|
395 |
if (slave->current_state & EC_SLAVE_STATE_ACK_ERR) { |
e6cc33cac6a2
Removed unnecessary ec_master_foe_request_t; fixed FoE access.
Florian Pose <fp@igh-essen.com>
parents:
2462
diff
changeset
|
396 |
EC_SLAVE_WARN(slave, "Aborting FoE request," |
e6cc33cac6a2
Removed unnecessary ec_master_foe_request_t; fixed FoE access.
Florian Pose <fp@igh-essen.com>
parents:
2462
diff
changeset
|
397 |
" slave has error flag set.\n"); |
e6cc33cac6a2
Removed unnecessary ec_master_foe_request_t; fixed FoE access.
Florian Pose <fp@igh-essen.com>
parents:
2462
diff
changeset
|
398 |
request->state = EC_INT_REQUEST_FAILURE; |
2467
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
399 |
wake_up(&slave->master->request_queue); |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
400 |
fsm->state = ec_fsm_slave_state_idle; |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
401 |
return 1; |
2464
e6cc33cac6a2
Removed unnecessary ec_master_foe_request_t; fixed FoE access.
Florian Pose <fp@igh-essen.com>
parents:
2462
diff
changeset
|
402 |
} |
e6cc33cac6a2
Removed unnecessary ec_master_foe_request_t; fixed FoE access.
Florian Pose <fp@igh-essen.com>
parents:
2462
diff
changeset
|
403 |
|
e6cc33cac6a2
Removed unnecessary ec_master_foe_request_t; fixed FoE access.
Florian Pose <fp@igh-essen.com>
parents:
2462
diff
changeset
|
404 |
request->state = EC_INT_REQUEST_BUSY; |
e6cc33cac6a2
Removed unnecessary ec_master_foe_request_t; fixed FoE access.
Florian Pose <fp@igh-essen.com>
parents:
2462
diff
changeset
|
405 |
|
e6cc33cac6a2
Removed unnecessary ec_master_foe_request_t; fixed FoE access.
Florian Pose <fp@igh-essen.com>
parents:
2462
diff
changeset
|
406 |
EC_SLAVE_DBG(slave, 1, "Processing FoE request.\n"); |
e6cc33cac6a2
Removed unnecessary ec_master_foe_request_t; fixed FoE access.
Florian Pose <fp@igh-essen.com>
parents:
2462
diff
changeset
|
407 |
|
e6cc33cac6a2
Removed unnecessary ec_master_foe_request_t; fixed FoE access.
Florian Pose <fp@igh-essen.com>
parents:
2462
diff
changeset
|
408 |
fsm->foe_request = request; |
e6cc33cac6a2
Removed unnecessary ec_master_foe_request_t; fixed FoE access.
Florian Pose <fp@igh-essen.com>
parents:
2462
diff
changeset
|
409 |
fsm->state = ec_fsm_slave_state_foe_request; |
e6cc33cac6a2
Removed unnecessary ec_master_foe_request_t; fixed FoE access.
Florian Pose <fp@igh-essen.com>
parents:
2462
diff
changeset
|
410 |
ec_fsm_foe_transfer(&fsm->fsm_foe, slave, request); |
e6cc33cac6a2
Removed unnecessary ec_master_foe_request_t; fixed FoE access.
Florian Pose <fp@igh-essen.com>
parents:
2462
diff
changeset
|
411 |
ec_fsm_foe_exec(&fsm->fsm_foe); |
e6cc33cac6a2
Removed unnecessary ec_master_foe_request_t; fixed FoE access.
Florian Pose <fp@igh-essen.com>
parents:
2462
diff
changeset
|
412 |
ec_master_queue_external_datagram(fsm->slave->master, fsm->datagram); |
e6cc33cac6a2
Removed unnecessary ec_master_foe_request_t; fixed FoE access.
Florian Pose <fp@igh-essen.com>
parents:
2462
diff
changeset
|
413 |
return 1; |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
414 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
415 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
416 |
/*****************************************************************************/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
417 |
|
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
418 |
/** Slave state: FOE REQUEST. |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
419 |
*/ |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
420 |
void ec_fsm_slave_state_foe_request( |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
421 |
ec_fsm_slave_t *fsm /**< Slave state machine. */ |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
422 |
) |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
423 |
{ |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
424 |
ec_slave_t *slave = fsm->slave; |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
425 |
ec_foe_request_t *request = fsm->foe_request; |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
426 |
|
2268
5e1d3c9430e0
Datagram device_index member.
Florian Pose <fp@igh-essen.com>
parents:
2099
diff
changeset
|
427 |
if (ec_fsm_foe_exec(&fsm->fsm_foe)) { |
2374
e898451c054a
Slave scanning and configuration on all links.
Florian Pose <fp@igh-essen.com>
parents:
2304
diff
changeset
|
428 |
ec_master_queue_external_datagram(fsm->slave->master, fsm->datagram); |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
429 |
return; |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
430 |
} |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
431 |
|
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
432 |
if (!ec_fsm_foe_success(&fsm->fsm_foe)) { |
1921 | 433 |
EC_SLAVE_ERR(slave, "Failed to handle FoE request.\n"); |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
434 |
request->state = EC_INT_REQUEST_FAILURE; |
2467
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
435 |
wake_up(&slave->master->request_queue); |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
436 |
fsm->foe_request = NULL; |
2442
86ebf18a029f
Immediately restart slave FSM on several failed requests.
Florian Pose <fp@igh-essen.com>
parents:
2440
diff
changeset
|
437 |
fsm->state = ec_fsm_slave_state_ready; |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
438 |
return; |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
439 |
} |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
440 |
|
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
441 |
// finished transferring FoE |
1930
59a50053ccc6
Made send_interval variable an unsigned int; fixed format specifiers for
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
442 |
EC_SLAVE_DBG(slave, 1, "Successfully transferred %zu bytes of FoE" |
1921 | 443 |
" data.\n", request->data_size); |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
444 |
|
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
445 |
request->state = EC_INT_REQUEST_SUCCESS; |
2467
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
446 |
wake_up(&slave->master->request_queue); |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
447 |
fsm->foe_request = NULL; |
1804 | 448 |
fsm->state = ec_fsm_slave_state_ready; |
449 |
} |
|
450 |
||
451 |
/*****************************************************************************/ |
|
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
452 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
453 |
/** Check for pending SoE requests and process one. |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
454 |
* |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
455 |
* \return non-zero, if a request is processed. |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
456 |
*/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
457 |
int ec_fsm_slave_action_process_soe( |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
458 |
ec_fsm_slave_t *fsm /**< Slave state machine. */ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
459 |
) |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
460 |
{ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
461 |
ec_slave_t *slave = fsm->slave; |
2465
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
462 |
ec_soe_request_t *req; |
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
463 |
|
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
464 |
if (list_empty(&slave->soe_requests)) { |
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
465 |
return 0; |
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
466 |
} |
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
467 |
|
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
468 |
// take the first request to be processed |
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
469 |
req = list_entry(slave->soe_requests.next, ec_soe_request_t, list); |
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
470 |
list_del_init(&req->list); // dequeue |
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
471 |
|
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
472 |
if (slave->current_state & EC_SLAVE_STATE_ACK_ERR) { |
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
473 |
EC_SLAVE_WARN(slave, "Aborting SoE request," |
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
474 |
" slave has error flag set.\n"); |
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
475 |
req->state = EC_INT_REQUEST_FAILURE; |
2467
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
476 |
wake_up(&slave->master->request_queue); |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
477 |
fsm->state = ec_fsm_slave_state_idle; |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
478 |
return 1; |
2465
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
479 |
} |
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
480 |
|
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
481 |
if (slave->current_state == EC_SLAVE_STATE_INIT) { |
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
482 |
EC_SLAVE_WARN(slave, "Aborting SoE request, slave is in INIT.\n"); |
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
483 |
req->state = EC_INT_REQUEST_FAILURE; |
2467
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
484 |
wake_up(&slave->master->request_queue); |
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
485 |
fsm->state = ec_fsm_slave_state_idle; |
2465
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
486 |
return 0; |
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
487 |
} |
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
488 |
|
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
489 |
req->state = EC_INT_REQUEST_BUSY; |
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
490 |
|
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
491 |
// Found pending request. Execute it! |
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
492 |
EC_SLAVE_DBG(slave, 1, "Processing SoE request...\n"); |
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
493 |
|
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
494 |
// Start SoE transfer |
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
495 |
fsm->soe_request = req; |
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
496 |
fsm->state = ec_fsm_slave_state_soe_request; |
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
497 |
ec_fsm_soe_transfer(&fsm->fsm_soe, slave, req); |
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
498 |
ec_fsm_soe_exec(&fsm->fsm_soe); // execute immediately |
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
499 |
ec_master_queue_external_datagram(fsm->slave->master, fsm->datagram); |
35611452b785
Removed unnecessary ec_master_soe_request_t type.
Florian Pose <fp@igh-essen.com>
parents:
2464
diff
changeset
|
500 |
return 1; |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
501 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
502 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
503 |
/*****************************************************************************/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
504 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
505 |
/** Slave state: SOE_REQUEST. |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
506 |
*/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
507 |
void ec_fsm_slave_state_soe_request( |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
508 |
ec_fsm_slave_t *fsm /**< Slave state machine. */ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
509 |
) |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
510 |
{ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
511 |
ec_slave_t *slave = fsm->slave; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
512 |
ec_soe_request_t *request = fsm->soe_request; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
513 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
514 |
if (ec_fsm_soe_exec(&fsm->fsm_soe)) { |
2374
e898451c054a
Slave scanning and configuration on all links.
Florian Pose <fp@igh-essen.com>
parents:
2304
diff
changeset
|
515 |
ec_master_queue_external_datagram(fsm->slave->master, fsm->datagram); |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
516 |
return; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
517 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
518 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
519 |
if (!ec_fsm_soe_success(&fsm->fsm_soe)) { |
1921 | 520 |
EC_SLAVE_ERR(slave, "Failed to process SoE request.\n"); |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
521 |
request->state = EC_INT_REQUEST_FAILURE; |
2467
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
522 |
wake_up(&slave->master->request_queue); |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
523 |
fsm->soe_request = NULL; |
2442
86ebf18a029f
Immediately restart slave FSM on several failed requests.
Florian Pose <fp@igh-essen.com>
parents:
2440
diff
changeset
|
524 |
fsm->state = ec_fsm_slave_state_ready; |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
525 |
return; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
526 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
527 |
|
1921 | 528 |
EC_SLAVE_DBG(slave, 1, "Finished SoE request.\n"); |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
529 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
530 |
// SoE request finished |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
531 |
request->state = EC_INT_REQUEST_SUCCESS; |
2467
74ede087bc85
Using common waitqueue for requests.
Florian Pose <fp@igh-essen.com>
parents:
2465
diff
changeset
|
532 |
wake_up(&slave->master->request_queue); |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
533 |
fsm->soe_request = NULL; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
534 |
fsm->state = ec_fsm_slave_state_ready; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
535 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
536 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
537 |
/*****************************************************************************/ |