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

DC_PUSDumpMemoryOffset.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // DC_PUSDumpMemoryOffset.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_PUSDumpMemoryOffset.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_PUSDumpMemoryOffset::DC_PUSDumpMemoryOffset(void) { 00024 setClassId(ID_PUSDUMPMEMORYOFFSET); 00025 setSubType(PUS_ST_TC_DMP_OFF); 00026 } 00027 00028 TD_ActionOutcome DC_PUSDumpMemoryOffset::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_PUSMemData*)+sizeof(TD_PUSNumberMemBlocks); 00042 00043 // compute the length of the data part of the telemetry packet 00044 unsigned int t = fixedLength+sizeof(TD_PUSMemOffset); 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_PUSMemOffset); 00051 } 00052 00053 // compute the total length of the telemery packet 00054 unsigned int packetLength = fixedLength+dataLength+numberBlocks* 00055 (sizeof(TD_PUSMemOffset)+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_PUSMemOffset)+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); 00070 TD_PUSMemData* base; 00071 memcpy(&base,data+offset,sizeof(TD_PUSMemData*)); 00072 pPck->setBaseAddress(base); 00073 offset = sizeof(TD_PUSMemId)+sizeof(TD_PUSMemData*)+sizeof(TD_PUSNumberMemBlocks); 00074 for (TD_PUSNumberMemBlocks i=0; i<numberBlocks; i++) { 00075 TD_PUSMemOffset blockOffset; 00076 memcpy(&blockOffset,data+offset,sizeof(TD_PUSMemOffset)); 00077 offset = offset + sizeof(TD_PUSMemOffset); 00078 TD_PUSMemData* startAddress = base+blockOffset; 00079 TD_PUSMemLength blockLength; 00080 memcpy(&blockLength,data+offset,sizeof(TD_PUSMemLength)); 00081 offset = offset + sizeof(TD_PUSMemLength); 00082 pPck->defineBlock(i,startAddress,blockLength); 00083 } 00084 00085 // Load the telemetry packet in the telemetry manager 00086 if ( !pTmManager->isImmediateQueueFull() ) { 00087 pPck->setInUse(NOT_IN_USE); 00088 return TM_MAN_QUEUE_FULL; 00089 } else 00090 pTmManager->sendTelemetryPacket(pPck); 00091 00092 return ACTION_SUCCESS; 00093 } 00094
Copyright 2003 P&P Software GmbH - All Rights Reserved