CORDET Framework - C2 Implementation
CrPsCmd3SidStartFunc.c
Go to the documentation of this file.
1 
25 #include "CrPsCmd3SidStartCreate.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 CrFwCounterU4_t i, iSidFail, iMax;
57 CrPsSid_t currentSid;
58 
59 
60 /* ----------------------------------------------------------------------------------------------------------------- */
61 
63 void CrPsCmd3SidStartN1(FwPrDesc_t prDesc)
64 {
65  CrFwCmpData_t *cmpData;
66  CrFwInCmdData_t *cmpSpecificData;
67  CrFwPckt_t pckt;
68  FwSmDesc_t smDesc;
69  prDescMultiSidCmdStart_t *prDataPtr;
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  servSubType = CrFwPcktGetServSubType(pckt);
86 
87  switch(servSubType)
88  {
90  currentSid = getHkEnableCmdRepStrucIdItem(pckt, i+1);
91  iMax = getHkEnableCmdN(pckt);
92  break;
94  currentSid = getHkEnableCmdRepStrucIdItem(pckt, i+1);
95  iMax = getHkEnableCmdN(pckt);
96  break;
97 
99  currentSid = getHkDisableCmdRepStrucIdItem(pckt, i+1);
100  iMax = getHkDisableCmdN(pckt);
101  break;
103  currentSid = getHkDisableCmdRepStrucIdItem(pckt, i+1);
104  iMax = getHkDisableCmdN(pckt);
105  break;
106 
108  currentSid = getHkRepStructCmdRepStrucIdItem(pckt, i+1);
109  iMax = getHkRepStructCmdN(pckt);
110  break;
112  currentSid = getHkRepStructCmdRepStrucIdItem(pckt, i+1);
113  iMax = getHkRepStructCmdN(pckt);
114  break;
115 
117  currentSid = getHkOneShotCmdRepStrucIdItem(pckt, i+1);
118  iMax = getHkOneShotCmdN(pckt);
119  break;
121  currentSid = getHkOneShotCmdRepStrucIdItem(pckt, i+1);
122  iMax = getHkOneShotCmdN(pckt);
123  break;
124 
125  default:
126  currentSid = 0;
127  iMax = 1;
128  break;
129  }
130 
131  return;
132 }
133 
135 void CrPsCmd3SidStartN2(FwPrDesc_t prDesc)
136 {
137  CRFW_UNUSED(prDesc);
138  /*Load invalid SID in data pool item verFailData */
139 
140  iSidFail++;
141  setDpverFailData((CrPsFailData_t)currentSid);
142 
143  return;
144 }
145 
147 void CrPsCmd3SidStartN3(FwPrDesc_t prDesc)
148 {
149  FwSmDesc_t smDesc;
150  prDescMultiSidCmdStart_t *prDataPtr;
151 
152  /* Run Command Verification Failure Procedure to generate (1,4) report with failure code VER_ILL_SID */
153  /* Get smDesc from prData */
154  prDataPtr = FwPrGetData(prDesc);
155  smDesc = prDataPtr->smDesc;
156 
158 
159  return;
160 }
161 
163 void CrPsCmd3SidStartN4(FwPrDesc_t prDesc)
164 {
165  CrFwCmpData_t *cmpData;
166  CrFwInCmdData_t *cmpSpecificData;
167  CrFwPckt_t pckt;
168  FwSmDesc_t smDesc;
169  prDescMultiSidCmdStart_t *prDataPtr;
171 
172  /*Increment i */
173  i++;
174 
175  /* Get smDesc from prData */
176  prDataPtr = FwPrGetData(prDesc);
177  smDesc = prDataPtr->smDesc;
178 
179  /* Get in data */
180  cmpData = (CrFwCmpData_t*)FwSmGetData(smDesc);
181  cmpSpecificData = (CrFwInCmdData_t *) cmpData->cmpSpecificData;
182  pckt = cmpSpecificData->pckt;
183 
184  servSubType = CrFwPcktGetServSubType(pckt);
185 
186  switch(servSubType)
187  {
189  currentSid = getHkEnableCmdRepStrucIdItem(pckt, i+1);
190  break;
192  currentSid = getHkEnableCmdRepStrucIdItem(pckt, i+1);
193  break;
194 
196  currentSid = getHkDisableCmdRepStrucIdItem(pckt, i+1);
197  break;
199  currentSid = getHkDisableCmdRepStrucIdItem(pckt, i+1);
200  break;
201 
203  currentSid = getHkRepStructCmdRepStrucIdItem(pckt, i+1);
204  break;
206  currentSid = getHkRepStructCmdRepStrucIdItem(pckt, i+1);
207  break;
208 
210  currentSid = getHkOneShotCmdRepStrucIdItem(pckt, i+1);
211  break;
213  currentSid = getHkOneShotCmdRepStrucIdItem(pckt, i+1);
214  break;
215 
216  default: /*TODO (01.02.2018) can not be reached because(N1 maxsid is set to 1 !)*/
217  currentSid = 0;
218  break;
219  }
220 
221  return;
222 }
223 
225 void CrPsCmd3SidStartN7(FwPrDesc_t prDesc)
226 {
227  prDescMultiSidCmdStart_t *prDataPtr;
228  CrFwCmpData_t *cmpData;
229  FwSmDesc_t smDesc;
230 
231  /*Set action outcome to 'success' */
232  /* Get smDesc from OutCmp */
233  prDataPtr = FwPrGetData(prDesc);
234  smDesc = prDataPtr->smDesc;
235 
236  /* Set outcome in InCmd prData to 'success' */
237  cmpData = (CrFwCmpData_t*) FwSmGetData(smDesc);
238  cmpData->outcome = 1;
239  FwSmSetData(smDesc, cmpData);
240 
241  return;
242 }
243 
245 void CrPsCmd3SidStartN8(FwPrDesc_t prDesc)
246 {
247  prDescMultiSidCmdStart_t *prDataPtr;
248  CrFwCmpData_t *cmpData;
249  FwSmDesc_t smDesc;
250 
251  /*Set action outcome to 'failure' with failure code VER_SID_START_FD */
252  /* Get smDesc from OutCmp */
253  prDataPtr = FwPrGetData(prDesc);
254  smDesc = prDataPtr->smDesc;
255 
256  /* Set outcome in InCmd prData to 'failure' */
257  cmpData = (CrFwCmpData_t*) FwSmGetData(smDesc);
258  cmpData->outcome = VER_SID_START_FD;
259  FwSmSetData(smDesc, cmpData);
260 
261  return;
262 }
263 
264 /**************/
265 /*** GUARDS ***/
266 /**************/
267 
269 FwPrBool_t CrPsCmd3SidStartG1(FwPrDesc_t prDesc)
270 {
271  CrPsSid_t rdlSid, rdlSlot;
272 
273  CRFW_UNUSED(prDesc);
274  /*The i-th SID is not in the RDL */
275 
276  /* look for the slot */
277  for (rdlSlot = 0; rdlSlot < HK_N_REP_DEF; rdlSlot++)
278  {
279  rdlSid = getDpsidItem(rdlSlot);
280 
281  if (currentSid == rdlSid)
282  break;
283  }
284 
285  /* sid not found in list */
286  if (rdlSlot == HK_N_REP_DEF)
287  {
288  return 1;
289  }
290  else
291  {
292  return 0;
293  }
294 }
295 
297 FwPrBool_t CrPsCmd3SidStartG2(FwPrDesc_t prDesc)
298 {
299  CRFW_UNUSED(prDesc);
300 
301  /*The i-th SID was the last SID in the command*/
302  if (i == iMax-1)
303  {
304  return 1;
305  }
306  else
307  {
308  return 0;
309  }
310 }
311 
313 FwPrBool_t CrPsCmd3SidStartG3(FwPrDesc_t prDesc)
314 {
315  CRFW_UNUSED(prDesc);
316 
317  /*All SIDs in the command are invalid */
318  if (iSidFail == iMax)
319  {
320  return 1;
321  }
322  else
323  {
324  return 0;
325  }
326 }
327 
328 /* ----------------------------------------------------------------------------------------------------------------- */
329 
void CrPsCmd3SidStartN4(FwPrDesc_t prDesc)
Action for node N4.
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.
#define CRPS_HK_DISABLE_PERIODICDIAG_CMD
Subtype identifier of the Housekeeping Disable Periodic Generation of a Diagnostic Parameter Report S...
void CrPsCmd3SidStartN8(FwPrDesc_t prDesc)
Action for node N8.
static CrFwServSubType_t servSubType
Service sub-type.
void CrPsCmd3SidStartN1(FwPrDesc_t prDesc)
Action for node N1.
Interface through which applications can initialize and execute framework PUS extension components...
void CrPsCmd3SidStartN2(FwPrDesc_t prDesc)
Action for node N2.
#define CRFW_UNUSED(x)
A macro that can be used to specify that a function parameter is not used.
Definition: CrFwConstants.h:27
CrPsSid_t getHkOneShotCmdRepStrucIdItem(void *p, CrFwCounterU4_t N)
Get "RepStrucId" from "HkOneShotCmd" packet.
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 CrPsCmd3SidStartG2(FwPrDesc_t prDesc)
Guard on the Control Flow from DECISION3 to DECISION4.
Create one instance of the CrPsCmd3SidStart procedure.
Interface for accessing data pool items.
Definition of the OutFactory component.
CrFwPckt_t pckt
Packet holding the InCommand.
static CrFwCounterU4_t getHkEnableCmdN(void *p)
Get "N" from "HkEnableCmd" packet.
Header file to define all service and packet identifiers.
Interface for creating and accessing a report or command packet.
static void setDpverFailData(CrPsFailData_t verFailData)
Sets the value of the datapool item verFailData.
Header file to define all invariant publicly available constants and types for the CORDET Framework...
CrPsSid_t getHkDisableCmdRepStrucIdItem(void *p, CrFwCounterU4_t N)
Get "RepStrucId" from "HkDisableCmd" 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".
void CrPsCmd3SidStartN3(FwPrDesc_t prDesc)
Action for node N3.
FwPrBool_t CrPsCmd3SidStartG3(FwPrDesc_t prDesc)
Guard on the Control Flow from DECISION4 to N8.
Interface for accessing data pool items.
CrPsSid_t getHkRepStructCmdRepStrucIdItem(void *p, CrFwCounterU4_t N)
Get "RepStrucId" from "HkRepStructCmd" packet.
static CrFwCounterU4_t getHkOneShotCmdN(void *p)
Get "N" from "HkOneShotCmd" packet.
CrPsSid_t getHkEnableCmdRepStrucIdItem(void *p, CrFwCounterU4_t N)
Get "RepStrucId" from "HkEnableCmd" packet.
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.
CrFwCounterU4_t i
CrPsCmd3SidStart function definitions.
#define CRPS_REQVERIF_START_FAIL
Subtype identifier of the Request Verification Start Failed out-going report packet.
#define CRPS_HK_ENABLE_PERIODICDIAG_CMD
Subtype identifier of the Housekeeping Enable Periodic Generation of a Diagnostic Parameter Report St...
FwPrBool_t CrPsCmd3SidStartG1(FwPrDesc_t prDesc)
Guard on the Control Flow from DECISION1 to N2.
static CrFwCounterU4_t getHkRepStructCmdN(void *p)
Get "N" from "HkRepStructCmd" packet.
#define CRPS_HK_DIAGONESHOT_CMD
Subtype identifier of the Housekeeping Generate One-Shot Report for Diagnostic Parameters command pac...
CrFwServSubType_t CrFwPcktGetServSubType(CrFwPckt_t pckt)
Return the service sub-type of the command or report encapsulated in a packet.
void CrPsCmd3SidStartN7(FwPrDesc_t prDesc)
Action for node N7.
#define HK_N_REP_DEF
Number of Report Definitions in the Report Definition List (maximum number of housekeeping/diagnostic...
#define CRPS_HK_DISABLE_PERIODICHK_CMD
Subtype identifier of the Housekeeping Disable Periodic Generation of a Housekeeping Parameter Report...
uint8_t CrPsSid_t
Type used for the Parameter Report Structure ID of a packet.
#define CRPS_HK_HKONESHOT_CMD
Subtype identifier of the Housekeeping Generate One-Shot Report for Housekeeping Parameters command p...
char * CrFwPckt_t
Type for packets (see CrFwPckt.h).
Definition: CrFwConstants.h:36
static CrFwCounterU4_t getHkDisableCmdN(void *p)
Get "N" from "HkDisableCmd" packet.
Definition of the OutComponent Component of the framework.
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 CRPS_HK_DIAGREP_STRUCT_CMD
Subtype identifier of the Housekeeping Report Diagnostic Parameter Report Structure command packet...
#define VER_ILL_SID
Failure Codes of Service 3 (Housekeeping) for Service 1 (Request Verification)
Definition of the OutLoader component.
#define CRPS_HK_HKREP_STRUCT_CMD
Subtype identifier of the Housekeeping Report Housekeeping Parameter Report Structure command packet...
void SendReqVerifCmdFailRep(FwSmDesc_t smDesc, uint16_t reqVerifCmdFailType, CrPsFailCode_t FailureCode)
Generate a Request Verification Start/Termination Failed out-going report.
#define CRPS_HK_ENABLE_PERIODICHK_CMD
Subtype identifier of the Housekeeping Enable Periodic Generation of a Housekeeping Parameter Report ...
P&P Software GmbH, Copyright 2012-2013, All Rights Reserved