CORDET Framework - C2 Implementation
CrPsCmd3s3StartFunc.c
Go to the documentation of this file.
1 
25 #include "CrPsCmd3s3StartCreate.h"
26 
28 #include "CrFwConstants.h"
29 #include "Pckt/CrFwPckt.h"
31 #include "OutCmp/CrFwOutCmp.h"
33 #include "CrFwCmpData.h"
34 
36 #include "FwSmConstants.h"
37 #include "FwSmConfig.h"
38 #include "FwSmCore.h"
39 #include "FwPrDCreate.h"
40 #include "FwPrConfig.h"
41 #include "FwPrCore.h"
42 #include "FwPrConstants.h"
43 
45 #include <DataPool/CrPsDpServHk.h>
49 #include <CrPsUtilitiesServHk.h>
51 #include <CrPsUserConstants.h>
52 
53 #include <stdlib.h>
54 #include <time.h>
55 
56 
57 CrFwCounterU4_t i, iSidFail, iMax;
58 CrPsSid_t currentSid;
59 
60 /* ----------------------------------------------------------------------------------------------------------------- */
61 
63 void CrPsCmd3s3StartN1(FwPrDesc_t prDesc)
64 {
65  CrFwCmpData_t *cmpData;
66  CrFwInCmdData_t *cmpSpecificData;
67  CrFwPckt_t pckt;
68  FwSmDesc_t smDesc;
69  prDescCmd3s3Start_t *prDataPtr;
70  /* CrFwServSubType_t servSubType;*/
71 
72  /* Set i equal to 1 */
73  i = 0;
74  iSidFail = 0;
75 
76  /* Get smDesc from prData */
77  prDataPtr = FwPrGetData(prDesc);
78  smDesc = prDataPtr->smDesc;
79 
80  /* Get in data */
81  cmpData = (CrFwCmpData_t*)FwSmGetData(smDesc);
82  cmpSpecificData = (CrFwInCmdData_t *) cmpData->cmpSpecificData;
83  pckt = cmpSpecificData->pckt;
84 
85 
86  /* Get current SID and iMax = N */
87  currentSid = getHkDeleteCmdRepStrucIdItem(pckt, i+1);
88  iMax = getHkDeleteCmdN(pckt);
89 
90  return;
91 }
92 
94 void CrPsCmd3s3StartN2(FwPrDesc_t prDesc)
95 {
96  CRFW_UNUSED(prDesc);
97  /* Load invalid SID in data pool item verFailData */
98  iSidFail++;
99  setDpverFailData((CrFwCounterU4_t)currentSid);
100 
101  return;
102 }
103 
105 void CrPsCmd3s3StartN3(FwPrDesc_t prDesc)
106 {
107  FwSmDesc_t smDesc;
108  prDescCmd3s3Start_t *prDataPtr;
109 
110  /* Run Command Verification Failure Procedure to generate (1,4) report with failure code VER_ILL_SID */
111  /* Get smDesc from prData */
112  prDataPtr = FwPrGetData(prDesc);
113  smDesc = prDataPtr->smDesc;
114 
116 
117  return;
118 }
119 
121 void CrPsCmd3s3StartN4(FwPrDesc_t prDesc)
122 {
123  CrFwCmpData_t *cmpData;
124  CrFwInCmdData_t *cmpSpecificData;
125  CrFwPckt_t pckt;
126  FwSmDesc_t smDesc;
127  prDescCmd3s3Start_t *prDataPtr;
128  /* CrFwServSubType_t servSubType;*/
129 
130  /* Increment i */
131  i++;
132 
133  /* Get smDesc from prData */
134  prDataPtr = FwPrGetData(prDesc);
135  smDesc = prDataPtr->smDesc;
136 
137  /* Get in data */
138  cmpData = (CrFwCmpData_t*)FwSmGetData(smDesc);
139  cmpSpecificData = (CrFwInCmdData_t *) cmpData->cmpSpecificData;
140  pckt = cmpSpecificData->pckt;
141 
142  /* Get current SID */
143  currentSid = getHkDeleteCmdRepStrucIdItem(pckt, i+1);
144 
145  return;
146 }
147 
149 void CrPsCmd3s3StartN5(FwPrDesc_t prDesc)
150 {
151  CRFW_UNUSED(prDesc);
152  /* Load the enabled SID in data pool verFailData */
153  iSidFail++;
154  setDpverFailData((CrFwCounterU4_t)currentSid);
155 
156  return;
157 }
158 
160 void CrPsCmd3s3StartN6(FwPrDesc_t prDesc)
161 {
162  FwSmDesc_t smDesc;
163  prDescCmd3s3Start_t *prDataPtr;
164 
165  /* Run Command Verification Failure Procedure to generate (1,4) report with failure code VER_ENABLED_SID */
166  /* Get smDesc from prData */
167  prDataPtr = FwPrGetData(prDesc);
168  smDesc = prDataPtr->smDesc;
169 
170  SendReqVerifCmdFailRep(smDesc, CRPS_REQVERIF_START_FAIL, VER_ENABLED_SID);
171 
172  return;
173 }
174 
176 void CrPsCmd3s3StartN7(FwPrDesc_t prDesc)
177 {
178  prDescCmd3s3Start_t *prDataPtr;
179  CrFwCmpData_t *cmpData;
180  FwSmDesc_t smDesc;
181 
182  /* Set action outcome to 'success' */
183  /* Get smDesc from OutCmp */
184  prDataPtr = FwPrGetData(prDesc);
185  smDesc = prDataPtr->smDesc;
186 
187  /* Set outcome in InCmd prData to 'success' */
188  cmpData = (CrFwCmpData_t*) FwSmGetData(smDesc);
189  cmpData->outcome = 1;
190  FwSmSetData(smDesc, cmpData);
191 
192  return;
193 }
194 
196 void CrPsCmd3s3StartN8(FwPrDesc_t prDesc)
197 {
198  prDescCmd3s3Start_t *prDataPtr;
199  CrFwCmpData_t *cmpData;
200  FwSmDesc_t smDesc;
201 
202  /* Set action outcome to 'failure' with failure code VER_S3S_START_FD */
203  /* Get smDesc from OutCmp */
204  prDataPtr = FwPrGetData(prDesc);
205  smDesc = prDataPtr->smDesc;
206 
207  /* Set outcome in InCmd prData to 'success' */
208  cmpData = (CrFwCmpData_t*) FwSmGetData(smDesc);
209  cmpData->outcome = VER_S3S_START_FD;
210  FwSmSetData(smDesc, cmpData);
211 
212  return;
213 }
214 
215 /**************/
216 /*** GUARDS ***/
217 /**************/
218 
220 FwPrBool_t CrPsCmd3s3StartG1(FwPrDesc_t prDesc)
221 {
222  CrPsSid_t rdlSid, rdlSlot;
223  CRFW_UNUSED(prDesc);
224 
225  /* The i-th SID is not in the RDL */
226 
227  /* look for the slot */
228  for (rdlSlot = 0; rdlSlot < HK_N_REP_DEF; rdlSlot++)
229  {
230 
231  rdlSid = getDpsidItem(rdlSlot);
232 
233  if (currentSid == rdlSid)
234  break;
235  }
236 
237  /* sid not found in list */
238  if (rdlSlot == HK_N_REP_DEF)
239  {
240  return 1;
241  }
242  else
243  {
244  return 0;
245  }
246 }
247 
249 FwPrBool_t CrPsCmd3s3StartG2(FwPrDesc_t prDesc)
250 {
251  CrPsSid_t rdlSid, rdlSlot;
252  CrFwBool_t isEnabled;
253 
254  CRFW_UNUSED(prDesc);
255  /* The i-th SID is enabled in the RDL */
256  /* look for the slot */
257  for (rdlSlot = 0; rdlSlot < HK_N_REP_DEF; rdlSlot++)
258  {
259  rdlSid = getDpsidItem(rdlSlot);
260 
261  if (currentSid == rdlSid)
262  break;
263  }
264 
265  isEnabled = getDpisEnabledItem(rdlSlot);
266 
267  if (isEnabled)
268  {
269  return 1;
270  }
271  else
272  {
273  return 0;
274  }
275 }
276 
278 FwPrBool_t CrPsCmd3s3StartG3(FwPrDesc_t prDesc)
279 {
280  CRFW_UNUSED(prDesc);
281  /* The i-th SID was the last SID in the command */
282 
283  if (i == iMax-1)
284  {
285  return 1;
286  }
287  else
288  {
289  return 0;
290  }
291 }
292 
294 FwPrBool_t CrPsCmd3s3StartG4(FwPrDesc_t prDesc)
295 {
296  CRFW_UNUSED(prDesc);
297  /* All SIDs in the command are invalid */
298 
299  if (iSidFail == iMax)
300  {
301  return 1;
302  }
303  else
304  {
305  return 0;
306  }
307 }
308 
309 /* ----------------------------------------------------------------------------------------------------------------- */
310 
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.
FwPrBool_t CrPsCmd3s3StartG4(FwPrDesc_t prDesc)
Guard on the Control Flow from DECISION4 to N8.
Interface through which applications can initialize and execute framework PUS extension components...
#define CRFW_UNUSED(x)
A macro that can be used to specify that a function parameter is not used.
Definition: CrFwConstants.h:27
Header file to define all user-configurable constants and types for the IASW Application.
Interface for accessing data pool items.
void CrPsCmd3s3StartN2(FwPrDesc_t prDesc)
Action for node N2.
CrPsSid_t getHkDeleteCmdRepStrucIdItem(void *p, CrFwCounterU4_t N)
Get "RepStrucId" from "HkDeleteCmd" packet.
Create one instance of the CrPsCmd3s3Start procedure.
Definition of the OutFactory component.
CrFwPckt_t pckt
Packet holding the InCommand.
static CrPsFlag_t getDpisEnabledItem(int i)
Gets the value of the i-th element in the datapool array isEnabled.
Definition: CrPsDpServHk.h:229
Header file to define all service and packet identifiers.
FwPrBool_t CrPsCmd3s3StartG3(FwPrDesc_t prDesc)
Guard on the Control Flow from DECISION3 to DECISION4.
void CrPsCmd3s3StartN8(FwPrDesc_t prDesc)
Action for node N8.
Interface for creating and accessing a report or command packet.
int CrFwBool_t
Type used for boolean values (1 represent "true" and 0 represents "false").
Definition: CrFwConstants.h:30
static void setDpverFailData(CrPsFailData_t verFailData)
Sets the value of the datapool item verFailData.
void CrPsCmd3s3StartN1(FwPrDesc_t prDesc)
Action for node N1.
Header file to define all invariant publicly available constants and types for the CORDET Framework...
static CrFwCounterU4_t getHkDeleteCmdN(void *p)
Get "N" from "HkDeleteCmd" packet.
static CrPsSid_t getDpsidItem(int i)
Gets the value of the i-th element in the datapool array sid.
Definition: CrPsDpServHk.h:289
auxiliary Interface for accessing fields in packets of service "ServHk".
FwPrBool_t CrPsCmd3s3StartG2(FwPrDesc_t prDesc)
Guard on the Control Flow from DECISION2 to N5.
void CrPsCmd3s3StartN7(FwPrDesc_t prDesc)
Action for node N7.
Interface for accessing data pool items.
void * cmpSpecificData
Derived data which are specific to each type of framework component.
void CrPsCmd3s3StartN5(FwPrDesc_t prDesc)
Action for node N5.
void CrPsCmd3s3StartN4(FwPrDesc_t prDesc)
Action for node N4.
#define CRPS_REQVERIF_START_FAIL
Subtype identifier of the Request Verification Start Failed out-going report packet.
CrFwCounterU4_t i
CrPsCmd3s3Start function definitions.
#define HK_N_REP_DEF
Number of Report Definitions in the Report Definition List (maximum number of housekeeping/diagnostic...
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
FwPrBool_t CrPsCmd3s3StartG1(FwPrDesc_t prDesc)
Guard on the Control Flow from DECISION1 to N2.
Definition of the OutComponent Component of the framework.
void CrPsCmd3s3StartN6(FwPrDesc_t prDesc)
Action for node N6.
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.
#define VER_ILL_SID
Failure Codes of Service 3 (Housekeeping) for Service 1 (Request Verification)
void CrPsCmd3s3StartN3(FwPrDesc_t prDesc)
Action for node N3.
Definition of the OutLoader component.
void SendReqVerifCmdFailRep(FwSmDesc_t smDesc, uint16_t reqVerifCmdFailType, CrPsFailCode_t FailureCode)
Generate a Request Verification Start/Termination Failed out-going report.
P&P Software GmbH, Copyright 2012-2013, All Rights Reserved