Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

DC_PUSDumpMemoryAbsolute.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // DC_PUSDumpMemoryAbsolute.cpp 00005 // 00006 // Version 1.0 00007 // Date 4.01.04 00008 // Author A. Pasetti (P&P Software) 00009 00010 #include "../GeneralInclude/CompilerSwitches.h" 00011 #include "../GeneralInclude/DebugSupport.h" 00012 #include "../GeneralInclude/ClassId.h" 00013 #include "../GeneralInclude/Constants.h" 00014 #include "DC_PUSDumpMemoryAbsolute.h" 00015 #include "../Telemetry/CC_TelemetryManager.h" 00016 #include "../Telemetry/CC_TelemetryPacketFactory.h" 00017 #include "../Telemetry/DC_PUSMemoryDumpOffset.h" 00018 #include "../Telemetry/DC_PUSMemoryDumpAbsolute.h" 00019 #include "../Data/DataPool.h" 00020 00021 #include <string.h> 00022 00023 DC_PUSDumpMemoryAbsolute::DC_PUSDumpMemoryAbsolute(void) { 00024 setClassId(ID_PUSDUMPMEMORYABSOLUTE); 00025 setSubType(PUS_ST_TC_DMP_ABS); 00026 } 00027 00028 TD_ActionOutcome DC_PUSDumpMemoryAbsolute::doAction(void) { 00029 assert( isObjectConfigured() ); 00030 00031 CC_TelemetryPacketFactory* pFct = CC_TelemetryPacketFactory::getInstance(); 00032 unsigned int offset; 00033 00034 // recover the number of blocks 00035 offset = sizeof(TD_PUSMemId)+sizeof(TD_PUSMemData*); 00036 TD_PUSNumberMemBlocks numberBlocks; 00037 memcpy(&numberBlocks,data+offset,sizeof(TD_PUSNumberMemBlocks)); 00038 00039 // compute the length of the fixed part of the telemetry packet 00040 unsigned int fixedLength; 00041 fixedLength = sizeof(TD_PUSMemId)+sizeof(TD_PUSNumberMemBlocks); 00042 00043 // compute the length of the data part of the telemetry packet 00044 unsigned int t = fixedLength+sizeof(TD_PUSMemData*); 00045 unsigned int dataLength = 0; 00046 for (TD_PUSNumberMemBlocks i=0; i<numberBlocks; i++) { 00047 TD_PUSMemLength blockLength; 00048 memcpy(&blockLength,data+t,sizeof(TD_PUSMemLength)); 00049 dataLength = dataLength+blockLength; 00050 t = t+sizeof(TD_PUSMemData*); 00051 } 00052 00053 // compute the total length of the telemery packet 00054 unsigned int packetLength = fixedLength+dataLength+ 00055 numberBlocks*(sizeof(TD_PUSMemData*)+sizeof(TD_PUSMemLength)+sizeof(unsigned short)); 00056 00057 // performa a consistency check: the number of blocks must be consistent with the 00058 // length of the application data 00059 if ( numberData!=(fixedLength+numberBlocks*(sizeof(TD_PUSMemData*)+sizeof(TD_PUSMemLength))) ) 00060 return APP_DATA_INCONSISTENT; 00061 00062 // recover the telemetry packet from the telemetry factory 00063 DC_PUSMemoryDumpOffset* pPck = pFct->allocatePUSMemoryDumpOffset(numberBlocks,packetLength); 00064 if ( pPck==pNULL ) 00065 return PACKET_NOT_FOUND; 00066 00067 //configure the telemetry packet 00068 pPck->setNumberBlocks(numberBlocks); 00069 offset = sizeof(TD_PUSMemId)+sizeof(TD_PUSMemData*)+sizeof(TD_PUSNumberMemBlocks); 00070 for (TD_PUSNumberMemBlocks i=0; i<numberBlocks; i++) { 00071 TD_PUSMemData* startAddress; 00072 memcpy(&startAddress,data+offset,sizeof(TD_PUSMemData*)); 00073 offset = offset + sizeof(TD_PUSMemData*); 00074 TD_PUSMemLength blockLength; 00075 memcpy(&blockLength,data+offset,sizeof(TD_PUSMemLength)); 00076 offset = offset + sizeof(TD_PUSMemLength); 00077 pPck->defineBlock(i,startAddress,blockLength); 00078 } 00079 00080 // Load the telemetry packet in the telemetry manager 00081 if ( !pTmManager->isImmediateQueueFull() ) { 00082 pPck->setInUse(NOT_IN_USE); 00083 return TM_MAN_QUEUE_FULL; 00084 } else 00085 pTmManager->sendTelemetryPacket(pPck); 00086 00087 return ACTION_SUCCESS; 00088 } 00089
Copyright 2003 P&P Software GmbH - All Rights Reserved