CORDET Framework - C2 Implementation
CrPsLptUpCmdStartFunc.c
Go to the documentation of this file.
1 
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 <CrPsUtilitiesServLpt.h>
44 #include <DataPool/CrPsDpServLpt.h>
48 
49 #include <stdlib.h>
50 #include <time.h>
51 
52 CrPsTid_t Tid;
53 
54 
55 /* ----------------------------------------------------------------------------------------------------------------- */
56 
58 void CrPsLptUpCmdStartN1(FwPrDesc_t prDesc)
59 {
60  CrFwCmpData_t *cmpData;
61  CrFwInCmdData_t *cmpSpecificData;
62  CrFwPckt_t pckt;
63  FwSmDesc_t smDesc;
64 
65  /* Determine the identifier of the LPT Buffer */
66 
67  /* Get smDesc from OutCmp */
68  smDesc = FwPrGetData(prDesc);
69 
70  /* Get inPckt */
71  cmpData = (CrFwCmpData_t*) FwSmGetData(smDesc);
72  cmpSpecificData = (CrFwInCmdData_t *) cmpData->cmpSpecificData;
73  pckt = cmpSpecificData->pckt;
74 
75  Tid = getLptUpInterCmdTid(pckt);
76 
77  return;
78 }
79 
81 void CrPsLptUpCmdStartN2(FwPrDesc_t prDesc)
82 {
83  CrFwCmpData_t *cmpData;
84  FwSmDesc_t smDesc;
85 
86  /* Set action outcome to 'Failure' */
87 
88  /* Get smDesc from OutCmp */
89  smDesc = FwPrGetData(prDesc);
90 
91  /* Set outcome in InCmd prData to 'failure' */
92  cmpData = (CrFwCmpData_t*) FwSmGetData(smDesc);
93  cmpData->outcome = 0;
94  FwSmSetData(smDesc, cmpData);
95 
96  return;
97 }
98 
100 void CrPsLptUpCmdStartN3(FwPrDesc_t prDesc)
101 {
102  uint32_t LptBufferId;
103 
104  CRFW_UNUSED(prDesc);
105 
106  /* Set lptFailCode to PART_NMB_ERR */
107 
108  LptBufferId = Tid % LPT_N_BUF;
109  setDplptFailCodeItem(LptBufferId, PART_NMB_ERR);
110 
111  return;
112 }
113 
115 void CrPsLptUpCmdStartN4(FwPrDesc_t prDesc)
116 {
117  CrFwCmpData_t *cmpData;
118  FwSmDesc_t smDesc;
119 
120  /* Set action outcome to 'Success' */
121 
122  /* Get smDesc from OutCmp */
123  smDesc = FwPrGetData(prDesc);
124 
125  /* Set outcome in InCmd prData to 'success' */
126  cmpData = (CrFwCmpData_t*) FwSmGetData(smDesc);
127  cmpData->outcome = 1;
128  FwSmSetData(smDesc, cmpData);
129 
130  return;
131 }
132 
133 /**************/
134 /*** GUARDS ***/
135 /**************/
136 
138 FwPrBool_t CrPsLptUpCmdStartG1(FwPrDesc_t prDesc)
139 {
140  uint16_t sm_state;
141 
142  CRFW_UNUSED(prDesc);
143 
144  /* LPT State Machine associated to LPT Buffer is not in state UP_TRANSFER */
145 
146  sm_state = FwSmGetCurState(getSmDescLpt());
147  if (sm_state != CrPsLpt_UP_TRANSFER)
148  {
149  return 1;
150  }
151  else
152  {
153  return 0;
154  }
155 }
156 
158 FwPrBool_t CrPsLptUpCmdStartNG2(FwPrDesc_t prDesc)
159 {
160  CrFwCmpData_t *cmpData;
161  CrFwInCmdData_t *cmpSpecificData;
162  CrFwPckt_t pckt;
163  CrPsNumberU4_t PartSeqNmbOld, PartSeqNmb;
164  uint32_t LptBufferId;
165  FwSmDesc_t smDesc;
166 
167  CRFW_UNUSED(prDesc);
168 
169  /* Flag_1 */
170  /* ... is true if the part sequence number of the current up-transfer command
171  is out of sequence with the part sequence number of the previous up-transfer
172  command for this LPT Buffer */
173 
174  LptBufferId = Tid % LPT_N_BUF;
175 
176  /* Get smDesc from OutCmp */
177  smDesc = FwPrGetData(prDesc);
178 
179  /* Get inPckt */
180  cmpData = (CrFwCmpData_t*) FwSmGetData(smDesc);
181  cmpSpecificData = (CrFwInCmdData_t *) cmpData->cmpSpecificData;
182  pckt = cmpSpecificData->pckt;
183 
184  /* Get PartSeqNum to determine memory address */
185  PartSeqNmb = getLptUpFirstCmdPartSeqNmb(pckt);
186 
187  PartSeqNmbOld = getDppartSeqNmbItem(LptBufferId);
188 
189  if (PartSeqNmb != PartSeqNmbOld + 1)
190  {
191  return 1;
192  }
193  else
194  {
195  return 0;
196  }
197 }
198 
199 /* ----------------------------------------------------------------------------------------------------------------- */
200 
Type for the Framework Component Data (FCD).
FwPrBool_t CrPsLptUpCmdStartG1(FwPrDesc_t prDesc)
Guard on the Control Flow from DECISION1 to N2.
CrFwOutcome_t outcome
The outcome of an action or check executed by a state machine or by one of its procedures.
static CrPsNumberU4_t getLptUpFirstCmdPartSeqNmb(void *p)
Get "PartSeqNmb" from "LptUpFirstCmd" packet.
Create one instance of the CrPsLptUpCmdStart procedure.
#define CRFW_UNUSED(x)
A macro that can be used to specify that a function parameter is not used.
Definition: CrFwConstants.h:27
static void setDplptFailCodeItem(int i, CrPsFailCode_t lptFailCode)
Sets the value of the i-th element in the datapool array lptFailCode.
Interface for accessing data pool items.
Definition of the OutFactory component.
CrFwPckt_t pckt
Packet holding the InCommand.
Header file to define all service and packet identifiers.
Interface for creating and accessing a report or command packet.
void CrPsLptUpCmdStartN2(FwPrDesc_t prDesc)
Action for node N2.
Interface through which applications can initialize and execute framework PUS extension components...
void CrPsLptUpCmdStartN1(FwPrDesc_t prDesc)
Action for node N1.
Create one instance of the CrPsLpt state machine.
CrPsTid_t Tid
CrPsLptUpCmdStart function definitions.
void * cmpSpecificData
Derived data which are specific to each type of framework component.
Interface for accessing fields in packets of service "ServLPT".
FwSmDesc_t getSmDescLpt()
Getter for Lpt state machine descriptor.
char * CrFwPckt_t
Type for packets (see CrFwPckt.h).
Definition: CrFwConstants.h:36
Definition of the OutComponent Component of the framework.
static CrFwCounterU4_t getDppartSeqNmbItem(int i)
Gets the value of the i-th element in the datapool array partSeqNmb.
FwPrBool_t CrPsLptUpCmdStartNG2(FwPrDesc_t prDesc)
Guard on the Control Flow from DECISION2 to N3.
void CrPsLptUpCmdStartN4(FwPrDesc_t prDesc)
Action for node N4.
Type for the data describing an InCommand.
static CrPsTid_t getLptUpInterCmdTid(void *p)
Get "Tid" from "LptUpInterCmd" packet.
void CrPsLptUpCmdStartN3(FwPrDesc_t prDesc)
Action for node N3.
Definition of the OutLoader component.
P&P Software GmbH, Copyright 2012-2013, All Rights Reserved