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