CORDET Framework - C2 Implementation
CrPsLptUpLastCmd.c
Go to the documentation of this file.
1 
24 #include "CrPsLptUpLastCmd.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 
58 void CrPsLptUpLastCmdStartAction(FwSmDesc_t smDesc)
59 {
60  /* Set prData of procedure */
61  /* initial setting of prData */
62  FwPrSetData(getPrDescLptUpCmdStart(), smDesc);
63 
64  FwPrRun(getPrDescLptUpCmdStart());
65 
66  return;
67 }
68 
77 void CrPsLptUpLastCmdProgressAction(FwSmDesc_t smDesc)
78 {
79  CrFwCmpData_t *cmpData;
80  CrFwInCmdData_t *cmpSpecificData;
81  CrFwPckt_t pckt;
82  uint32_t dataSize, pos;
83  uint32_t *lptMemStartAddr;
84  CrPsNumberU4_t PartSeqNmb;
85  CrPsSize_t partSize;
86  CrFwTimeStamp_t ts;
87  time_t coarse;
88  uint16_t fine;
89  CrPsTid_t Tid;
90  uint32_t LptBufferId;
91 
92  /* Get inPckt */
93  cmpData = (CrFwCmpData_t*) FwSmGetData(smDesc);
94  cmpSpecificData = (CrFwInCmdData_t *) cmpData->cmpSpecificData;
95  pckt = cmpSpecificData->pckt;
96 
97  Tid = getLptUpLastCmdTid(pckt);
98  LptBufferId = Tid % LPT_N_BUF;
99 
100  /* Get packet size and calculate amount of data */
101  dataSize = CrFwPcktGetLength(pckt) - (sizeof(TcHeader_t) + sizeof(CrPsTid_t) + sizeof(CrPsNumberU4_t) + CRC_LENGTH);
102 
103  /* Get PartSeqNum to determine memory address */
104  PartSeqNmb = getLptUpFirstCmdPartSeqNmb(pckt);
105 
106  /* Copy the lptSize up-transfer data to LPT Buffer */
107  lptMemStartAddr = getLptMemStartAddr(LptBufferId);
108  partSize = (CR_FW_MAX_PCKT_LENGTH - (sizeof(TcHeader_t) + sizeof(CrPsTid_t) + sizeof(CrPsNumberU4_t) + CRC_LENGTH));
109  pos = sizeof(TcHeader_t)+sizeof(CrPsTid_t) + sizeof(CrPsNumberU4_t);
110  memcpy((uint8_t *)lptMemStartAddr + (PartSeqNmb-1)*partSize, &((uint8_t*)pckt)[pos], dataSize);
111 
112  /* Increment lptSize by the amount of copied data */
113  setDplptSizeItem(LptBufferId, getDplptSizeItem(LptBufferId) + (CrPsSize_t)dataSize);
114 
115  /* Set current time */
117  coarse = (ts.t[0] << 24) | (ts.t[1] << 16) | (ts.t[2] << 8) | ts.t[3];
118  fine = (ts.t[4] << 7) | (ts.t[5] & 0xfe);
119  setDplptTimeItem(LptBufferId, ts);
120 
121  /* Set patSeqNmb to the part sequence number carried by the command */
122  setDppartSeqNmbItem(LptBufferId, PartSeqNmb);
123 
124  /* Send EndUpTransfer command to LPT State Machine */
125  FwSmMakeTrans(getSmDescLpt(), EndUpTransfer);
126 
127  cmpData->outcome = 1;
128 
129  /*TODO*/
130  CRFW_UNUSED(coarse);
131  CRFW_UNUSED(fine);
132 
133  return;
134 }
135 
141 void CrPsLptUpLastCmdTerminationAction(FwSmDesc_t smDesc)
142 {
143  CrFwCmpData_t *inData;
144 
145  /* Set action outcome to 'success' */
146 
147  /* Get in data */
148  inData = (CrFwCmpData_t*)FwSmGetData(smDesc);
149 
150  inData->outcome = 1;
151 
152  return;
153 }
154 
Type for the Framework Component Data (FCD).
static CrPsTid_t getLptUpLastCmdTid(void *p)
Get "Tid" from "LptUpLastCmd" packet.
CrFwOutcome_t outcome
The outcome of an action or check executed by a state machine or by one of its procedures.
FwPrDesc_t getPrDescLptUpCmdStart()
Getter for LptUpCmdStart procedure descriptor.
static CrPsNumberU4_t getLptUpFirstCmdPartSeqNmb(void *p)
Get "PartSeqNmb" from "LptUpFirstCmd" packet.
#define CR_FW_MAX_PCKT_LENGTH
The maximum size in number of bytes of a 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.
void CrPsLptUpLastCmdStartAction(FwSmDesc_t smDesc)
Start action of TC(13,11) LptUpLastCmd.
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.
void CrPsLptUpLastCmdTerminationAction(FwSmDesc_t smDesc)
Termination action of TC(13,11) LptUpLastCmd.
Interface through which applications can initialize and execute framework PUS extension components...
Create one instance of the CrPsLpt state machine.
CrFwPcktLength_t CrFwPcktGetLength(CrFwPckt_t pckt)
Return the length (in number of bytes) of a packet.
CrPsTid_t Tid
CrPsLptUpCmdStart function definitions.
void CrPsLptUpLastCmdProgressAction(FwSmDesc_t smDesc)
Progress action of TC(13,11) LptUpLastCmd.
void * cmpSpecificData
Derived data which are specific to each type of framework component.
Interface for accessing fields in packets of service "ServLPT".
static CrPsSize_t getDplptSizeItem(int i)
Gets the value of the i-th element in the datapool array lptSize.
FwSmDesc_t getSmDescLpt()
Getter for Lpt state machine descriptor.
uint32_t * getLptMemStartAddr(uint32_t LptBuffer)
Getter function for the Address of the Data.
Implementation of TC(13,11) LptUpLastCmd.
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.
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