author | Florian Pose <fp@igh-essen.com> |
Mon, 23 Jun 2008 10:27:40 +0000 | |
changeset 1051 | 40a4f31ec3b8 |
parent 1045 | c4fd73507076 |
child 1053 | 0cb9604cbaa7 |
permissions | -rw-r--r-- |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
768
b709149d5bba
Added missing svn properties.
Florian Pose <fp@igh-essen.com>
parents:
767
diff
changeset
|
3 |
* $Id$ |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
* |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
5 |
* Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
* |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
8 |
* |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
10 |
* and/or modify it under the terms of the GNU General Public License |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
11 |
* as published by the Free Software Foundation; either version 2 of the |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
12 |
* License, or (at your option) any later version. |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
13 |
* |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
14 |
* The IgH EtherCAT Master is distributed in the hope that it will be |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
15 |
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
17 |
* GNU General Public License for more details. |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
18 |
* |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
19 |
* You should have received a copy of the GNU General Public License |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
20 |
* along with the IgH EtherCAT Master; if not, write to the Free Software |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
21 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
22 |
* |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
23 |
* The right to use EtherCAT Technology is granted and comes free of |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
24 |
* charge under condition of compatibility of product made by |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
25 |
* Licensee. People intending to distribute/sell products based on the |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
26 |
* code, have to sign an agreement to guarantee that products using |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
27 |
* software based on IgH EtherCAT master stay compatible with the actual |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
* EtherCAT specification (which are released themselves as an open |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
* standard) as the (only) precondition to have the right to use EtherCAT |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
30 |
* Technology, IP and trade marks. |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
31 |
* |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
*****************************************************************************/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
/** |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
\file |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
859
diff
changeset
|
36 |
EtherCAT Pdo information state machines. |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
*/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
/*****************************************************************************/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
#include "globals.h" |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
#include "master.h" |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
#include "mailbox.h" |
847
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
44 |
#include "sdo_request.h" |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
45 |
#include "fsm_coe_map.h" |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
46 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
47 |
/*****************************************************************************/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
48 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
49 |
void ec_fsm_coe_map_state_start(ec_fsm_coe_map_t *); |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
50 |
void ec_fsm_coe_map_state_pdo_count(ec_fsm_coe_map_t *); |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
51 |
void ec_fsm_coe_map_state_pdo(ec_fsm_coe_map_t *); |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
52 |
void ec_fsm_coe_map_state_pdo_entry_count(ec_fsm_coe_map_t *); |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
53 |
void ec_fsm_coe_map_state_pdo_entry(ec_fsm_coe_map_t *); |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
54 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
55 |
void ec_fsm_coe_map_state_end(ec_fsm_coe_map_t *); |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
56 |
void ec_fsm_coe_map_state_error(ec_fsm_coe_map_t *); |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
57 |
|
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
58 |
void ec_fsm_coe_map_action_next_dir(ec_fsm_coe_map_t *); |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
59 |
void ec_fsm_coe_map_action_next_pdo(ec_fsm_coe_map_t *); |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
60 |
void ec_fsm_coe_map_action_next_pdo_entry(ec_fsm_coe_map_t *); |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
61 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
62 |
/*****************************************************************************/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
63 |
|
1045
c4fd73507076
Introduced global upload timeout for fsm_coe_map.
Florian Pose <fp@igh-essen.com>
parents:
1044
diff
changeset
|
64 |
/** Sdo upload timeout in ms for reading Pdo assigment/mapping. |
c4fd73507076
Introduced global upload timeout for fsm_coe_map.
Florian Pose <fp@igh-essen.com>
parents:
1044
diff
changeset
|
65 |
*/ |
c4fd73507076
Introduced global upload timeout for fsm_coe_map.
Florian Pose <fp@igh-essen.com>
parents:
1044
diff
changeset
|
66 |
#define EC_FSM_COE_MAP_UPLOAD_TIMEOUT 3000 |
c4fd73507076
Introduced global upload timeout for fsm_coe_map.
Florian Pose <fp@igh-essen.com>
parents:
1044
diff
changeset
|
67 |
|
c4fd73507076
Introduced global upload timeout for fsm_coe_map.
Florian Pose <fp@igh-essen.com>
parents:
1044
diff
changeset
|
68 |
/*****************************************************************************/ |
c4fd73507076
Introduced global upload timeout for fsm_coe_map.
Florian Pose <fp@igh-essen.com>
parents:
1044
diff
changeset
|
69 |
|
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
70 |
/** |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
71 |
Constructor. |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
72 |
*/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
73 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
74 |
void ec_fsm_coe_map_init( |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
75 |
ec_fsm_coe_map_t *fsm, /**< finite state machine */ |
758
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
751
diff
changeset
|
76 |
ec_fsm_coe_t *fsm_coe /**< CoE state machine to use */ |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
77 |
) |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
78 |
{ |
852
ab439cbc7a81
Separated ec_sdo_request_init() and ec_sdo_request_read().
Florian Pose <fp@igh-essen.com>
parents:
849
diff
changeset
|
79 |
fsm->fsm_coe = fsm_coe; |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
80 |
fsm->state = NULL; |
852
ab439cbc7a81
Separated ec_sdo_request_init() and ec_sdo_request_read().
Florian Pose <fp@igh-essen.com>
parents:
849
diff
changeset
|
81 |
ec_sdo_request_init(&fsm->request); |
1045
c4fd73507076
Introduced global upload timeout for fsm_coe_map.
Florian Pose <fp@igh-essen.com>
parents:
1044
diff
changeset
|
82 |
fsm->request.response_timeout = EC_FSM_COE_MAP_UPLOAD_TIMEOUT; |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
859
diff
changeset
|
83 |
ec_pdo_list_init(&fsm->pdos); |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
84 |
} |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
85 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
86 |
/*****************************************************************************/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
87 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
88 |
/** |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
89 |
Destructor. |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
90 |
*/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
91 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
92 |
void ec_fsm_coe_map_clear(ec_fsm_coe_map_t *fsm /**< finite state machine */) |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
93 |
{ |
852
ab439cbc7a81
Separated ec_sdo_request_init() and ec_sdo_request_read().
Florian Pose <fp@igh-essen.com>
parents:
849
diff
changeset
|
94 |
ec_sdo_request_clear(&fsm->request); |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
859
diff
changeset
|
95 |
ec_pdo_list_clear(&fsm->pdos); |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
96 |
} |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
97 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
98 |
/*****************************************************************************/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
99 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
100 |
/** |
814 | 101 |
Starts to upload an Sdo from a slave. |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
102 |
*/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
103 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
104 |
void ec_fsm_coe_map_start( |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
105 |
ec_fsm_coe_map_t *fsm, /**< finite state machine */ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
106 |
ec_slave_t *slave /**< EtherCAT slave */ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
107 |
) |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
108 |
{ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
109 |
fsm->slave = slave; |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
110 |
fsm->state = ec_fsm_coe_map_state_start; |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
111 |
} |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
112 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
113 |
/*****************************************************************************/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
114 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
115 |
/** |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
116 |
Executes the current state of the state machine. |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
117 |
\return false, if state machine has terminated |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
118 |
*/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
119 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
120 |
int ec_fsm_coe_map_exec(ec_fsm_coe_map_t *fsm /**< finite state machine */) |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
121 |
{ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
122 |
fsm->state(fsm); |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
123 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
124 |
return fsm->state != ec_fsm_coe_map_state_end |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
125 |
&& fsm->state != ec_fsm_coe_map_state_error; |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
126 |
} |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
127 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
128 |
/*****************************************************************************/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
129 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
130 |
/** |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
131 |
Returns, if the state machine terminated with success. |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
132 |
\return non-zero if successful. |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
133 |
*/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
134 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
135 |
int ec_fsm_coe_map_success(ec_fsm_coe_map_t *fsm /**< Finite state machine */) |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
136 |
{ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
137 |
return fsm->state == ec_fsm_coe_map_state_end; |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
138 |
} |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
139 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
140 |
/****************************************************************************** |
751 | 141 |
* state functions |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
142 |
*****************************************************************************/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
143 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
144 |
/** |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
859
diff
changeset
|
145 |
* Start reading Pdo assignment. |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
146 |
*/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
147 |
|
751 | 148 |
void ec_fsm_coe_map_state_start( |
149 |
ec_fsm_coe_map_t *fsm /**< finite state machine */ |
|
150 |
) |
|
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
151 |
{ |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
859
diff
changeset
|
152 |
// read Pdo assignment for first direction |
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
153 |
fsm->dir = (ec_direction_t) -1; // next is EC_DIR_OUTPUT |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
154 |
ec_fsm_coe_map_action_next_dir(fsm); |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
155 |
} |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
156 |
|
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
157 |
/*****************************************************************************/ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
158 |
|
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
159 |
/** |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
859
diff
changeset
|
160 |
* Read Pdo assignment of next direction manager. |
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
161 |
*/ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
162 |
|
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
163 |
void ec_fsm_coe_map_action_next_dir( |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
164 |
ec_fsm_coe_map_t *fsm /**< finite state machine */ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
165 |
) |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
166 |
{ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
167 |
ec_slave_t *slave = fsm->slave; |
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
168 |
|
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
169 |
fsm->dir++; |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
170 |
|
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
171 |
if (slave->master->debug_level) |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
172 |
EC_DBG("Processing dir %u of slave %u.\n", |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
173 |
fsm->dir, slave->ring_position); |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
174 |
|
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
175 |
for (; fsm->dir <= EC_DIR_INPUT; fsm->dir++) { |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
176 |
|
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
177 |
if (!(fsm->sync = ec_slave_get_pdo_sync(slave, fsm->dir))) { |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
178 |
if (slave->master->debug_level) |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
179 |
EC_DBG("No sync manager for direction %u!\n", fsm->dir); |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
180 |
continue; |
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
181 |
} |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
182 |
|
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
183 |
fsm->sync_sdo_index = 0x1C10 + fsm->sync->index; |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
184 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
185 |
if (slave->master->debug_level) |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
859
diff
changeset
|
186 |
EC_DBG("Reading Pdo assignment of sync manager %u of slave %u.\n", |
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
187 |
fsm->sync->index, slave->ring_position); |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
188 |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
859
diff
changeset
|
189 |
ec_pdo_list_clear_pdos(&fsm->pdos); |
749
c8f1395f818a
Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
190 |
|
854
f4f53be425ac
Removed ec_sdodata_t; CoE state machines work on ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
852
diff
changeset
|
191 |
ec_sdo_request_address(&fsm->request, fsm->sync_sdo_index, 0); |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
192 |
ecrt_sdo_request_read(&fsm->request); |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
193 |
fsm->state = ec_fsm_coe_map_state_pdo_count; |
859
233e32f428e1
Replaced ec_fsm_coe_\(upload\|download\)() with ec_fsm_coe_transfer();
Florian Pose <fp@igh-essen.com>
parents:
858
diff
changeset
|
194 |
ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request); |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
195 |
ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
196 |
return; |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
197 |
} |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
198 |
|
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
199 |
if (slave->master->debug_level) |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
859
diff
changeset
|
200 |
EC_DBG("Reading of Pdo assignment finished for slave %u.\n", |
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
201 |
slave->ring_position); |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
202 |
|
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
203 |
fsm->state = ec_fsm_coe_map_state_end; |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
204 |
} |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
205 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
206 |
/*****************************************************************************/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
207 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
208 |
/** |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
859
diff
changeset
|
209 |
* Count assigned Pdos. |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
210 |
*/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
211 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
212 |
void ec_fsm_coe_map_state_pdo_count( |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
213 |
ec_fsm_coe_map_t *fsm /**< finite state machine */ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
214 |
) |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
215 |
{ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
216 |
if (ec_fsm_coe_exec(fsm->fsm_coe)) return; |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
217 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
218 |
if (!ec_fsm_coe_success(fsm->fsm_coe)) { |
903
d13004440b6d
Improved a few debugging outputs.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
219 |
EC_ERR("Failed to read number of assigned Pdos from slave %u.\n", |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
220 |
fsm->slave->ring_position); |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
221 |
fsm->state = ec_fsm_coe_map_state_error; |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
222 |
return; |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
223 |
} |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
224 |
|
1036
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
225 |
if (fsm->request.data_size != sizeof(uint8_t)) { |
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
226 |
EC_ERR("Invalid data size %u returned when uploading Sdo 0x%04X:%02X " |
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
227 |
"from slave %u.\n", fsm->request.data_size, |
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
228 |
fsm->request.index, fsm->request.subindex, |
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
229 |
fsm->slave->ring_position); |
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
230 |
fsm->state = ec_fsm_coe_map_state_error; |
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
231 |
return; |
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
232 |
} |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
233 |
fsm->sync_subindices = EC_READ_U8(fsm->request.data); |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
234 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
235 |
if (fsm->slave->master->debug_level) |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
859
diff
changeset
|
236 |
EC_DBG(" %u Pdos assigned.\n", fsm->sync_subindices); |
814 | 237 |
|
238 |
// read first Pdo |
|
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
239 |
fsm->sync_subindex = 1; |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
240 |
ec_fsm_coe_map_action_next_pdo(fsm); |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
241 |
} |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
242 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
243 |
/*****************************************************************************/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
244 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
245 |
/** |
814 | 246 |
* Read next Pdo. |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
247 |
*/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
248 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
249 |
void ec_fsm_coe_map_action_next_pdo( |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
250 |
ec_fsm_coe_map_t *fsm /**< finite state machine */ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
251 |
) |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
252 |
{ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
253 |
if (fsm->sync_subindex <= fsm->sync_subindices) { |
854
f4f53be425ac
Removed ec_sdodata_t; CoE state machines work on ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
852
diff
changeset
|
254 |
ec_sdo_request_address(&fsm->request, fsm->sync_sdo_index, |
849
4b712ec8929d
Removed slave pointer from ec_sdo_request_t class.
Florian Pose <fp@igh-essen.com>
parents:
847
diff
changeset
|
255 |
fsm->sync_subindex); |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
256 |
ecrt_sdo_request_read(&fsm->request); |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
257 |
fsm->state = ec_fsm_coe_map_state_pdo; |
859
233e32f428e1
Replaced ec_fsm_coe_\(upload\|download\)() with ec_fsm_coe_transfer();
Florian Pose <fp@igh-essen.com>
parents:
858
diff
changeset
|
258 |
ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request); |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
259 |
ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
260 |
return; |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
261 |
} |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
262 |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
859
diff
changeset
|
263 |
// finished reading Pdo assignment/mapping |
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
264 |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
859
diff
changeset
|
265 |
if (ec_pdo_list_copy(&fsm->sync->pdos, &fsm->pdos)) { |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
859
diff
changeset
|
266 |
fsm->state = ec_fsm_coe_map_state_error; |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
859
diff
changeset
|
267 |
return; |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
859
diff
changeset
|
268 |
} |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
859
diff
changeset
|
269 |
|
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
859
diff
changeset
|
270 |
fsm->sync->assign_source = EC_ASSIGN_COE; |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
859
diff
changeset
|
271 |
ec_pdo_list_clear_pdos(&fsm->pdos); |
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
272 |
|
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
273 |
// next direction |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
274 |
ec_fsm_coe_map_action_next_dir(fsm); |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
275 |
} |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
276 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
277 |
/*****************************************************************************/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
278 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
279 |
/** |
814 | 280 |
* Fetch Pdo information. |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
281 |
*/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
282 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
283 |
void ec_fsm_coe_map_state_pdo( |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
284 |
ec_fsm_coe_map_t *fsm /**< finite state machine */ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
285 |
) |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
286 |
{ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
287 |
if (ec_fsm_coe_exec(fsm->fsm_coe)) return; |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
288 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
289 |
if (!ec_fsm_coe_success(fsm->fsm_coe)) { |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
859
diff
changeset
|
290 |
EC_ERR("Failed to read assigned Pdo index from slave %u.\n", |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
291 |
fsm->slave->ring_position); |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
292 |
fsm->state = ec_fsm_coe_map_state_error; |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
293 |
return; |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
294 |
} |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
295 |
|
1036
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
296 |
if (fsm->request.data_size != sizeof(uint16_t)) { |
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
297 |
EC_ERR("Invalid data size %u returned when uploading Sdo 0x%04X:%02X " |
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
298 |
"from slave %u.\n", fsm->request.data_size, |
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
299 |
fsm->request.index, fsm->request.subindex, |
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
300 |
fsm->slave->ring_position); |
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
301 |
fsm->state = ec_fsm_coe_map_state_error; |
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
302 |
return; |
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
303 |
} |
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
304 |
|
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
305 |
if (!(fsm->pdo = (ec_pdo_t *) |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
306 |
kmalloc(sizeof(ec_pdo_t), GFP_KERNEL))) { |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
307 |
EC_ERR("Failed to allocate Pdo.\n"); |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
308 |
fsm->state = ec_fsm_coe_map_state_error; |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
309 |
return; |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
310 |
} |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
311 |
|
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
312 |
ec_pdo_init(fsm->pdo); |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
313 |
fsm->pdo->index = EC_READ_U16(fsm->request.data); |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
314 |
fsm->pdo->dir = ec_sync_direction(fsm->sync); |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
315 |
|
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
316 |
if (fsm->slave->master->debug_level) |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
317 |
EC_DBG(" Pdo 0x%04X.\n", fsm->pdo->index); |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
318 |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
859
diff
changeset
|
319 |
list_add_tail(&fsm->pdo->list, &fsm->pdos.list); |
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
320 |
|
854
f4f53be425ac
Removed ec_sdodata_t; CoE state machines work on ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
852
diff
changeset
|
321 |
ec_sdo_request_address(&fsm->request, fsm->pdo->index, 0); |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
322 |
ecrt_sdo_request_read(&fsm->request); |
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
323 |
fsm->state = ec_fsm_coe_map_state_pdo_entry_count; |
859
233e32f428e1
Replaced ec_fsm_coe_\(upload\|download\)() with ec_fsm_coe_transfer();
Florian Pose <fp@igh-essen.com>
parents:
858
diff
changeset
|
324 |
ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request); |
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
325 |
ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
326 |
} |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
327 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
328 |
/*****************************************************************************/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
329 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
330 |
/** |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
859
diff
changeset
|
331 |
* Read number of mapped Pdo entries. |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
332 |
*/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
333 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
334 |
void ec_fsm_coe_map_state_pdo_entry_count( |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
335 |
ec_fsm_coe_map_t *fsm /**< finite state machine */ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
336 |
) |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
337 |
{ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
338 |
if (ec_fsm_coe_exec(fsm->fsm_coe)) return; |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
339 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
340 |
if (!ec_fsm_coe_success(fsm->fsm_coe)) { |
814 | 341 |
EC_ERR("Failed to read number of mapped Pdo entries from slave %u.\n", |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
342 |
fsm->slave->ring_position); |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
343 |
fsm->state = ec_fsm_coe_map_state_error; |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
344 |
return; |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
345 |
} |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
346 |
|
1036
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
347 |
if (fsm->request.data_size != sizeof(uint8_t)) { |
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
348 |
EC_ERR("Invalid data size %u returned when uploading Sdo 0x%04X:%02X " |
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
349 |
"from slave %u.\n", fsm->request.data_size, |
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
350 |
fsm->request.index, fsm->request.subindex, |
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
351 |
fsm->slave->ring_position); |
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
352 |
fsm->state = ec_fsm_coe_map_state_error; |
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
353 |
return; |
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
354 |
} |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
355 |
fsm->pdo_subindices = EC_READ_U8(fsm->request.data); |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
356 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
357 |
if (fsm->slave->master->debug_level) |
814 | 358 |
EC_DBG(" %u Pdo entries mapped.\n", fsm->pdo_subindices); |
359 |
||
360 |
// read first Pdo entry |
|
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
361 |
fsm->pdo_subindex = 1; |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
362 |
ec_fsm_coe_map_action_next_pdo_entry(fsm); |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
363 |
} |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
364 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
365 |
/*****************************************************************************/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
366 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
367 |
/** |
814 | 368 |
* Read next Pdo entry. |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
369 |
*/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
370 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
371 |
void ec_fsm_coe_map_action_next_pdo_entry( |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
372 |
ec_fsm_coe_map_t *fsm /**< finite state machine */ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
373 |
) |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
374 |
{ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
375 |
if (fsm->pdo_subindex <= fsm->pdo_subindices) { |
854
f4f53be425ac
Removed ec_sdodata_t; CoE state machines work on ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
852
diff
changeset
|
376 |
ec_sdo_request_address(&fsm->request, fsm->pdo->index, fsm->pdo_subindex); |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
377 |
ecrt_sdo_request_read(&fsm->request); |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
378 |
fsm->state = ec_fsm_coe_map_state_pdo_entry; |
859
233e32f428e1
Replaced ec_fsm_coe_\(upload\|download\)() with ec_fsm_coe_transfer();
Florian Pose <fp@igh-essen.com>
parents:
858
diff
changeset
|
379 |
ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request); |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
380 |
ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
381 |
return; |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
382 |
} |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
383 |
|
814 | 384 |
// next Pdo |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
385 |
fsm->sync_subindex++; |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
386 |
ec_fsm_coe_map_action_next_pdo(fsm); |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
387 |
} |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
388 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
389 |
/*****************************************************************************/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
390 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
391 |
/** |
814 | 392 |
* Read Pdo entry information. |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
393 |
*/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
394 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
395 |
void ec_fsm_coe_map_state_pdo_entry( |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
396 |
ec_fsm_coe_map_t *fsm /**< finite state machine */ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
397 |
) |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
398 |
{ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
399 |
if (ec_fsm_coe_exec(fsm->fsm_coe)) return; |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
400 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
401 |
if (!ec_fsm_coe_success(fsm->fsm_coe)) { |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
859
diff
changeset
|
402 |
EC_ERR("Failed to read mapped Pdo entry from slave %u.\n", |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
403 |
fsm->slave->ring_position); |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
404 |
fsm->state = ec_fsm_coe_map_state_error; |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
405 |
return; |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
406 |
} |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
407 |
|
1036
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
408 |
if (fsm->request.data_size != sizeof(uint32_t)) { |
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
409 |
EC_ERR("Invalid data size %u returned when uploading Sdo 0x%04X:%02X " |
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
410 |
"from slave %u.\n", fsm->request.data_size, |
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
411 |
fsm->request.index, fsm->request.subindex, |
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
412 |
fsm->slave->ring_position); |
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
413 |
fsm->state = ec_fsm_coe_map_state_error; |
dc2008bc8113
Check for data sizes when reading Pdo assignment/mapping from CoE.
Florian Pose <fp@igh-essen.com>
parents:
1035
diff
changeset
|
414 |
} else { |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
415 |
uint32_t pdo_entry_info; |
749
c8f1395f818a
Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
416 |
ec_pdo_entry_t *pdo_entry; |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
417 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
418 |
pdo_entry_info = EC_READ_U32(fsm->request.data); |
749
c8f1395f818a
Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
419 |
|
c8f1395f818a
Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
420 |
if (!(pdo_entry = (ec_pdo_entry_t *) |
c8f1395f818a
Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
421 |
kmalloc(sizeof(ec_pdo_entry_t), GFP_KERNEL))) { |
814 | 422 |
EC_ERR("Failed to allocate Pdo entry.\n"); |
749
c8f1395f818a
Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
423 |
fsm->state = ec_fsm_coe_map_state_error; |
c8f1395f818a
Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
424 |
return; |
c8f1395f818a
Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
425 |
} |
c8f1395f818a
Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
426 |
|
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
768
diff
changeset
|
427 |
ec_pdo_entry_init(pdo_entry); |
749
c8f1395f818a
Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
428 |
pdo_entry->index = pdo_entry_info >> 16; |
c8f1395f818a
Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
429 |
pdo_entry->subindex = (pdo_entry_info >> 8) & 0xFF; |
c8f1395f818a
Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
430 |
pdo_entry->bit_length = pdo_entry_info & 0xFF; |
c8f1395f818a
Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
431 |
|
767 | 432 |
if (!pdo_entry->index && !pdo_entry->subindex) { |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
768
diff
changeset
|
433 |
if (ec_pdo_entry_set_name(pdo_entry, "Gap")) { |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
768
diff
changeset
|
434 |
ec_pdo_entry_clear(pdo_entry); |
767 | 435 |
kfree(pdo_entry); |
436 |
fsm->state = ec_fsm_coe_map_state_error; |
|
437 |
return; |
|
438 |
} |
|
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
439 |
} |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
440 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
441 |
if (fsm->slave->master->debug_level) { |
926
6bb33c6ec770
Output subindices with %02X.
Florian Pose <fp@igh-essen.com>
parents:
903
diff
changeset
|
442 |
EC_DBG(" Pdo entry 0x%04X:%02X, %u bit, \"%s\".\n", |
6bb33c6ec770
Output subindices with %02X.
Florian Pose <fp@igh-essen.com>
parents:
903
diff
changeset
|
443 |
pdo_entry->index, pdo_entry->subindex, |
6bb33c6ec770
Output subindices with %02X.
Florian Pose <fp@igh-essen.com>
parents:
903
diff
changeset
|
444 |
pdo_entry->bit_length, |
6bb33c6ec770
Output subindices with %02X.
Florian Pose <fp@igh-essen.com>
parents:
903
diff
changeset
|
445 |
pdo_entry->name ? pdo_entry->name : "???"); |
749
c8f1395f818a
Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
446 |
} |
c8f1395f818a
Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
447 |
|
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
448 |
// next Pdo entry |
749
c8f1395f818a
Only exchange sync manager PDOs, if they could completely be read in.
Florian Pose <fp@igh-essen.com>
parents:
741
diff
changeset
|
449 |
list_add_tail(&pdo_entry->list, &fsm->pdo->entries); |
741
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
450 |
fsm->pdo_subindex++; |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
451 |
ec_fsm_coe_map_action_next_pdo_entry(fsm); |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
452 |
} |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
453 |
} |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
454 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
455 |
/*****************************************************************************/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
456 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
457 |
/** |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
458 |
State: ERROR. |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
459 |
*/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
460 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
461 |
void ec_fsm_coe_map_state_error( |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
462 |
ec_fsm_coe_map_t *fsm /**< finite state machine */ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
463 |
) |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
464 |
{ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
465 |
} |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
466 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
467 |
/*****************************************************************************/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
468 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
469 |
/** |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
470 |
State: END. |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
471 |
*/ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
472 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
473 |
void ec_fsm_coe_map_state_end( |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
474 |
ec_fsm_coe_map_t *fsm /**< finite state machine */ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
475 |
) |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
476 |
{ |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
477 |
} |
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
478 |
|
aece53f82df3
Read PDO mapping from SDO dictionary (working, not finished yet).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
479 |
/*****************************************************************************/ |