author | Florian Pose <fp@igh-essen.com> |
Fri, 16 Sep 2016 12:35:09 +0200 | |
changeset 2663 | b101637f503c |
parent 2629 | a2701af27fde |
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 |
* |
2414
f35c7c8e6591
Replaced all mangled hg keywords.
Florian Pose <fp@igh-essen.com>
parents:
2181
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 |
* |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
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" |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
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 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
45 |
void ec_fsm_slave_state_idle(ec_fsm_slave_t *, ec_datagram_t *); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
46 |
void ec_fsm_slave_state_ready(ec_fsm_slave_t *, ec_datagram_t *); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
47 |
int ec_fsm_slave_action_process_sdo(ec_fsm_slave_t *, ec_datagram_t *); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
48 |
void ec_fsm_slave_state_sdo_request(ec_fsm_slave_t *, ec_datagram_t *); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
49 |
int ec_fsm_slave_action_process_reg(ec_fsm_slave_t *, ec_datagram_t *); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
50 |
void ec_fsm_slave_state_reg_request(ec_fsm_slave_t *, ec_datagram_t *); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
51 |
int ec_fsm_slave_action_process_foe(ec_fsm_slave_t *, ec_datagram_t *); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
52 |
void ec_fsm_slave_state_foe_request(ec_fsm_slave_t *, ec_datagram_t *); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
53 |
int ec_fsm_slave_action_process_soe(ec_fsm_slave_t *, ec_datagram_t *); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
54 |
void ec_fsm_slave_state_soe_request(ec_fsm_slave_t *, ec_datagram_t *); |
2597
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
55 |
int ec_fsm_slave_action_process_eoe(ec_fsm_slave_t *, ec_datagram_t *); |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
56 |
void ec_fsm_slave_state_eoe_request(ec_fsm_slave_t *, ec_datagram_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
|
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 |
/*****************************************************************************/ |
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 |
/** 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
|
61 |
*/ |
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 |
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
|
63 |
ec_fsm_slave_t *fsm, /**< Slave state machine. */ |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
64 |
ec_slave_t *slave /**< EtherCAT slave. */ |
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
|
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 |
{ |
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->slave = slave; |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
68 |
INIT_LIST_HEAD(&fsm->list); // mark as unlisted |
1804 | 69 |
|
70 |
fsm->state = ec_fsm_slave_state_idle; |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
71 |
fsm->datagram = NULL; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
72 |
fsm->sdo_request = NULL; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
73 |
fsm->reg_request = NULL; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
74 |
fsm->foe_request = NULL; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
75 |
fsm->soe_request = NULL; |
2597
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
76 |
fsm->eoe_request = NULL; |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
77 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
78 |
// Init sub-state-machines |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
79 |
ec_fsm_coe_init(&fsm->fsm_coe); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
80 |
ec_fsm_foe_init(&fsm->fsm_foe); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
81 |
ec_fsm_soe_init(&fsm->fsm_soe); |
2597
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
82 |
ec_fsm_eoe_init(&fsm->fsm_eoe); |
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
|
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 |
|
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 |
/*****************************************************************************/ |
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 |
/** 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
|
88 |
*/ |
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 |
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
|
90 |
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
|
91 |
) |
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 |
{ |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
93 |
// signal requests that are currently in operation |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
94 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
95 |
if (fsm->sdo_request) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
96 |
fsm->sdo_request->state = EC_INT_REQUEST_FAILURE; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
97 |
wake_up_all(&fsm->slave->master->request_queue); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
98 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
99 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
100 |
if (fsm->reg_request) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
101 |
fsm->reg_request->state = EC_INT_REQUEST_FAILURE; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
102 |
wake_up_all(&fsm->slave->master->request_queue); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
103 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
104 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
105 |
if (fsm->foe_request) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
106 |
fsm->foe_request->state = EC_INT_REQUEST_FAILURE; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
107 |
wake_up_all(&fsm->slave->master->request_queue); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
108 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
109 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
110 |
if (fsm->soe_request) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
111 |
fsm->soe_request->state = EC_INT_REQUEST_FAILURE; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
112 |
wake_up_all(&fsm->slave->master->request_queue); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
113 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
114 |
|
2597
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
115 |
if (fsm->eoe_request) { |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
116 |
fsm->soe_request->state = EC_INT_REQUEST_FAILURE; |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
117 |
wake_up_all(&fsm->slave->master->request_queue); |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
118 |
} |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
119 |
|
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
|
120 |
// 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
|
121 |
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
|
122 |
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
|
123 |
ec_fsm_soe_clear(&fsm->fsm_soe); |
2597
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
124 |
ec_fsm_eoe_clear(&fsm->fsm_eoe); |
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
|
125 |
} |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
126 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
127 |
/*****************************************************************************/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
128 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
129 |
/** 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
|
130 |
* |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
131 |
* \return 1 if \a datagram was used, else 0. |
2017
4b16e2dce5fb
Increment injection_seq on slave state changes
Martin Troxler <ch1010277@ch10pc446>
parents:
1930
diff
changeset
|
132 |
*/ |
4b16e2dce5fb
Increment injection_seq on slave state changes
Martin Troxler <ch1010277@ch10pc446>
parents:
1930
diff
changeset
|
133 |
int ec_fsm_slave_exec( |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
134 |
ec_fsm_slave_t *fsm, /**< Slave state machine. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
135 |
ec_datagram_t *datagram /**< New datagram to use. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
136 |
) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
137 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
138 |
int datagram_used; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
139 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
140 |
fsm->state(fsm, datagram); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
141 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
142 |
datagram_used = fsm->state != ec_fsm_slave_state_idle && |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
143 |
fsm->state != ec_fsm_slave_state_ready; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
144 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
145 |
if (datagram_used) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
146 |
fsm->datagram = datagram; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
147 |
} else { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
148 |
fsm->datagram = NULL; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
149 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
150 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
151 |
return datagram_used; |
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
|
152 |
} |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
153 |
|
1601
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
154 |
/*****************************************************************************/ |
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
155 |
|
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
156 |
/** 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
|
157 |
*/ |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
158 |
void ec_fsm_slave_set_ready( |
1804 | 159 |
ec_fsm_slave_t *fsm /**< Slave state machine. */ |
160 |
) |
|
161 |
{ |
|
162 |
if (fsm->state == ec_fsm_slave_state_idle) { |
|
1921 | 163 |
EC_SLAVE_DBG(fsm->slave, 1, "Ready for requests.\n"); |
1804 | 164 |
fsm->state = ec_fsm_slave_state_ready; |
165 |
} |
|
1601
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
166 |
} |
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
167 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
168 |
/*****************************************************************************/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
169 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
170 |
/** Returns, if the FSM is currently not busy and ready to execute. |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
171 |
* |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
172 |
* \return Non-zero if ready. |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
173 |
*/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
174 |
int ec_fsm_slave_is_ready( |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
175 |
const ec_fsm_slave_t *fsm /**< Slave state machine. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
176 |
) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
177 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
178 |
return fsm->state == ec_fsm_slave_state_ready; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
179 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
180 |
|
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
|
181 |
/****************************************************************************** |
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 |
* 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
|
183 |
*****************************************************************************/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
184 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
185 |
/** 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
|
186 |
*/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
187 |
void ec_fsm_slave_state_idle( |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
188 |
ec_fsm_slave_t *fsm, /**< Slave state machine. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
189 |
ec_datagram_t *datagram /**< Datagram to use. */ |
1804 | 190 |
) |
191 |
{ |
|
192 |
// do nothing |
|
1601
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
193 |
} |
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
194 |
|
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
195 |
/*****************************************************************************/ |
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
196 |
|
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
197 |
/** Slave state: READY. |
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
198 |
*/ |
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
199 |
void ec_fsm_slave_state_ready( |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
200 |
ec_fsm_slave_t *fsm, /**< Slave state machine. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
201 |
ec_datagram_t *datagram /**< Datagram to use. */ |
1804 | 202 |
) |
203 |
{ |
|
2629
a2701af27fde
Internal SDO requests now synchronized with external requests.
Knud Baastrup <kba@deif.com>
parents:
2597
diff
changeset
|
204 |
ec_slave_t *slave = fsm->slave; |
a2701af27fde
Internal SDO requests now synchronized with external requests.
Knud Baastrup <kba@deif.com>
parents:
2597
diff
changeset
|
205 |
ec_sdo_request_t *req; |
a2701af27fde
Internal SDO requests now synchronized with external requests.
Knud Baastrup <kba@deif.com>
parents:
2597
diff
changeset
|
206 |
|
a2701af27fde
Internal SDO requests now synchronized with external requests.
Knud Baastrup <kba@deif.com>
parents:
2597
diff
changeset
|
207 |
if (slave->config) { |
a2701af27fde
Internal SDO requests now synchronized with external requests.
Knud Baastrup <kba@deif.com>
parents:
2597
diff
changeset
|
208 |
list_for_each_entry(req, &slave->config->sdo_requests, list) { |
a2701af27fde
Internal SDO requests now synchronized with external requests.
Knud Baastrup <kba@deif.com>
parents:
2597
diff
changeset
|
209 |
if (req->state == EC_INT_REQUEST_QUEUED || req->state == EC_INT_REQUEST_BUSY) { |
a2701af27fde
Internal SDO requests now synchronized with external requests.
Knud Baastrup <kba@deif.com>
parents:
2597
diff
changeset
|
210 |
EC_SLAVE_DBG(slave, 1, "Busy - processing internal SDO request!\n"); |
a2701af27fde
Internal SDO requests now synchronized with external requests.
Knud Baastrup <kba@deif.com>
parents:
2597
diff
changeset
|
211 |
return; |
a2701af27fde
Internal SDO requests now synchronized with external requests.
Knud Baastrup <kba@deif.com>
parents:
2597
diff
changeset
|
212 |
} |
a2701af27fde
Internal SDO requests now synchronized with external requests.
Knud Baastrup <kba@deif.com>
parents:
2597
diff
changeset
|
213 |
} |
a2701af27fde
Internal SDO requests now synchronized with external requests.
Knud Baastrup <kba@deif.com>
parents:
2597
diff
changeset
|
214 |
} |
a2701af27fde
Internal SDO requests now synchronized with external requests.
Knud Baastrup <kba@deif.com>
parents:
2597
diff
changeset
|
215 |
|
1804 | 216 |
// Check for pending external SDO requests |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
217 |
if (ec_fsm_slave_action_process_sdo(fsm, datagram)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
218 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
219 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
220 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
221 |
// Check for pending external register requests |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
222 |
if (ec_fsm_slave_action_process_reg(fsm, datagram)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
223 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
224 |
} |
1804 | 225 |
|
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
226 |
// Check for pending FoE requests |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
227 |
if (ec_fsm_slave_action_process_foe(fsm, datagram)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
228 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
229 |
} |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
230 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
231 |
// Check for pending SoE requests |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
232 |
if (ec_fsm_slave_action_process_soe(fsm, datagram)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
233 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
234 |
} |
2597
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
235 |
|
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
236 |
// Check for pending EoE IP parameter requests |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
237 |
if (ec_fsm_slave_action_process_eoe(fsm, datagram)) { |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
238 |
return; |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
239 |
} |
1804 | 240 |
} |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
241 |
|
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
242 |
/*****************************************************************************/ |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
243 |
|
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
244 |
/** 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
|
245 |
* |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
246 |
* \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
|
247 |
*/ |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
248 |
int ec_fsm_slave_action_process_sdo( |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
249 |
ec_fsm_slave_t *fsm, /**< Slave state machine. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
250 |
ec_datagram_t *datagram /**< Datagram to use. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
251 |
) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
252 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
253 |
ec_slave_t *slave = fsm->slave; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
254 |
ec_sdo_request_t *request; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
255 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
256 |
if (list_empty(&slave->sdo_requests)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
257 |
return 0; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
258 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
259 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
260 |
// take the first request to be processed |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
261 |
request = list_entry(slave->sdo_requests.next, ec_sdo_request_t, list); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
262 |
list_del_init(&request->list); // dequeue |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
263 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
264 |
if (slave->current_state & EC_SLAVE_STATE_ACK_ERR) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
265 |
EC_SLAVE_WARN(slave, "Aborting SDO request," |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
266 |
" slave has error flag set.\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
267 |
request->state = EC_INT_REQUEST_FAILURE; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
268 |
wake_up_all(&slave->master->request_queue); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
269 |
fsm->state = ec_fsm_slave_state_idle; |
2597
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
270 |
return 0; |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
271 |
} |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
272 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
273 |
if (slave->current_state == EC_SLAVE_STATE_INIT) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
274 |
EC_SLAVE_WARN(slave, "Aborting SDO request, slave is in INIT.\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
275 |
request->state = EC_INT_REQUEST_FAILURE; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
276 |
wake_up_all(&slave->master->request_queue); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
277 |
fsm->state = ec_fsm_slave_state_idle; |
2597
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
278 |
return 0; |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
279 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
280 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
281 |
fsm->sdo_request = request; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
282 |
request->state = EC_INT_REQUEST_BUSY; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
283 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
284 |
// Found pending SDO request. Execute it! |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
285 |
EC_SLAVE_DBG(slave, 1, "Processing SDO request...\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
286 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
287 |
// Start SDO transfer |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
288 |
fsm->state = ec_fsm_slave_state_sdo_request; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
289 |
ec_fsm_coe_transfer(&fsm->fsm_coe, slave, request); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
290 |
ec_fsm_coe_exec(&fsm->fsm_coe, datagram); // execute immediately |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
291 |
return 1; |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
292 |
} |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
293 |
|
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
|
294 |
/*****************************************************************************/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
295 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
296 |
/** 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
|
297 |
*/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
298 |
void ec_fsm_slave_state_sdo_request( |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
299 |
ec_fsm_slave_t *fsm, /**< Slave state machine. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
300 |
ec_datagram_t *datagram /**< Datagram to use. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
301 |
) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
302 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
303 |
ec_slave_t *slave = fsm->slave; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
304 |
ec_sdo_request_t *request = fsm->sdo_request; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
305 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
306 |
if (ec_fsm_coe_exec(&fsm->fsm_coe, datagram)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
307 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
308 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
309 |
|
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
|
310 |
if (!ec_fsm_coe_success(&fsm->fsm_coe)) { |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
311 |
EC_SLAVE_ERR(slave, "Failed to process SDO request.\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
312 |
request->state = EC_INT_REQUEST_FAILURE; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
313 |
wake_up_all(&slave->master->request_queue); |
1804 | 314 |
fsm->sdo_request = NULL; |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
315 |
fsm->state = ec_fsm_slave_state_ready; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
316 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
317 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
318 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
319 |
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
|
320 |
|
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
|
321 |
// SDO request finished |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
322 |
request->state = EC_INT_REQUEST_SUCCESS; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
323 |
wake_up_all(&slave->master->request_queue); |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
324 |
fsm->sdo_request = NULL; |
1804 | 325 |
fsm->state = ec_fsm_slave_state_ready; |
326 |
} |
|
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
327 |
|
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
328 |
/*****************************************************************************/ |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
329 |
|
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
330 |
/** Check for pending register requests and process one. |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
331 |
* |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
332 |
* \return non-zero, if a register request is processed. |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
333 |
*/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
334 |
int ec_fsm_slave_action_process_reg( |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
335 |
ec_fsm_slave_t *fsm, /**< Slave state machine. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
336 |
ec_datagram_t *datagram /**< Datagram to use. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
337 |
) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
338 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
339 |
ec_slave_t *slave = fsm->slave; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
340 |
ec_reg_request_t *reg; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
341 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
342 |
fsm->reg_request = NULL; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
343 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
344 |
if (slave->config) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
345 |
// search the first internal register request to be processed |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
346 |
list_for_each_entry(reg, &slave->config->reg_requests, list) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
347 |
if (reg->state == EC_INT_REQUEST_QUEUED) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
348 |
fsm->reg_request = reg; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
349 |
break; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
350 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
351 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
352 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
353 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
354 |
if (!fsm->reg_request && !list_empty(&slave->reg_requests)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
355 |
// take the first external request to be processed |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
356 |
fsm->reg_request = |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
357 |
list_entry(slave->reg_requests.next, ec_reg_request_t, list); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
358 |
list_del_init(&fsm->reg_request->list); // dequeue |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
359 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
360 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
361 |
if (!fsm->reg_request) { // no register request to process |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
362 |
return 0; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
363 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
364 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
365 |
if (slave->current_state & EC_SLAVE_STATE_ACK_ERR) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
366 |
EC_SLAVE_WARN(slave, "Aborting register request," |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
367 |
" slave has error flag set.\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
368 |
fsm->reg_request->state = EC_INT_REQUEST_FAILURE; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
369 |
wake_up_all(&slave->master->request_queue); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
370 |
fsm->reg_request = NULL; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
371 |
fsm->state = ec_fsm_slave_state_idle; |
2597
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
372 |
return 0; |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
373 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
374 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
375 |
// Found pending register request. Execute it! |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
376 |
EC_SLAVE_DBG(slave, 1, "Processing register request...\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
377 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
378 |
fsm->reg_request->state = EC_INT_REQUEST_BUSY; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
379 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
380 |
// Start register access |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
381 |
if (fsm->reg_request->dir == EC_DIR_INPUT) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
382 |
ec_datagram_fprd(datagram, slave->station_address, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
383 |
fsm->reg_request->address, fsm->reg_request->transfer_size); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
384 |
ec_datagram_zero(datagram); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
385 |
} else { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
386 |
ec_datagram_fpwr(datagram, slave->station_address, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
387 |
fsm->reg_request->address, fsm->reg_request->transfer_size); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
388 |
memcpy(datagram->data, fsm->reg_request->data, |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
389 |
fsm->reg_request->transfer_size); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
390 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
391 |
datagram->device_index = slave->device_index; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
392 |
fsm->state = ec_fsm_slave_state_reg_request; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
393 |
return 1; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
394 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
395 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
396 |
/*****************************************************************************/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
397 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
398 |
/** Slave state: Register request. |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
399 |
*/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
400 |
void ec_fsm_slave_state_reg_request( |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
401 |
ec_fsm_slave_t *fsm, /**< Slave state machine. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
402 |
ec_datagram_t *datagram /**< Datagram to use. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
403 |
) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
404 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
405 |
ec_slave_t *slave = fsm->slave; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
406 |
ec_reg_request_t *reg = fsm->reg_request; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
407 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
408 |
if (!reg) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
409 |
// configuration was cleared in the meantime |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
410 |
fsm->state = ec_fsm_slave_state_ready; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
411 |
fsm->reg_request = NULL; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
412 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
413 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
414 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
415 |
if (fsm->datagram->state != EC_DATAGRAM_RECEIVED) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
416 |
EC_SLAVE_ERR(slave, "Failed to receive register" |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
417 |
" request datagram: "); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
418 |
ec_datagram_print_state(fsm->datagram); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
419 |
reg->state = EC_INT_REQUEST_FAILURE; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
420 |
wake_up_all(&slave->master->request_queue); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
421 |
fsm->reg_request = NULL; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
422 |
fsm->state = ec_fsm_slave_state_ready; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
423 |
return; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
424 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
425 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
426 |
if (fsm->datagram->working_counter == 1) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
427 |
if (reg->dir == EC_DIR_INPUT) { // read request |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
428 |
memcpy(reg->data, fsm->datagram->data, reg->transfer_size); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
429 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
430 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
431 |
reg->state = EC_INT_REQUEST_SUCCESS; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
432 |
EC_SLAVE_DBG(slave, 1, "Register request successful.\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
433 |
} else { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
434 |
reg->state = EC_INT_REQUEST_FAILURE; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
435 |
ec_datagram_print_state(fsm->datagram); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
436 |
EC_SLAVE_ERR(slave, "Register request failed" |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
437 |
" (working counter is %u).\n", |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
438 |
fsm->datagram->working_counter); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
439 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
440 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
441 |
wake_up_all(&slave->master->request_queue); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
442 |
fsm->reg_request = NULL; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
443 |
fsm->state = ec_fsm_slave_state_ready; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
444 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
445 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
446 |
/*****************************************************************************/ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
447 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
448 |
/** Check for pending FoE requests and process one. |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
449 |
* |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
450 |
* \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
|
451 |
*/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
452 |
int ec_fsm_slave_action_process_foe( |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
453 |
ec_fsm_slave_t *fsm, /**< Slave state machine. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
454 |
ec_datagram_t *datagram /**< Datagram to use. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
455 |
) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
456 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
457 |
ec_slave_t *slave = fsm->slave; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
458 |
ec_foe_request_t *request; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
459 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
460 |
if (list_empty(&slave->foe_requests)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
461 |
return 0; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
462 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
463 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
464 |
// take the first request to be processed |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
465 |
request = list_entry(slave->foe_requests.next, ec_foe_request_t, list); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
466 |
list_del_init(&request->list); // dequeue |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
467 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
468 |
if (slave->current_state & EC_SLAVE_STATE_ACK_ERR) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
469 |
EC_SLAVE_WARN(slave, "Aborting FoE request," |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
470 |
" slave has error flag set.\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
471 |
request->state = EC_INT_REQUEST_FAILURE; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
472 |
wake_up_all(&slave->master->request_queue); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
473 |
fsm->state = ec_fsm_slave_state_idle; |
2597
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
474 |
return 0; |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
475 |
} |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
476 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
477 |
request->state = EC_INT_REQUEST_BUSY; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
478 |
fsm->foe_request = request; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
479 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
480 |
EC_SLAVE_DBG(slave, 1, "Processing FoE request.\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
481 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
482 |
fsm->state = ec_fsm_slave_state_foe_request; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
483 |
ec_fsm_foe_transfer(&fsm->fsm_foe, slave, request); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
484 |
ec_fsm_foe_exec(&fsm->fsm_foe, datagram); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
485 |
return 1; |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
486 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
487 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
488 |
/*****************************************************************************/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
489 |
|
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
490 |
/** Slave state: FOE REQUEST. |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
491 |
*/ |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
492 |
void ec_fsm_slave_state_foe_request( |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
493 |
ec_fsm_slave_t *fsm, /**< Slave state machine. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
494 |
ec_datagram_t *datagram /**< Datagram to use. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
495 |
) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
496 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
497 |
ec_slave_t *slave = fsm->slave; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
498 |
ec_foe_request_t *request = fsm->foe_request; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
499 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
500 |
if (ec_fsm_foe_exec(&fsm->fsm_foe, datagram)) { |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
501 |
return; |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
502 |
} |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
503 |
|
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
504 |
if (!ec_fsm_foe_success(&fsm->fsm_foe)) { |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
505 |
EC_SLAVE_ERR(slave, "Failed to handle FoE request.\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
506 |
request->state = EC_INT_REQUEST_FAILURE; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
507 |
wake_up_all(&slave->master->request_queue); |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
508 |
fsm->foe_request = NULL; |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
509 |
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
|
510 |
return; |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
511 |
} |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
512 |
|
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
513 |
// finished transferring FoE |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
514 |
EC_SLAVE_DBG(slave, 1, "Successfully transferred %zu bytes of FoE" |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
515 |
" data.\n", request->data_size); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
516 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
517 |
request->state = EC_INT_REQUEST_SUCCESS; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
518 |
wake_up_all(&slave->master->request_queue); |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
519 |
fsm->foe_request = NULL; |
1804 | 520 |
fsm->state = ec_fsm_slave_state_ready; |
521 |
} |
|
522 |
||
523 |
/*****************************************************************************/ |
|
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
524 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
525 |
/** 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
|
526 |
* |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
527 |
* \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
|
528 |
*/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
529 |
int ec_fsm_slave_action_process_soe( |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
530 |
ec_fsm_slave_t *fsm, /**< Slave state machine. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
531 |
ec_datagram_t *datagram /**< Datagram to use. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
532 |
) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
533 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
534 |
ec_slave_t *slave = fsm->slave; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
535 |
ec_soe_request_t *req; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
536 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
537 |
if (list_empty(&slave->soe_requests)) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
538 |
return 0; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
539 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
540 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
541 |
// take the first request to be processed |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
542 |
req = list_entry(slave->soe_requests.next, ec_soe_request_t, list); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
543 |
list_del_init(&req->list); // dequeue |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
544 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
545 |
if (slave->current_state & EC_SLAVE_STATE_ACK_ERR) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
546 |
EC_SLAVE_WARN(slave, "Aborting SoE request," |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
547 |
" slave has error flag set.\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
548 |
req->state = EC_INT_REQUEST_FAILURE; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
549 |
wake_up_all(&slave->master->request_queue); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
550 |
fsm->state = ec_fsm_slave_state_idle; |
2597
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
551 |
return 0; |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
552 |
} |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
553 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
554 |
if (slave->current_state == EC_SLAVE_STATE_INIT) { |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
555 |
EC_SLAVE_WARN(slave, "Aborting SoE request, slave is in INIT.\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
556 |
req->state = EC_INT_REQUEST_FAILURE; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
557 |
wake_up_all(&slave->master->request_queue); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
558 |
fsm->state = ec_fsm_slave_state_idle; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
559 |
return 0; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
560 |
} |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
561 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
562 |
fsm->soe_request = req; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
563 |
req->state = EC_INT_REQUEST_BUSY; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
564 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
565 |
// Found pending request. Execute it! |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
566 |
EC_SLAVE_DBG(slave, 1, "Processing SoE request...\n"); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
567 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
568 |
// Start SoE transfer |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
569 |
fsm->state = ec_fsm_slave_state_soe_request; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
570 |
ec_fsm_soe_transfer(&fsm->fsm_soe, slave, req); |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
571 |
ec_fsm_soe_exec(&fsm->fsm_soe, datagram); // execute immediately |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
572 |
return 1; |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
573 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
574 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
575 |
/*****************************************************************************/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
576 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
577 |
/** Slave state: SOE_REQUEST. |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
578 |
*/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
579 |
void ec_fsm_slave_state_soe_request( |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
580 |
ec_fsm_slave_t *fsm, /**< Slave state machine. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
581 |
ec_datagram_t *datagram /**< Datagram to use. */ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
582 |
) |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
583 |
{ |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
584 |
ec_slave_t *slave = fsm->slave; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
585 |
ec_soe_request_t *request = fsm->soe_request; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
586 |
|
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
587 |
if (ec_fsm_soe_exec(&fsm->fsm_soe, datagram)) { |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
588 |
return; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
589 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
590 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
591 |
if (!ec_fsm_soe_success(&fsm->fsm_soe)) { |
1921 | 592 |
EC_SLAVE_ERR(slave, "Failed to process SoE request.\n"); |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
593 |
request->state = EC_INT_REQUEST_FAILURE; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
594 |
wake_up_all(&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
|
595 |
fsm->soe_request = NULL; |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
596 |
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
|
597 |
return; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
598 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
599 |
|
1921 | 600 |
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
|
601 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
602 |
// SoE request finished |
2589
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
603 |
request->state = EC_INT_REQUEST_SUCCESS; |
2b9c78543663
Reverted default branch to stable-1.5.
Florian Pose <fp@igh-essen.com>
parents:
2414
diff
changeset
|
604 |
wake_up_all(&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
|
605 |
fsm->soe_request = NULL; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
606 |
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
|
607 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
608 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
609 |
/*****************************************************************************/ |
2597
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
610 |
|
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
611 |
/** Check for pending EoE IP parameter requests and process one. |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
612 |
* |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
613 |
* \return non-zero, if a request is processed. |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
614 |
*/ |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
615 |
int ec_fsm_slave_action_process_eoe( |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
616 |
ec_fsm_slave_t *fsm, /**< Slave state machine. */ |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
617 |
ec_datagram_t *datagram /**< Datagram to use. */ |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
618 |
) |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
619 |
{ |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
620 |
ec_slave_t *slave = fsm->slave; |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
621 |
ec_eoe_request_t *request; |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
622 |
|
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
623 |
if (list_empty(&slave->eoe_requests)) { |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
624 |
return 0; |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
625 |
} |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
626 |
|
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
627 |
// take the first request to be processed |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
628 |
request = list_entry(slave->eoe_requests.next, ec_eoe_request_t, list); |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
629 |
list_del_init(&request->list); // dequeue |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
630 |
|
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
631 |
if (slave->current_state & EC_SLAVE_STATE_ACK_ERR) { |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
632 |
EC_SLAVE_WARN(slave, "Aborting EoE request," |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
633 |
" slave has error flag set.\n"); |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
634 |
request->state = EC_INT_REQUEST_FAILURE; |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
635 |
wake_up_all(&slave->master->request_queue); |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
636 |
fsm->state = ec_fsm_slave_state_idle; |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
637 |
return 0; |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
638 |
} |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
639 |
|
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
640 |
if (slave->current_state == EC_SLAVE_STATE_INIT) { |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
641 |
EC_SLAVE_WARN(slave, "Aborting EoE request, slave is in INIT.\n"); |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
642 |
request->state = EC_INT_REQUEST_FAILURE; |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
643 |
wake_up_all(&slave->master->request_queue); |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
644 |
fsm->state = ec_fsm_slave_state_idle; |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
645 |
return 0; |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
646 |
} |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
647 |
|
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
648 |
fsm->eoe_request = request; |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
649 |
request->state = EC_INT_REQUEST_BUSY; |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
650 |
|
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
651 |
// Found pending request. Execute it! |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
652 |
EC_SLAVE_DBG(slave, 1, "Processing EoE request...\n"); |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
653 |
|
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
654 |
// Start EoE command |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
655 |
fsm->state = ec_fsm_slave_state_eoe_request; |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
656 |
ec_fsm_eoe_set_ip_param(&fsm->fsm_eoe, slave, request); |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
657 |
ec_fsm_eoe_exec(&fsm->fsm_eoe, datagram); // execute immediately |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
658 |
return 1; |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
659 |
} |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
660 |
|
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
661 |
/*****************************************************************************/ |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
662 |
|
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
663 |
/** Slave state: EOE_REQUEST. |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
664 |
*/ |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
665 |
void ec_fsm_slave_state_eoe_request( |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
666 |
ec_fsm_slave_t *fsm, /**< Slave state machine. */ |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
667 |
ec_datagram_t *datagram /**< Datagram to use. */ |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
668 |
) |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
669 |
{ |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
670 |
ec_slave_t *slave = fsm->slave; |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
671 |
ec_eoe_request_t *req = fsm->eoe_request; |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
672 |
|
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
673 |
if (ec_fsm_eoe_exec(&fsm->fsm_eoe, datagram)) { |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
674 |
return; |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
675 |
} |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
676 |
|
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
677 |
if (ec_fsm_eoe_success(&fsm->fsm_eoe)) { |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
678 |
req->state = EC_INT_REQUEST_SUCCESS; |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
679 |
EC_SLAVE_DBG(slave, 1, "Finished EoE request.\n"); |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
680 |
} |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
681 |
else { |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
682 |
req->state = EC_INT_REQUEST_FAILURE; |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
683 |
EC_SLAVE_ERR(slave, "Failed to process EoE request.\n"); |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
684 |
} |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
685 |
|
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
686 |
wake_up_all(&slave->master->request_queue); |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
687 |
fsm->eoe_request = NULL; |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
688 |
fsm->state = ec_fsm_slave_state_ready; |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
689 |
} |
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
690 |
|
0e145bb05859
Implemented EoE Set IP parameter request via command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
2589
diff
changeset
|
691 |
/*****************************************************************************/ |