00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
#include "../GeneralInclude/CompilerSwitches.h"
00011
#include "../GeneralInclude/ClassId.h"
00012
#include "../GeneralInclude/BasicTypes.h"
00013
#include "../GeneralInclude/Constants.h"
00014
#include "../Telemetry/CC_TelemetryPacketFactory.h"
00015
#include "../Telemetry/DC_DummyPUSTelemetryPacket.h"
00016
#include "../Telemetry/DC_BasicPUSTmStream.h"
00017
#include "../Data/DC_SampleFullDataPool.h"
00018
#include "../Utilities/TestCasePUSFull.h"
00019
#include "TestCaseBasicPUSTmStream_1.h"
00020
00021
#include <string.h>
00022
#include <assert.h>
00023
00024 TestCaseBasicPUSTmStream_1::TestCaseBasicPUSTmStream_1(
void) :
00025
TestCaseWithFactories(ID_BASICPUSTMSTREAM*10+1,"
TestCaseBasicPUSTmStream_1") {
00026
return;
00027 }
00028
00029 void TestCaseBasicPUSTmStream_1::runTestCase(
void) {
00030
00031
const unsigned int TM_AREA_SIZE = 50;
00032 tmArea =
new unsigned char[TM_AREA_SIZE];
00033
CC_TelemetryPacketFactory* pTCF =
CC_TelemetryPacketFactory::getInstance();
00034
if ( (pTCF->
getCapacityDummyPUSTelemetryPacket()-
00035 pTCF->
getNumberDummyPUSTelemetryPacket())==0 )
00036 { setTestResult(
TEST_FAILURE,
"No more available TM packets");
00037
return;
00038 }
00039 pTM = pTCF->
allocateDummyPUSTelemetryPacket();
00040
unsigned int nEvt =
getNumberOfEvents();
00041 pTMS =
new DC_BasicPUSTmStream();;
00042
00043
00044
if ( (pTMS->
getClassId() != ID_BASICPUSTMSTREAM) )
00045 { setTestResult(
TEST_FAILURE,
"Wrong class identifier");
00046
return;
00047 }
00048
00049
00050
if ( pTMS->
isObjectConfigured() )
00051 { setTestResult(
TEST_FAILURE,
"Wrong configuration status");
00052
return;
00053 }
00054
00055
00056 pTMS->
setCapacity(TM_AREA_SIZE);
00057
if ( pTMS->
getCapacity()!=TM_AREA_SIZE )
00058 { setTestResult(
TEST_FAILURE,
"Wrong stream capacity");
00059
return;
00060 }
00061
00062
00063 pTMS->
setStartAddress(tmArea);
00064
if ( pTMS->
getStartAddress()!=tmArea )
00065 { setTestResult(
TEST_FAILURE,
"Wrong tm write area address");
00066
return;
00067 }
00068
00069
00070
if ( !pTMS->
isObjectConfigured() )
00071 { setTestResult(
TEST_FAILURE,
"Wrong configuration status");
00072
return;
00073 }
00074
00075
00076
if ( pTMS->
getPacketCounter()!=0 )
00077 { setTestResult(
TEST_FAILURE,
"Wrong packet counter value");
00078
return;
00079 }
00080
00081
00082
unsigned int seqCounter = pTMS->
getSequenceCounter();
00083
00084
00085
unsigned char value = 10;
00086 pTM->
setValue(value);
00087 pTMS->
write(pTM);
00088
if ( !
checkTmImage(1, value) )
00089 { setTestResult(
TEST_FAILURE,
"Incorrect packet image");
00090
return;
00091 }
00092
00093
00094
if ( pTMS->
getPacketCounter()!=1 )
00095 { setTestResult(
TEST_FAILURE,
"Wrong packet counter value");
00096
return;
00097 }
00098
00099
00100
if ( pTMS->
getSequenceCounter()!=seqCounter+1 )
00101 { setTestResult(
TEST_FAILURE,
"Wrong sequence counter value");
00102
return;
00103 }
00104
00105
00106
unsigned int maxNPackets = (TM_AREA_SIZE-1)/(pTM->
getNumberOfBytes()+11+
sizeof(
TD_ObsTime));
00107
00108
00109
for (
unsigned int i=1; i<(maxNPackets+1); i++)
00110 pTMS->
write(pTM);
00111
00112
00113
if ( !verifyLatestEvent(nEvt+1,EVT_TM_STREAM_END) )
00114
return;
00115
00116
00117
if ( pTMS->
getPacketCounter()!=maxNPackets )
00118 { setTestResult(
TEST_FAILURE,
"Wrong packet counter value");
00119
return;
00120 }
00121
00122
00123
if ( pTMS->
getSequenceCounter()!=seqCounter+maxNPackets+1 )
00124 { setTestResult(
TEST_FAILURE,
"Wrong sequence counter value");
00125
return;
00126 }
00127
00128
00129 pTMS->
reset();
00130
if ( pTMS->
getPacketCounter()!=0 )
00131 { setTestResult(
TEST_FAILURE,
"Wrong packet counter value");
00132
return;
00133 }
00134
00135
00136 pTMS->
write(pTM);
00137
if ( pTMS->
getPacketCounter()!=1 )
00138 { setTestResult(
TEST_FAILURE,
"Wrong packet counter value");
00139
return;
00140 }
00141
if (
getNumberOfEvents()!=nEvt+1 )
00142 { setTestResult(
TEST_FAILURE,
"Wrong number of events");
00143
return;
00144 }
00145
00146
00147
for (
unsigned int i=1; i<(maxNPackets+1); i++)
00148 pTMS->
write(pTM);
00149
00150
00151 pTMS->
flush();
00152
if ( pTMS->
getPacketCounter()!=0 )
00153 { setTestResult(
TEST_FAILURE,
"Wrong packet counter value");
00154
return;
00155 }
00156
00157
00158 pTMS->
write(pTM);
00159
if ( pTMS->
getPacketCounter()!=1 )
00160 { setTestResult(
TEST_FAILURE,
"Wrong packet counter value");
00161
return;
00162 }
00163
if (
getNumberOfEvents()!=nEvt+2 )
00164 { setTestResult(
TEST_FAILURE,
"Wrong number of events");
00165
return;
00166 }
00167
00168 setTestResult(
TEST_SUCCESS,
"Test Successful");
00169
return;
00170 }
00171
00172 bool TestCaseBasicPUSTmStream_1::checkTmImage(
unsigned int start,
unsigned char value) {
00173
00174
unsigned short usTemp = 0;
00175
unsigned char ucTemp = 0;
00176
TD_ObsTime otTemp = 0;
00177 assert(
sizeof(
unsigned short)==2);
00178
00179 memcpy(&usTemp,tmArea+start,2);
00180
if ( usTemp!=pTM->
getPacketId() ) {
00181 setTestResult(
TEST_FAILURE,
"Bytes 0 and 1 of header are wrong");
00182
return false;
00183 }
00184
00185 memcpy(&usTemp,tmArea+start+2,2);
00186
if ( usTemp!=0xC0+pTMS->
getSequenceCounter() ) {
00187 setTestResult(
TEST_FAILURE,
"Bytes 2 and 3 of header are wrong");
00188
return false;
00189 }
00190
00191 memcpy(&usTemp,tmArea+start+4,2);
00192
if ( usTemp!=3+
sizeof(
TD_ObsTime)+pTM->
getNumberOfBytes()+2 ) {
00193 setTestResult(
TEST_FAILURE,
"Bytes 4 and 5 of header are wrong");
00194
return false;
00195 }
00196
00197 memcpy(&ucTemp,tmArea+start+6,1);
00198
if ( ucTemp!=0x10 ) {
00199 setTestResult(
TEST_FAILURE,
"Byte 1 of data field is wrong");
00200
return false;
00201 }
00202
00203 memcpy(&ucTemp,tmArea+start+7,1);
00204
if ( ucTemp!=pTM->
getType() ) {
00205 setTestResult(
TEST_FAILURE,
"Byte 2 of data field is wrong");
00206
return false;
00207 }
00208
00209 memcpy(&ucTemp,tmArea+start+8,1);
00210
if ( ucTemp!=pTM->
getSubType() ) {
00211 setTestResult(
TEST_FAILURE,
"Byte 3 of data field is wrong");
00212
return false;
00213 }
00214
00215 memcpy(&otTemp,tmArea+start+9,
sizeof(
TD_ObsTime));
00216
if ( otTemp!=pTM->
getTimeTag() ) {
00217 setTestResult(
TEST_FAILURE,
"Time field is wrong");
00218
return false;
00219 }
00220
00221 memcpy(&ucTemp,tmArea+start+9+
sizeof(
TD_ObsTime),1);
00222
if ( usTemp!=value ) {
00223 setTestResult(
TEST_FAILURE,
"Application data field is wrong");
00224
return false;
00225 }
00226
00227 memcpy(&usTemp,tmArea+start+9+
sizeof(
TD_ObsTime)+1,2);
00228
if ( usTemp!=(
unsigned short)0 ) {
00229 setTestResult(
TEST_FAILURE,
"Error control field is wrong");
00230
return false;
00231 }
00232
00233
return true;
00234 }
00235