1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
|
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for Epl Configuration Manager Module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplCfgMau.h,v $
$Author: D.Krueger $
$Revision: 1.4 $ $Date: 2008/10/17 15:32:32 $
$State: Exp $
Build Environment:
VC7
-------------------------------------------------------------------------
Revision History:
2006/07/14 k.t.: start of the implementation
-> based on CANopen CfgMa-Modul (CANopen version 5.34)
****************************************************************************/
#include "../EplInc.h"
#ifndef _EPLCFGMA_H_
#define _EPLCFGMA_H_
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_CFGMA)) != 0)
#include "EplObdu.h"
#include "EplSdoComu.h"
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
//define max number of timeouts for configuration of 1 device
#define EPL_CFGMA_MAX_TIMEOUT 3
//callbackfunction, called if configuration is finished
typedef void (PUBLIC* tfpEplCfgMaCb) (unsigned int uiNodeId_p,
tEplKernel Errorstate_p);
//State for configuartion manager Statemachine
typedef enum
{
// general states
kEplCfgMaIdle = 0x0000, // Configurationsprocess
// is idle
kEplCfgMaWaitForSdocEvent = 0x0001, // wait until the last
// SDOC is finisched
kEplCfgMaSkipMappingSub0 = 0x0002, // write Sub0 of mapping
// parameter with 0
kEplCfgMaFinished = 0x0004 // configuartion is finished
} tEplCfgState;
typedef enum
{
kEplCfgMaDcfTypSystecSeg = 0x00,
kEplCfgMaDcfTypConDcf = 0x01,
kEplCfgMaDcfTypDcf = 0x02, // not supported
kEplCfgMaDcfTypXdc = 0x03 // not supported
}tEplCfgMaDcfTyp;
typedef enum
{
kEplCfgMaCommon = 0, // all other index
kEplCfgMaPdoComm = 1, // communication index
kEplCfgMaPdoMapp = 2, // mapping index
kEplCfgMaPdoCommAfterMapp = 3, // write PDO Cob-Id after mapping subindex 0(set PDO valid)
} tEplCfgMaIndexType;
//bitcoded answer about the last sdo transfer saved in m_SdocState
// also used to singal start of the State Maschine
typedef enum
{
kEplCfgMaSdocBusy = 0x00, // SDOC activ
kEplCfgMaSdocReady = 0x01, // SDOC finished
kEplCfgMaSdocTimeout = 0x02, // SDOC Timeout
kEplCfgMaSdocAbortReceived = 0x04, // SDOC Abort, see Abortcode
kEplCfgMaSdocStart = 0x08 // start State Mschine
}tEplSdocState;
//internal structure (instancetable for modul configuration manager)
typedef struct
{
tEplCfgState m_CfgState; // state of the configuration state maschine
tEplSdoComConHdl m_SdoComConHdl; // handle for sdo connection
DWORD m_dwLastAbortCode;
unsigned int m_uiLastIndex; // last index of configuration, to compair with actual index
BYTE* m_pbConcise; // Ptr to concise DCF
BYTE* m_pbActualIndex; // Ptr to actual index in the DCF segment
tfpEplCfgMaCb m_pfnCfgMaCb; // Ptr to CfgMa Callback, is call if configuration finished
tEplKernel m_EplKernelError; // errorcode
DWORD m_dwNumValueCopy; // numeric values are copied in this variable
unsigned int m_uiPdoNodeId; // buffer for PDO node id
BYTE m_bNrOfMappedObject; // number of mapped objects
unsigned int m_uiNodeId; // Epl node addresse
tEplSdocState m_SdocState; // bitcoded state of the SDO transfer
unsigned int m_uiLastSubIndex; // last subindex of configuration
BOOL m_fOneTranferOk; // atleased one transfer was successful
BYTE m_bEventFlag; // for Eventsignaling to the State Maschine
DWORD m_dwCntObjectInDcf; // number of Objects in DCF
tEplCfgMaIndexType m_SkipCfg; // TRUE if a adsitional Configurationprocess
// have to insert e.g. PDO-mapping
WORD m_wTimeOutCnt; // Timeout Counter, break configuration is
// m_wTimeOutCnt == CFGMA_MAX_TIMEOUT
} tEplCfgMaNode;
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Function: EplCfgMaInit()
//
// Description: Function creates first instance of Configuration Manager
//
// Parameters:
//
// Returns: tEplKernel = error code
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplCfgMaInit();
//---------------------------------------------------------------------------
// Function: EplCfgMaAddInstance()
//
// Description: Function creates additional instance of Configuration Manager
//
// Parameters:
//
// Returns: tEplKernel = error code
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplCfgMaAddInstance();
//---------------------------------------------------------------------------
// Function: EplCfgMaDelInstance()
//
// Description: Function delete instance of Configuration Manager
//
// Parameters:
//
// Returns: tEplKernel = error code
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplCfgMaDelInstance();
//---------------------------------------------------------------------------
// Function: EplCfgMaStartConfig()
//
// Description: Function starts the configuration process
// initialization the statemachine for CfgMa- process
//
// Parameters: uiNodeId_p = NodeId of the node to configure
// pbConcise_p = pointer to DCF
// fpCfgMaCb_p = pointer to callback function (should not be NULL)
// SizeOfConcise_p = size of DCF in BYTE -> for future use
// DcfType_p = type of the DCF
//
// Returns: tCopKernel = error code
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplCfgMaStartConfig(unsigned int uiNodeId_p,
BYTE* pbConcise_p,
tfpEplCfgMaCb fpCfgMaCb_p,
tEplObdSize SizeOfConcise_p,
tEplCfgMaDcfTyp DcfType_p);
//---------------------------------------------------------------------------
// Function: CfgMaStartConfigurationNode()
//
// Description: Function started the configuration process
// with the DCF from according OD-entry Subindex == bNodeId_p
//
// Parameters: uiNodeId_p = NodeId of the node to configure
// fpCfgMaCb_p = pointer to callback function (should not be NULL)
// DcfType_p = type of the DCF
//
// Returns: tCopKernel = error code
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplCfgMaStartConfigNode(unsigned int uiNodeId_p,
tfpEplCfgMaCb fpCfgMaCb_p,
tEplCfgMaDcfTyp DcfType_p);
//---------------------------------------------------------------------------
// Function: EplCfgMaStartConfigNodeDcf()
//
// Description: Function starts the configuration process
// and links the configuration data to the OD
//
// Parameters: uiNodeId_p = NodeId of the node to configure
// pbConcise_p = pointer to DCF
// fpCfgMaCb_p = pointer to callback function (should not be NULL)
// SizeOfConcise_p = size of DCF in BYTE -> for future use
// DcfType_p = type of the DCF
//
// Returns: tCopKernel = error code
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplCfgMaStartConfigNodeDcf(unsigned int uiNodeId_p,
BYTE* pbConcise_p,
tfpEplCfgMaCb fpCfgMaCb_p,
tEplObdSize SizeOfConcise_p,
tEplCfgMaDcfTyp DcfType_p);
//---------------------------------------------------------------------------
// Function: EplCfgMaLinkDcf()
//
// Description: Function links the configuration data to the OD
//
// Parameters: uiNodeId_p = NodeId of the node to configure
// pbConcise_p = pointer to DCF
// SizeOfConcise_p = size of DCF in BYTE -> for future use
// DcfType_p = type of the DCF
//
// Returns: tCopKernel = error code
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplCfgMaLinkDcf(unsigned int uiNodeId_p,
BYTE* pbConcise_p,
tEplObdSize SizeOfConcise_p,
tEplCfgMaDcfTyp DcfType_p);
//---------------------------------------------------------------------------
// Function: EplCfgMaCheckDcf()
//
// Description: Function check if there is allready a configuration file linked
// to the OD (type is given by DcfType_p)
//
// Parameters: uiNodeId_p = NodeId
// DcfType_p = type of the DCF
//
// Returns: tCopKernel = error code
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplCfgMaCheckDcf(unsigned int uiNodeId_p,
tEplCfgMaDcfTyp DcfType_p);
#endif // #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_CFGMA)) != 0)
#endif // _EPLCFGMA_H_
// EOF
|