CORDET Framework - C2 Implementation
CrPsCmdVerFailFunc.c
Go to the documentation of this file.
1 
25 #include "CrPsCmdVerFailCreate.h"
26 
28 #include "FwPrConstants.h"
29 #include "FwPrDCreate.h"
30 #include "FwPrConfig.h"
31 #include "FwPrCore.h"
32 #include "FwSmConfig.h"
33 
34 #include "Pckt/CrFwPckt.h" /* --- interface to adaptation point CrFwPckt --- */
35 #include <CrFwCmpData.h>
38 #include <OutCmp/CrFwOutCmp.h>
39 
40 #include <CrPsRepErr.h>
46 
47 #include <stdlib.h>
48 #include <time.h>
49 
50 static FwSmDesc_t rep;
51 
52 
53 /* ----------------------------------------------------------------------------------------------------------------- */
54 
55 /* ------------------------------------------------------------------------------------ */
57 void CrPsCmdVerFailN2(FwPrDesc_t prDesc)
58 {
59  prData_t* prData;
60 
61  /* Retrieve an OutComponent of type (1,4) or (1,8) from the OutFactory */
62 
63  /* Get procedure parameters */
64  prData = FwPrGetData(prDesc);
65 
66  /* Create out component */
67  rep = CrFwOutFactoryMakeOutCmp(CRPS_REQVERIF, prData->ushortParam2, 0, 0);
68 
69  return;
70 }
71 
72 /* ------------------------------------------------------------------------------------ */
74 void CrPsCmdVerFailN3(FwPrDesc_t prDesc)
75 {
76  prData_t *prData;
77  CrPsRepErrCode_t errCode;
78 
79  /* Generate error report OUTFACTORY_FAIL */
80 
81  /* Get procedure parameters */
82  prData = FwPrGetData(prDesc);
83 
84  errCode = crOutfactoryFail;
85  CrPsRepErr(errCode, CRPS_REQVERIF, prData->ushortParam2, 0);
86 
87  return;
88 }
89 
90 /* ------------------------------------------------------------------------------------ */
92 void CrPsCmdVerFailN4(FwPrDesc_t prDesc)
93 {
94  CrFwDestSrc_t source;
95  CrPsFailData_t VerFailData;
96  CrFwCmpData_t *inData;
97  CrFwInCmdData_t *inSpecificData;
98  CrFwPckt_t inPckt;
99  FwSmDesc_t smDesc;
100  prData_t *prData;
101  CrFwCmpData_t *cmpDataStart;
102  CrFwOutCmpData_t *cmpSpecificData;
103  CrFwPckt_t pckt;
104  CrPsRid_t Rid;
105 
106  cmpDataStart = (CrFwCmpData_t *) FwSmGetData(rep);
107  cmpSpecificData = (CrFwOutCmpData_t *) cmpDataStart->cmpSpecificData;
108  pckt = cmpSpecificData->pckt;
109 
110  /* Configure report and load it in the OutLoader */
111 
112  /* Get procedure parameters */
113  prData = FwPrGetData(prDesc);
114 
115  smDesc = prData->smDesc;
116 
117  /* Get in packet */
118  inData = FwSmGetData(smDesc);
119  inSpecificData = (CrFwInCmdData_t*)inData->cmpSpecificData;
120  inPckt = inSpecificData->pckt;
121 
122  Rid = getPcktRid(inPckt);
123 
124  if (prData->ushortParam2 == 4)
125  {
126  /* 1,4 */
127  /* set Packet request ID */
128  setVerFailedStartRepRid(pckt, Rid);
129 
130  /* Set failCodeAccFailed */
131  setVerFailedStartRepFailureCode(pckt, (CrPsFailCode_t)prData->ushortParam1);
132 
133  /* Set verFailData */
134  VerFailData = getDpverFailData();
135  setVerFailedStartRepFailureData(pckt, VerFailData);
136  }
137 
138  if (prData->ushortParam2 == 8)
139  {
140  /* 1,8 */
141  /* set Packet request ID */
142  setVerFailedTermRepRid(pckt, Rid);
143 
144  /* Set failCodeAccFailed */
145  setVerFailedTermRepFailureCode(pckt, (CrPsFailCode_t)prData->ushortParam1);
146 
147  /* Set verFailData */
148  VerFailData = getDpverFailData();
149  setVerFailedTermRepFailureData(pckt, VerFailData);
150  }
151 
152  /* Set the destination of the report to the source of the in-coming packet */
153  source = CrFwPcktGetSrc(inPckt);
154  CrFwOutCmpSetDest(rep, source);
155 
156  /* Load report in the Outloader */
158 
159  return;
160 }
161 
162 /* ------------------------------------------------------------------------------------ */
164 void CrPsCmdVerFailN5(FwPrDesc_t prDesc)
165 {
166  prData_t *prData;
167  CrFwCounterU4_t nOfStartFailed, nOfTermFailed;
168 
169  /* Increment data pool variable nOfXyFailed */
170 
171  /* Get procedure parameters */
172  prData = FwPrGetData(prDesc);
173 
174  if (prData->ushortParam2 == CRPS_REQVERIF_START_FAIL)
175  {
176  nOfStartFailed = getDpnOfStartFailed();
177  nOfStartFailed += 1;
178  setDpnOfStartFailed(nOfStartFailed);
179  }
180  else if (prData->ushortParam2 == CRPS_REQVERIF_TERM_FAIL)
181  {
182  nOfTermFailed = getDpnOfTermFailed();
183  nOfTermFailed += 1;
184  setDpnOfTermFailed(nOfTermFailed);
185  }
186 
187  return;
188 }
189 
190 /* ------------------------------------------------------------------------------------ */
192 void CrPsCmdVerFailN6(FwPrDesc_t prDesc)
193 {
194  CrFwTypeId_t PacketId;
195  CrFwCmpData_t *inData;
196  CrFwInCmdData_t *inSpecificData;
197  CrFwPckt_t inPckt;
198  FwSmDesc_t smDesc;
199  prData_t *prData;
200 
201  /* Update data pool variable pcktIdXyFailed and failCodeXyFailed */
202 
203  /* Get procedure parameters */
204  prData = FwPrGetData(prDesc);
205 
206  smDesc = prData->smDesc;
207 
208  /* Get in packet */
209  inData = FwSmGetData(smDesc);
210  inSpecificData = (CrFwInCmdData_t*)inData->cmpSpecificData;
211  inPckt = inSpecificData->pckt;
212 
213  /* Set pcktIdAccFailed */
214  PacketId = (CrFwTypeId_t)CrFwPcktGetApid(inPckt); /* --- adaptation point CrFwPckt ---> */
215 
216  if (prData->ushortParam2 == CRPS_REQVERIF_START_FAIL)
217  {
218  /* Set pcktIdStartFailed */
219  setDppcktIdStartFailed(PacketId);
220 
221  /* Set failCodeStartFailed */
222  setDpfailCodeStartFailed(prData->ushortParam1);
223  }
224  else if (prData->ushortParam2 == CRPS_REQVERIF_TERM_FAIL)
225  {
226  /* Set pcktIdTermFailed */
227  setDppcktIdTermFailed(PacketId);
228 
229  /* Set failCodeTermFailed */
230  setDpfailCodeTermFailed(prData->ushortParam1);
231  }
232 
233  return;
234 }
235 
236 /* ------------------------------------------------------------------------------------ */
237 /**************/
238 /*** GUARDS ***/
239 /**************/
240 
242 FwPrBool_t CrPsCmdVerFailG1(FwPrDesc_t prDesc)
243 {
244  CRFW_UNUSED(prDesc);
245 
246  /* [ OutFactory fails to generate OutComponent ] */
247 
248  if (rep == NULL)
249  {
250  return 1;
251  }
252  else
253  {
254  return 0;
255  }
256 
257 }
258 
259 /* ----------------------------------------------------------------------------------------------------------------- */
260 
Type for the Framework Component Data (FCD).
FwPrBool_t CrPsCmdVerFailG1(FwPrDesc_t prDesc)
Guard on the Control Flow from DECISION2 to N3.
CrFwDestSrc_t CrFwPcktGetSrc(CrFwPckt_t pckt)
Return the source of the command or report encapsulated in a packet.
#define CRFW_UNUSED(x)
A macro that can be used to specify that a function parameter is not used.
Definition: CrFwConstants.h:27
void setVerFailedTermRepRid(void *p, CrPsRid_t Rid)
Set "RequestId" in a "VerFailedTermRep" packet.
static CrPsFailData_t getDpverFailData()
Gets the value of the datapool item verFailData.
static void setDppcktIdTermFailed(CrFwTypeId_t pcktIdTermFailed)
Sets the value of the datapool item pcktIdTermFailed.
unsigned short int CrFwTypeId_t
Type used for the identifier of a component type.
Definition of the OutFactory component.
Type for the data describing an OutComponent.
CrFwPckt_t pckt
Packet holding the InCommand.
unsigned char CrFwDestSrc_t
Type used for the command or report destination and source.
void CrPsCmdVerFailN2(FwPrDesc_t prDesc)
Action for node N2.
static void setVerFailedStartRepFailureData(void *p, CrPsFailData_t FailureData)
Set "FailureData" in "VerFailedStartRep" packet.
Header file to define all service and packet identifiers.
static CrFwCounterU4_t getDpnOfTermFailed()
Gets the value of the datapool item nOfTermFailed.
CrFwPckt_t pckt
Packet to which the out-going command or report is serialized.
Interface for creating and accessing a report or command packet.
void CrPsCmdVerFailN6(FwPrDesc_t prDesc)
Action for node N6.
void CrFwOutLoaderLoad(FwSmDesc_t outCmp)
Load an OutComponent into its OutManager.
Interface for accessing fields in packets of service "ServReqVerif".
static void setVerFailedStartRepFailureCode(void *p, CrPsFailCode_t FailureCode)
Set "FailureCode" in "VerFailedStartRep" packet.
The Outfactory failed to make the component (see CrPsRepErr.h)
static CrFwCounterU4_t getDpnOfStartFailed()
Gets the value of the datapool item nOfStartFailed.
void CrPsCmdVerFailN3(FwPrDesc_t prDesc)
Action for node N3.
Interface for accessing data pool items.
CrPsRepErrCode_t
Identifier for the errors reported through the error reporting interface of CrFwRepErr.h.
#define CRPS_REQVERIF_TERM_FAIL
Subtype identifier of the Request Verification Termination Failed out-going report packet...
static void setDpnOfStartFailed(CrFwCounterU4_t nOfStartFailed)
Sets the value of the datapool item nOfStartFailed.
static void setVerFailedTermRepFailureData(void *p, CrPsFailData_t FailureData)
Set "FailureData" in "VerFailedTermRep" packet.
generic Interface for accessing fields in packets.
uint32_t CrPsFailData_t
Type used for the Failure Data of a packet.
void * cmpSpecificData
Derived data which are specific to each type of framework component.
void CrPsCmdVerFailN5(FwPrDesc_t prDesc)
Action for node N5.
#define CRPS_REQVERIF_START_FAIL
Subtype identifier of the Request Verification Start Failed out-going report packet.
static void setDpfailCodeStartFailed(CrPsFailCode_t failCodeStartFailed)
Sets the value of the datapool item failCodeStartFailed.
uint16_t CrPsFailCode_t
Type used for the Failure Code of a packet.
static void setDpfailCodeTermFailed(CrPsFailCode_t failCodeTermFailed)
Sets the value of the datapool item failCodeTermFailed.
void CrPsRepErr(CrPsRepErrCode_t errCode, CrFwServType_t repType, CrFwServSubType_t repSubType, CrFwDiscriminant_t repDiscriminant)
Report an error which has no parameters attached to it.
Definition: CrPsRepErr.c:37
Interface for reporting an error detected by a PUS Extension component.
auxiliary Interface for accessing fields in packets of service "ServReqVerif".
char * CrFwPckt_t
Type for packets (see CrFwPckt.h).
Definition: CrFwConstants.h:36
void CrPsCmdVerFailN4(FwPrDesc_t prDesc)
Action for node N4.
Definition of the OutComponent Component of the framework.
static CrPsRid_t getPcktRid(void *p)
Getter for the RequestId from a packet.
Definition: CrPsPkt.h:1067
void CrFwOutCmpSetDest(FwSmDesc_t smDesc, CrFwDestSrc_t dest)
Set the destination of the OutComponent.
Definition: CrFwOutCmp.c:192
static FwSmDesc_t rep
CrPsCmdVerFail function definitions.
static void setDppcktIdStartFailed(CrFwTypeId_t pcktIdStartFailed)
Sets the value of the datapool item pcktIdStartFailed.
void setVerFailedStartRepRid(void *p, CrPsRid_t Rid)
Set "RequestId" in a "VerFailedStartRep" packet.
Type for the data describing an InCommand.
static void setVerFailedTermRepFailureCode(void *p, CrPsFailCode_t FailureCode)
Set "FailureCode" in "VerFailedTermRep" packet.
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.
#define CRPS_REQVERIF
Type identifier of the Request Verification Service.
Definition: CrPsConstants.h:80
Create one instance of the CrPsCmdVerFail procedure.
static void setDpnOfTermFailed(CrFwCounterU4_t nOfTermFailed)
Sets the value of the datapool item nOfTermFailed.
P&P Software GmbH, Copyright 2012-2013, All Rights Reserved