diff options
author | Daniel Krueger <daniel.krueger@systec-electronic.com> | 2008-12-19 14:41:57 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-01-06 16:52:36 -0500 |
commit | 9d7164cfdb611c2f864d535ae5794f23db3d84f7 (patch) | |
tree | 046847f7d6432f1f3dc8236f62492503f4c9ebdc /drivers/staging/epl/EplNmtk.c | |
parent | 37bcd24b845abbfd85c838ee9ce07c2b254d3a05 (diff) |
Staging: add epl stack
This is the openPOWERLINK network stack from systec electronic.
It's a bit messed up as there is a driver mixed into the
middle of it, lots of work needs to be done to unwind the
different portions to make it sane.
Cc: Daniel Krueger <daniel.krueger@systec-electronic.com>
Cc: Ronald Sieber <Ronald.Sieber@systec-electronic.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/epl/EplNmtk.c')
-rw-r--r-- | drivers/staging/epl/EplNmtk.c | 1750 |
1 files changed, 1750 insertions, 0 deletions
diff --git a/drivers/staging/epl/EplNmtk.c b/drivers/staging/epl/EplNmtk.c new file mode 100644 index 00000000000..8bfa59a7e32 --- /dev/null +++ b/drivers/staging/epl/EplNmtk.c | |||
@@ -0,0 +1,1750 @@ | |||
1 | /**************************************************************************** | ||
2 | |||
3 | (c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29 | ||
4 | www.systec-electronic.com | ||
5 | |||
6 | Project: openPOWERLINK | ||
7 | |||
8 | Description: source file for NMT-Kernelspace-Module | ||
9 | |||
10 | License: | ||
11 | |||
12 | Redistribution and use in source and binary forms, with or without | ||
13 | modification, are permitted provided that the following conditions | ||
14 | are met: | ||
15 | |||
16 | 1. Redistributions of source code must retain the above copyright | ||
17 | notice, this list of conditions and the following disclaimer. | ||
18 | |||
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. | ||
22 | |||
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. | ||
27 | |||
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. | ||
40 | |||
41 | Severability Clause: | ||
42 | |||
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. | ||
49 | |||
50 | ------------------------------------------------------------------------- | ||
51 | |||
52 | $RCSfile: EplNmtk.c,v $ | ||
53 | |||
54 | $Author: D.Krueger $ | ||
55 | |||
56 | $Revision: 1.12 $ $Date: 2008/11/13 17:13:09 $ | ||
57 | |||
58 | $State: Exp $ | ||
59 | |||
60 | Build Environment: | ||
61 | GCC V3.4 | ||
62 | |||
63 | ------------------------------------------------------------------------- | ||
64 | |||
65 | Revision History: | ||
66 | |||
67 | 2006/06/09 k.t.: start of the implementation | ||
68 | |||
69 | ****************************************************************************/ | ||
70 | |||
71 | #include "kernel/EplNmtk.h" | ||
72 | #include "kernel/EplTimerk.h" | ||
73 | |||
74 | #include "kernel/EplDllk.h" // for EplDllkProcess() | ||
75 | |||
76 | #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTK)) != 0) | ||
77 | /***************************************************************************/ | ||
78 | /* */ | ||
79 | /* */ | ||
80 | /* G L O B A L D E F I N I T I O N S */ | ||
81 | /* */ | ||
82 | /* */ | ||
83 | /***************************************************************************/ | ||
84 | |||
85 | //--------------------------------------------------------------------------- | ||
86 | // const defines | ||
87 | //--------------------------------------------------------------------------- | ||
88 | |||
89 | // TracePoint support for realtime-debugging | ||
90 | #ifdef _DBG_TRACE_POINTS_ | ||
91 | void PUBLIC TgtDbgSignalTracePoint (BYTE bTracePointNumber_p); | ||
92 | void PUBLIC TgtDbgPostTraceValue (DWORD dwTraceValue_p); | ||
93 | #define TGT_DBG_SIGNAL_TRACE_POINT(p) TgtDbgSignalTracePoint(p) | ||
94 | #define TGT_DBG_POST_TRACE_VALUE(v) TgtDbgPostTraceValue(v) | ||
95 | #else | ||
96 | #define TGT_DBG_SIGNAL_TRACE_POINT(p) | ||
97 | #define TGT_DBG_POST_TRACE_VALUE(v) | ||
98 | #endif | ||
99 | #define EPL_NMTK_DBG_POST_TRACE_VALUE(NmtEvent_p, OldNmtState_p, NewNmtState_p) \ | ||
100 | TGT_DBG_POST_TRACE_VALUE((kEplEventSinkNmtk << 28) | (NmtEvent_p << 16) \ | ||
101 | | ((OldNmtState_p & 0xFF) << 8) \ | ||
102 | | (NewNmtState_p & 0xFF)) | ||
103 | |||
104 | |||
105 | //--------------------------------------------------------------------------- | ||
106 | // local types | ||
107 | //--------------------------------------------------------------------------- | ||
108 | // struct for instance table | ||
109 | INSTANCE_TYPE_BEGIN | ||
110 | |||
111 | EPL_MCO_DECL_INSTANCE_MEMBER () | ||
112 | |||
113 | STATIC volatile tEplNmtState INST_FAR m_NmtState; | ||
114 | STATIC volatile BOOL INST_FAR m_fEnableReadyToOperate; | ||
115 | STATIC volatile BOOL INST_FAR m_fAppReadyToOperate; | ||
116 | STATIC volatile BOOL INST_FAR m_fTimerMsPreOp2; | ||
117 | STATIC volatile BOOL INST_FAR m_fAllMandatoryCNIdent; | ||
118 | STATIC volatile BOOL INST_FAR m_fFrozen; | ||
119 | |||
120 | INSTANCE_TYPE_END | ||
121 | //--------------------------------------------------------------------------- | ||
122 | // modul globale vars | ||
123 | //--------------------------------------------------------------------------- | ||
124 | // This macro replace the unspecific pointer to an instance through | ||
125 | // the modul specific type for the local instance table. This macro | ||
126 | // must defined in each modul. | ||
127 | //#define tEplPtrInstance tEplInstanceInfo MEM* | ||
128 | |||
129 | EPL_MCO_DECL_INSTANCE_VAR () | ||
130 | |||
131 | //--------------------------------------------------------------------------- | ||
132 | // local function prototypes | ||
133 | //--------------------------------------------------------------------------- | ||
134 | EPL_MCO_DEFINE_INSTANCE_FCT () | ||
135 | |||
136 | |||
137 | /***************************************************************************/ | ||
138 | /* */ | ||
139 | /* */ | ||
140 | /* C L A S S <NMT_Kernel-Module> */ | ||
141 | /* */ | ||
142 | /* */ | ||
143 | /***************************************************************************/ | ||
144 | // | ||
145 | // Description: This module realize the NMT-State-Machine of the EPL-Stack | ||
146 | // | ||
147 | // | ||
148 | /***************************************************************************/ | ||
149 | //=========================================================================// | ||
150 | // // | ||
151 | // P U B L I C F U N C T I O N S // | ||
152 | // // | ||
153 | //=========================================================================// | ||
154 | //--------------------------------------------------------------------------- | ||
155 | // | ||
156 | // Function: EplNmtkInit | ||
157 | // | ||
158 | // Description: initializes the first instance | ||
159 | // | ||
160 | // | ||
161 | // | ||
162 | // Parameters: EPL_MCO_DECL_PTR_INSTANCE_PTR = Instance pointer | ||
163 | // uiNodeId_p = Node Id of the lokal node | ||
164 | // | ||
165 | // | ||
166 | // Returns: tEplKernel = Errorcode | ||
167 | // | ||
168 | // | ||
169 | // State: | ||
170 | // | ||
171 | //--------------------------------------------------------------------------- | ||
172 | EPLDLLEXPORT tEplKernel PUBLIC EplNmtkInit(EPL_MCO_DECL_PTR_INSTANCE_PTR) | ||
173 | { | ||
174 | tEplKernel Ret; | ||
175 | |||
176 | Ret = EplNmtkAddInstance (EPL_MCO_PTR_INSTANCE_PTR); | ||
177 | |||
178 | return Ret; | ||
179 | } | ||
180 | |||
181 | |||
182 | //--------------------------------------------------------------------------- | ||
183 | // | ||
184 | // Function: EplNmtkAddInstance | ||
185 | // | ||
186 | // Description: adds a new instance | ||
187 | // | ||
188 | // | ||
189 | // | ||
190 | // Parameters: EPL_MCO_DECL_PTR_INSTANCE_PTR = Instance pointer | ||
191 | // | ||
192 | // | ||
193 | // Returns: tEplKernel = Errorcode | ||
194 | // | ||
195 | // | ||
196 | // State: | ||
197 | // | ||
198 | //--------------------------------------------------------------------------- | ||
199 | EPLDLLEXPORT tEplKernel PUBLIC EplNmtkAddInstance(EPL_MCO_DECL_PTR_INSTANCE_PTR) | ||
200 | { | ||
201 | EPL_MCO_DECL_INSTANCE_PTR_LOCAL | ||
202 | tEplKernel Ret; | ||
203 | //tEplEvent Event; | ||
204 | //tEplEventNmtStateChange NmtStateChange; | ||
205 | |||
206 | // check if pointer to instance pointer valid | ||
207 | // get free instance and set the globale instance pointer | ||
208 | // set also the instance addr to parameterlist | ||
209 | EPL_MCO_CHECK_PTR_INSTANCE_PTR (); | ||
210 | EPL_MCO_GET_FREE_INSTANCE_PTR (); | ||
211 | EPL_MCO_SET_PTR_INSTANCE_PTR (); | ||
212 | |||
213 | // sign instance as used | ||
214 | EPL_MCO_WRITE_INSTANCE_STATE (kStateUsed); | ||
215 | |||
216 | |||
217 | Ret = kEplSuccessful; | ||
218 | |||
219 | // initialize intern vaiables | ||
220 | // 2006/07/31 d.k.: set NMT-State to kEplNmtGsOff | ||
221 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsOff; | ||
222 | // set NMT-State to kEplNmtGsInitialising | ||
223 | //EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsInitialising; | ||
224 | |||
225 | // set flags to FALSE | ||
226 | EPL_MCO_GLB_VAR(m_fEnableReadyToOperate) = FALSE; | ||
227 | EPL_MCO_GLB_VAR(m_fAppReadyToOperate) = FALSE; | ||
228 | EPL_MCO_GLB_VAR(m_fTimerMsPreOp2) = FALSE; | ||
229 | EPL_MCO_GLB_VAR(m_fAllMandatoryCNIdent) = FALSE; | ||
230 | EPL_MCO_GLB_VAR(m_fFrozen) = FALSE; | ||
231 | |||
232 | // EPL_MCO_GLB_VAR(m_TimerHdl) = 0; | ||
233 | |||
234 | // inform higher layer about state change | ||
235 | // 2006/07/31 d.k.: The EPL API layer/application has to start NMT state | ||
236 | // machine via NmtEventSwReset after initialisation of | ||
237 | // all modules has been completed. DLL has to be initialised | ||
238 | // after NMTk because NMT state shall not be uninitialised | ||
239 | // at that time. | ||
240 | /* NmtStateChange.m_NewNmtState = EPL_MCO_GLB_VAR(m_NmtState); | ||
241 | NmtStateChange.m_NmtEvent = kEplNmtEventNoEvent; | ||
242 | Event.m_EventSink = kEplEventSinkNmtu; | ||
243 | Event.m_EventType = kEplEventTypeNmtStateChange; | ||
244 | EPL_MEMSET(&Event.m_NetTime, 0x00, sizeof(Event.m_NetTime)); | ||
245 | Event.m_pArg = &NmtStateChange; | ||
246 | Event.m_uiSize = sizeof(NmtStateChange); | ||
247 | Ret = EplEventkPost(&Event); | ||
248 | */ | ||
249 | return Ret; | ||
250 | } | ||
251 | |||
252 | |||
253 | //--------------------------------------------------------------------------- | ||
254 | // | ||
255 | // Function: EplNmtkDelInstance | ||
256 | // | ||
257 | // Description: delete instance | ||
258 | // | ||
259 | // | ||
260 | // | ||
261 | // Parameters: EPL_MCO_DECL_PTR_INSTANCE_PTR = Instance pointer | ||
262 | // | ||
263 | // | ||
264 | // Returns: tEplKernel = Errorcode | ||
265 | // | ||
266 | // | ||
267 | // State: | ||
268 | // | ||
269 | //--------------------------------------------------------------------------- | ||
270 | #if (EPL_USE_DELETEINST_FUNC != FALSE) | ||
271 | EPLDLLEXPORT tEplKernel PUBLIC EplNmtkDelInstance(EPL_MCO_DECL_PTR_INSTANCE_PTR) | ||
272 | { | ||
273 | tEplKernel Ret = kEplSuccessful; | ||
274 | // check for all API function if instance is valid | ||
275 | EPL_MCO_CHECK_INSTANCE_STATE (); | ||
276 | |||
277 | // set NMT-State to kEplNmtGsOff | ||
278 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsOff; | ||
279 | |||
280 | // sign instance as unused | ||
281 | EPL_MCO_WRITE_INSTANCE_STATE (kStateUnused); | ||
282 | |||
283 | // delete timer | ||
284 | // Ret = EplTimerkDeleteTimer(&EPL_MCO_GLB_VAR(m_TimerHdl)); | ||
285 | |||
286 | return Ret; | ||
287 | } | ||
288 | #endif // (EPL_USE_DELETEINST_FUNC != FALSE) | ||
289 | |||
290 | |||
291 | //--------------------------------------------------------------------------- | ||
292 | // | ||
293 | // Function: EplNmtkProcess | ||
294 | // | ||
295 | // Description: main process function | ||
296 | // -> process NMT-State-Maschine und read NMT-Events from Queue | ||
297 | // | ||
298 | // | ||
299 | // | ||
300 | // Parameters: EPL_MCO_DECL_PTR_INSTANCE_PTR_ = Instance pointer | ||
301 | // pEvent_p = Epl-Event with NMT-event to process | ||
302 | // | ||
303 | // | ||
304 | // Returns: tEplKernel = Errorcode | ||
305 | // | ||
306 | // | ||
307 | // State: | ||
308 | // | ||
309 | //--------------------------------------------------------------------------- | ||
310 | EPLDLLEXPORT tEplKernel PUBLIC EplNmtkProcess(EPL_MCO_DECL_PTR_INSTANCE_PTR_ | ||
311 | tEplEvent* pEvent_p) | ||
312 | { | ||
313 | tEplKernel Ret; | ||
314 | tEplNmtState OldNmtState; | ||
315 | tEplNmtEvent NmtEvent; | ||
316 | tEplEvent Event; | ||
317 | tEplEventNmtStateChange NmtStateChange; | ||
318 | |||
319 | // check for all API function if instance is valid | ||
320 | EPL_MCO_CHECK_INSTANCE_STATE (); | ||
321 | |||
322 | Ret = kEplSuccessful; | ||
323 | |||
324 | switch(pEvent_p->m_EventType) | ||
325 | { | ||
326 | case kEplEventTypeNmtEvent: | ||
327 | { | ||
328 | NmtEvent = *((tEplNmtEvent*)pEvent_p->m_pArg); | ||
329 | break; | ||
330 | } | ||
331 | |||
332 | case kEplEventTypeTimer: | ||
333 | { | ||
334 | NmtEvent = (tEplNmtEvent)((tEplTimerEventArg*)pEvent_p->m_pArg)->m_ulArg; | ||
335 | break; | ||
336 | } | ||
337 | default: | ||
338 | { | ||
339 | Ret = kEplNmtInvalidEvent; | ||
340 | goto Exit; | ||
341 | } | ||
342 | } | ||
343 | |||
344 | // save NMT-State | ||
345 | // needed for later comparison to | ||
346 | // inform hgher layer about state change | ||
347 | OldNmtState = EPL_MCO_GLB_VAR(m_NmtState); | ||
348 | |||
349 | // NMT-State-Maschine | ||
350 | switch(EPL_MCO_GLB_VAR(m_NmtState)) | ||
351 | { | ||
352 | //----------------------------------------------------------- | ||
353 | // general part of the statemaschine | ||
354 | |||
355 | // first init of the hardware | ||
356 | case kEplNmtGsOff: | ||
357 | { | ||
358 | // leave this state only if higher layer says so | ||
359 | if(NmtEvent == kEplNmtEventSwReset) | ||
360 | { // new state kEplNmtGsInitialising | ||
361 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsInitialising; | ||
362 | } | ||
363 | break; | ||
364 | } | ||
365 | |||
366 | // first init of the hardware | ||
367 | case kEplNmtGsInitialising: | ||
368 | { | ||
369 | // leave this state only if higher layer says so | ||
370 | |||
371 | // check events | ||
372 | switch(NmtEvent) | ||
373 | { | ||
374 | // 2006/07/31 d.k.: react also on NMT reset commands in ResetApp state | ||
375 | // NMT Command SwitchOff | ||
376 | case kEplNmtEventCriticalError: | ||
377 | case kEplNmtEventSwitchOff: | ||
378 | { | ||
379 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsOff; | ||
380 | break; | ||
381 | } | ||
382 | |||
383 | // new state kEplNmtGsResetApplication | ||
384 | case kEplNmtEventEnterResetApp: | ||
385 | { | ||
386 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetApplication; | ||
387 | break; | ||
388 | } | ||
389 | |||
390 | default: | ||
391 | { | ||
392 | break; | ||
393 | } | ||
394 | } | ||
395 | break; | ||
396 | } | ||
397 | |||
398 | // init of the manufacturer-specific profile area and the | ||
399 | // standardised device profile area | ||
400 | case kEplNmtGsResetApplication: | ||
401 | { | ||
402 | // check events | ||
403 | switch(NmtEvent) | ||
404 | { | ||
405 | // 2006/07/31 d.k.: react also on NMT reset commands in ResetApp state | ||
406 | // NMT Command SwitchOff | ||
407 | case kEplNmtEventCriticalError: | ||
408 | case kEplNmtEventSwitchOff: | ||
409 | { | ||
410 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsOff; | ||
411 | break; | ||
412 | } | ||
413 | |||
414 | // NMT Command SwReset | ||
415 | case kEplNmtEventSwReset: | ||
416 | { | ||
417 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsInitialising; | ||
418 | break; | ||
419 | } | ||
420 | |||
421 | // leave this state only if higher layer | ||
422 | // say so | ||
423 | case kEplNmtEventEnterResetCom: | ||
424 | { | ||
425 | // new state kEplNmtGsResetCommunication | ||
426 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetCommunication; | ||
427 | break; | ||
428 | } | ||
429 | |||
430 | default: | ||
431 | { | ||
432 | break; | ||
433 | } | ||
434 | } | ||
435 | break; | ||
436 | } | ||
437 | |||
438 | // init of the communication profile area | ||
439 | case kEplNmtGsResetCommunication: | ||
440 | { | ||
441 | // check events | ||
442 | switch(NmtEvent) | ||
443 | { | ||
444 | // 2006/07/31 d.k.: react also on NMT reset commands in ResetComm state | ||
445 | // NMT Command SwitchOff | ||
446 | case kEplNmtEventCriticalError: | ||
447 | case kEplNmtEventSwitchOff: | ||
448 | { | ||
449 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsOff; | ||
450 | break; | ||
451 | } | ||
452 | |||
453 | // NMT Command SwReset | ||
454 | case kEplNmtEventSwReset: | ||
455 | { | ||
456 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsInitialising; | ||
457 | break; | ||
458 | } | ||
459 | |||
460 | // NMT Command ResetNode | ||
461 | case kEplNmtEventResetNode: | ||
462 | { | ||
463 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetApplication; | ||
464 | break; | ||
465 | } | ||
466 | |||
467 | // leave this state only if higher layer | ||
468 | // say so | ||
469 | case kEplNmtEventEnterResetConfig: | ||
470 | { | ||
471 | // new state kEplNmtGsResetCommunication | ||
472 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetConfiguration; | ||
473 | break; | ||
474 | } | ||
475 | |||
476 | default: | ||
477 | { | ||
478 | break; | ||
479 | } | ||
480 | } | ||
481 | break; | ||
482 | } | ||
483 | |||
484 | // build the configuration with infos from OD | ||
485 | case kEplNmtGsResetConfiguration: | ||
486 | { | ||
487 | // reset flags | ||
488 | EPL_MCO_GLB_VAR(m_fEnableReadyToOperate) = FALSE; | ||
489 | EPL_MCO_GLB_VAR(m_fAppReadyToOperate) = FALSE; | ||
490 | EPL_MCO_GLB_VAR(m_fFrozen) = FALSE; | ||
491 | |||
492 | // check events | ||
493 | switch(NmtEvent) | ||
494 | { | ||
495 | // 2006/07/31 d.k.: react also on NMT reset commands in ResetConf state | ||
496 | // NMT Command SwitchOff | ||
497 | case kEplNmtEventCriticalError: | ||
498 | case kEplNmtEventSwitchOff: | ||
499 | { | ||
500 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsOff; | ||
501 | break; | ||
502 | } | ||
503 | |||
504 | // NMT Command SwReset | ||
505 | case kEplNmtEventSwReset: | ||
506 | { | ||
507 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsInitialising; | ||
508 | break; | ||
509 | } | ||
510 | |||
511 | // NMT Command ResetNode | ||
512 | case kEplNmtEventResetNode: | ||
513 | { | ||
514 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetApplication; | ||
515 | break; | ||
516 | } | ||
517 | |||
518 | // NMT Command ResetCommunication | ||
519 | case kEplNmtEventResetCom: | ||
520 | { | ||
521 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetCommunication; | ||
522 | break; | ||
523 | } | ||
524 | |||
525 | // leave this state only if higher layer says so | ||
526 | case kEplNmtEventEnterCsNotActive: | ||
527 | { // Node should be CN | ||
528 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsNotActive; | ||
529 | break; | ||
530 | |||
531 | } | ||
532 | |||
533 | case kEplNmtEventEnterMsNotActive: | ||
534 | { // Node should be CN | ||
535 | #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) == 0) | ||
536 | // no MN functionality | ||
537 | // TODO: -create error E_NMT_BA1_NO_MN_SUPPORT | ||
538 | EPL_MCO_GLB_VAR(m_fFrozen) = TRUE; | ||
539 | #else | ||
540 | |||
541 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtMsNotActive; | ||
542 | #endif | ||
543 | break; | ||
544 | |||
545 | } | ||
546 | |||
547 | default: | ||
548 | { | ||
549 | break; | ||
550 | } | ||
551 | } | ||
552 | break; | ||
553 | } | ||
554 | |||
555 | //----------------------------------------------------------- | ||
556 | // CN part of the statemaschine | ||
557 | |||
558 | // node liste for EPL-Frames and check timeout | ||
559 | case kEplNmtCsNotActive: | ||
560 | { | ||
561 | |||
562 | // check events | ||
563 | switch(NmtEvent) | ||
564 | { | ||
565 | // 2006/07/31 d.k.: react also on NMT reset commands in NotActive state | ||
566 | // NMT Command SwitchOff | ||
567 | case kEplNmtEventCriticalError: | ||
568 | case kEplNmtEventSwitchOff: | ||
569 | { | ||
570 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsOff; | ||
571 | break; | ||
572 | } | ||
573 | |||
574 | // NMT Command SwReset | ||
575 | case kEplNmtEventSwReset: | ||
576 | { | ||
577 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsInitialising; | ||
578 | // Ret = EplTimerkDeleteTimer(&EPL_MCO_GLB_VAR(m_TimerHdl)); | ||
579 | break; | ||
580 | } | ||
581 | |||
582 | // NMT Command ResetNode | ||
583 | case kEplNmtEventResetNode: | ||
584 | { | ||
585 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetApplication; | ||
586 | // Ret = EplTimerkDeleteTimer(&EPL_MCO_GLB_VAR(m_TimerHdl)); | ||
587 | break; | ||
588 | } | ||
589 | |||
590 | // NMT Command ResetCommunication | ||
591 | // or internal Communication error | ||
592 | case kEplNmtEventResetCom: | ||
593 | case kEplNmtEventInternComError: | ||
594 | { | ||
595 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetCommunication; | ||
596 | // Ret = EplTimerkDeleteTimer(&EPL_MCO_GLB_VAR(m_TimerHdl)); | ||
597 | break; | ||
598 | } | ||
599 | |||
600 | // NMT Command Reset Configuration | ||
601 | case kEplNmtEventResetConfig: | ||
602 | { | ||
603 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetConfiguration; | ||
604 | // Ret = EplTimerkDeleteTimer(&EPL_MCO_GLB_VAR(m_TimerHdl)); | ||
605 | break; | ||
606 | } | ||
607 | |||
608 | // see if SoA or SoC received | ||
609 | // k.t. 20.07.2006: only SoA forces change of state | ||
610 | // see EPL V2 DS 1.0.0 p.267 | ||
611 | // case kEplNmtEventDllCeSoc: | ||
612 | case kEplNmtEventDllCeSoa: | ||
613 | { // new state PRE_OPERATIONAL1 | ||
614 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsPreOperational1; | ||
615 | // Ret = EplTimerkDeleteTimer(&EPL_MCO_GLB_VAR(m_TimerHdl)); | ||
616 | break; | ||
617 | } | ||
618 | // timeout for SoA and Soc | ||
619 | case kEplNmtEventTimerBasicEthernet: | ||
620 | { | ||
621 | // new state BASIC_ETHERNET | ||
622 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsBasicEthernet; | ||
623 | break; | ||
624 | } | ||
625 | |||
626 | default: | ||
627 | { | ||
628 | break; | ||
629 | } | ||
630 | }// end of switch(NmtEvent) | ||
631 | |||
632 | break; | ||
633 | } | ||
634 | |||
635 | // node processes only async frames | ||
636 | case kEplNmtCsPreOperational1: | ||
637 | { | ||
638 | |||
639 | // check events | ||
640 | switch(NmtEvent) | ||
641 | { | ||
642 | // NMT Command SwitchOff | ||
643 | case kEplNmtEventCriticalError: | ||
644 | case kEplNmtEventSwitchOff: | ||
645 | { | ||
646 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsOff; | ||
647 | break; | ||
648 | } | ||
649 | |||
650 | // NMT Command SwReset | ||
651 | case kEplNmtEventSwReset: | ||
652 | { | ||
653 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsInitialising; | ||
654 | break; | ||
655 | } | ||
656 | |||
657 | // NMT Command ResetNode | ||
658 | case kEplNmtEventResetNode: | ||
659 | { | ||
660 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetApplication; | ||
661 | break; | ||
662 | } | ||
663 | |||
664 | // NMT Command ResetCommunication | ||
665 | // or internal Communication error | ||
666 | case kEplNmtEventResetCom: | ||
667 | case kEplNmtEventInternComError: | ||
668 | { | ||
669 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetCommunication; | ||
670 | break; | ||
671 | } | ||
672 | |||
673 | // NMT Command Reset Configuration | ||
674 | case kEplNmtEventResetConfig: | ||
675 | { | ||
676 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetConfiguration; | ||
677 | break; | ||
678 | } | ||
679 | |||
680 | // NMT Command StopNode | ||
681 | case kEplNmtEventStopNode: | ||
682 | { | ||
683 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsStopped; | ||
684 | break; | ||
685 | } | ||
686 | |||
687 | // check if SoC received | ||
688 | case kEplNmtEventDllCeSoc: | ||
689 | { | ||
690 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsPreOperational2; | ||
691 | break; | ||
692 | } | ||
693 | |||
694 | default: | ||
695 | { | ||
696 | break; | ||
697 | } | ||
698 | |||
699 | }// end of switch(NmtEvent) | ||
700 | |||
701 | break; | ||
702 | } | ||
703 | |||
704 | // node processes isochronous and asynchronous frames | ||
705 | case kEplNmtCsPreOperational2: | ||
706 | { | ||
707 | // check events | ||
708 | switch(NmtEvent) | ||
709 | { | ||
710 | // NMT Command SwitchOff | ||
711 | case kEplNmtEventCriticalError: | ||
712 | case kEplNmtEventSwitchOff: | ||
713 | { | ||
714 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsOff; | ||
715 | break; | ||
716 | } | ||
717 | |||
718 | // NMT Command SwReset | ||
719 | case kEplNmtEventSwReset: | ||
720 | { | ||
721 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsInitialising; | ||
722 | break; | ||
723 | } | ||
724 | |||
725 | // NMT Command ResetNode | ||
726 | case kEplNmtEventResetNode: | ||
727 | { | ||
728 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetApplication; | ||
729 | break; | ||
730 | } | ||
731 | |||
732 | // NMT Command ResetCommunication | ||
733 | // or internal Communication error | ||
734 | case kEplNmtEventResetCom: | ||
735 | case kEplNmtEventInternComError: | ||
736 | { | ||
737 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetCommunication; | ||
738 | break; | ||
739 | } | ||
740 | |||
741 | // NMT Command Reset Configuration | ||
742 | case kEplNmtEventResetConfig: | ||
743 | { | ||
744 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetConfiguration; | ||
745 | break; | ||
746 | } | ||
747 | |||
748 | // NMT Command StopNode | ||
749 | case kEplNmtEventStopNode: | ||
750 | { | ||
751 | // reset flags | ||
752 | EPL_MCO_GLB_VAR(m_fEnableReadyToOperate) = FALSE; | ||
753 | EPL_MCO_GLB_VAR(m_fAppReadyToOperate) = FALSE; | ||
754 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsStopped; | ||
755 | break; | ||
756 | } | ||
757 | |||
758 | // error occured | ||
759 | case kEplNmtEventNmtCycleError: | ||
760 | { | ||
761 | // reset flags | ||
762 | EPL_MCO_GLB_VAR(m_fEnableReadyToOperate) = FALSE; | ||
763 | EPL_MCO_GLB_VAR(m_fAppReadyToOperate) = FALSE; | ||
764 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsPreOperational1; | ||
765 | break; | ||
766 | } | ||
767 | |||
768 | // check if application is ready to operate | ||
769 | case kEplNmtEventEnterReadyToOperate: | ||
770 | { | ||
771 | // check if command NMTEnableReadyToOperate from MN was received | ||
772 | if(EPL_MCO_GLB_VAR(m_fEnableReadyToOperate) == TRUE) | ||
773 | { // reset flags | ||
774 | EPL_MCO_GLB_VAR(m_fEnableReadyToOperate) = FALSE; | ||
775 | EPL_MCO_GLB_VAR(m_fAppReadyToOperate) = FALSE; | ||
776 | // change state | ||
777 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsReadyToOperate; | ||
778 | } | ||
779 | else | ||
780 | { // set Flag | ||
781 | EPL_MCO_GLB_VAR(m_fAppReadyToOperate) = TRUE; | ||
782 | } | ||
783 | break; | ||
784 | } | ||
785 | |||
786 | // NMT Commando EnableReadyToOperate | ||
787 | case kEplNmtEventEnableReadyToOperate: | ||
788 | { | ||
789 | // check if application is ready | ||
790 | if(EPL_MCO_GLB_VAR(m_fAppReadyToOperate) == TRUE) | ||
791 | { // reset flags | ||
792 | EPL_MCO_GLB_VAR(m_fEnableReadyToOperate) = FALSE; | ||
793 | EPL_MCO_GLB_VAR(m_fAppReadyToOperate) = FALSE; | ||
794 | // change state | ||
795 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsReadyToOperate; | ||
796 | } | ||
797 | else | ||
798 | { // set Flag | ||
799 | EPL_MCO_GLB_VAR(m_fEnableReadyToOperate) = TRUE; | ||
800 | } | ||
801 | break; | ||
802 | } | ||
803 | |||
804 | default: | ||
805 | { | ||
806 | break; | ||
807 | } | ||
808 | |||
809 | }// end of switch(NmtEvent) | ||
810 | break; | ||
811 | } | ||
812 | |||
813 | // node should be configured und application is ready | ||
814 | case kEplNmtCsReadyToOperate: | ||
815 | { | ||
816 | // check events | ||
817 | switch(NmtEvent) | ||
818 | { | ||
819 | // NMT Command SwitchOff | ||
820 | case kEplNmtEventCriticalError: | ||
821 | case kEplNmtEventSwitchOff: | ||
822 | { | ||
823 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsOff; | ||
824 | break; | ||
825 | } | ||
826 | |||
827 | // NMT Command SwReset | ||
828 | case kEplNmtEventSwReset: | ||
829 | { | ||
830 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsInitialising; | ||
831 | break; | ||
832 | } | ||
833 | |||
834 | // NMT Command ResetNode | ||
835 | case kEplNmtEventResetNode: | ||
836 | { | ||
837 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetApplication; | ||
838 | break; | ||
839 | } | ||
840 | |||
841 | // NMT Command ResetCommunication | ||
842 | // or internal Communication error | ||
843 | case kEplNmtEventResetCom: | ||
844 | case kEplNmtEventInternComError: | ||
845 | { | ||
846 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetCommunication; | ||
847 | break; | ||
848 | } | ||
849 | |||
850 | // NMT Command ResetConfiguration | ||
851 | case kEplNmtEventResetConfig: | ||
852 | { | ||
853 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetConfiguration; | ||
854 | break; | ||
855 | } | ||
856 | |||
857 | // NMT Command StopNode | ||
858 | case kEplNmtEventStopNode: | ||
859 | { | ||
860 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsStopped; | ||
861 | break; | ||
862 | } | ||
863 | |||
864 | // error occured | ||
865 | case kEplNmtEventNmtCycleError: | ||
866 | { | ||
867 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsPreOperational1; | ||
868 | break; | ||
869 | } | ||
870 | |||
871 | // NMT Command StartNode | ||
872 | case kEplNmtEventStartNode: | ||
873 | { | ||
874 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsOperational; | ||
875 | break; | ||
876 | } | ||
877 | |||
878 | default: | ||
879 | { | ||
880 | break; | ||
881 | } | ||
882 | |||
883 | }// end of switch(NmtEvent) | ||
884 | break; | ||
885 | } | ||
886 | |||
887 | // normal work state | ||
888 | case kEplNmtCsOperational: | ||
889 | { | ||
890 | |||
891 | // check events | ||
892 | switch(NmtEvent) | ||
893 | { | ||
894 | // NMT Command SwitchOff | ||
895 | case kEplNmtEventCriticalError: | ||
896 | case kEplNmtEventSwitchOff: | ||
897 | { | ||
898 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsOff; | ||
899 | break; | ||
900 | } | ||
901 | |||
902 | // NMT Command SwReset | ||
903 | case kEplNmtEventSwReset: | ||
904 | { | ||
905 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsInitialising; | ||
906 | break; | ||
907 | } | ||
908 | |||
909 | // NMT Command ResetNode | ||
910 | case kEplNmtEventResetNode: | ||
911 | { | ||
912 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetApplication; | ||
913 | break; | ||
914 | } | ||
915 | |||
916 | // NMT Command ResetCommunication | ||
917 | // or internal Communication error | ||
918 | case kEplNmtEventResetCom: | ||
919 | case kEplNmtEventInternComError: | ||
920 | { | ||
921 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetCommunication; | ||
922 | break; | ||
923 | } | ||
924 | |||
925 | // NMT Command ResetConfiguration | ||
926 | case kEplNmtEventResetConfig: | ||
927 | { | ||
928 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetConfiguration; | ||
929 | break; | ||
930 | } | ||
931 | |||
932 | // NMT Command StopNode | ||
933 | case kEplNmtEventStopNode: | ||
934 | { | ||
935 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsStopped; | ||
936 | break; | ||
937 | } | ||
938 | |||
939 | // NMT Command EnterPreOperational2 | ||
940 | case kEplNmtEventEnterPreOperational2: | ||
941 | { | ||
942 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsPreOperational2; | ||
943 | break; | ||
944 | } | ||
945 | |||
946 | // error occured | ||
947 | case kEplNmtEventNmtCycleError: | ||
948 | { | ||
949 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsPreOperational1; | ||
950 | break; | ||
951 | } | ||
952 | |||
953 | default: | ||
954 | { | ||
955 | break; | ||
956 | } | ||
957 | |||
958 | }// end of switch(NmtEvent) | ||
959 | break; | ||
960 | } | ||
961 | |||
962 | // node stopped by MN | ||
963 | // -> only process asynchronous frames | ||
964 | case kEplNmtCsStopped: | ||
965 | { | ||
966 | // check events | ||
967 | switch(NmtEvent) | ||
968 | { | ||
969 | // NMT Command SwitchOff | ||
970 | case kEplNmtEventCriticalError: | ||
971 | case kEplNmtEventSwitchOff: | ||
972 | { | ||
973 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsOff; | ||
974 | break; | ||
975 | } | ||
976 | |||
977 | // NMT Command SwReset | ||
978 | case kEplNmtEventSwReset: | ||
979 | { | ||
980 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsInitialising; | ||
981 | break; | ||
982 | } | ||
983 | |||
984 | // NMT Command ResetNode | ||
985 | case kEplNmtEventResetNode: | ||
986 | { | ||
987 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetApplication; | ||
988 | break; | ||
989 | } | ||
990 | |||
991 | // NMT Command ResetCommunication | ||
992 | // or internal Communication error | ||
993 | case kEplNmtEventResetCom: | ||
994 | case kEplNmtEventInternComError: | ||
995 | { | ||
996 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetCommunication; | ||
997 | break; | ||
998 | } | ||
999 | |||
1000 | // NMT Command ResetConfiguration | ||
1001 | case kEplNmtEventResetConfig: | ||
1002 | { | ||
1003 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetConfiguration; | ||
1004 | break; | ||
1005 | } | ||
1006 | |||
1007 | // NMT Command EnterPreOperational2 | ||
1008 | case kEplNmtEventEnterPreOperational2: | ||
1009 | { | ||
1010 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsPreOperational2; | ||
1011 | break; | ||
1012 | } | ||
1013 | |||
1014 | // error occured | ||
1015 | case kEplNmtEventNmtCycleError: | ||
1016 | { | ||
1017 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsPreOperational1; | ||
1018 | break; | ||
1019 | } | ||
1020 | |||
1021 | default: | ||
1022 | { | ||
1023 | break; | ||
1024 | } | ||
1025 | |||
1026 | }// end of switch(NmtEvent) | ||
1027 | break; | ||
1028 | } | ||
1029 | |||
1030 | // no epl cycle | ||
1031 | // -> normal ethernet communication | ||
1032 | case kEplNmtCsBasicEthernet: | ||
1033 | { | ||
1034 | // check events | ||
1035 | switch(NmtEvent) | ||
1036 | { | ||
1037 | // NMT Command SwitchOff | ||
1038 | case kEplNmtEventCriticalError: | ||
1039 | case kEplNmtEventSwitchOff: | ||
1040 | { | ||
1041 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsOff; | ||
1042 | break; | ||
1043 | } | ||
1044 | |||
1045 | // NMT Command SwReset | ||
1046 | case kEplNmtEventSwReset: | ||
1047 | { | ||
1048 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsInitialising; | ||
1049 | break; | ||
1050 | } | ||
1051 | |||
1052 | // NMT Command ResetNode | ||
1053 | case kEplNmtEventResetNode: | ||
1054 | { | ||
1055 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetApplication; | ||
1056 | break; | ||
1057 | } | ||
1058 | |||
1059 | // NMT Command ResetCommunication | ||
1060 | // or internal Communication error | ||
1061 | case kEplNmtEventResetCom: | ||
1062 | case kEplNmtEventInternComError: | ||
1063 | { | ||
1064 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetCommunication; | ||
1065 | break; | ||
1066 | } | ||
1067 | |||
1068 | // NMT Command ResetConfiguration | ||
1069 | case kEplNmtEventResetConfig: | ||
1070 | { | ||
1071 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetConfiguration; | ||
1072 | break; | ||
1073 | } | ||
1074 | |||
1075 | // error occured | ||
1076 | // d.k.: how does this error occur? on CRC errors | ||
1077 | /* case kEplNmtEventNmtCycleError: | ||
1078 | { | ||
1079 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsPreOperational1; | ||
1080 | break; | ||
1081 | } | ||
1082 | */ | ||
1083 | case kEplNmtEventDllCeSoc: | ||
1084 | case kEplNmtEventDllCePreq: | ||
1085 | case kEplNmtEventDllCePres: | ||
1086 | case kEplNmtEventDllCeSoa: | ||
1087 | { // Epl-Frame on net -> stop any communication | ||
1088 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsPreOperational1; | ||
1089 | break; | ||
1090 | } | ||
1091 | |||
1092 | default: | ||
1093 | { | ||
1094 | break; | ||
1095 | } | ||
1096 | |||
1097 | }// end of switch(NmtEvent) | ||
1098 | |||
1099 | break; | ||
1100 | } | ||
1101 | |||
1102 | //----------------------------------------------------------- | ||
1103 | // MN part of the statemaschine | ||
1104 | |||
1105 | // MN listen to network | ||
1106 | // -> if no EPL traffic go to next state | ||
1107 | case kEplNmtMsNotActive: | ||
1108 | { | ||
1109 | #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) == 0) | ||
1110 | // no MN functionality | ||
1111 | // TODO: -create error E_NMT_BA1_NO_MN_SUPPORT | ||
1112 | EPL_MCO_GLB_VAR(m_fFrozen) = TRUE; | ||
1113 | #else | ||
1114 | |||
1115 | // check events | ||
1116 | switch(NmtEvent) | ||
1117 | { | ||
1118 | // NMT Command SwitchOff | ||
1119 | case kEplNmtEventCriticalError: | ||
1120 | case kEplNmtEventSwitchOff: | ||
1121 | { | ||
1122 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsOff; | ||
1123 | break; | ||
1124 | } | ||
1125 | |||
1126 | // NMT Command SwReset | ||
1127 | case kEplNmtEventSwReset: | ||
1128 | { | ||
1129 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsInitialising; | ||
1130 | break; | ||
1131 | } | ||
1132 | |||
1133 | // NMT Command ResetNode | ||
1134 | case kEplNmtEventResetNode: | ||
1135 | { | ||
1136 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetApplication; | ||
1137 | break; | ||
1138 | } | ||
1139 | |||
1140 | // NMT Command ResetCommunication | ||
1141 | // or internal Communication error | ||
1142 | case kEplNmtEventResetCom: | ||
1143 | case kEplNmtEventInternComError: | ||
1144 | { | ||
1145 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetCommunication; | ||
1146 | break; | ||
1147 | } | ||
1148 | |||
1149 | // NMT Command ResetConfiguration | ||
1150 | case kEplNmtEventResetConfig: | ||
1151 | { | ||
1152 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetConfiguration; | ||
1153 | break; | ||
1154 | } | ||
1155 | |||
1156 | // EPL frames received | ||
1157 | case kEplNmtEventDllCeSoc: | ||
1158 | case kEplNmtEventDllCeSoa: | ||
1159 | { // other MN in network | ||
1160 | // $$$ d.k.: generate error history entry | ||
1161 | EPL_MCO_GLB_VAR(m_fFrozen) = TRUE; | ||
1162 | break; | ||
1163 | } | ||
1164 | |||
1165 | // timeout event | ||
1166 | case kEplNmtEventTimerBasicEthernet: | ||
1167 | { | ||
1168 | if (EPL_MCO_GLB_VAR(m_fFrozen) == FALSE) | ||
1169 | { // new state BasicEthernet | ||
1170 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtMsBasicEthernet; | ||
1171 | } | ||
1172 | break; | ||
1173 | } | ||
1174 | |||
1175 | // timeout event | ||
1176 | case kEplNmtEventTimerMsPreOp1: | ||
1177 | { | ||
1178 | if (EPL_MCO_GLB_VAR(m_fFrozen) == FALSE) | ||
1179 | { // new state PreOp1 | ||
1180 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtMsPreOperational1; | ||
1181 | EPL_MCO_GLB_VAR(m_fTimerMsPreOp2) = FALSE; | ||
1182 | EPL_MCO_GLB_VAR(m_fAllMandatoryCNIdent) = FALSE; | ||
1183 | |||
1184 | } | ||
1185 | break; | ||
1186 | } | ||
1187 | |||
1188 | default: | ||
1189 | { | ||
1190 | break; | ||
1191 | } | ||
1192 | |||
1193 | }// end of switch(NmtEvent) | ||
1194 | |||
1195 | #endif // ((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) == 0) | ||
1196 | |||
1197 | break; | ||
1198 | } | ||
1199 | #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0) | ||
1200 | // MN process reduces epl cycle | ||
1201 | case kEplNmtMsPreOperational1: | ||
1202 | { | ||
1203 | // check events | ||
1204 | switch(NmtEvent) | ||
1205 | { | ||
1206 | // NMT Command SwitchOff | ||
1207 | case kEplNmtEventCriticalError: | ||
1208 | case kEplNmtEventSwitchOff: | ||
1209 | { | ||
1210 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsOff; | ||
1211 | break; | ||
1212 | } | ||
1213 | |||
1214 | // NMT Command SwReset | ||
1215 | case kEplNmtEventSwReset: | ||
1216 | { | ||
1217 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsInitialising; | ||
1218 | break; | ||
1219 | } | ||
1220 | |||
1221 | // NMT Command ResetNode | ||
1222 | case kEplNmtEventResetNode: | ||
1223 | { | ||
1224 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetApplication; | ||
1225 | break; | ||
1226 | } | ||
1227 | |||
1228 | // NMT Command ResetCommunication | ||
1229 | // or internal Communication error | ||
1230 | case kEplNmtEventResetCom: | ||
1231 | case kEplNmtEventInternComError: | ||
1232 | { | ||
1233 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetCommunication; | ||
1234 | break; | ||
1235 | } | ||
1236 | |||
1237 | // NMT Command ResetConfiguration | ||
1238 | case kEplNmtEventResetConfig: | ||
1239 | { | ||
1240 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetConfiguration; | ||
1241 | break; | ||
1242 | } | ||
1243 | |||
1244 | // EPL frames received | ||
1245 | case kEplNmtEventDllCeSoc: | ||
1246 | case kEplNmtEventDllCeSoa: | ||
1247 | { // other MN in network | ||
1248 | // $$$ d.k.: generate error history entry | ||
1249 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetCommunication; | ||
1250 | break; | ||
1251 | } | ||
1252 | |||
1253 | // error occured | ||
1254 | // d.k. MSPreOp1->CSPreOp1: nonsense -> keep state | ||
1255 | /* | ||
1256 | case kEplNmtEventNmtCycleError: | ||
1257 | { | ||
1258 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsPreOperational1; | ||
1259 | break; | ||
1260 | } | ||
1261 | */ | ||
1262 | |||
1263 | case kEplNmtEventAllMandatoryCNIdent: | ||
1264 | { // all mandatory CN identified | ||
1265 | if (EPL_MCO_GLB_VAR(m_fTimerMsPreOp2) != FALSE) | ||
1266 | { | ||
1267 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtMsPreOperational2; | ||
1268 | } | ||
1269 | else | ||
1270 | { | ||
1271 | EPL_MCO_GLB_VAR(m_fAllMandatoryCNIdent) = TRUE; | ||
1272 | } | ||
1273 | break; | ||
1274 | } | ||
1275 | |||
1276 | case kEplNmtEventTimerMsPreOp2: | ||
1277 | { // residence time for PreOp1 is elapsed | ||
1278 | if (EPL_MCO_GLB_VAR(m_fAllMandatoryCNIdent) != FALSE) | ||
1279 | { | ||
1280 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtMsPreOperational2; | ||
1281 | } | ||
1282 | else | ||
1283 | { | ||
1284 | EPL_MCO_GLB_VAR(m_fTimerMsPreOp2) = TRUE; | ||
1285 | } | ||
1286 | break; | ||
1287 | } | ||
1288 | |||
1289 | default: | ||
1290 | { | ||
1291 | break; | ||
1292 | } | ||
1293 | |||
1294 | }// end of switch(NmtEvent) | ||
1295 | break; | ||
1296 | } | ||
1297 | |||
1298 | // MN process full epl cycle | ||
1299 | case kEplNmtMsPreOperational2: | ||
1300 | { | ||
1301 | // check events | ||
1302 | switch(NmtEvent) | ||
1303 | { | ||
1304 | // NMT Command SwitchOff | ||
1305 | case kEplNmtEventCriticalError: | ||
1306 | case kEplNmtEventSwitchOff: | ||
1307 | { | ||
1308 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsOff; | ||
1309 | break; | ||
1310 | } | ||
1311 | |||
1312 | // NMT Command SwReset | ||
1313 | case kEplNmtEventSwReset: | ||
1314 | { | ||
1315 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsInitialising; | ||
1316 | break; | ||
1317 | } | ||
1318 | |||
1319 | // NMT Command ResetNode | ||
1320 | case kEplNmtEventResetNode: | ||
1321 | { | ||
1322 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetApplication; | ||
1323 | break; | ||
1324 | } | ||
1325 | |||
1326 | // NMT Command ResetCommunication | ||
1327 | // or internal Communication error | ||
1328 | case kEplNmtEventResetCom: | ||
1329 | case kEplNmtEventInternComError: | ||
1330 | { | ||
1331 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetCommunication; | ||
1332 | break; | ||
1333 | } | ||
1334 | |||
1335 | // NMT Command ResetConfiguration | ||
1336 | case kEplNmtEventResetConfig: | ||
1337 | { | ||
1338 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetConfiguration; | ||
1339 | break; | ||
1340 | } | ||
1341 | |||
1342 | // EPL frames received | ||
1343 | case kEplNmtEventDllCeSoc: | ||
1344 | case kEplNmtEventDllCeSoa: | ||
1345 | { // other MN in network | ||
1346 | // $$$ d.k.: generate error history entry | ||
1347 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetCommunication; | ||
1348 | break; | ||
1349 | } | ||
1350 | |||
1351 | // error occured | ||
1352 | case kEplNmtEventNmtCycleError: | ||
1353 | { | ||
1354 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtMsPreOperational1; | ||
1355 | break; | ||
1356 | } | ||
1357 | |||
1358 | case kEplNmtEventEnterReadyToOperate: | ||
1359 | { | ||
1360 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtMsReadyToOperate; | ||
1361 | break; | ||
1362 | } | ||
1363 | |||
1364 | default: | ||
1365 | { | ||
1366 | break; | ||
1367 | } | ||
1368 | |||
1369 | }// end of switch(NmtEvent) | ||
1370 | |||
1371 | break; | ||
1372 | } | ||
1373 | |||
1374 | // all madatory nodes ready to operate | ||
1375 | // -> MN process full epl cycle | ||
1376 | case kEplNmtMsReadyToOperate: | ||
1377 | { | ||
1378 | |||
1379 | // check events | ||
1380 | switch(NmtEvent) | ||
1381 | { | ||
1382 | // NMT Command SwitchOff | ||
1383 | case kEplNmtEventCriticalError: | ||
1384 | case kEplNmtEventSwitchOff: | ||
1385 | { | ||
1386 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsOff; | ||
1387 | break; | ||
1388 | } | ||
1389 | |||
1390 | // NMT Command SwReset | ||
1391 | case kEplNmtEventSwReset: | ||
1392 | { | ||
1393 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsInitialising; | ||
1394 | break; | ||
1395 | } | ||
1396 | |||
1397 | // NMT Command ResetNode | ||
1398 | case kEplNmtEventResetNode: | ||
1399 | { | ||
1400 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetApplication; | ||
1401 | break; | ||
1402 | } | ||
1403 | |||
1404 | // NMT Command ResetCommunication | ||
1405 | // or internal Communication error | ||
1406 | case kEplNmtEventResetCom: | ||
1407 | case kEplNmtEventInternComError: | ||
1408 | { | ||
1409 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetCommunication; | ||
1410 | break; | ||
1411 | } | ||
1412 | |||
1413 | // NMT Command ResetConfiguration | ||
1414 | case kEplNmtEventResetConfig: | ||
1415 | { | ||
1416 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetConfiguration; | ||
1417 | break; | ||
1418 | } | ||
1419 | |||
1420 | // EPL frames received | ||
1421 | case kEplNmtEventDllCeSoc: | ||
1422 | case kEplNmtEventDllCeSoa: | ||
1423 | { // other MN in network | ||
1424 | // $$$ d.k.: generate error history entry | ||
1425 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetCommunication; | ||
1426 | break; | ||
1427 | } | ||
1428 | |||
1429 | // error occured | ||
1430 | case kEplNmtEventNmtCycleError: | ||
1431 | { | ||
1432 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtMsPreOperational1; | ||
1433 | break; | ||
1434 | } | ||
1435 | |||
1436 | case kEplNmtEventEnterMsOperational: | ||
1437 | { | ||
1438 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtMsOperational; | ||
1439 | break; | ||
1440 | } | ||
1441 | |||
1442 | default: | ||
1443 | { | ||
1444 | break; | ||
1445 | } | ||
1446 | |||
1447 | }// end of switch(NmtEvent) | ||
1448 | |||
1449 | break; | ||
1450 | } | ||
1451 | |||
1452 | // normal eplcycle processing | ||
1453 | case kEplNmtMsOperational: | ||
1454 | { | ||
1455 | // check events | ||
1456 | switch(NmtEvent) | ||
1457 | { | ||
1458 | // NMT Command SwitchOff | ||
1459 | case kEplNmtEventCriticalError: | ||
1460 | case kEplNmtEventSwitchOff: | ||
1461 | { | ||
1462 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsOff; | ||
1463 | break; | ||
1464 | } | ||
1465 | |||
1466 | // NMT Command SwReset | ||
1467 | case kEplNmtEventSwReset: | ||
1468 | { | ||
1469 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsInitialising; | ||
1470 | break; | ||
1471 | } | ||
1472 | |||
1473 | // NMT Command ResetNode | ||
1474 | case kEplNmtEventResetNode: | ||
1475 | { | ||
1476 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetApplication; | ||
1477 | break; | ||
1478 | } | ||
1479 | |||
1480 | // NMT Command ResetCommunication | ||
1481 | // or internal Communication error | ||
1482 | case kEplNmtEventResetCom: | ||
1483 | case kEplNmtEventInternComError: | ||
1484 | { | ||
1485 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetCommunication; | ||
1486 | break; | ||
1487 | } | ||
1488 | |||
1489 | // NMT Command ResetConfiguration | ||
1490 | case kEplNmtEventResetConfig: | ||
1491 | { | ||
1492 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetConfiguration; | ||
1493 | break; | ||
1494 | } | ||
1495 | |||
1496 | // EPL frames received | ||
1497 | case kEplNmtEventDllCeSoc: | ||
1498 | case kEplNmtEventDllCeSoa: | ||
1499 | { // other MN in network | ||
1500 | // $$$ d.k.: generate error history entry | ||
1501 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetCommunication; | ||
1502 | break; | ||
1503 | } | ||
1504 | |||
1505 | // error occured | ||
1506 | case kEplNmtEventNmtCycleError: | ||
1507 | { | ||
1508 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtMsPreOperational1; | ||
1509 | break; | ||
1510 | } | ||
1511 | |||
1512 | default: | ||
1513 | { | ||
1514 | break; | ||
1515 | } | ||
1516 | |||
1517 | }// end of switch(NmtEvent) | ||
1518 | break; | ||
1519 | } | ||
1520 | |||
1521 | // normal ethernet traffic | ||
1522 | case kEplNmtMsBasicEthernet: | ||
1523 | { | ||
1524 | |||
1525 | // check events | ||
1526 | switch(NmtEvent) | ||
1527 | { | ||
1528 | // NMT Command SwitchOff | ||
1529 | case kEplNmtEventCriticalError: | ||
1530 | case kEplNmtEventSwitchOff: | ||
1531 | { | ||
1532 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsOff; | ||
1533 | break; | ||
1534 | } | ||
1535 | |||
1536 | // NMT Command SwReset | ||
1537 | case kEplNmtEventSwReset: | ||
1538 | { | ||
1539 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsInitialising; | ||
1540 | break; | ||
1541 | } | ||
1542 | |||
1543 | // NMT Command ResetNode | ||
1544 | case kEplNmtEventResetNode: | ||
1545 | { | ||
1546 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetApplication; | ||
1547 | break; | ||
1548 | } | ||
1549 | |||
1550 | // NMT Command ResetCommunication | ||
1551 | // or internal Communication error | ||
1552 | case kEplNmtEventResetCom: | ||
1553 | case kEplNmtEventInternComError: | ||
1554 | { | ||
1555 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetCommunication; | ||
1556 | break; | ||
1557 | } | ||
1558 | |||
1559 | // NMT Command ResetConfiguration | ||
1560 | case kEplNmtEventResetConfig: | ||
1561 | { | ||
1562 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetConfiguration; | ||
1563 | break; | ||
1564 | } | ||
1565 | |||
1566 | // EPL frames received | ||
1567 | case kEplNmtEventDllCeSoc: | ||
1568 | case kEplNmtEventDllCeSoa: | ||
1569 | { // other MN in network | ||
1570 | // $$$ d.k.: generate error history entry | ||
1571 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetCommunication; | ||
1572 | break; | ||
1573 | } | ||
1574 | |||
1575 | // error occured | ||
1576 | // d.k. BE->PreOp1 on cycle error? No | ||
1577 | /* case kEplNmtEventNmtCycleError: | ||
1578 | { | ||
1579 | EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsPreOperational1; | ||
1580 | break; | ||
1581 | } | ||
1582 | */ | ||
1583 | default: | ||
1584 | { | ||
1585 | break; | ||
1586 | } | ||
1587 | |||
1588 | }// end of switch(NmtEvent) | ||
1589 | break; | ||
1590 | } | ||
1591 | #endif //#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0) | ||
1592 | |||
1593 | default: | ||
1594 | { | ||
1595 | //DEBUG_EPL_DBGLVL_NMTK_TRACE0(EPL_DBGLVL_NMT ,"Error in EplNmtProcess: Unknown NMT-State"); | ||
1596 | //EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetApplication; | ||
1597 | Ret = kEplNmtInvalidState; | ||
1598 | goto Exit; | ||
1599 | } | ||
1600 | |||
1601 | }// end of switch(NmtEvent) | ||
1602 | |||
1603 | // inform higher layer about State-Change if needed | ||
1604 | if(OldNmtState != EPL_MCO_GLB_VAR(m_NmtState)) | ||
1605 | { | ||
1606 | EPL_NMTK_DBG_POST_TRACE_VALUE(NmtEvent, OldNmtState, EPL_MCO_GLB_VAR(m_NmtState)); | ||
1607 | |||
1608 | // d.k.: memorize NMT state before posting any events | ||
1609 | NmtStateChange.m_NewNmtState = EPL_MCO_GLB_VAR(m_NmtState); | ||
1610 | |||
1611 | // inform DLL | ||
1612 | if ((OldNmtState > kEplNmtGsResetConfiguration) | ||
1613 | && (EPL_MCO_GLB_VAR(m_NmtState) <= kEplNmtGsResetConfiguration)) | ||
1614 | { | ||
1615 | // send DLL DEINIT | ||
1616 | Event.m_EventSink = kEplEventSinkDllk; | ||
1617 | Event.m_EventType = kEplEventTypeDllkDestroy; | ||
1618 | EPL_MEMSET(&Event.m_NetTime, 0x00, sizeof(Event.m_NetTime)); | ||
1619 | Event.m_pArg = &OldNmtState; | ||
1620 | Event.m_uiSize = sizeof (OldNmtState); | ||
1621 | // d.k.: directly call DLLk process function, because | ||
1622 | // 1. execution of process function is still synchonized and serialized, | ||
1623 | // 2. it is the same as without event queues (i.e. well tested), | ||
1624 | // 3. DLLk will get those necessary events even if event queue is full, | ||
1625 | // 4. event queue is very inefficient | ||
1626 | #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0) | ||
1627 | Ret = EplDllkProcess(&Event); | ||
1628 | #else | ||
1629 | Ret = EplEventkPost(&Event); | ||
1630 | #endif | ||
1631 | } | ||
1632 | else if ((OldNmtState <= kEplNmtGsResetConfiguration) | ||
1633 | && (EPL_MCO_GLB_VAR(m_NmtState) > kEplNmtGsResetConfiguration)) | ||
1634 | { | ||
1635 | // send DLL INIT | ||
1636 | Event.m_EventSink = kEplEventSinkDllk; | ||
1637 | Event.m_EventType = kEplEventTypeDllkCreate; | ||
1638 | EPL_MEMSET(&Event.m_NetTime, 0x00, sizeof(Event.m_NetTime)); | ||
1639 | Event.m_pArg = &NmtStateChange.m_NewNmtState; | ||
1640 | Event.m_uiSize = sizeof (NmtStateChange.m_NewNmtState); | ||
1641 | // d.k.: directly call DLLk process function, because | ||
1642 | // 1. execution of process function is still synchonized and serialized, | ||
1643 | // 2. it is the same as without event queues (i.e. well tested), | ||
1644 | // 3. DLLk will get those necessary events even if event queue is full | ||
1645 | // 4. event queue is very inefficient | ||
1646 | #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0) | ||
1647 | Ret = EplDllkProcess(&Event); | ||
1648 | #else | ||
1649 | Ret = EplEventkPost(&Event); | ||
1650 | #endif | ||
1651 | } | ||
1652 | else if ((EPL_MCO_GLB_VAR(m_NmtState) == kEplNmtCsBasicEthernet) | ||
1653 | || (EPL_MCO_GLB_VAR(m_NmtState) == kEplNmtMsBasicEthernet)) | ||
1654 | { | ||
1655 | tEplDllAsyncReqPriority AsyncReqPriority; | ||
1656 | |||
1657 | // send DLL Fill Async Tx Buffer, because state BasicEthernet was entered | ||
1658 | Event.m_EventSink = kEplEventSinkDllk; | ||
1659 | Event.m_EventType = kEplEventTypeDllkFillTx; | ||
1660 | EPL_MEMSET(&Event.m_NetTime, 0x00, sizeof(Event.m_NetTime)); | ||
1661 | AsyncReqPriority = kEplDllAsyncReqPrioGeneric; | ||
1662 | Event.m_pArg = &AsyncReqPriority; | ||
1663 | Event.m_uiSize = sizeof (AsyncReqPriority); | ||
1664 | // d.k.: directly call DLLk process function, because | ||
1665 | // 1. execution of process function is still synchonized and serialized, | ||
1666 | // 2. it is the same as without event queues (i.e. well tested), | ||
1667 | // 3. DLLk will get those necessary events even if event queue is full | ||
1668 | // 4. event queue is very inefficient | ||
1669 | #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0) | ||
1670 | Ret = EplDllkProcess(&Event); | ||
1671 | #else | ||
1672 | Ret = EplEventkPost(&Event); | ||
1673 | #endif | ||
1674 | } | ||
1675 | |||
1676 | // inform higher layer about state change | ||
1677 | NmtStateChange.m_NmtEvent = NmtEvent; | ||
1678 | Event.m_EventSink = kEplEventSinkNmtu; | ||
1679 | Event.m_EventType = kEplEventTypeNmtStateChange; | ||
1680 | EPL_MEMSET(&Event.m_NetTime, 0x00, sizeof(Event.m_NetTime)); | ||
1681 | Event.m_pArg = &NmtStateChange; | ||
1682 | Event.m_uiSize = sizeof(NmtStateChange); | ||
1683 | Ret = EplEventkPost(&Event); | ||
1684 | EPL_DBGLVL_NMTK_TRACE2("EplNmtkProcess(NMT-Event = 0x%04X): New NMT-State = 0x%03X\n", NmtEvent, NmtStateChange.m_NewNmtState); | ||
1685 | |||
1686 | |||
1687 | } | ||
1688 | |||
1689 | Exit: | ||
1690 | |||
1691 | return Ret; | ||
1692 | } | ||
1693 | |||
1694 | //--------------------------------------------------------------------------- | ||
1695 | // | ||
1696 | // Function: EplNmtkGetNmtState | ||
1697 | // | ||
1698 | // Description: return the actuell NMT-State and the bits | ||
1699 | // to for MN- or CN-mode | ||
1700 | // | ||
1701 | // | ||
1702 | // | ||
1703 | // Parameters: EPL_MCO_DECL_PTR_INSTANCE_PTR_ = Instancepointer | ||
1704 | // | ||
1705 | // | ||
1706 | // Returns: tEplNmtState = NMT-State | ||
1707 | // | ||
1708 | // | ||
1709 | // State: | ||
1710 | // | ||
1711 | //--------------------------------------------------------------------------- | ||
1712 | EPLDLLEXPORT tEplNmtState PUBLIC EplNmtkGetNmtState(EPL_MCO_DECL_PTR_INSTANCE_PTR) | ||
1713 | { | ||
1714 | tEplNmtState NmtState; | ||
1715 | |||
1716 | NmtState = EPL_MCO_GLB_VAR(m_NmtState); | ||
1717 | |||
1718 | return NmtState; | ||
1719 | |||
1720 | } | ||
1721 | |||
1722 | //=========================================================================// | ||
1723 | // // | ||
1724 | // P R I V A T E D E F I N I T I O N S // | ||
1725 | // // | ||
1726 | //=========================================================================// | ||
1727 | EPL_MCO_DECL_INSTANCE_FCT () | ||
1728 | //--------------------------------------------------------------------------- | ||
1729 | // | ||
1730 | // Function: | ||
1731 | // | ||
1732 | // Description: | ||
1733 | // | ||
1734 | // | ||
1735 | // | ||
1736 | // Parameters: | ||
1737 | // | ||
1738 | // | ||
1739 | // Returns: | ||
1740 | // | ||
1741 | // | ||
1742 | // State: | ||
1743 | // | ||
1744 | //--------------------------------------------------------------------------- | ||
1745 | |||
1746 | |||
1747 | #endif // #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTK)) != 0) | ||
1748 | |||
1749 | // EOF | ||
1750 | |||