##// END OF EJS Templates
Additional files added to the repository
paul@pc-solar1.lab-lpp.local -
r4:ca873e4e03b3 default
parent child
Show More
1 NO CONTENT: new file 100755, binary diff hidden
NO CONTENT: new file 100755, binary diff hidden
@@ -0,0 +1,49
1 <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
2 <CodeBlocks_project_file>
3 <FileVersion major="1" minor="6" />
4 <Project>
5 <Option title="TC_Handler_TEST" />
6 <Option pch_mode="2" />
7 <Option compiler="sparc_gcc_compiler" />
8 <Build>
9 <Target title="Debug">
10 <Option output="bin/Debug/test" prefix_auto="1" extension_auto="1" />
11 <Option object_output="obj/Debug/" />
12 <Option type="1" />
13 <Option compiler="sparc_gcc_compiler" />
14 <Compiler>
15 <Add option="-g" />
16 <Add directory="../src" />
17 <Add directory="../header" />
18 </Compiler>
19 </Target>
20 <Target title="Release">
21 <Option output="bin/Release/TC_Handler_TEST" prefix_auto="1" extension_auto="1" />
22 <Option object_output="obj/Release/" />
23 <Option type="1" />
24 <Option compiler="sparc_gcc_compiler" />
25 <Compiler>
26 <Add option="-O2" />
27 </Compiler>
28 <Linker>
29 <Add option="-s" />
30 </Linker>
31 </Target>
32 </Build>
33 <Compiler>
34 <Add option="-Wall" />
35 </Compiler>
36 <Unit filename="../header/TC_handler.h" />
37 <Unit filename="../header/ccsds_types.h" />
38 <Unit filename="../src/TC_Handler_TEST.c">
39 <Option compilerVar="CC" />
40 </Unit>
41 <Unit filename="../src/TC_handler.c">
42 <Option compilerVar="CC" />
43 </Unit>
44 <Extensions>
45 <code_completion />
46 <debugger />
47 </Extensions>
48 </Project>
49 </CodeBlocks_project_file>
@@ -0,0 +1,14
1 # depslib dependency file v1.0
2 1358260558 source:/opt/DEV_PLE/src/TC_Handler_TEST.c
3 <stdio.h>
4 <stdlib.h>
5 <TC_handler.h>
6
7 1358259104 /opt/DEV_PLE/header/TC_handler.h
8 <ccsds_types.h>
9
10 1358260528 /opt/DEV_PLE/header/ccsds_types.h
11
12 1358257573 source:/opt/DEV_PLE/src/TC_handler.c
13 <TC_handler.h>
14
@@ -0,0 +1,16
1 <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
2 <CodeBlocks_layout_file>
3 <ActiveTarget name="Debug" />
4 <File name="../header/TC_handler.h" open="1" top="0" tabpos="4">
5 <Cursor position="139" topLine="0" />
6 </File>
7 <File name="../header/ccsds_types.h" open="1" top="0" tabpos="2">
8 <Cursor position="822" topLine="18" />
9 </File>
10 <File name="../src/TC_Handler_TEST.c" open="1" top="1" tabpos="5">
11 <Cursor position="8845" topLine="211" />
12 </File>
13 <File name="../src/TC_handler.c" open="1" top="0" tabpos="3">
14 <Cursor position="1979" topLine="54" />
15 </File>
16 </CodeBlocks_layout_file>
1 NO CONTENT: new file 100755, binary diff hidden
NO CONTENT: new file 100755, binary diff hidden
@@ -0,0 +1,29
1 #ifndef FSW_RTEMS_H_INCLUDED
2 #define FSW_RTEMS_H_INCLUDED
3
4 #define REGS_ADDRESS_GPTIMER 0x80000300
5 #define REGS_ADDRESS_SPECTRAL_MATRICES 0x80000700
6
7 #define IRQ_SPECTRAL_MATRICES 9
8 #define IRQ_WAVEFORMS 10
9
10 #define PRINT_MESSAGES_ON_CONSOLE // enable or disable the printf instructions
11 #ifdef PRINT_MESSAGES_ON_CONSOLE
12 #define PRINTF(x) printf(x);
13 #define PRINTF1(x,y) printf(x,y);
14 #define PRINTF2(x,y,z) printf(x,y,z);
15 #else
16 #define PRINTF(x) ;
17 #define PRINTF1(x,y) ;
18 #define PRINTF2(x,y,z) ;
19 #endif
20
21 #define NB_SAMPLES_PER_SNAPSHOT 2048
22 #define NB_BYTES_SWF_BLK 2 * 6
23
24 volatile int waveform_snapshot_f0[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
25 volatile int waveform_snapshot_f1[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
26 volatile int waveform_snapshot_f2[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
27 volatile int waveform_continuous_f3[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_SWF_BLK ]; // 24576 bytes
28
29 #endif // FSW_RTEMS_H_INCLUDED
@@ -0,0 +1,6
1 #ifndef WF_HANDLER_H_INCLUDED
2 #define WF_HANDLER_H_INCLUDED
3
4
5
6 #endif // WF_HANDLER_H_INCLUDED
@@ -0,0 +1,40
1 #ifndef GRLIBREGS_H_INCLUDED
2 #define GRLIBREGS_H_INCLUDED
3
4 struct apbuart_regs_str{
5 volatile unsigned int data;
6 volatile unsigned int status;
7 volatile unsigned int ctrl;
8 volatile unsigned int scaler;
9 volatile unsigned int fifoDebug;
10 };
11
12 struct gptimer_regs_str
13 {
14 volatile unsigned int scaler_value;
15 volatile unsigned int scaler_reload;
16 volatile unsigned int conf;
17 volatile unsigned int unused0;
18 volatile unsigned int timer1_counter;
19 volatile unsigned int timer1_reload;
20 volatile unsigned int timer1_ctrl;
21 volatile unsigned int unused1;
22 volatile unsigned int timer2_counter;
23 volatile unsigned int timer2_reload;
24 volatile unsigned int timer2_ctrl;
25 volatile unsigned int unused2;
26 volatile unsigned int timer3_counter;
27 volatile unsigned int timer3_reload;
28 volatile unsigned int timer3_ctrl;
29 volatile unsigned int unused3;
30 };
31 typedef struct gptimer_regs_str gptimer_regs_t;
32
33 struct spectral_matrices_regs_str{
34 volatile int ctrl;
35 volatile int address0;
36 volatile int address1;
37 };
38 typedef struct spectral_matrices_regs_str spectral_matrices_regs_t;
39
40 #endif // GRLIBREGS_H_INCLUDED
@@ -0,0 +1,298
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <TC_handler.h>
4
5 char *errorCCSDSMsg[8] = { "ILLEGAL_APID 0",
6 "WRONG_LEN_PACKET 1",
7 "INCOR_CHECKSUM 2",
8 "ILL_TYPE 3",
9 "ILL_SUBTYPE 4",
10 "WRONG_APP_DATA 5",
11 "WRONG_CMD_CODE 6",
12 "CCSDS_TM_VALID 7"
13 };
14
15 char *tmGeneratorMsg[2] = { "NOTHING_TO_DO",
16 "TM_GENERATED"
17 };
18
19 void test_TC_handler(){
20 ccsdsTelecommandPacket_t TCPacketToCheck;
21 unsigned char result;
22 unsigned char CRCAsTwoBytes[2] = {0, 0};
23 unsigned char *ccsdsContent;
24 unsigned int i = 0;
25 unsigned int length = 0;
26 unsigned int packetLengthField = 0;
27
28 printf("\n*** start of test_TC_handler()\n");
29
30 //*******************
31 // TC_LFR_DUMP_PAR TC
32 printf("\n =============> TEST TC_LFR_DUMP_PAR_TC <============\n");
33 length = 12;
34 packetLengthField = length - 6 - 1; // -6 for the header and -1 to meet the definition of PACKET_LENGTH
35 currentTC_LEN_RCV[0] = 0x00;
36 currentTC_LEN_RCV[1] = packetLengthField;
37 //
38 //TCPacketToCheck.targetLogicalAddress = 0xfe;
39 TCPacketToCheck.protocolIdentifier = 0x02;
40 TCPacketToCheck.reserved = 0x00;
41 TCPacketToCheck.userApplication = 0x00;
42 //
43 TCPacketToCheck.packetID[0] = 0x1c;
44 TCPacketToCheck.packetID[1] = 0xcc;
45 TCPacketToCheck.packetSequenceControl[0] = 0xc0;
46 TCPacketToCheck.packetSequenceControl[1] = 0x00;
47 TCPacketToCheck.packetLength[0] = 0x00;
48 TCPacketToCheck.packetLength[1] = packetLengthField;
49 TCPacketToCheck.dataFieldHeader[0] = 0x19; //
50 TCPacketToCheck.dataFieldHeader[1] = 0xb5; // type
51 TCPacketToCheck.dataFieldHeader[2] = 0x1e; // subtype
52 TCPacketToCheck.dataFieldHeader[3] = 0x00; // source ID
53 // no data, the CRC comes immediately after the packet header
54 GetCRCAsTwoBytes((unsigned char*)TCPacketToCheck.packetID, CRCAsTwoBytes, packetLengthField + 5);
55 TCPacketToCheck.dataAndCRC[length-10-2] = CRCAsTwoBytes[0];
56 TCPacketToCheck.dataAndCRC[length-10-1] = CRCAsTwoBytes[1];
57
58 ccsdsContent = (unsigned char*)TCPacketToCheck.packetID;
59 // TEST 1
60 result = TM_checker(&TCPacketToCheck);
61 printf(" => test TC_LFR_DUMP_PAR %s\n", errorCCSDSMsg[result]);
62 // TEST 2
63 TCPacketToCheck.dataFieldHeader[2] = 0x04; // subtype
64 result = TM_checker(&TCPacketToCheck);
65 printf(" => test TC_LFR_DUMP_PAR (with wrong subtype) %s\n", errorCCSDSMsg[result]);
66 // TEST 3
67 TCPacketToCheck.dataFieldHeader[2] = 0x1e; // subtype
68 result = TM_checker(&TCPacketToCheck);
69 printf(" => test TC_LFR_DUMP_PAR %s\n", errorCCSDSMsg[result]);
70 // TEST 4
71 TCPacketToCheck.packetLength[1] = 49; // length
72 result = TM_checker(&TCPacketToCheck);
73 printf(" => test TC_LFR_DUMP_PAR (with wrong length) %s\n", errorCCSDSMsg[result]);
74 // TEST 5
75 TCPacketToCheck.packetLength[1] = packetLengthField; // length
76 TCPacketToCheck.dataAndCRC[0] = 0;
77 result = TM_checker(&TCPacketToCheck);
78 printf(" => test TC_LFR_DUMP_PAR (with wrong CRC) %s\n", errorCCSDSMsg[result]);
79
80 //*******************
81 // TC_LFR_UPDATE_INFO
82 printf("\n =============> TEST TC_LFR_UPDATE_INFO <============\n");
83 length = 50;
84 packetLengthField = length - 6 - 1; // -6 for the header and -1 to meet the definition of PACKET_LENGTH
85 currentTC_LEN_RCV[0] = 0x00;
86 currentTC_LEN_RCV[1] = packetLengthField;
87 //
88 //TCPacketToCheck.targetLogicalAddress = 0xfe;
89 TCPacketToCheck.protocolIdentifier = 0x02;
90 TCPacketToCheck.reserved = 0x00;
91 TCPacketToCheck.userApplication = 0x00;
92 //
93 TCPacketToCheck.packetID[0] = 0x1c;
94 TCPacketToCheck.packetID[1] = 0xcc;
95 TCPacketToCheck.packetSequenceControl[0] = 0xc0;
96 TCPacketToCheck.packetSequenceControl[1] = 0x00;
97 TCPacketToCheck.packetLength[0] = 0x00;
98 TCPacketToCheck.packetLength[1] = packetLengthField;
99 TCPacketToCheck.dataFieldHeader[0] = 0x19; //
100 TCPacketToCheck.dataFieldHeader[1] = 0xb5; // type
101 TCPacketToCheck.dataFieldHeader[2] = 0x32; // subtype
102 TCPacketToCheck.dataFieldHeader[3] = 0x00; // source ID
103 // no data, the CRC comes immediately after the packet header
104 for (i=0; i<length-12; i++) TCPacketToCheck.dataAndCRC[i] = 0;
105 GetCRCAsTwoBytes((unsigned char*)TCPacketToCheck.packetID, CRCAsTwoBytes, packetLengthField + 5);
106 TCPacketToCheck.dataAndCRC[packetLengthField-3-2] = CRCAsTwoBytes[0];
107 TCPacketToCheck.dataAndCRC[packetLengthField-3-1] = CRCAsTwoBytes[1];
108
109 ccsdsContent = (unsigned char*)TCPacketToCheck.packetID;
110 // TEST 1
111 result = TM_checker(&TCPacketToCheck);
112 printf(" => test TC_LFR_UPDATE_INFO %s\n", errorCCSDSMsg[result]);
113 // TEST 2
114 TCPacketToCheck.dataFieldHeader[2] = 0x05; // subtype
115 result = TM_checker(&TCPacketToCheck);
116 printf(" => test TC_LFR_UPDATE_INFO (with wrong subtype) %s\n", errorCCSDSMsg[result]);
117 // TEST 3
118 TCPacketToCheck.dataFieldHeader[2] = 0x32; // subtype
119 result = TM_checker(&TCPacketToCheck);
120 printf(" => test TC_LFR_UPDATE_INFO %s\n", errorCCSDSMsg[result]);
121 // TEST 4
122 TCPacketToCheck.packetLength[1] = 49; // length
123 result = TM_checker(&TCPacketToCheck);
124 printf(" => test TC_LFR_UPDATE_INFO (invalid length) %s\n", errorCCSDSMsg[result]);
125 // TEST 5
126 TCPacketToCheck.packetLength[1] = packetLengthField; // length reset to the right value
127 TCPacketToCheck.dataAndCRC[0] = TCPacketToCheck.dataAndCRC[0]+1; // introduce error in the CRC
128 result = TM_checker(&TCPacketToCheck);
129 printf(" => test TC_LFR_UPDATE_INFO (wrong CRC) %s\n", errorCCSDSMsg[result]);
130 // TEST 6
131 currentTC_LEN_RCV[1] = 0; // introduce error in the receive packet length
132 GetCRCAsTwoBytes((unsigned char*)TCPacketToCheck.packetID, CRCAsTwoBytes, packetLengthField + 5);
133 TCPacketToCheck.dataAndCRC[packetLengthField-3-2] = CRCAsTwoBytes[0];
134 TCPacketToCheck.dataAndCRC[packetLengthField-3-1] = CRCAsTwoBytes[1];
135 result = TM_checker(&TCPacketToCheck);
136 printf(" => test TC_LFR_UPDATE_INFO (LEN RCV != SIZE) %s\n", errorCCSDSMsg[result]);
137 // TEST 6
138 currentTC_LEN_RCV[1] = packetLengthField; // introduce error in the receive packet length
139 result = TM_checker(&TCPacketToCheck);
140 printf(" => test TC_LFR_UPDATE_INFO %s\n", errorCCSDSMsg[result]);
141
142 printf("*** end of test_TC_handler()\n");
143 }
144
145 void test_GetCRC(){
146 unsigned char indata[2];
147 unsigned char indata0[3];
148 unsigned char indata1[4];
149 unsigned char indata2[6];
150 unsigned char indata3[10];
151 unsigned char crcAsTwoBytes[2];
152
153 printf("\n*** start of test_GetCRC()\n");
154
155 indata[0] = 0x00;
156 indata[1] = 0x00;
157 GetCRCAsTwoBytes(indata, crcAsTwoBytes, 2);
158 printf("crc is %x %x, should be 0x1d 0x0f\n", crcAsTwoBytes[0], crcAsTwoBytes[1]);
159
160 indata0[0] = 0x00;
161 indata0[1] = 0x00;
162 indata0[2] = 0x00;
163 GetCRCAsTwoBytes(indata0, crcAsTwoBytes, 3);
164 printf("crc is %x %x, should be 0xcc 0x9c\n", crcAsTwoBytes[0], crcAsTwoBytes[1]);
165
166 indata1[0] = 0xab;
167 indata1[1] = 0xcd;
168 indata1[2] = 0xef;
169 indata1[3] = 0x01;
170 GetCRCAsTwoBytes(indata1, crcAsTwoBytes, 4);
171 printf("crc is %x %x, should be 0x04 0xa2\n", crcAsTwoBytes[0], crcAsTwoBytes[1]);
172
173 indata2[0] = 0x14;
174 indata2[1] = 0x56;
175 indata2[2] = 0xf8;
176 indata2[3] = 0x9a;
177 indata2[4] = 0x00;
178 indata2[5] = 0x01;
179 GetCRCAsTwoBytes(indata2, crcAsTwoBytes, 6);
180 printf("crc is %x %x, should be 0x7f 0xd5\n", crcAsTwoBytes[0], crcAsTwoBytes[1]);
181
182 indata3[0] = 0x1c;
183 indata3[1] = 0xcc;
184 indata3[2] = 0xc0;
185 indata3[3] = 0x00;
186 indata3[4] = 0x00;
187 indata3[5] = 0x0c;
188 indata3[6] = 0x19; //
189 indata3[7] = 0xb5; // type
190 indata3[8] = 0x1e; // subtype
191 indata3[9] = 0x00; // source ID
192 GetCRCAsTwoBytes(indata3, crcAsTwoBytes, 10);
193 printf("crc is %x %x\n", crcAsTwoBytes[0], crcAsTwoBytes[1]);
194
195 printf("*** end of test_GetCRC()\n");
196 }
197
198 void test_TM_acceptance_generator()
199 {
200 unsigned char result = 0;
201 unsigned char code = 0;
202 unsigned char CRCAsTwoBytes[2] = {0,0};
203 unsigned char * ccsdsContent;
204 unsigned int length = 0;
205 unsigned int packetLengthField = 0;
206 ccsdsTelemetryPacket_t TMPacket;
207 ccsdsTelecommandPacket_t TCPacket;
208
209 //*******************
210 // TC_LFR_DUMP_PAR TC
211 length = 12;
212 packetLengthField = length - 6 - 1; // -6 for the header and -1 to meet the definition of PACKET_LENGTH
213 currentTC_LEN_RCV[0] = 0x00;
214 currentTC_LEN_RCV[01] = packetLengthField;
215 //
216 //TCPacket.targetLogicalAddress = 0xfe;
217 TCPacket.protocolIdentifier = 0x02;
218 TCPacket.reserved = 0x00;
219 TCPacket.userApplication = 0x00;
220 //
221 TCPacket.packetID[0] = 0x1c;
222 TCPacket.packetID[1] = 0xcc;
223 TCPacket.packetSequenceControl[0] = 0xc0;
224 TCPacket.packetSequenceControl[1] = 0x00;
225 TCPacket.packetLength[0] = 0x00;
226 TCPacket.packetLength[1] = packetLengthField;
227 TCPacket.dataFieldHeader[0] = 0x19; //
228 TCPacket.dataFieldHeader[1] = 0xb5; // type
229 TCPacket.dataFieldHeader[2] = 0x1e; // subtype
230 TCPacket.dataFieldHeader[3] = 0x00; // source ID
231 // no data, the CRC comes immediately after the packet header
232 GetCRCAsTwoBytes((unsigned char*)TCPacket.packetID, CRCAsTwoBytes, packetLengthField + 5);
233 TCPacket.dataAndCRC[length-10-2] = CRCAsTwoBytes[0];
234 TCPacket.dataAndCRC[length-10-1] = CRCAsTwoBytes[1];
235
236 ccsdsContent = (unsigned char*)TCPacket.packetID;
237 // TEST 1
238 code = TM_checker(&TCPacket);
239 result = TM_acceptance_generator(&TCPacket, code, &TMPacket);
240 printf(" => TEST 1\n");
241 printf(" => test TC_LFR_DUMP_PAR %s\n", errorCCSDSMsg[code]);
242 printf(" => result %s\n", tmGeneratorMsg[result]);
243 // TEST 2
244 TCPacket.dataFieldHeader[2] = 0x04; // subtype
245 code = TM_checker(&TCPacket);
246 result = TM_acceptance_generator(&TCPacket, code, &TMPacket);
247 printf(" => TEST 2\n");
248 printf(" => test TC_LFR_DUMP_PAR (with wrong subtype) %s\n", errorCCSDSMsg[code]);
249 printf(" => result %s\n", tmGeneratorMsg[result]);
250 // TEST 3
251 TCPacket.dataFieldHeader[2] = 0x1e; // subtype
252 code = TM_checker(&TCPacket);
253 result = TM_acceptance_generator(&TCPacket, code, &TMPacket);
254 printf(" => TEST 2\n");
255 printf(" => test TC_LFR_DUMP_PAR %s\n", errorCCSDSMsg[code]);
256 printf(" => result %s\n", tmGeneratorMsg[result]);
257 // TEST 4
258 TCPacket.packetLength[1] = 49; // length
259 code = TM_checker(&TCPacket);
260 result = TM_acceptance_generator(&TCPacket, code, &TMPacket);
261 printf(" => TEST 4\n");
262 printf(" => test TC_LFR_DUMP_PAR (invalid length) %s\n", errorCCSDSMsg[code]);
263 printf(" => result %s\n", tmGeneratorMsg[result]);
264 // TEST 5
265 TCPacket.packetLength[1] = packetLengthField; // length
266 TCPacket.dataAndCRC[0] = 0;
267 code = TM_checker(&TCPacket);
268 result = TM_acceptance_generator(&TCPacket, code, &TMPacket);
269 printf(" => TEST 5\n");
270 printf(" => test TC_LFR_DUMP_PAR (with wrong CRC) %s\n", errorCCSDSMsg[code]);
271 printf(" => result %s\n", tmGeneratorMsg[result]);
272 printf(" => received CRC: [%x, %x], should be [%x, %x]\n",
273 TCPacket.dataAndCRC[0], TCPacket.dataAndCRC[1],
274 currentTC_COMPUTED_CRC[0], TCPacket.dataAndCRC[1]);
275 // TEST 6
276 GetCRCAsTwoBytes((unsigned char*)TCPacket.packetID, CRCAsTwoBytes, packetLengthField + 5);
277 TCPacket.dataAndCRC[length-10-2] = CRCAsTwoBytes[0]; // restore the CRC
278 currentTC_LEN_RCV[1] = 1; // put error in the received packet length
279 code = TM_checker(&TCPacket);
280 result = TM_acceptance_generator(&TCPacket, code, &TMPacket);
281 printf(" => TEST 6\n");
282 printf(" => test TC_LFR_DUMP_PAR (RCV LEN != SIZE FIELD) %s\n", errorCCSDSMsg[code]);
283 printf(" => result: %s\n", tmGeneratorMsg[result]);
284 printf(" => RCV LEN: [%x, %x], should be [%x, %x]\n",
285 currentTC_LEN_RCV[0], currentTC_LEN_RCV[1],
286 TCPacket.packetLength[0], TCPacket.packetLength[1]);
287 }
288
289 int main()
290 {
291 InitLookUpTableForCRC();
292
293 //test_GetCRC();
294 //test_TC_handler();
295 test_TM_acceptance_generator();
296
297 return 0;
298 }
1 NO CONTENT: new file 100644
NO CONTENT: new file 100644
1 NO CONTENT: new file 100644
NO CONTENT: new file 100644
General Comments 0
You need to be logged in to leave comments. Login now