CORDET Framework - C2 Implementation
CrPsCmd3s9PrgrFunc.c
Go to the documentation of this file.
1 
25 #include "CrPsCmd3s9PrgrCreate.h"
26 
27 /* CrFramework includes */
28 #include "Pckt/CrFwPckt.h"
30 #include "OutCmp/CrFwOutCmp.h"
32 #include "CrFwCmpData.h"
33 
35 #include "FwSmConstants.h"
36 #include "FwSmConfig.h"
37 #include "FwSmCore.h"
38 #include "FwPrDCreate.h"
39 #include "FwPrConfig.h"
40 #include "FwPrCore.h"
41 #include "FwPrConstants.h"
42 
43 #include <CrPsUserConstants.h>
45 #include <DataPool/CrPsDpServHk.h>
49 #include <CrPsUtilitiesServHk.h>
50 #include <CrPsRepErr.h>
51 
53 
54 #include <stdlib.h>
55 #include <time.h>
56 
57 FwSmDesc_t rep;
58 CrPsSid_t currentSid;
59 CrFwCounterU4_t iSid;
60 
61 
62 /* ----------------------------------------------------------------------------------------------------------------- */
63 
65 void CrPsCmd3s9PrgrN1(FwPrDesc_t prDesc)
66 {
67  CrFwCmpData_t *cmpData;
68  CrFwInCmdData_t *cmpSpecificData;
69  CrFwPckt_t pckt;
70  prDescCmd3s9Prgr_t *prDataPtr;
71  FwSmDesc_t smDesc;
72  CrFwServSubType_t tcServSubType;
73 
74  /* Retrieve a (3,10) or (3,12) report from the OutFactory to hold
75  * the structurereport for the SID which is being processed */
76 
77  /* Get smDesc from prData */
78  prDataPtr = FwPrGetData(prDesc);
79  smDesc = prDataPtr->smDesc;
80 
81  /* Get inPckt */
82  cmpData = (CrFwCmpData_t*)FwSmGetData(smDesc);
83  cmpSpecificData = (CrFwInCmdData_t *) cmpData->cmpSpecificData;
84  pckt = cmpSpecificData->pckt;
85 
86  /* Get SubType */
87  tcServSubType = CrFwPcktGetServSubType(pckt);
88 
89  /* Generate report of type (3,10) or (3,12) according to TC(3,9) or TC(3,11) */
90  if (tcServSubType == 9)
91  {
92  rep = CrFwOutFactoryMakeOutCmp(CRPS_HK, CRPS_HK_HKREP_STRUCT_REP, currentSid, getHkRepStructSize(currentSid)); /* arguments: type, subType, discriminant/evtId, length */
93  }
94  else if (tcServSubType == 11)
95  {
96  rep = CrFwOutFactoryMakeOutCmp(CRPS_HK, CRPS_HK_DIAGREP_STRUCT_REP, currentSid, getHkRepStructSize(currentSid)); /* arguments: type, subType, discriminant/evtId, length */
97  }
98 
99  return;
100 }
101 
103 void CrPsCmd3s9PrgrN2(FwPrDesc_t prDesc)
104 {
105  CRFW_UNUSED(prDesc);
106 
107  /* Load the SID which is being processed in data pool item verFailData */
108  setDpverFailData((CrPsFailData_t)currentSid);
109 
110  return;
111 }
112 
114 void CrPsCmd3s9PrgrN3(FwPrDesc_t prDesc)
115 {
116  FwSmDesc_t smDesc;
117  prDescCmd3s9Prgr_t *prDataPtr;
118  CrPsStepId_t stepIdentifier;
119  CrPsFailCode_t FailureCode;
120 
121  /* Run the Command Progress Failure Procedure */
122 
123  /* Get smDesc from prData */
124  prDataPtr = FwPrGetData(prDesc);
125  smDesc = prDataPtr->smDesc;
126 
127  stepIdentifier = iSid;
128  FailureCode = OUTFACTORY_FAIL; /* TODO: check if correct use for Service 1 reports */
129 
130  CRFW_UNUSED(smDesc);
131  CRFW_UNUSED(FailureCode);
132  CRFW_UNUSED(stepIdentifier);
133 
134  SendReqVerifPrgrFailRep(smDesc, stepIdentifier, FailureCode); /* TODO: can not be sent: segmentation fault
135  pckt can not be retrieved by cmpSpecificData->pckt in CrFwOutCmp: CrFwOutCmpSetDest(FwSmDesc_t smDesc, CrFwDestSrc_t dest) */
136 
137  return;
138 }
139 
141 void CrPsCmd3s9PrgrN4(FwPrDesc_t prDesc)
142 {
143  CrPsRepErrCode_t errCode;
144  CRFW_UNUSED(prDesc);
145 
146  /* Generate error report OUTFACTORY_FAIL */
147 
148  errCode = crOutfactoryFail;
150 
151  return;
152 }
153 
155 void CrPsCmd3s9PrgrN5(FwPrDesc_t prDesc)
156 {
157  CrFwCmpData_t *cmpData;
158  CrFwInCmdData_t *cmpSpecificData;
159  CrFwPckt_t pckt;
160  prDescCmd3s9Prgr_t *prDataPtr;
161  FwSmDesc_t smDesc;
163 
164  /* Configure the (3,10) or (3,12) report with the SID being processed and load it in the OutLoader */
165 
166  /* Get smDesc from OutCmp */
167  prDataPtr = FwPrGetData(prDesc);
168  smDesc = prDataPtr->smDesc;
169 
170  /* Get inPckt */
171  cmpData = (CrFwCmpData_t*) FwSmGetData(smDesc);
172  cmpSpecificData = (CrFwInCmdData_t *) cmpData->cmpSpecificData;
173  pckt = cmpSpecificData->pckt;
174 
175  dest = CrFwPcktGetSrc(pckt);
176  CrFwOutCmpSetDest(rep, dest);
177 
179 
180  return;
181 }
182 
184 void CrPsCmd3s9PrgrN6(FwPrDesc_t prDesc)
185 {
186  prDescCmd3s9Prgr_t *prDataPtr;
187  CrFwCmpData_t *cmpData;
188  FwSmDesc_t smDesc;
189 
190  /* Set action outcome to: 'completed' */
191 
192  /* Get smDesc from OutCmp */
193  prDataPtr = FwPrGetData(prDesc);
194  smDesc = prDataPtr->smDesc;
195 
196  /* Set outcome in prData */
197  prDataPtr->outcome = 1;
198  FwPrSetData(prDesc, prDataPtr);
199 
200  /* Set outcome in InCmd prData to 'success' */
201  cmpData = (CrFwCmpData_t*) FwSmGetData(smDesc);
202  cmpData->outcome = 1;
203  FwSmSetData(smDesc, cmpData);
204 
205  return;
206 }
207 
209 void CrPsCmd3s9PrgrN7(FwPrDesc_t prDesc)
210 {
211  prDescCmd3s9Prgr_t *prDataPtr;
212  CrFwCmpData_t *cmpData;
213  FwSmDesc_t smDesc;
214 
215  /* Set action outcome to: 'continue' */
216 
217  /* Get smDesc from OutCmp */
218  prDataPtr = FwPrGetData(prDesc);
219  smDesc = prDataPtr->smDesc;
220 
221  /* Set outcome in prData */
222  prDataPtr->outcome = 2;
223  FwPrSetData(prDesc, prDataPtr);
224 
225  /* Set outcome in InCmd prData to 'continue' */
226  cmpData = (CrFwCmpData_t*) FwSmGetData(smDesc);
227  cmpData->outcome = 2;
228  FwSmSetData(smDesc, cmpData);
229 
230  return;
231 }
232 
234 void CrPsCmd3s9PrgrN8(FwPrDesc_t prDesc)
235 {
236  prDescCmd3s9Prgr_t *prDataPtr;
237  CrPsSid_t *sid;
238 
239  /* Start processing the first valid SID in the command */
240 
241  /* Get sid from OutCmp */
242  prDataPtr = FwPrGetData(prDesc);
243  sid = prDataPtr->sidPtr;
244 
245  /* Get first SID */
246  iSid = 0;
247  currentSid = sid[iSid];
248 
249  return;
250 }
251 
253 void CrPsCmd3s9PrgrN9(FwPrDesc_t prDesc)
254 {
255  prDescCmd3s9Prgr_t *prDataPtr;
256  CrPsSid_t *sid;
257 
258  /* Process the next valid SID in the command */
259 
260  /* Get sid from OutCmp */
261  prDataPtr = FwPrGetData(prDesc);
262  sid = prDataPtr->sidPtr;
263 
264  /* Get next SID */
265  iSid++;
266  currentSid = sid[iSid];
267 
268  return;
269 }
270 
271 /**************/
272 /*** GUARDS ***/
273 /**************/
274 
276 FwPrBool_t CrPsCmd3s9PrgrG1(FwPrDesc_t prDesc)
277 {
278  CRFW_UNUSED(prDesc);
279 
280  /* OutFactory fails to return a report */
281 
282  if (rep == NULL)
283  {
284  return 1;
285  }
286  else
287  {
288  return 0;
289  }
290 }
291 
293 FwPrBool_t CrPsCmd3s9PrgrG2(FwPrDesc_t prDesc)
294 {
295  prDescCmd3s9Prgr_t *prDataPtr;
296  CrPsSid_t *sid;
297 
298  /* This SID was the last valid SID in the (3,9) or (3,11) */
299 
300  /* Get sid from OutCmp */
301  prDataPtr = FwPrGetData(prDesc);
302  sid = prDataPtr->sidPtr;
303 
304  /* Check next SID. If 0 the current SID was the last valid one. */
305  if (sid[iSid + 1] == 0)
306  {
307  return 1;
308  }
309  else
310  {
311  return 0;
312  }
313 }
314 
316 FwPrBool_t CrPsCmd3s9PrgrG3(FwPrDesc_t prDesc)
317 {
318  CRFW_UNUSED(prDesc);
319 
320  /* Next Execution */
321 
322  if (FwPrGetNodeExecCnt(prDesc))
323  {
324  return 1;
325  }
326  else
327  {
328  return 0;
329  }
330 }
331 
332 /* ----------------------------------------------------------------------------------------------------------------- */
333 
Type for the Framework Component Data (FCD).
CrFwOutcome_t outcome
The outcome of an action or check executed by a state machine or by one of its procedures.
CrFwDestSrc_t CrFwPcktGetSrc(CrFwPckt_t pckt)
Return the source of the command or report encapsulated in a packet.
FwPrBool_t CrPsCmd3s9PrgrG3(FwPrDesc_t prDesc)
Guard on the Control Flow from N7 to N9.
Interface through which applications can initialize and execute framework PUS extension components...
#define CRPS_REQVERIF_PROG_FAIL
Subtype identifier of the Request Verification Progress Failed out-going report 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 CrPsCmd3s9PrgrN5(FwPrDesc_t prDesc)
Action for node N5.
unsigned char CrFwServSubType_t
Type used for the command or report sub-type.
Header file to define all user-configurable constants and types for the IASW Application.
FwPrBool_t CrPsCmd3s9PrgrG2(FwPrDesc_t prDesc)
Guard on the Control Flow from DECISION2 to N6.
Create one instance of the CrPsCmd3s9Prgr procedure.
Interface for accessing data pool items.
FwSmDesc_t rep
CrPsCmd3s9Prgr function definitions.
Definition of the OutFactory component.
CrFwPckt_t pckt
Packet holding the InCommand.
unsigned char CrFwDestSrc_t
Type used for the command or report destination and source.
Header file to define all service and packet identifiers.
Interface for creating and accessing a report or command packet.
void CrPsCmd3s9PrgrN7(FwPrDesc_t prDesc)
Action for node N7.
static void setDpverFailData(CrPsFailData_t verFailData)
Sets the value of the datapool item verFailData.
void CrPsCmd3s9PrgrN9(FwPrDesc_t prDesc)
Action for node N9.
uint32_t CrPsStepId_t
Type used for the Step ID of a packet.
void CrFwOutLoaderLoad(FwSmDesc_t outCmp)
Load an OutComponent into its OutManager.
auxiliary Interface for accessing fields in packets of service "ServHk".
#define OUTFACTORY_FAIL
Failure Codes for Service 5 (Event Report)
void CrPsCmd3s9PrgrN4(FwPrDesc_t prDesc)
Action for node N4.
#define CRPS_HK_DIAGREP_STRUCT_REP
Subtype identifier of the Housekeeping Diagnostic Parameter Report Structure Report out-going report ...
The Outfactory failed to make the component (see CrPsRepErr.h)
Interface for accessing data pool items.
CrPsRepErrCode_t
Identifier for the errors reported through the error reporting interface of CrFwRepErr.h.
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.
FwPrBool_t CrPsCmd3s9PrgrG1(FwPrDesc_t prDesc)
Guard on the Control Flow from DECISION1 to N2.
void CrPsCmd3s9PrgrN2(FwPrDesc_t prDesc)
Action for node N2.
size_t getHkRepStructSize(CrPsSid_t sid)
Get "RepStrucSize by SID".
void CrPsCmd3s9PrgrN3(FwPrDesc_t prDesc)
Action for node N3.
uint16_t CrPsFailCode_t
Type used for the Failure Code of a packet.
CrFwServSubType_t CrFwPcktGetServSubType(CrFwPckt_t pckt)
Return the service sub-type of the command or report encapsulated in a packet.
static CrFwDestSrc_t dest
Destination.
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
#define CRPS_HK
Type identifier of the Housekeeping Data Report out-going report packet.
void SendReqVerifPrgrFailRep(FwSmDesc_t smDesc, CrPsStepId_t stepIdentifier, CrPsFailCode_t FailureCode)
Generate a Request Verification Progress Failed out-going report.
Interface for reporting an error detected by a PUS Extension component.
uint8_t CrPsSid_t
Type used for the Parameter Report Structure ID of a packet.
char * CrFwPckt_t
Type for packets (see CrFwPckt.h).
Definition: CrFwConstants.h:36
#define CRPS_HK_HKREP_STRUCT_REP
Subtype identifier of the Housekeeping Housekeeping Parameter Report Structure Report out-going repor...
void CrPsCmd3s9PrgrN1(FwPrDesc_t prDesc)
Action for node N1.
Definition of the OutComponent Component of the framework.
void CrFwOutCmpSetDest(FwSmDesc_t smDesc, CrFwDestSrc_t dest)
Set the destination of the OutComponent.
Definition: CrFwOutCmp.c:192
void CrPsCmd3s9PrgrN8(FwPrDesc_t prDesc)
Action for node N8.
Interface through which applications can initialize and execute framework PUS extension components...
Interface for accessing fields in packets of service "ServHk".
Type for the data describing an InCommand.
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.
void CrPsCmd3s9PrgrN6(FwPrDesc_t prDesc)
Action for node N6.
#define CRPS_REQVERIF
Type identifier of the Request Verification Service.
Definition: CrPsConstants.h:80
P&P Software GmbH, Copyright 2012-2013, All Rights Reserved