CORDET Framework - C2 Implementation
CrPsLptUpFirstCmd.c
Go to the documentation of this file.
1 
24 #include "CrPsLptUpFirstCmd.h"
25 
26 /* CrFramework includes */
27 #include <Pckt/CrFwPckt.h>
29 #include <OutCmp/CrFwOutCmp.h>
31 #include <CrFwCmpData.h>
32 
33 /* FwProfile includes */
34 #include "FwSmConstants.h"
35 #include "FwSmConfig.h"
36 #include "FwSmCore.h"
37 #include "FwPrDCreate.h"
38 #include "FwPrConfig.h"
39 #include "FwPrCore.h"
40 #include "FwPrConstants.h"
41 
42 #include <CrPsUtilitiesServLpt.h>
47 #include <CrPsUserConstants.h>
48 #include <DataPool/CrPsDpServLpt.h>
49 
50 #include <time.h>
51 
52 unsigned int UpTransferLptBufferId;
53 
54 
64 void CrPsLptUpFirstCmdStartAction(FwSmDesc_t smDesc)
65 {
66  CrFwCmpData_t *cmpData;
67  CrFwInCmdData_t *cmpSpecificData;
68  CrFwPckt_t pckt;
69  CrPsTid_t Tid;
70  uint32_t LptBufferId;
71  CrPsNumberU4_t PartSeqNmb;
72 
73  /* Get inPckt */
74  cmpData = (CrFwCmpData_t*) FwSmGetData(smDesc);
75  cmpSpecificData = (CrFwInCmdData_t *) cmpData->cmpSpecificData;
76  pckt = cmpSpecificData->pckt;
77 
78  Tid = getLptUpFirstCmdTid(pckt);
79 
80  LptBufferId = Tid % LPT_N_BUF;
81 
82  /* Set UpTransferLptBufferId for current Up Transfer */
83  UpTransferLptBufferId = LptBufferId;
84 
85  PartSeqNmb = getLptUpFirstCmdPartSeqNmb(pckt);
86 
87  /*TODO*/
88  CRFW_UNUSED(PartSeqNmb);
89 
90  return;
91 }
92 
101 void CrPsLptUpFirstCmdProgressAction(FwSmDesc_t smDesc)
102 {
103  CrFwCmpData_t *cmpData;
104  CrFwInCmdData_t *cmpSpecificData;
105  CrFwPckt_t pckt;
106  uint32_t dataSize, pos;
107  uint32_t *lptMemStartAddr;
108  uint32_t LptBufferId;
109  CrFwTimeStamp_t ts;
110  time_t coarse;
111  uint16_t fine;
112 
113  /* Send command StartUpTransfer to LPT State Machine */
114  FwSmMakeTrans(getSmDescLpt(), StartUpTransfer);
115 
116  LptBufferId = UpTransferLptBufferId;
117 
118  /* Get inPckt */
119  cmpData = (CrFwCmpData_t*) FwSmGetData(smDesc);
120  cmpSpecificData = (CrFwInCmdData_t *) cmpData->cmpSpecificData;
121  pckt = cmpSpecificData->pckt;
122 
123  /* Get packet size and calculate amount of data */
124  dataSize = CrFwPcktGetLength(pckt) - (sizeof(TcHeader_t) + sizeof(CrPsTid_t) + sizeof(CrPsNumberU4_t) + CRC_LENGTH);
125 
126  /* Copy the up-transfer data to LPT Buffer */
127  lptMemStartAddr = getLptMemStartAddr(LptBufferId);
128  pos = sizeof(TcHeader_t)+sizeof(CrPsTid_t) + sizeof(CrPsNumberU4_t);
129  memcpy((uint8_t *)lptMemStartAddr, &((uint8_t*)pckt)[pos], dataSize);
130 
131  /* Set lptSize to be equal to the amount of copied data */
132  setDplptSizeItem(LptBufferId, (CrPsSize_t)dataSize);
133 
134  /* Set lptTime to the current time */
136  coarse = (ts.t[0] << 24) | (ts.t[1] << 16) | (ts.t[2] << 8) | ts.t[3];
137  fine = (ts.t[4] << 7) | (ts.t[5] & 0xfe);
138  setDplptTimeItem(LptBufferId, ts);
139 
140  /* Set partSeqNmb to 1 */
141  setDppartSeqNmbItem(LptBufferId, 1);
142 
143  /* Set lptSrc to the source of the command */
144  setDplptSrcItem(LptBufferId, CrFwPcktGetSrc(pckt));
145 
146  /*TODO*/
147  CRFW_UNUSED(coarse);
148  CRFW_UNUSED(fine);
149 
150  return;
151 }
152 
158 void CrPsLptUpFirstCmdTerminationAction(FwSmDesc_t smDesc)
159 {
160  CrFwCmpData_t *inData;
161 
162  /* Set action outcome to 'success' */
163 
164  /* Get in data */
165  inData = (CrFwCmpData_t*)FwSmGetData(smDesc);
166 
167  inData->outcome = 1;
168 
169  return;
170 }
171 
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.
Implementation of TC(13,9) LptUpFirstCmd.
static CrPsNumberU4_t getLptUpFirstCmdPartSeqNmb(void *p)
Get "PartSeqNmb" from "LptUpFirstCmd" packet.
#define CRFW_UNUSED(x)
A macro that can be used to specify that a function parameter is not used.
Definition: CrFwConstants.h:27
#define CRC_LENGTH
The length of CRC.
Interface for accessing data pool items.
Header file to define all user-configurable constants and types for the IASW Application.
Definition of the OutFactory component.
CrFwPckt_t pckt
Packet holding the InCommand.
static void setDplptSizeItem(int i, CrPsSize_t lptSize)
Sets the value of the i-th element in the datapool array lptSize.
Header file to define all service and packet identifiers.
static void setDplptTimeItem(int i, CrFwTimeStamp_t lptTime)
Sets the value of the i-th element in the datapool array lptTime.
Interface for creating and accessing a report or command packet.
Interface through which applications can initialize and execute framework PUS extension components...
Create one instance of the CrPsLpt state machine.
static CrPsTid_t getLptUpFirstCmdTid(void *p)
Get "Tid" from "LptUpFirstCmd" packet.
CrFwPcktLength_t CrFwPcktGetLength(CrFwPckt_t pckt)
Return the length (in number of bytes) of a packet.
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.
uint32_t * getLptMemStartAddr(uint32_t LptBuffer)
Getter function for the Address of the Data.
void CrPsLptUpFirstCmdTerminationAction(FwSmDesc_t smDesc)
Termination action of TC(13,9) LptUpFirstCmd.
void CrPsLptUpFirstCmdProgressAction(FwSmDesc_t smDesc)
Progress action of TC(13,9) LptUpFirstCmd.
char * CrFwPckt_t
Type for packets (see CrFwPckt.h).
Definition: CrFwConstants.h:36
Definition of the OutComponent Component of the framework.
auxiliary Interface for accessing fields in packets of service "ServLPT".
Type for the data describing an InCommand.
static void setDppartSeqNmbItem(int i, CrFwCounterU4_t partSeqNmb)
Sets the value of the i-th element in the datapool array partSeqNmb.
void CrPsLptUpFirstCmdStartAction(FwSmDesc_t smDesc)
Start action of TC(13,9) LptUpFirstCmd.
static void setDplptSrcItem(int i, CrPsDestSrc_t lptSrc)
Sets the value of the i-th element in the datapool array lptSrc.
Definition of the OutLoader component.
CrFwTimeStamp_t CrFwGetCurrentTimeServer()
Provide the current time.
unsigned int CrFwTimeStamp_t
Type used for the time stamp of a command or report.
P&P Software GmbH, Copyright 2012-2013, All Rights Reserved