CORDET Framework - C2 Implementation
CrPsServiceTestCases.c
Go to the documentation of this file.
1 
20 /* Include FW Profile files */
21 #include "FwSmConstants.h"
22 #include "FwSmConfig.h"
23 #include "FwSmCore.h"
24 #include "FwPrConfig.h"
25 #include "FwPrCore.h"
26 #include "FwPrConstants.h"
27 #include "FwPrDCreate.h"
28 /* Include framework files */
29 #include "CrFwCmpData.h"
31 #include "BaseCmp/CrFwBaseCmp.h"
32 #include "Pckt/CrFwPckt.h"
33 #include "InCmd/CrFwInCmd.h"
36 #include "InLoader/CrFwInLoader.h"
38 #include "InLoader/CrFwInLoader.h"
39 #include "CrFwTime.h"
40 
41 #include "CrFwRepErr.h"
51 #include <CrPsUtilitiesServTest.h>
53 #include "config/CrFwOutFactoryUserPar.h"
54 
55 /* Include system files */
56 #include <stdlib.h>
57 #include <unistd.h>
58 #include <stdint.h>
59 
60 /* ---------------------------------------------------------------------------------------------*/
62 {
63  /* Check 17,1 and 17,2 */
64  FwSmDesc_t inFactory, outFactory, outManager, inCmd, outCmp, outCmpArr[CR_FW_OUTFACTORY_MAX_NOF_OUTCMP];
65  CrFwPckt_t pckt;
67  CrFwOutManagerData_t* outManagerCSData;
68  uint16_t i;
69 
70  /* run all getters for the procedure descriptors*/
74 
75  /* Instantiate the OutFactory, InFactory and OutManager*/
76  outFactory = CrFwOutFactoryMake();
77  if (outFactory == NULL)
78  return 0;
79  if (FwSmCheckRec(outFactory) != smSuccess)
80  return 0;
81 
82  inFactory = CrFwInFactoryMake();
83  if (inFactory == NULL)
84  return 0;
85  if (FwSmCheckRec(inFactory) != smSuccess)
86  return 0;
87 
88  outManager = CrFwOutManagerMake(0);
89  if (outManager == NULL)
90  return 0;
91  if (FwSmCheckRec(outManager) != smSuccess)
92  return 0;
93 
94  /* Initialize and Configure OutFactory and check success */
95  CrFwCmpInit(outFactory);
96  CrFwCmpReset(outFactory);
97  if (!CrFwCmpIsInConfigured(outFactory))
98  return 0;
99 
100  /* Initialize and Configure InFactory and check success */
101  CrFwCmpInit(inFactory);
102  CrFwCmpReset(inFactory);
103  if (!CrFwCmpIsInConfigured(inFactory))
104  return 0;
105 
106  /* Initialize and Configure OutManager and check success */
107  CrFwCmpInit(outManager);
108  CrFwCmpReset(outManager);
109  if (!CrFwCmpIsInConfigured(outManager))
110  return 0;
111 
112  /* Check if number of Allocated Packets = 0*/
113  if (CrFwPcktGetNOfAllocated() != 0)
114  return 0;
115 
116  /* Allocate a 17,1 Packet */
117  pckt = CrFwPcktMake(20);
118  CrFwPcktSetServType(pckt,17);
119  CrFwPcktSetServSubType(pckt,1);
121  CrFwPcktSetDiscriminant(pckt,0);
122  CrFwPcktSetSrc(pckt,0);
123  CrFwPcktSetDest(pckt,10);
124  CrFwPcktSetGroup(pckt,1);
125  CrFwPcktSetAckLevel(pckt,0,0,0,0);
126  CrFwPcktSetSeqCnt(pckt,2);
127 
128  /* Check if number of Allocated Packets now is 1*/
129  if (CrFwPcktGetNOfAllocated() != 1)
130  return 0;
131 
132  /* Check if number of Allocated InCommands = 0*/
134  return 0;
135 
136  /*Creating an InCommand out of the 17,1 packet*/
137  inCmd = CrFwInFactoryMakeInCmd(pckt);
138 
139  /*Check if number of Allocated InCommands is now 1*/
141  return 0;
142 
143  /* Check the type identifier */
145  return 0;
146 
147  /* Check type and sub-type of the InCommand*/
148  if (CrFwInCmdGetServType(inCmd) != 17)
149  return 0;
150  if (CrFwInCmdGetServSubType(inCmd) != 1)
151  return 0;
152 
153  /*check that the InCommand is in ACCEPTED state*/
154  if (!CrFwInCmdIsInAccepted(inCmd))
155  return 0;
156 
157  /* Check if number of Allocated OutComponents = 0*/
159  return 0;
160 
161  /* Execute the InCommand */
162  CrFwCmpExecute(inCmd);
163 
164  /*check that the InCommand is in PROGRESS state*/
165  if (!CrFwInCmdIsInProgress(inCmd))
166  return 0;
167 
168  /* Check if number of Allocated Packets now is 2*/
169  if (CrFwPcktGetNOfAllocated() != 2)
170  return 0;
171 
172  /* Check if number of Allocated OutComponents now is 1 */
174  return 0;
175 
176  /*Get the Data from the out Manager (there is only one Component)*/
177  outManagerData = (CrFwCmpData_t*)FwSmGetData(outManager);
178  outManagerCSData = (CrFwOutManagerData_t*)outManagerData->cmpSpecificData;
179  outCmp = outManagerCSData->pocl[0];
180 
181  /*Check if there is a 17,2 Report waitig in the OutManager*/
182  if (CrFwCmpGetTypeId(outCmp) != CR_FW_OUTCMP_TYPE)
183  return 0;
184  if (CrFwOutCmpGetServType(outCmp) != 17)
185  return 0;
186  if (CrFwOutCmpGetServSubType(outCmp) != 2)
187  return 0;
188 
189  /*Terminate the InCommand*/
190  CrFwInCmdTerminate(inCmd);
191 
192  /*Check if the InCommand is in TERMINATED state*/
193  if (!CrFwInCmdIsInTerminated(inCmd))
194  return 0;
195 
196  /*Release the InCommand */
198 
199  /* Check if number of Allocated Packets now is 1*/
200  if (CrFwPcktGetNOfAllocated() != 1)
201  return 0;
202 
203  /*Check if number of Allocated InCommands is now 0*/
205  return 0;
206 
207  /* Execute the OutComponent (17,2) */
208  CrFwCmpExecute(outCmp);
209 
210  /*Release the OutComponent*/
212 
213  /* Check if number of Allocated OutComponents now is 0 */
215  return 0;
216 
217  /* Check that there are no allocated packets */
218  if (CrFwPcktGetNOfAllocated() != 0)
219  return 0;
220 
221  /* Allocate a 17,1 Packet */
222  pckt = CrFwPcktMake(20);
223  CrFwPcktSetServType(pckt,17);
224  CrFwPcktSetServSubType(pckt,1);
226  CrFwPcktSetDiscriminant(pckt,0);
227  CrFwPcktSetSrc(pckt,0);
228  CrFwPcktSetDest(pckt,10);
229  CrFwPcktSetGroup(pckt,1);
230  CrFwPcktSetAckLevel(pckt,1,1,1,1);
231  CrFwPcktSetSeqCnt(pckt,2);
232 
233  /*Creating an InCommand out of the 17,1 packet*/
234  inCmd = CrFwInFactoryMakeInCmd(pckt);
235 
236  /*Check if number of Allocated InCommands is now 1*/
238  return 0;
239 
240  /* Fill the outfactory so that an Error could occur (leave one free slot) */
241  for (i=0;i<=CR_FW_OUTFACTORY_MAX_NOF_OUTCMP-1;i++)
242  {
243  outCmpArr[i] = CrFwOutFactoryMakeOutCmp(17,2,0,0);
244  }
245 
246  /* Execute the InCommand */
247  CrFwCmpExecute(inCmd);
248 
249  /* Check application errors */
251  return 0;
252 
253  /*Reset application error Code*/
255 
256  /* Release all outcomponents, that have been created to fill the outfactory */
257  for (i=0;i<=CR_FW_OUTFACTORY_MAX_NOF_OUTCMP-1;i++)
258  {
259  CrFwOutFactoryReleaseOutCmp(outCmpArr[i]);
260  }
261 
262  /*Release the InCommand */
264 
265  /* Reset OutManager and check that all OutComponents are unloaded and released */
266  CrFwCmpReset(outManager);
267  if (CrFwOutManagerGetNOfPendingOutCmp(outManager) != 0)
268  return 0;
269 
270  /*Here the ErrorCode gets 11, because there are no outcomponents in the OutManager*/
272 
273  /* Reset the OutFactory */
274  CrFwCmpReset(outFactory);
276  return 0;
277 
278  /* Reset the InFactory and check that no InCommands are allocated */
279  CrFwCmpReset(inFactory);
281  return 0;
282 
283  /* Check application errors */
284  if (CrFwGetAppErrCode() != crNoAppErr)
285  return 0;
286 
287  return 1;
288 }
289 
290 /*--------------------------------------------------------------------------------*/
292 {
293  /* Check 17,3 and 17,4 */
294  FwSmDesc_t inFactory, inManager, outFactory, outManager, inCmd, outCmp, outCmp1, inRep1;
295  CrFwPckt_t pckt, pckt2;
297  CrFwOutManagerData_t* outManagerCSData;
298  CrPsApid_t appId;
299  appId = 60;
300 
301  /* Instantiate all relevant CORDET Framework PUS Extension components, e.g. all the procedures and state machines */
304  /*Initialize Applications */
305  CrPsInitServTestApp(appId);
306  CrPsInitServTestApp(200);
307 
308  /* Instantiate the OutFactory, InFactory, OutManager and inManager */
309  outFactory = CrFwOutFactoryMake();
310  if (outFactory == NULL)
311  return 0;
312  if (FwSmCheckRec(outFactory) != smSuccess)
313  return 0;
314 
315  inFactory = CrFwInFactoryMake();
316  if (inFactory == NULL)
317  return 0;
318  if (FwSmCheckRec(inFactory) != smSuccess)
319  return 0;
320 
321  outManager = CrFwOutManagerMake(0);
322  if (outManager == NULL)
323  return 0;
324  if (FwSmCheckRec(outManager) != smSuccess)
325  return 0;
326 
327  inManager = CrFwInManagerMake(0);
328  if (inManager == NULL)
329  return 0;
330  if (FwSmCheckRec(inManager) != smSuccess)
331  return 0;
332 
333  /* Initialize and Configure OutFactory and check success */
334  CrFwCmpInit(outFactory);
335  CrFwCmpReset(outFactory);
336  if (!CrFwCmpIsInConfigured(outFactory))
337  return 0;
338 
339  /* Initialize and Configure InFactory and check success */
340  CrFwCmpInit(inFactory);
341  CrFwCmpReset(inFactory);
342  if (!CrFwCmpIsInConfigured(inFactory))
343  return 0;
344 
345  /* Initialize and Configure OutManager and check success */
346  CrFwCmpInit(outManager);
347  CrFwCmpReset(outManager);
348  if (!CrFwCmpIsInConfigured(outManager))
349  return 0;
350 
351  /* Initialize and Configure InManager and check success */
352  CrFwCmpInit(inManager);
353  CrFwCmpReset(inManager);
354  if (!CrFwCmpIsInConfigured(inManager))
355  return 0;
356 
357  /* Check if number of Allocated Packets = 0*/
358  if (CrFwPcktGetNOfAllocated() != 0)
359  return 0;
360 
361  /* Allocate a 17,3 Packet with a wrong AppId*/
362  pckt = CrFwPcktMake(20);
363  CrFwPcktSetServType(pckt,17);
364  CrFwPcktSetServSubType(pckt,3);
365  CrFwPcktSetDiscriminant(pckt,0);
367  CrFwPcktSetSrc(pckt,3);
368  CrFwPcktSetDest(pckt,3);
369  CrFwPcktSetGroup(pckt,1);
370  CrFwPcktSetAckLevel(pckt,0,0,0,0);
371  CrFwPcktSetSeqCnt(pckt,2);
372 
373  /*give the Packet a wrong appId so the process fails*/
374  appId = 88;
375  setOnBoardConnectCmdAppId(pckt, appId);
376  appId = 60;
377 
378  /* Check if number of Allocated Packets now is 1*/
379  if (CrFwPcktGetNOfAllocated() != 1)
380  return 0;
381 
382  /* Check if number of Allocated InCommands = 0*/
384  return 0;
385 
386  /*Creating an InCommand out of the 17,3 packet*/
387  inCmd = CrFwInFactoryMakeInCmd(pckt);
388 
389  /*Check if number of Allocated InCommands is now 1*/
391  return 0;
392 
393  /* Check the type identifier */
395  return 0;
396 
397  /* Check type and sub-type of the InCommand*/
398  if (CrFwInCmdGetServType(inCmd) != 17)
399  return 0;
400  if (CrFwInCmdGetServSubType(inCmd) != 3)
401  return 0;
402 
403  /*check that the InCommand is in ACCEPTED state*/
404  if (!CrFwInCmdIsInAccepted(inCmd))
405  return 0;
406 
407  /* Check if number of Allocated OutComponents = 0*/
409  return 0;
410 
411  /* Execute the InCommand */
412  /* The inCommand has no Parameter for the Destination set so it should abort!*/
413  CrFwCmpExecute(inCmd);
414 
415  /*Check that the InCommand is in the State ABORTED*/
416  if (!CrFwInCmdIsInAborted(inCmd))
417  return 0;
418 
419  /* Release the inCommand*/
421 
422  /* Check if number of Allocated Packets now is 1 - a Request Verification (1,4) should be in the Outmanager */
423  if (CrFwPcktGetNOfAllocated() != 1)
424  return 0;
425 
426  /* Check that there is one Packet Pending in the OutManager - Request Verification (1,4) */
427  if (CrFwOutManagerGetNOfPendingOutCmp(outManager) != 1)
428  return 0;
429 
430  /* Check if number of loaded OutComponents in the OutManager is 1 - Request Verification (1,4)*/
431  if (CrFwOutManagerGetNOfLoadedOutCmp(outManager) != 1)
432  return 0;
433 
434  /* Get the Data from the out Manager (there is only one Component) */
435  outManagerData = (CrFwCmpData_t*)FwSmGetData(outManager);
436  outManagerCSData = (CrFwOutManagerData_t*)outManagerData->cmpSpecificData;
437  outCmp = outManagerCSData->pocl[0];
438 
439  /* Check if there is a 1,4 Command waitig in the OutManager (loaded) */
440  if (CrFwCmpGetTypeId(outCmp) != CR_FW_OUTCMP_TYPE)
441  return 0;
442  if (CrFwOutCmpGetServType(outCmp) != 1)
443  return 0;
444  if (CrFwOutCmpGetServSubType(outCmp) != 4)
445  return 0;
446 
447  /*Release the OutComponent*/
449 
450  /* Reset the OutManager (this should clear the POCL and release all OutComponents) */
451  CrFwCmpReset(outManager);
452 
453  /* Check and reset application error code */
455  return 0;
457  if (!CrFwCmpIsInConfigured(outManager))
458  return 0;
459  if (CrFwOutManagerGetNOfPendingOutCmp(outManager) != 0)
460  return 0;
461  if (CrFwOutManagerGetNOfLoadedOutCmp(outManager) != 0)
462  return 0;
463 
464  /* Check if number of Allocated OutComponents now is 0 */
466  return 0;
467 
468  /* Check if number of Allocated Packets now is 0 */
469  if (CrFwPcktGetNOfAllocated() != 0)
470  return 0;
471 
472  /* Allocate a 17,3 Packet */
473  pckt = CrFwPcktMake(20);
474  CrFwPcktSetServType(pckt,17);
475  CrFwPcktSetServSubType(pckt,3);
476  CrFwPcktSetDiscriminant(pckt,0);
478  CrFwPcktSetSrc(pckt,0);
479  CrFwPcktSetDest(pckt,10);
480  CrFwPcktSetGroup(pckt,1);
481  CrFwPcktSetAckLevel(pckt,0,0,0,0);
482  CrFwPcktSetSeqCnt(pckt,2);
483 
484  /*give the Packet a correct appId so the process should success*/
485  setOnBoardConnectCmdAppId(pckt, appId);
486 
487  /* Check if number of Allocated Packets now is 1*/
488  if (CrFwPcktGetNOfAllocated() != 1)
489  return 0;
490 
491  /* Check if number of Allocated InCommands = 0*/
493  return 0;
494 
495  /*Creating an InCommand out of the 17,3 packet*/
496  inCmd = CrFwInFactoryMakeInCmd(pckt);
497 
498  /* Check if number of Allocated InCommands now in the InFactory is 1*/
500  return 0;
501 
502  /* Check the type identifier */
504  return 0;
505 
506  /* Check type and sub-type of the InCommand*/
507  if (CrFwInCmdGetServType(inCmd) != 17)
508  return 0;
509  if (CrFwInCmdGetServSubType(inCmd) != 3)
510  return 0;
511 
512  /*check that the InCommand is in ACCEPTED state*/
513  if (!CrFwInCmdIsInAccepted(inCmd))
514  return 0;
515 
516  /* Check if number of Allocated OutComponents = 0*/
518  return 0;
519 
520  /* Execute the InCommand */
521  /* The inCommand has now a correct Parameter for the Destination */
522  CrFwCmpExecute(inCmd);
523 
524  /* Check if now 3 Packets are Allocated
525  * one InCommand we just created and executed
526  * one InCommand (17,1) to the application that was specified in the parameter of the 17,3 packet
527  * and a Packet holding the 17,4 Report is allocated (outManager Pending)
528  */
529  if (CrFwPcktGetNOfAllocated() != 3)
530  return 0;
531 
532  /* Check if number of Allocated InCommands in the InFactory stays at 1 */
534  return 0;
535 
536  /* Check if number of loaded OutComponents in the OutManager is 1 */
537  if (CrFwOutManagerGetNOfLoadedOutCmp(outManager) != 1)
538  return 0;
539 
540  /* Get the Data from the out Manager (there is only one Component) */
541  outManagerData = (CrFwCmpData_t*)FwSmGetData(outManager);
542  outManagerCSData = (CrFwOutManagerData_t*)outManagerData->cmpSpecificData;
543  outCmp = outManagerCSData->pocl[0];
544 
545  /* Check if there is a 17,1 Command waitig in the OutManager (loaded) */
546  if (CrFwCmpGetTypeId(outCmp) != CR_FW_OUTCMP_TYPE)
547  return 0;
548  if (CrFwOutCmpGetServType(outCmp) != 17)
549  return 0;
550  if (CrFwOutCmpGetServSubType(outCmp) != 1)
551  return 0;
552 
553  /* Check that there is one Packet Pending in the OutManager */
554  if (CrFwOutManagerGetNOfPendingOutCmp(outManager) != 1)
555  return 0;
556 
557  /* allocate an 17,2 in Report */
558  pckt2 = CrFwPcktMake(20);
559  CrFwPcktSetServType(pckt2,17);
560  CrFwPcktSetServSubType(pckt2,2);
561  CrFwPcktSetDiscriminant(pckt2,0);
562  CrFwPcktSetDest(pckt2,10);
563  CrFwPcktSetSrc(pckt2,appId);
564 
565  /* Check if number of Allocated Packets now is 4*/
566  if (CrFwPcktGetNOfAllocated() != 4)
567  return 0;
568 
569  /* Check that there are no InReports in the InFactory*/
571  return 0;
572 
573  /*Create an InReport from pckt2 (17.2)*/
574  inRep1 = CrFwInFactoryMakeInRep(pckt2);
575 
576  /* Check if number of Allocated InReports in the InFactory now is 1*/
578  return 0;
579 
580  /* Check that there are no Packets Pending or Loaded in the InManager*/
581  if (CrFwInManagerGetNOfPendingInCmp(inManager) != 0)
582  return 0;
583  if (CrFwInManagerGetNOfLoadedInCmp(inManager) != 0)
584  return 0;
585 
586  /*Load the InReport into the InManager*/
587  CrFwInManagerLoad(inManager, inRep1);
588 
589  /* Check is now one Pending (inCmd)(17,3) and one Loaded (inRep)(17,2) Packets in the InManager*/
590  if (CrFwInManagerGetNOfPendingInCmp(inManager) != 1)
591  return 0;
592  if (CrFwInManagerGetNOfLoadedInCmp(inManager) != 1)
593  return 0;
594 
595  /*Execute the InManager*/
596  CrFwCmpExecute(inManager);
597 
598  /* Check that there is now no Pending but one Loaded (inCmd)(17,3) Packets in the InManager*/
599  if (CrFwInManagerGetNOfPendingInCmp(inManager) != 0)
600  return 0;
601  if (CrFwInManagerGetNOfLoadedInCmp(inManager) != 1)
602  return 0;
603 
604  /* Check that there is one Pending and one Loaded Packet in the OutManager */
605  if (CrFwOutManagerGetNOfPendingOutCmp(outManager) != 1)
606  return 0;
607  if (CrFwOutManagerGetNOfLoadedOutCmp(outManager) != 1)
608  return 0;
609 
610  /*Execute the InCommand*/
611  CrFwCmpExecute(inCmd);
612 
613  /* 17,4 now in the OutManager*/
614  /* Check that there are now two Pending and two Loaded Packets in the OutManager */
615  if (CrFwOutManagerGetNOfPendingOutCmp(outManager) != 2)
616  return 0;
617  if (CrFwOutManagerGetNOfLoadedOutCmp(outManager) != 2)
618  return 0;
619 
620  /*Terminate the InCommand*/
621  CrFwInCmdTerminate(inCmd);
622 
623  /* Get the Information from the OutManager (there are two Component!) */
624  outManagerData = (CrFwCmpData_t*)FwSmGetData(outManager);
625  outManagerCSData = (CrFwOutManagerData_t*)outManagerData->cmpSpecificData;
626  outCmp = outManagerCSData->pocl[0];
627  outCmp1 = outManagerCSData->pocl[1];
628 
629  /*Check if there is a 17,1 Command waitig in the OutManager (loaded)*/
630  if (CrFwOutManagerGetNOfLoadedOutCmp(outManager) != 2)
631  return 0;
632  if (CrFwCmpGetTypeId(outCmp) != CR_FW_OUTCMP_TYPE)
633  return 0;
634  if (CrFwOutCmpGetServType(outCmp) != 17)
635  return 0;
636  if (CrFwOutCmpGetServSubType(outCmp) != 1)
637  return 0;
638 
639  /* Execute the OutComponent (17,1) */
640  CrFwCmpExecute(outCmp);
641 
642  /* Check and reset application error code (i think because there is no outstream defined) */
644 
645  /* Check if there is a 17,4 Command waitig in the OutManager (loaded)*/
646  if (CrFwOutManagerGetNOfLoadedOutCmp(outManager) != 2)
647  return 0;
648  if (CrFwCmpGetTypeId(outCmp1) != CR_FW_OUTCMP_TYPE)
649  return 0;
650  if (CrFwOutCmpGetServType(outCmp1) != 17)
651  return 0;
652  if (CrFwOutCmpGetServSubType(outCmp1) != 4)
653  return 0;
654 
655  /* Execute the OutComponent (17,4) */
656  CrFwCmpExecute(outCmp1);
657 
658  /* Check that there are 3 allocated packets */
659  if (CrFwPcktGetNOfAllocated() != 3)
660  return 0;
661 
662  /* Release the (17,3) InCommand*/
664 
665  /* Check that now there are only 2 allocated packets */
666  if (CrFwPcktGetNOfAllocated() != 2)
667  return 0;
668 
669  /* Check that there are no Allocated InCommands in the InFactory*/
671  return 0;
672 
673  /* Release the (17,2) InReport*/
676 
677  /* Check that now there are only 2 allocated packets */
678  if (CrFwPcktGetNOfAllocated() != 2)
679  return 0;
680 
681  /* Release the (17,1) Outcomponent*/
683 
684  /* Check that now there is only 1 allocated packet */
685  if (CrFwPcktGetNOfAllocated() != 1)
686  return 0;
687 
688  /* Release the (17,4) OutComponent*/
690 
691  /* Check that there are no allocated packets */
692  if (CrFwPcktGetNOfAllocated() != 0)
693  return 0;
694 
695  /* Check application errors */
696  if (CrFwGetAppErrCode() != crNoAppErr)
697  return 0;
698 
699  /* Reset OutManager and check that all OutComponents are unloaded and released */
700  CrFwCmpReset(outManager);
701  if (CrFwOutManagerGetNOfPendingOutCmp(outManager) != 0)
702  return 0;
703 
705 
706  /* Reset InManager and check that all InComponents are unloaded and released */
707  CrFwCmpReset(inManager);
708  if (CrFwOutManagerGetNOfPendingOutCmp(inManager) != 0)
709  return 0;
710 
711  /* Reset the OutFactory and check that no OutComponents are allocated */
712  CrFwCmpReset(outFactory);
714  return 0;
715 
716  /* Reset the InFactory and check that no InCommands are allocated */
717  CrFwCmpReset(inFactory);
719  return 0;
720 
721  /* Check application errors */
722  if (CrFwGetAppErrCode() != crNoAppErr)
723  return 0;
724 
725  return 1;
726 }
727 
728 /*--------------------------------------------------------------------------------*/
730 {
731  /* Service 17 exceptional cases */
732  FwSmDesc_t inFactory, inManager, outFactory, outManager, inCmd, outCmp1, outCmp[CR_FW_OUTFACTORY_MAX_NOF_OUTCMP];
733  FwPrDesc_t prDesc;
734  CrFwPckt_t pckt;
736  CrFwOutManagerData_t* outManagerCSData;
737  CrPsApid_t appId;
738  unsigned short timeout;
739  CrFwCounterU4_t i;
740 
741  appId=60;
742  prDesc = NULL;
743 
744  /*Initialize Applications Applications (10 are Available) */
745  /*To test the whole Code i will try to initialize 11 Aplications*/
746  CrPsInitServTestApp(201);
747  CrPsInitServTestApp(202);
748  CrPsInitServTestApp(203);
749  CrPsInitServTestApp(204);
750  CrPsInitServTestApp(205);
751  CrPsInitServTestApp(206);
752  CrPsInitServTestApp(207);
753  CrPsInitServTestApp(208);
754  CrPsInitServTestApp(209);
755 
756  /* Instantiate the OutFactory, InFactory, OutManager and inManager */
757  outFactory = CrFwOutFactoryMake();
758  if (outFactory == NULL)
759  return 0;
760  if (FwSmCheckRec(outFactory) != smSuccess)
761  return 0;
762 
763  inFactory = CrFwInFactoryMake();
764  if (inFactory == NULL)
765  return 0;
766  if (FwSmCheckRec(inFactory) != smSuccess)
767  return 0;
768 
769  outManager = CrFwOutManagerMake(0);
770  if (outManager == NULL)
771  return 0;
772  if (FwSmCheckRec(outManager) != smSuccess)
773  return 0;
774 
775  inManager = CrFwInManagerMake(0);
776  if (inManager == NULL)
777  return 0;
778  if (FwSmCheckRec(inManager) != smSuccess)
779  return 0;
780 
781  /* Initialize and Configure OutFactory and check success */
782  CrFwCmpInit(outFactory);
783  CrFwCmpReset(outFactory);
784  if (!CrFwCmpIsInConfigured(outFactory))
785  return 0;
786 
787  /* Initialize and Configure InFactory and check success */
788  CrFwCmpInit(inFactory);
789  CrFwCmpReset(inFactory);
790  if (!CrFwCmpIsInConfigured(inFactory))
791  return 0;
792 
793  /* Initialize and Configure OutManager and check success */
794  CrFwCmpInit(outManager);
795  CrFwCmpReset(outManager);
796  if (!CrFwCmpIsInConfigured(outManager))
797  return 0;
798 
799  /* Initialize and Configure InManager and check success */
800  CrFwCmpInit(inManager);
801  CrFwCmpReset(inManager);
802  if (!CrFwCmpIsInConfigured(inManager))
803  return 0;
804 
805  /* Check if number of Allocated Packets = 0*/
806  if (CrFwPcktGetNOfAllocated() != 0)
807  return 0;
808 
809  /* Allocate a 17,3 Packet */
810  pckt = CrFwPcktMake(20);
811  CrFwPcktSetServType(pckt,17);
812  CrFwPcktSetServSubType(pckt,3);
813  CrFwPcktSetDiscriminant(pckt,0);
815  CrFwPcktSetSrc(pckt,1);
816  CrFwPcktSetDest(pckt,10);
817  CrFwPcktSetGroup(pckt,1);
818  CrFwPcktSetAckLevel(pckt,0,0,0,0);
819  CrFwPcktSetSeqCnt(pckt,2);
820  setOnBoardConnectCmdAppId(pckt, appId);
821 
822  /* make an inCommand out of the packet */
823  inCmd = CrFwInFactoryMakeInCmd(pckt);
824 
825  /* Check if number of Allocated InCommands now in the InFactory is 1*/
827  return 0;
828 
829  /* Check if number of Allocated Packets now is 1*/
830  if (CrFwPcktGetNOfAllocated() != 1)
831  return 0;
832 
833  /* Check type and sub-type of the InCommand*/
834  if (CrFwInCmdGetServType(inCmd) != 17)
835  return 0;
836  if (CrFwInCmdGetServSubType(inCmd) != 3)
837  return 0;
838 
839  /*check that the InCommand is in ACCEPTED state*/
840  if (!CrFwInCmdIsInAccepted(inCmd))
841  return 0;
842 
843  /* Fill the outfactory so that an Error could occur (leave one free slot) */
844  for (i=0;i<=CR_FW_OUTFACTORY_MAX_NOF_OUTCMP-2;i++)
845  {
846  outCmp[i] = CrFwOutFactoryMakeOutCmp(17,2,0,0);
847  }
848 
849  /* Execute the InCommand */
850  /* If the OutFactory is full it should fail !!!*/
851  CrFwCmpExecute(inCmd);
852 
853  /* Release all outcomponents, that have been created to fill the outfactory */
854  for (i=0;i<=CR_FW_OUTFACTORY_MAX_NOF_OUTCMP-2;i++)
855  {
856  CrFwOutFactoryReleaseOutCmp(outCmp[i]);
857  }
858 
859  /* Here the ErrorCode gets 10*/
861 
862  /* Release the original inCmd */
864 
865  /* Get the Information from the OutManager (there are two Component!) */
866  outManagerData = (CrFwCmpData_t*)FwSmGetData(outManager);
867  outManagerCSData = (CrFwOutManagerData_t*)outManagerData->cmpSpecificData;
868  outCmp1 = outManagerCSData->pocl[0];
869 
870  /* Check if there is a 1,4 Command waitig in the OutManager */
871  if (CrFwCmpGetTypeId(outCmp1) != CR_FW_OUTCMP_TYPE)
872  return 0;
873  if (CrFwOutCmpGetServType(outCmp1) != 1)
874  return 0;
875  if (CrFwOutCmpGetServSubType(outCmp1) != 4)
876  return 0;
877 
878  /*Release the (1,4) Outcomponent*/
880 
881  /* Reset OutManager and check that all OutComponents are unloaded and released */
882  CrFwCmpReset(outManager);
883  if (CrFwOutManagerGetNOfPendingOutCmp(outManager) != 0)
884  return 0;
885 
886  /* Check if number of Allocated Packets now is 0*/
887  if (CrFwPcktGetNOfAllocated() != 0)
888  return 0;
889 
890  /* Allocating a 17,3 Packet */
891  pckt = CrFwPcktMake(20);
892  CrFwPcktSetServType(pckt,17);
893  CrFwPcktSetServSubType(pckt,3);
894  CrFwPcktSetDiscriminant(pckt,0);
896  CrFwPcktSetSrc(pckt,1);
897  CrFwPcktSetDest(pckt,10);
898  CrFwPcktSetGroup(pckt,1);
899  CrFwPcktSetAckLevel(pckt,0,0,0,0);
900  CrFwPcktSetSeqCnt(pckt,2);
901 
902  setOnBoardConnectCmdAppId(pckt, appId);
903  inCmd = CrFwInFactoryMakeInCmd(pckt);
904 
905  /* Fill the outfactory so that an Error could occur */
906  for (i=0;i<=CR_FW_OUTFACTORY_MAX_NOF_OUTCMP-1;i++)
907  {
908  outCmp[i] = CrFwOutFactoryMakeOutCmp(17,2,0,0);
909  }
910 
911  /* Execute the InCommand */
912  /* If the OutFactory is full it should fail, there is also no place for a 1,4 to be generated !!!*/
913  CrFwCmpExecute(inCmd);
914 
915  /* Release all outcomponents, that have been created to fill the outfactory */
916  for (i=0;i<=CR_FW_OUTFACTORY_MAX_NOF_OUTCMP-1;i++)
917  {
918  CrFwOutFactoryReleaseOutCmp(outCmp[i]);
919  }
920 
921  /*Here the ErrorCode gets 10*/
923 
924  /* Release the original inCmd */
926 
927  /* Check if number of Allocated Packets now is 0*/
928  if (CrFwPcktGetNOfAllocated() != 0)
929  return 0;
930 
931  /* Allocating a 17,3 Packet */
932  pckt = CrFwPcktMake(20);
933  CrFwPcktSetServType(pckt,17);
934  CrFwPcktSetServSubType(pckt,3);
936  CrFwPcktSetSrc(pckt,1);
937  CrFwPcktSetDest(pckt,10);
938  CrFwPcktSetAckLevel(pckt,0,0,0,0);
939  setOnBoardConnectCmdAppId(pckt, appId);
940 
941  /* make an inCommand out of the packet */
942  inCmd = CrFwInFactoryMakeInCmd(pckt);
943 
944  /* Execute the InCommand */
945  CrFwCmpExecute(inCmd);
946 
947  /*Check if now 3 Packets are Allocated
948  * one InCommand we just created and executed)
949  * one InCommand (17.1) to the application that was specified in the parameter of the 17.3 packet
950  * and a Packet holding the 17.4 Report is allocated (outManagerPending)
951  */
952  if (CrFwPcktGetNOfAllocated() != 3)
953  return 0;
954 
955  /* Check if number of Allocated InCommands in the InFactory stays at 1*/
957  return 0;
958 
959  /*Trigger a Timeout by executing the incommand as often as the value in the datapool specifies*/
960  for (i=1;i<=getDpAreYouAliveTimeOut();i++)
961  {
962  CrFwCmpExecute(inCmd);
963  }
964 
965  /* for coverace call - CrPsTestOnBoardConnectionTerminationAction so the else will be executed*/
967 
968  /* for coverage call - CrPsTestOnBoardConnectionStartN3 */
970 
971  /* Set the Timeout Variable in the Datapool to 100 to trigger an error */
972  timeout = getDpAreYouAliveTimeOut();
974 
975  /* for coverage call - CrPsTestOnBoardConnectionPrgrG13 */
976  if(CrPsTestOnBoardConnectionPrgrG13(prDesc) == 1)
977  return 0;
978 
979  setDpAreYouAliveTimeOut(timeout);
980 
981  FwPrExecute(getPrDescServTestOnBoardConnStart());
982 
983  /* call the N10 release function for coverage (an error 11 is created) */
985 
986  /* Release the original inCmd */
988 
989  /* Reset OutManager and check that all OutComponents are unloaded and released */
990  CrFwCmpReset(outManager);
991  if (CrFwOutManagerGetNOfPendingOutCmp(outManager) != 0)
992  return 0;
993 
995 
996  /* Reset InManager and check that all InComponents are unloaded and released */
997  CrFwCmpReset(inManager);
998  if (CrFwOutManagerGetNOfPendingOutCmp(inManager) != 0)
999  return 0;
1000 
1001  /* Reset the OutFactory */
1002  CrFwCmpReset(outFactory);
1004  return 0;
1005 
1006  /* Reset the InFactory and check that no InCommands are allocated */
1007  CrFwCmpReset(inFactory);
1009  return 0;
1010 
1011  /* Here the ErrorCode gets 6*/
1013 
1014  /* Check application errors */
1015  if (CrFwGetAppErrCode() != crNoAppErr)
1016  return 0;
1017 
1018  return 1;
1019 }
1020 
1021 
Declaration of the Perform Connection Test in-coming command packet.
void CrPsTestOnBoardConnectionStartN10(FwPrDesc_t prDesc)
Action for node N10.
Type for the Framework Component Data (FCD).
Interface through which framework components access the current time.
static void setOnBoardConnectCmdAppId(void *p, CrPsApid_t AppId)
Set "AppId" in "OnBoardConnectCmd" packet.
Definition of the InLoader component.
CrFwCounterU4_t i
CrPsCmd5EidStart function definitions.
#define CR_FW_OUTCMP_TYPE
Type identifier for the OutComponent components.
CrFwTypeId_t CrFwCmpGetTypeId(FwSmDesc_t smDesc)
Return the type identifier of the argument component.
Definition: CrFwBaseCmp.c:156
void CrFwCmpInit(FwSmDesc_t smDesc)
Initialize a framework component.
Definition: CrFwBaseCmp.c:112
CrFwBool_t CrPsServTestConnTestCase2()
Test the Service 17 On-Board Connection Test.
void CrFwPcktSetServType(CrFwPckt_t pckt, CrFwServType_t servType)
Set the service type of the command or report encapsulated in a packet.
static FwSmDesc_t outCmp[CR_FW_OUTFACTORY_MAX_NOF_OUTCMP]
The pre-allocated OutComponent instances.
CrFwBool_t CrFwCmpIsInConfigured(FwSmDesc_t smDesc)
Return true if the argument component is in state CONFIGURED.
Definition: CrFwBaseCmp.c:177
void CrFwSetAppErrCode(CrFwAppErrCode_t errCode)
Set the value of the application error code (see CrFwGetAppErrCode).
CrFwBool_t CrFwInCmdIsInAborted(FwSmDesc_t smDesc)
Return true if the argument InCommand is in state ABORTED.
Definition: CrFwInCmd.c:179
static FwSmDesc_t inFactory
The singleton instance of the InFactory.
void CrFwPcktSetSrc(CrFwPckt_t pckt, CrFwDestSrc_t src)
Set the source of the command or report encapsulated in a packet.
CrFwBool_t CrFwInCmdIsInProgress(FwSmDesc_t smDesc)
Return true if the argument InCommand is in state PROGRESS.
Definition: CrFwInCmd.c:169
#define CR_FW_OUTFACTORY_MAX_NOF_OUTCMP
The maximum number of OutComponents which may be allocated at any one time.
Interface for accessing data pool items.
Definition of the OutFactory component.
An OutComponent allocation request has failed (see CrFwOutFactoryMakeOutCmp).
Create one instance of the CrPsCmd17s3Prgr procedure.
CrFwPckt_t CrFwPcktMake(CrFwPcktLength_t pcktLength)
Make function for command or report packets.
FwPrDesc_t getPrDescServTestOnBoardConnStart()
Getter for TestOnBoardConnStart procedure descriptor.
static CrFwCmpData_t outManagerData[CR_FW_NOF_OUTMANAGER]
The data structures for the OutManager State Machines and their Procedures.
FwSmDesc_t CrFwOutManagerMake(CrFwInstanceId_t i)
Factory function to retrieve the i-th OutManager State Machine instance.
Interface for creating and accessing a report or command packet.
uint16_t CrPsApid_t
Type used for the Application ID of a packet.
int CrFwBool_t
Type used for boolean values (1 represent "true" and 0 represents "false").
Definition: CrFwConstants.h:30
CrFwServType_t CrFwOutCmpGetServType(FwSmDesc_t smDesc)
Return the type of the OutComponent.
Definition: CrFwOutCmp.c:230
void CrPsTestOnBoardConnectionTerminationAction(FwSmDesc_t smDesc)
Termination Action of the Perform Connection Test in-coming command packet.
An OutComponent release request has encountered an error (see CrFwOutFactoryReleaseOutCmp).
Definition of the OutRegistry Component.
void CrFwPcktSetCmdRepType(CrFwPckt_t pckt, CrFwCmdRepType_t type)
Set the type of a packet (either a command packet or a report packet).
Declaration of the Perform Connection Test in-coming command packet.
Interface for accessing fields in packets of service "ServTest".
void CrFwPcktSetSeqCnt(CrFwPckt_t pckt, CrFwSeqCnt_t seqCnt)
Set the sequence counter of the command or report encapsulated in a packet.
Create one instance of the CrPsCmd17s3Start procedure.
Command type.
Definition: CrFwConstants.h:41
CrFwServType_t CrFwInCmdGetServSubType(FwSmDesc_t smDesc)
Return the sub-type of the InCommand.
Definition: CrFwInCmd.c:344
void CrPsInitServTestApp(unsigned short onBoardTestConnectAppId)
Initialization of CORDET Framework PUS Extension application-specific components. ...
CrFwCounterU2_t CrFwOutManagerGetNOfLoadedOutCmp(FwSmDesc_t smDesc)
Return the number of OutComponents successfully loaded in the POCL of an OutManager since the OutMana...
static FwSmDesc_t outFactory
The singleton instance of the OutFactory.
CrFwBool_t CrPsServTestConnTestCase1()
Test the Service 17 Are-You-Alive Test Connection.
CrFwBool_t CrFwInCmdIsInAccepted(FwSmDesc_t smDesc)
Return true if the argument InCommand is in state ACCEPTED.
Definition: CrFwInCmd.c:164
Interface for reporting an error detected by a framework component.
void CrFwPcktSetGroup(CrFwPckt_t pckt, CrFwGroup_t group)
Set the group of the command/report encapsulated in a packet.
CrFwServType_t CrFwOutCmpGetServSubType(FwSmDesc_t smDesc)
Return the sub-type of the OutComponent.
Definition: CrFwOutCmp.c:244
void CrPsExecServTest()
Execution of CORDET Framework PUS Extension components.
FwSmDesc_t CrFwInManagerMake(CrFwInstanceId_t i)
Factory function to retrieve the i-th InManager State Machine instance.
Definition: CrFwInManager.c:96
void CrPsTestOnBoardConnectionStartN3(FwPrDesc_t prDesc)
Action for node N3.
void * cmpSpecificData
Derived data which are specific to each type of framework component.
void CrFwPcktSetAckLevel(CrFwPckt_t pckt, CrFwBool_t accept, CrFwBool_t start, CrFwBool_t progress, CrFwBool_t term)
Set the acknowledge level for the command encapsulated in a packet.
Definition of the InFactory component.
#define CR_FW_INCOMMAND_TYPE
Type identifier for the InCommand component.
Interface through which applications can initialize and execute framework PUS extension components...
Definition of the utility functions for the CORDET Framework.
CrFwBool_t CrPsServTestConnTestCase3()
Test the Service 17 exceptional cases.
void CrFwPcktSetServSubType(CrFwPckt_t pckt, CrFwServSubType_t servSubType)
Set the service sub-type of the command or report encapsulated in a packet.
Declaration of the Are-You-Alive Test in-coming report packet.
CrFwBool_t CrFwInCmdIsInTerminated(FwSmDesc_t smDesc)
Return true if the argument InCommand is in state TERMINATED.
Definition: CrFwInCmd.c:174
CrFwBool_t CrFwInManagerLoad(FwSmDesc_t smDesc, FwSmDesc_t inCmp)
Load a new InReport or InCommand into the InManager.
void CrFwCmpReset(FwSmDesc_t smDesc)
Reset a framework component.
Definition: CrFwBaseCmp.c:117
FwSmDesc_t * pocl
Pending OutComponent List (POCL) for the OutManager.
static void setDpAreYouAliveTimeOut(CrPsTimeOut_t AreYouAliveTimeOut)
Sets the value of the datapool item AreYouAliveTimeOut.
CrFwCounterU2_t CrFwPcktGetNOfAllocated()
Return the number of packets which are currently allocated.
void CrFwInCmdTerminate(FwSmDesc_t smDesc)
Send command Terminate to the argument InCommand.
Definition: CrFwInCmd.c:159
void CrFwCmpExecute(FwSmDesc_t smDesc)
Execute a framework component.
Definition: CrFwBaseCmp.c:127
void CrFwInFactoryReleaseInRep(FwSmDesc_t inRepInstance)
Release function for an InReport.
CrFwOutFactoryPoolIndex_t CrFwOutFactoryGetNOfAllocatedOutCmp()
Return the number of OutComponents which are currently allocated.
void CrFwPcktSetDest(CrFwPckt_t pckt, CrFwDestSrc_t dest)
Set the destination of the command or report encapsulated in a packet.
Definition of Base Component.
FwSmDesc_t CrFwInFactoryMake()
Factory function for the singleton instance of the InFactory.
int CrPsInitServTest()
Initialization of CORDET Framework PUS Extension components.
void CrFwOutFactoryReleaseOutCmp(FwSmDesc_t outCmpInstance)
Release function for an OutComponent.
void CrFwInFactoryReleaseInCmd(FwSmDesc_t inCmdInstance)
Release function for an InCommand.
char * CrFwPckt_t
Type for packets (see CrFwPckt.h).
Definition: CrFwConstants.h:36
FwSmDesc_t CrFwOutFactoryMake()
Factory function for the singleton instance of the OutFactory.
FwSmDesc_t CrFwInFactoryMakeInRep(CrFwPckt_t pckt)
Make function for a component encapsulating an incoming report (InReport).
CrFwCounterU2_t CrFwInManagerGetNOfLoadedInCmp(FwSmDesc_t smDesc)
Return the number of InReport or InCommands successfully loaded since the InManager was last reset...
Interface through which applications can initialize and execute framework PUS extension components...
int CrPsInitServReqVerif()
Initialization of CORDET Framework PUS Extension components.
static CrPsTimeOut_t getDpAreYouAliveTimeOut()
Gets the value of the datapool item AreYouAliveTimeOut.
CrFwCounterU1_t CrFwOutManagerGetNOfPendingOutCmp(FwSmDesc_t smDesc)
Return the number of OutComponents currently in the POCL of an OutManager.
CrFwInFactoryPoolIndex_t CrFwInFactoryGetNOfAllocatedInCmd()
Return the number of InCommands which are currently allocated.
No application errors have been detected.
static FwSmDesc_t inCmd[CR_FW_INFACTORY_MAX_NOF_INCMD]
The pre-allocated InCommand instances.
Definition: CrFwInFactory.c:58
CrFwInFactoryPoolIndex_t CrFwInFactoryGetNOfAllocatedInRep()
Return the number of InReports which are currently allocated.
CrFwServType_t CrFwInCmdGetServType(FwSmDesc_t smDesc)
Return the type of the InCommand.
Definition: CrFwInCmd.c:337
Definition of the OutLoader component.
FwSmDesc_t CrFwOutFactoryMakeOutCmp(CrFwServType_t type, CrFwServSubType_t subType, CrFwDiscriminant_t discriminant, CrFwPcktLength_t length)
Make function for an OutComponent.
FwSmDesc_t CrFwInFactoryMakeInCmd(CrFwPckt_t pckt)
Make function for a component encapsulating an incoming command (InCommand).
Declaration of the Perform Connection Test in-coming command packet.
CrFwAppErrCode_t CrFwGetAppErrCode()
Return the value of the application error code.
void CrFwPcktSetDiscriminant(CrFwPckt_t pckt, CrFwDiscriminant_t discriminant)
Set the discriminant of the command or report encapsulated in a packet.
CrFwCounterU1_t CrFwInManagerGetNOfPendingInCmp(FwSmDesc_t smDesc)
Return the number of InReport or InCommands currently in the PCRL of an InManager.
Definition of the InCommand Component of the framework.
Type for the data describing an OutManager.
FwPrBool_t CrPsTestOnBoardConnectionPrgrG13(FwPrDesc_t prDesc)
Guard on the Control Flow from DECISION1 to N3.
P&P Software GmbH, Copyright 2012-2013, All Rights Reserved