sd 32 update
Dependencies: FreescaleIAP mbed-rtos mbed
Fork of COM_MNG_TMTC_SIMPLE by
COM_MNG_TMTC.h
00001 // 8 Jul 00002 // did flowchart of states 00003 00004 // handle sd card with cdms team 00005 00006 // Jun 6 00007 // WHAT IS TC exec code in L1 ack ? 00008 00009 //Jan 7 00010 //added RLY_TMTC function 00011 //added included related files 00012 00013 #include "pinconfig.h" 00014 #include "i2c.h" 00015 #include "Flash.h" 00016 #include "cdms_rtc.h" 00017 00018 DigitalIn tm_status_4m_slv(PIN39); //I2C interrupt to CDMS from BAE 00019 //DigitalIn tm_status_4m_pl(PIN61); //I2C interrupt to CDMS from PL 00020 00021 uint8_t received = 0; 00022 uint16_t mid1; 00023 uint16_t mid2; 00024 uint16_t Nbytes; 00025 uint32_t Data[2]; 00026 uint16_t nbytes; 00027 uint8_t flash_counter = 0; 00028 uint16_t crc16; 00029 uint16_t mid; 00030 uint32_t block; 00031 00032 #define delete_TC(tc_ptr) {\ 00033 if(tc_ptr == gHEAD_NODE_TCL){\ 00034 gHEAD_NODE_TCL = tc_ptr->next_TC;\ 00035 }\ 00036 delete tc_ptr;\ 00037 } 00038 00039 #define print_all_tm(tm_ptr_head){\ 00040 Base_tm *temp_tm_ptr = tm_ptr_head;\ 00041 while( temp_tm_ptr != NULL ){\ 00042 int length = TM_SHORT_SIZE;\ 00043 if( GETshort_or_long_tm(temp_tm_ptr->fields) == SHORT_TM_CODE ){\ 00044 length = TM_SHORT_SIZE;\ 00045 }\ 00046 else{\ 00047 length = TM_LONG_SIZE;\ 00048 }\ 00049 for(int i = 0 ; i < length ; ++i){\ 00050 gPC.putc(temp_tm_ptr->TM_string[i]);\ 00051 }\ 00052 temp_tm_ptr = temp_tm_ptr->next_TM;\ 00053 }\ 00054 /*snd_tm.head_pointer(tm_ptr_head);*/\ 00055 } 00056 00057 #define delete_all_tm(tm_ptr_head){\ 00058 /*DELETE THE TM AFTER USE*/\ 00059 Base_tm *temp_tm_ptr = tm_ptr_head;\ 00060 int overflowCountExecute = 0;\ 00061 while(temp_tm_ptr != NULL){\ 00062 if( overflowCountExecute < TM_OVERFLOW_CONSTANT ){\ 00063 Base_tm *temp = temp_tm_ptr->next_TM;\ 00064 delete temp_tm_ptr;\ 00065 temp_tm_ptr = temp;\ 00066 ++overflowCountExecute;\ 00067 }\ 00068 else{\ 00069 /*PENDING: RESET CDMS*/\ 00070 break;\ 00071 }\ 00072 }\ 00073 } 00074 00075 // typeof tm_ptr: Base_tm 00076 // typeof tc_ptr: Base_tc 00077 // typeof temp_xxxx: uint8_t 00078 #define fill_l1_ack(tm_ptr) {\ 00079 uint8_t temp8;\ 00080 tm_ptr->next_TM = NULL;\ 00081 temp8 = TMID_ACK_L1;\ 00082 PUTtmid(tm_ptr->fields, temp8);\ 00083 temp8 = SHORT_TM_CODE;\ 00084 PUTshort_or_long_tm(tm_ptr->fields, temp8);\ 00085 tm_ptr->TM_string[0] = TMID_ACK_L1 << 4;\ 00086 /*PENDING: PA TEMPERATURE*/\ 00087 tm_ptr->TM_string[1] = gTOTAL_INCORRECT_SIZE_TC & 0xFF;\ 00088 tm_ptr->TM_string[2] = gTOTAL_CRC_FAIL_TC & 0xFF;\ 00089 } 00090 00091 #define put_crc_l1_ack(tm_ptr) {\ 00092 tm_ptr->TM_string[2] = gTOTAL_CRC_FAIL_TC & 0xFF;\ 00093 /*TC LIST STATUS*/\ 00094 tm_ptr->TM_string[3] |= (gMASTER_STATE << 5) & 0xE0;\ 00095 /*PA HOT*/\ 00096 if( gFLAGS & COM_PA_HOT_FLAG ){\ 00097 tm_ptr->TM_string[3] |= (1 << 4);\ 00098 }\ 00099 else{\ 00100 tm_ptr->TM_string[3] &= ~(1 << 4);\ 00101 }\ 00102 uint16_t crc_checksum = crc16_gen(tm_ptr->TM_string, TM_SHORT_SIZE-2);\ 00103 tm_ptr->TM_string[TM_SHORT_SIZE-2] = (crc_checksum >> 8) & 0xFF;\ 00104 tm_ptr->TM_string[TM_SHORT_SIZE-1] = crc_checksum & 0xFF;\ 00105 } 00106 00107 #define detect_ack(tm_ptr, temp_ack, tc_psc) {\ 00108 if( tm_ptr != NULL ){\ 00109 int length = TM_SHORT_SIZE;\ 00110 if( GETshort_or_long_tm(tm_ptr->fields) == SHORT_TM_CODE ){\ 00111 length = TM_SHORT_SIZE;\ 00112 }\ 00113 else{\ 00114 length = TM_LONG_SIZE;\ 00115 }\ 00116 uint16_t crc = crc16_gen(tm_ptr->TM_string, length-2);\ 00117 if( (((crc & 0xFF00) >> 8) == tm_ptr->TM_string[length-2]) && ( (crc & 0x00FF) == tm_ptr->TM_string[length-1] ) ){\ 00118 uint8_t temp8;\ 00119 temp8 = tm_ptr->TM_string[TM_ACK_CODE_INDEX];\ 00120 temp8 = temp8 & 0xE0;\ 00121 if( (temp8 == 0xC0) || (temp8 == 0xA0) )\ 00122 temp_ack = 0x01;\ 00123 else{\ 00124 temp_ack = 0x00;\ 00125 /*CHECK FOR NACK CODE: CRC FAIL NACK*/\ 00126 temp8 = tm_ptr->TM_string[TM_ACK_CODE_INDEX];\ 00127 temp8 = temp8 & 0x0F;\ 00128 if( temp8 == CRC_FAIL_NACK_CODE ){\ 00129 tm_ptr->TM_string[2] = tc_psc;\ 00130 }\ 00131 }\ 00132 }\ 00133 else\ 00134 temp_ack = 0x00;\ 00135 }\ 00136 else{\ 00137 temp_ack = 0x00;\ 00138 }\ 00139 } 00140 00141 #define isit_obosc(tc_ptr, temp_obosc) {\ 00142 temp_obosc = 0x00;\ 00143 if( GETapid(tc_ptr) == APID_COM ){\ 00144 if( ((tc_ptr->TC_string[2]) >> 4) == SERVICE_OBOSC ){\ 00145 temp_obosc = 0x01;\ 00146 }\ 00147 }\ 00148 } 00149 00150 #define isit_sdcard(tc_ptr, temp_sdcard) {\ 00151 temp_sdcard = 0x00;\ 00152 if( GETapid(tc_ptr) == APID_COM ){\ 00153 if( ( (tc_ptr->TC_string[2]) >> 4) == SERVICE_OBSRS ){\ 00154 temp_sdcard = 0x01;\ 00155 }\ 00156 }\ 00157 } 00158 00159 #define isPAhot(returnHere){\ 00160 /*PENDING : COMPLETE THIS FUNCTION*/\ 00161 returnHere = 0xFF;\ 00162 } 00163 00164 void after_cooling_pa(){ 00165 gCOM_MNG_TMTC_THREAD->signal_set(COM_MNG_TMTC_SIGNAL_UART_INT); 00166 } 00167 00168 /* 00169 @brief: check for missing tc, also check crc, i.e. 00170 if true execution can be started else have to wait 00171 decide the next state 00172 @param: none 00173 @return: bool indicating whether there are missing tc 00174 */ 00175 // PENDING: LAST FRAME BIT 00176 /* 00177 for loop: check for missing tc 00178 if: check for incorrect sized tc 00179 if: check for last frame bit 00180 */ 00181 #define continueToExecute(returnHere) {\ 00182 uint8_t tempReturn = 0x00;\ 00183 /*search for missing psc*/\ 00184 for(uint8_t p = 0x00 ; p < (gTOTAL_VALID_TC) ; ++p){\ 00185 bool flag = false;\ 00186 Base_tc *node_ptr = gHEAD_NODE_TCL;\ 00187 while(node_ptr != NULL){\ 00188 if( (GETpacket_seq_count(node_ptr) == p) && (GETcrc_pass(node_ptr) == 1) ){\ 00189 flag = true;\ 00190 break;\ 00191 }\ 00192 else{\ 00193 node_ptr = node_ptr->next_TC;\ 00194 }\ 00195 }\ 00196 if(flag == false){\ 00197 tempReturn = 0x02;\ 00198 break;\ 00199 }\ 00200 }\ 00201 /*search for last packet bit*/\ 00202 tempReturn = tempReturn + 0x01;\ 00203 Base_tc *tcp = gHEAD_NODE_TCL;\ 00204 while(tcp != NULL){\ 00205 if(GETpacket_seq_count(tcp) == (gTOTAL_VALID_TC - 1)){\ 00206 if( ( (tcp->TC_string[1]) & 0x20 ) == 0x20 ){\ 00207 tempReturn = tempReturn - 0x01;\ 00208 }\ 00209 break;\ 00210 }\ 00211 tcp = tcp->next_TC;\ 00212 }\ 00213 returnHere = tempReturn;\ 00214 /*UPDATE gMASTER STATE*/\ 00215 if( (returnHere == 0x00) ){\ 00216 if( (gMASTER_STATE == TCL_STATE_INCOMPLETE) || (gMASTER_STATE == TCL_STATE_COMPLETED) || (gMASTER_STATE == TCL_STATE_ABORTED) ){\ 00217 gMASTER_STATE = TCL_STATE_EXECUTING;\ 00218 }\ 00219 }\ 00220 else{\ 00221 if( (gMASTER_STATE == TCL_STATE_INCOMPLETE) || (gMASTER_STATE == TCL_STATE_COMPLETED) ){\ 00222 gMASTER_STATE = TCL_STATE_INCOMPLETE;\ 00223 }\ 00224 }\ 00225 } 00226 00227 /* 00228 return 1 if code match 00229 return 0 if code mismatch 00230 */ 00231 #define GScodeVerification(returnHere){\ 00232 Base_tc *testTC = gHEAD_NODE_TCL;\ 00233 uint16_t overflowCount = 0;\ 00234 returnHere = 0xFF;\ 00235 while( (overflowCount < TCL_OVERFLOW_CONSTANT) && (testTC != NULL) ){\ 00236 if( (GETpacket_seq_count(testTC) == PSC_CALLSIGN) && (GETapid(testTC) == APID_CALLSIGN) ){\ 00237 /*uint8_t temp8 = testTC->TC_string[1];*/\ 00238 if( true ){\ 00239 for( int i = 2 ; i <= 8 ; ++i ){\ 00240 if( testTC->TC_string[i] != gGSCODE[i-2] ){\ 00241 returnHere = 0;\ 00242 break;\ 00243 }\ 00244 }\ 00245 }\ 00246 break;\ 00247 }\ 00248 testTC = testTC->next_TC;\ 00249 ++overflowCount;\ 00250 }\ 00251 } 00252 00253 /* 00254 @brief: DELETE THE CRC FAILED TC FROM THE LIST TO FREE-UP MEMORY AND UPDATE 00255 THE TOTAL VALID TC AND GENERATE L1_ACK_TM 00256 @param: none 00257 @return: none 00258 */ 00259 /*tm_ptr is the next_TM of a linked list, and should have the value NULL, i.e. tm_ptr should be the next_TM pointer of thte last node */ 00260 #define get_ack_l1( tm_ptr ){\ 00261 Base_tc *current_TC = gHEAD_NODE_TCL;\ 00262 Base_tm *l1_ack = new Short_tm;\ 00263 /*APPEND TO THE tm_ptr HERE*/\ 00264 tm_ptr = l1_ack;\ 00265 fill_l1_ack(l1_ack);\ 00266 int TC_count = 0;\ 00267 int overflowCountL1 = 0;\ 00268 while(current_TC != NULL){\ 00269 if( overflowCountL1 < TCL_OVERFLOW_CONSTANT ){\ 00270 /*IF CRC PASS*/\ 00271 if( (GETcrc_pass(current_TC) == 1) ){\ 00272 if(TC_count > 4){\ 00273 /*PENDING: FILL TC_EXEC_CODE, APPEND CRC TO THE TM*/\ 00274 put_crc_l1_ack( l1_ack );\ 00275 /*extend the TM linked list*/\ 00276 TC_count = 0;\ 00277 l1_ack->next_TM = new Short_tm;\ 00278 l1_ack = l1_ack->next_TM;\ 00279 fill_l1_ack(l1_ack);\ 00280 }\ 00281 /*PSC starts from 7th byte*/\ 00282 l1_ack->TM_string[6+TC_count] = GETpacket_seq_count(current_TC);\ 00283 /*TC exec status*/\ 00284 switch(TC_count){\ 00285 case 0:\ 00286 l1_ack->TM_string[3] = (GETexec_status(current_TC)) & 0x0F;\ 00287 break;\ 00288 case 1:\ 00289 l1_ack->TM_string[4] = (GETexec_status(current_TC) << 4) & 0xF0;\ 00290 break;\ 00291 case 2:\ 00292 l1_ack->TM_string[4] |= (GETexec_status(current_TC)) & 0x0F;\ 00293 break;\ 00294 case 3:\ 00295 l1_ack->TM_string[5] = (GETexec_status(current_TC) << 4) & 0xF0;\ 00296 break;\ 00297 case 4:\ 00298 l1_ack->TM_string[5] |= (GETexec_status(current_TC)) & 0x0F;\ 00299 }\ 00300 ++TC_count;\ 00301 }\ 00302 current_TC = current_TC->next_TC;\ 00303 ++overflowCountL1;\ 00304 }\ 00305 else{\ 00306 /*PENDING: RESET CDMS*/\ 00307 break;\ 00308 }\ 00309 }\ 00310 /*FILL UP THE REMAINING FIELDS WITH 0x00 as PSC, AND 0xF as tc exec status*/\ 00311 if( (TC_count < 5) && (TC_count != 0) ){\ 00312 while(TC_count < 5){\ 00313 l1_ack->TM_string[6+TC_count] = 0x00;\ 00314 switch(TC_count){\ 00315 case 1:\ 00316 l1_ack->TM_string[4] = 0xF0;\ 00317 break;\ 00318 case 2:\ 00319 l1_ack->TM_string[4] |= 0x0F;\ 00320 break;\ 00321 case 3:\ 00322 l1_ack->TM_string[5] = 0xF0;\ 00323 break;\ 00324 case 4:\ 00325 l1_ack->TM_string[5] |= 0x0F;\ 00326 }\ 00327 ++TC_count;\ 00328 }\ 00329 }\ 00330 put_crc_l1_ack(l1_ack);\ 00331 } 00332 00333 /*tm_ptr is the next_TM of a linked list, and should have the value NULL, i.e. tm_ptr should be the next_TM pointer of thte last node */ 00334 #define get_tc_list(tm_ptr, thePSC){\ 00335 uint8_t TM_PSC = 0xFF;\ 00336 uint8_t TC_PSC = thePSC;\ 00337 int overflowCount = 0;\ 00338 uint8_t TC_LIST_TAG = 0x00;\ 00339 Base_tc *temp_tc = gHEAD_NODE_TCL;\ 00340 bool first_time = true;\ 00341 Base_tm *current_tm = NULL;\ 00342 while( temp_tc != NULL ){\ 00343 if( overflowCount < TCL_OVERFLOW_CONSTANT ){\ 00344 TM_PSC = TM_PSC + 1;\ 00345 /*Increment TM_PSC for every new TM pointer created*/\ 00346 Base_tm *temp_tm = new Long_tm;\ 00347 temp_tm->next_TM = NULL;\ 00348 uint8_t temp8 = LONG_TM_CODE;\ 00349 PUTshort_or_long_tm(temp_tm->fields, temp8);\ 00350 temp8 = TMID_TCL;\ 00351 PUTtmid((temp_tm->fields), temp8);\ 00352 temp_tm->TM_string[0] = 0x38;\ 00353 /*Frame type(1) = 0; TMID = 0111; Spare = 000*/\ 00354 temp_tm->TM_string[1] = TC_PSC;\ 00355 temp_tm->TM_string[3] = TM_PSC;\ 00356 int indexCustom = 4, num_of_short_tc = 0;\ 00357 while(temp_tc != NULL){\ 00358 if( overflowCount < TCL_OVERFLOW_CONSTANT ){\ 00359 if( GETshort_or_long_tc(temp_tc) == SHORT_TC_CODE ){\ 00360 for( int i = 0 ; i < TC_SHORT_SIZE ; ++i ){\ 00361 temp_tm->TM_string[indexCustom + i] = temp_tc->TC_string[i];\ 00362 }\ 00363 indexCustom = indexCustom + TC_SHORT_SIZE;\ 00364 ++overflowCount;\ 00365 /*INCREMENT STUFF*/\ 00366 temp_tc = temp_tc->next_TC;\ 00367 num_of_short_tc = num_of_short_tc + 1;\ 00368 if (temp_tc == NULL){\ 00369 for (int i = indexCustom ; i < TM_LONG_SIZE-2 ; ++i){\ 00370 temp_tm->TM_string[i] = 0;\ 00371 /*Fill remaining values with 0*/\ 00372 }\ 00373 TC_LIST_TAG = num_of_short_tc;\ 00374 break;\ 00375 }\ 00376 if( (GETshort_or_long_tc(temp_tc) == LONG_TC_CODE) || (num_of_short_tc == OBOSC_TCL_MAX_SHORT_SIZE) ){\ 00377 /*Next TC is long or memory is filled*/\ 00378 for(int i = indexCustom; i < TM_LONG_SIZE-2 ; ++i){\ 00379 temp_tm->TM_string[i] = 0;\ 00380 /*Fill remaining values with 0*/\ 00381 }\ 00382 TC_LIST_TAG = num_of_short_tc;\ 00383 break;\ 00384 }\ 00385 }\ 00386 else if (TC_LIST_TAG == OBOSC_TCL_TAG_LONG_FIRST_HALF){\ 00387 /*Long TC, 2nd half*/\ 00388 for (int i = 0; i < OBOSC_LONG_TC_SECOND_HALF_SIZE ; ++i){\ 00389 temp_tm->TM_string[indexCustom + i] = temp_tc->TC_string[OBOSC_LONG_TC_FIRST_HALF_SIZE + i];\ 00390 /*Fill the TM with TC_values*/\ 00391 }\ 00392 for (int i = OBOSC_LONG_TC_SECOND_HALF_SIZE + indexCustom ; i < TM_LONG_SIZE-2 ; ++i ){\ 00393 temp_tm->TM_string[i] = 0;\ 00394 /*Fill remaining values with 0*/\ 00395 }\ 00396 temp_tc = temp_tc->next_TC;\ 00397 TC_LIST_TAG = OBOSC_TCL_TAG_LONG_SECOND_HALF;\ 00398 ++overflowCount;\ 00399 break;\ 00400 }\ 00401 else{\ 00402 /*Long TC, 1st half */\ 00403 for (int i = 0; i < OBOSC_LONG_TC_FIRST_HALF_SIZE; ++i){\ 00404 /*gPC.printf("indexCustom = %d\r\n", indexCustom);*/\ 00405 temp_tm->TM_string[indexCustom + i] = temp_tc->TC_string[i];\ 00406 /*Fill the TM with TC_values*/\ 00407 }\ 00408 for (int i = OBOSC_LONG_TC_FIRST_HALF_SIZE + indexCustom ; i < TM_LONG_SIZE-2 ; ++i ){\ 00409 temp_tm->TM_string[i] = 0;\ 00410 /*Fill remaining values with 0*/\ 00411 }\ 00412 TC_LIST_TAG = OBOSC_TCL_TAG_LONG_FIRST_HALF;\ 00413 break;\ 00414 }\ 00415 }\ 00416 else{\ 00417 /*PENDING: reset cdms*/\ 00418 break;\ 00419 }\ 00420 }\ 00421 temp_tm->TM_string[2] = TC_LIST_TAG;\ 00422 /*TC_LIST_TAG as is updated in the inner while loop*/\ 00423 uint16_t crc16 = crc16_gen(temp_tm->TM_string, TM_LONG_SIZE-2);\ 00424 temp_tm->TM_string[TM_LONG_SIZE-2] = (crc16 & 0xFF00) >> 8 ;\ 00425 temp_tm->TM_string[TM_LONG_SIZE-1] = crc16 & 0x00FF;\ 00426 /*Attach this new node to the TM linked list*/\ 00427 if( first_time ){\ 00428 first_time = false;\ 00429 tm_ptr = temp_tm;\ 00430 current_tm = temp_tm;\ 00431 }\ 00432 else{\ 00433 current_tm->next_TM = temp_tm;\ 00434 current_tm = current_tm->next_TM;\ 00435 }\ 00436 /*Attach this new node at the end*/\ 00437 }\ 00438 else{\ 00439 /*PENDING: reset CDMS*/\ 00440 break;\ 00441 }\ 00442 }\ 00443 } 00444 00445 // CDMS TEAM CODE START 00446 inline Base_tm* FCTN_CDMS_RLY_TMTC(Base_tc *tc_ptr){ 00447 uint8_t ACKCODE = 0x00; 00448 printf("\rTC execution in progress\r\n"); 00449 Base_tm *tm_pointer = new Long_tm; 00450 Base_tm *tm_ptr = tm_pointer; 00451 received = 0; 00452 switch(GETapid(tc_ptr)) 00453 { 00454 case 1: //apid=01 implies it corresponds to bae 00455 { 00456 printf("Telecommand is for BAE\r\n"); 00457 printf("Sending TC to BAE...\r\n"); //interrupt to be sent to the bae 00458 FCTN_I2C_WRITE((char*)tc_ptr->TC_string); 00459 while(1) 00460 { 00461 wait(1); //TimeOut instead of wait 00462 if(tm_status_4m_slv == 1) 00463 { 00464 printf("receiving...\r\n"); 00465 FCTN_I2C_READ((char*)tm_pointer->TM_string); 00466 //printf("%s", tm_pointer->TM_string); 00467 received+=1; 00468 tm_pointer = tm_pointer->next_TM; 00469 break; //only for testing purpose 00470 } 00471 else 00472 { 00473 break; 00474 } 00475 } 00476 if(received >= 1 ) 00477 { 00478 printf("Telemetry is received from BAE\r\n"); 00479 Base_tm *tm_print = tm_ptr; 00480 for(uint8_t i=0;i<received;i++) 00481 { 00482 printf("%s", tm_print->TM_string); 00483 tm_print = tm_print->next_TM; //for check 00484 } 00485 received = 0; 00486 tm_pointer->next_TM = NULL; return tm_ptr; 00487 } 00488 else 00489 { 00490 printf("Telemetry is not received from BAE\r\n"); 00491 //tm_pointer = new Short_tm; 00492 tm_pointer->TM_string[0] = 0xB0; 00493 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); 00494 tm_pointer->TM_string[2] = 0x01; 00495 tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided 00496 tm_pointer->TM_string[4] = 0x01; 00497 for(uint8_t i=0;i<6;i++) 00498 { 00499 tm_pointer->TM_string[i+5] = 0; 00500 } 00501 crc16 = crc16_gen(tm_ptr->TM_string,11); 00502 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); 00503 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); 00504 tm_pointer->next_TM = NULL; return tm_ptr; 00505 } 00506 break; 00507 } 00508 case 2: 00509 { 00510 printf("Telecommand is for CDMS\r\n"); //apid = 10 corresponds to cdms 00511 switch(GETservice_type(tc_ptr)) 00512 { 00513 case 0x60: 00514 { 00515 printf("service:MMS\r\n"); 00516 switch(GETservice_subtype(tc_ptr)) 00517 { 00518 case 0x1: 00519 { 00520 printf("sub_service:Read from RAM_Memory\r\n"); 00521 mid=(uint16_t)(tc_ptr->TC_string[3]<<4)+(uint16_t)(tc_ptr->TC_string[4]); 00522 00523 Data[0] = FCTN_CDMS_RD_FLASH(0); 00524 Data[1] = FCTN_CDMS_RD_FLASH(1); 00525 //tm_pointer = new Long_tm; 00526 tm_pointer->TM_string[0] = 0x30; 00527 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); 00528 tm_pointer->TM_string[2] = (uint8_t)(flash_counter); 00529 for(uint8_t i=0;i<4;i++) 00530 { 00531 tm_pointer->TM_string[3+i] = (uint8_t)((Data[0]>>(8*i))&0x00FF); 00532 } 00533 for(uint8_t i=4;i<8;i++) 00534 { 00535 tm_pointer->TM_string[3+i] = (uint8_t)((Data[1]>>(8*i))&0x00FF); 00536 } 00537 crc16 = crc16_gen(tm_ptr->TM_string,9); 00538 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); 00539 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); 00540 tm_pointer->next_TM = NULL; return tm_ptr; 00541 } 00542 case 0x2: 00543 { 00544 printf("sub_service:Read from Flash_Memory\r\n"); 00545 mid=(uint16_t)(tc_ptr->TC_string[3]<<4)+(uint16_t)(tc_ptr->TC_string[4]); 00546 00547 Data[0] = FCTN_CDMS_RD_FLASH(0); 00548 Data[1] = FCTN_CDMS_RD_FLASH(1); 00549 //tm_pointer = new Long_tm; 00550 tm_pointer->TM_string[0] = 0x30; 00551 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); 00552 tm_pointer->TM_string[2] = (uint8_t)(flash_counter); 00553 for(uint8_t i=0;i<4;i++) 00554 { 00555 tm_pointer->TM_string[3+i] = (uint8_t)((Data[0]>>(8*i))&0x00FF); 00556 } 00557 for(uint8_t i=4;i<8;i++) 00558 { 00559 tm_pointer->TM_string[3+i] = (uint8_t)((Data[1]>>(8*i))&0x00FF); 00560 } 00561 crc16 = crc16_gen(tm_ptr->TM_string,9); 00562 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); 00563 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); 00564 tm_pointer->next_TM = NULL; return tm_ptr; 00565 } 00566 case 0x5: 00567 { 00568 printf("WRITE ON FLASH_MEMORY\r\n"); 00569 mid=(uint16_t)(tc_ptr->TC_string[3]<<4)+(uint16_t)(tc_ptr->TC_string[4]); 00570 block = (((uint32_t)(tc_ptr->TC_string[5])<<24)|((uint32_t)(tc_ptr->TC_string[5])<<16)|((uint32_t)(tc_ptr->TC_string[5])<<8)|((uint32_t)(tc_ptr->TC_string[5]))); 00571 FCTN_CDMS_WR_FLASH(mid,block); 00572 //tm_pointer = new Short_tm; 00573 tm_pointer->TM_string[0] = 0xB0; 00574 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); 00575 tm_pointer->TM_string[2] = 0x01; 00576 tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided 00577 tm_pointer->TM_string[4] = 0x01; 00578 for(uint8_t i=0;i<6;i++) 00579 { 00580 tm_pointer->TM_string[i+5] = 0; 00581 } 00582 crc16 = crc16_gen(tm_ptr->TM_string,11); 00583 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); 00584 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); 00585 tm_pointer->next_TM = NULL; return tm_ptr; 00586 break; 00587 } 00588 default: 00589 { 00590 printf("INVALID TC\r\n"); //Send Invalid TC Telemetry 00591 //tm_pointer = new Short_tm; 00592 tm_pointer->TM_string[0] = 0xB0; 00593 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); 00594 tm_pointer->TM_string[2] = 0x01; 00595 tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided 00596 tm_pointer->TM_string[4] = 0x01; 00597 for(uint8_t i=0;i<6;i++) 00598 { 00599 tm_pointer->TM_string[i+5] = 0; 00600 } 00601 crc16 = crc16_gen(tm_ptr->TM_string,11); 00602 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); 00603 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); 00604 tm_pointer->next_TM = NULL; return tm_ptr; 00605 } 00606 break; 00607 } 00608 } 00609 case 0x8: 00610 { 00611 printf("service:FUNCTION MANAGEMENT SERVICE\r\n"); 00612 if(GETservice_subtype(tc_ptr)==0x1) 00613 { 00614 if(GETpid(tc_ptr)==0x01) 00615 { 00616 printf("TC_PL_INIT\r\n"); // call PWR_SWCH_ON function 00617 //tm_pointer = new Short_tm; 00618 tm_pointer->TM_string[0] = 0xB0; 00619 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); 00620 tm_pointer->TM_string[2] = ACKCODE; 00621 for(uint8_t i=3;i<11;i++) 00622 { 00623 tm_pointer->TM_string[i] = 0; 00624 } 00625 crc16 = crc16_gen(tm_ptr->TM_string,11); 00626 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); 00627 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); 00628 tm_pointer->next_TM = NULL; return tm_ptr; 00629 break; 00630 } 00631 else if(GETpid(tc_ptr)==0x02) 00632 { 00633 printf("TC_PL_MAIN\r\n"); // call PWR_SWCH_ON function 00634 //tm_pointer = new Short_tm; 00635 tm_pointer->TM_string[0] = 0xB0; 00636 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); 00637 tm_pointer->TM_string[2] = ACKCODE; 00638 for(uint8_t i=3;i<11;i++) 00639 { 00640 tm_pointer->TM_string[i] = 0; 00641 } 00642 crc16 = crc16_gen(tm_ptr->TM_string,11); 00643 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); 00644 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); 00645 tm_pointer->next_TM = NULL; return tm_ptr; 00646 break; 00647 } 00648 else if(GETpid(tc_ptr)==0x03) 00649 { 00650 printf("TC_COM_INIT\r\n"); // call PWR_SWCH_ON function 00651 //tm_pointer = new Short_tm; 00652 tm_pointer->TM_string[0] = 0xB0; 00653 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); 00654 tm_pointer->TM_string[2] = ACKCODE; 00655 for(uint8_t i=3;i<11;i++) 00656 { 00657 tm_pointer->TM_string[i] = 0; 00658 } 00659 crc16 = crc16_gen(tm_ptr->TM_string,11); 00660 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); 00661 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); 00662 tm_pointer->next_TM = NULL; return tm_ptr; 00663 break; 00664 } 00665 else if(GETpid(tc_ptr)==0x04) 00666 { 00667 printf("TC_CDMS_HK_MAIN\r\n"); // call PWR_SWCH_ON function 00668 //tm_pointer = new Short_tm; 00669 tm_pointer->TM_string[0] = 0xB0; 00670 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); 00671 tm_pointer->TM_string[2] = ACKCODE; 00672 for(uint8_t i=3;i<11;i++) 00673 { 00674 tm_pointer->TM_string[i] = 0; 00675 } 00676 crc16 = crc16_gen(tm_ptr->TM_string,11); 00677 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); 00678 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); 00679 tm_pointer->next_TM = NULL; return tm_ptr; 00680 break; 00681 } 00682 else if(GETpid(tc_ptr)==0x11) 00683 { 00684 printf("TC_SW_ON_SD\r\n"); // call PWR_SWCH_ON function 00685 //tm_pointer = new Short_tm; 00686 tm_pointer->TM_string[0] = 0xB0; 00687 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); 00688 tm_pointer->TM_string[2] = ACKCODE; 00689 for(uint8_t i=3;i<11;i++) 00690 { 00691 tm_pointer->TM_string[i] = 0; 00692 } 00693 crc16 = crc16_gen(tm_ptr->TM_string,11); 00694 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); 00695 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); 00696 tm_pointer->next_TM = NULL; return tm_ptr; 00697 break; 00698 } 00699 else if(GETpid(tc_ptr)==0x12) 00700 { 00701 printf("TC_SW_ON_RTC\r\n"); // call PWR_SWCH_ON function 00702 //tm_pointer = new Short_tm; 00703 tm_pointer->TM_string[0] = 0xB0; 00704 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); 00705 tm_pointer->TM_string[2] = ACKCODE; 00706 for(uint8_t i=3;i<11;i++) 00707 { 00708 tm_pointer->TM_string[i] = 0; 00709 } 00710 crc16 = crc16_gen(tm_ptr->TM_string,11); 00711 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); 00712 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); 00713 tm_pointer->next_TM = NULL; return tm_ptr; 00714 break; 00715 } 00716 else if(GETpid(tc_ptr)==0x13) 00717 { 00718 printf("TC_SW_ON_BAE\r\n"); // call PWR_SWCH_ON function 00719 //tm_pointer = new Short_tm; 00720 tm_pointer->TM_string[0] = 0xB0; 00721 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); 00722 tm_pointer->TM_string[2] = ACKCODE; 00723 for(uint8_t i=3;i<11;i++) 00724 { 00725 tm_pointer->TM_string[i] = 0; 00726 } 00727 crc16 = crc16_gen(tm_ptr->TM_string,11); 00728 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); 00729 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); 00730 tm_pointer->next_TM = NULL; return tm_ptr; 00731 break; 00732 } 00733 else if(GETpid(tc_ptr)==0x14) 00734 { 00735 printf("TC_SW_ON_PL_DL\r\n"); // call PWR_SWCH_ON function 00736 //tm_pointer = new Short_tm; 00737 tm_pointer->TM_string[0] = 0xB0; 00738 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); 00739 tm_pointer->TM_string[2] = ACKCODE; 00740 for(uint8_t i=3;i<11;i++) 00741 { 00742 tm_pointer->TM_string[i] = 0; 00743 } 00744 crc16 = crc16_gen(tm_ptr->TM_string,11); 00745 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); 00746 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); 00747 tm_pointer->next_TM = NULL; return tm_ptr; 00748 break; 00749 } 00750 else if(GETpid(tc_ptr)==0x15) 00751 { 00752 printf("TC_SW_ON_PL_AG_HV\r\n"); // call PWR_SWCH_ON function 00753 //tm_pointer = new Short_tm; 00754 tm_pointer->TM_string[0] = 0xB0; 00755 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); 00756 tm_pointer->TM_string[2] = ACKCODE; 00757 for(uint8_t i=3;i<11;i++) 00758 { 00759 tm_pointer->TM_string[i] = 0; 00760 } 00761 crc16 = crc16_gen(tm_ptr->TM_string,11); 00762 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); 00763 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); 00764 tm_pointer->next_TM = NULL; return tm_ptr; 00765 break; 00766 } 00767 else if(GETpid(tc_ptr)==0x16) 00768 { 00769 printf("TC_SW_ON_V_A_EN\r\n"); // call PWR_SWCH_ON function 00770 //tm_pointer = new Short_tm; 00771 tm_pointer->TM_string[0] = 0xB0; 00772 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); 00773 tm_pointer->TM_string[2] = ACKCODE; 00774 for(uint8_t i=3;i<11;i++) 00775 { 00776 tm_pointer->TM_string[i] = 0; 00777 } 00778 crc16 = crc16_gen(tm_ptr->TM_string,11); 00779 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); 00780 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); 00781 tm_pointer->next_TM = NULL; return tm_ptr; 00782 break; 00783 } 00784 else if(GETpid(tc_ptr)==0x21) 00785 { 00786 printf("TC_SW_OFF_SD\r\n"); // call PWR_SWCH_ON function 00787 //tm_pointer = new Short_tm; 00788 tm_pointer->TM_string[0] = 0xB0; 00789 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); 00790 tm_pointer->TM_string[2] = ACKCODE; 00791 for(uint8_t i=3;i<11;i++) 00792 { 00793 tm_pointer->TM_string[i] = 0; 00794 } 00795 crc16 = crc16_gen(tm_ptr->TM_string,11); 00796 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); 00797 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); 00798 tm_pointer->next_TM = NULL; return tm_ptr; 00799 break; 00800 } 00801 else if(GETpid(tc_ptr)==0x22) 00802 { 00803 printf("TC_SW_OFF_RTC\r\n"); // call PWR_SWCH_ON function 00804 //tm_pointer = new Short_tm; 00805 tm_pointer->TM_string[0] = 0xB0; 00806 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); 00807 tm_pointer->TM_string[2] = ACKCODE; 00808 for(uint8_t i=3;i<11;i++) 00809 { 00810 tm_pointer->TM_string[i] = 0; 00811 } 00812 crc16 = crc16_gen(tm_ptr->TM_string,11); 00813 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); 00814 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); 00815 tm_pointer->next_TM = NULL; return tm_ptr; 00816 break; 00817 } 00818 else if(GETpid(tc_ptr)==0x23) 00819 { 00820 printf("TC_SW_OFF_BAE\r\n"); // call PWR_SWCH_ON function 00821 //tm_pointer = new Short_tm; 00822 tm_pointer->TM_string[0] = 0xB0; 00823 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); 00824 tm_pointer->TM_string[2] = ACKCODE; 00825 for(uint8_t i=3;i<11;i++) 00826 { 00827 tm_pointer->TM_string[i] = 0; 00828 } 00829 crc16 = crc16_gen(tm_ptr->TM_string,11); 00830 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); 00831 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); 00832 tm_pointer->next_TM = NULL; return tm_ptr; 00833 break; 00834 } 00835 else if(GETpid(tc_ptr)==0x24) 00836 { 00837 printf("TC_SW_OFF_PL_DL\r\n"); // call PWR_SWCH_ON function 00838 //tm_pointer = new Short_tm; 00839 tm_pointer->TM_string[0] = 0xB0; 00840 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); 00841 tm_pointer->TM_string[2] = ACKCODE; 00842 for(uint8_t i=3;i<11;i++) 00843 { 00844 tm_pointer->TM_string[i] = 0; 00845 } 00846 crc16 = crc16_gen(tm_ptr->TM_string,11); 00847 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); 00848 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); 00849 tm_pointer->next_TM = NULL; return tm_ptr; 00850 break; 00851 } 00852 else if(GETpid(tc_ptr)==0x25) 00853 { 00854 printf("TC_SW_OFF_PL_AG_HV\r\n"); // call PWR_SWCH_ON function 00855 //tm_pointer = new Short_tm; 00856 tm_pointer->TM_string[0] = 0xB0; 00857 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); 00858 tm_pointer->TM_string[2] = ACKCODE; 00859 for(uint8_t i=3;i<11;i++) 00860 { 00861 tm_pointer->TM_string[i] = 0; 00862 } 00863 crc16 = crc16_gen(tm_ptr->TM_string,11); 00864 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); 00865 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); 00866 tm_pointer->next_TM = NULL; return tm_ptr; 00867 break; 00868 } 00869 else if(GETpid(tc_ptr)==0x26) 00870 { 00871 printf("TC_SW_OFF_V_A_EN\r\n"); // call PWR_SWCH_ON function 00872 //tm_pointer = new Short_tm; 00873 tm_pointer->TM_string[0] = 0xB0; 00874 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); 00875 tm_pointer->TM_string[2] = ACKCODE; 00876 for(uint8_t i=3;i<11;i++) 00877 { 00878 tm_pointer->TM_string[i] = 0; 00879 } 00880 crc16 = crc16_gen(tm_ptr->TM_string,11); 00881 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); 00882 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); 00883 tm_pointer->next_TM = NULL; return tm_ptr; 00884 break; 00885 } 00886 else if(GETpid(tc_ptr)==0x31) 00887 { 00888 printf("TC_RST_SD\r\n"); // call PWR_SWCH_ON function 00889 //tm_pointer = new Short_tm; 00890 tm_pointer->TM_string[0] = 0xB0; 00891 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); 00892 tm_pointer->TM_string[2] = ACKCODE; 00893 for(uint8_t i=3;i<11;i++) 00894 { 00895 tm_pointer->TM_string[i] = 0; 00896 } 00897 crc16 = crc16_gen(tm_ptr->TM_string,11); 00898 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); 00899 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); 00900 tm_pointer->next_TM = NULL; return tm_ptr; 00901 break; 00902 } 00903 else if(GETpid(tc_ptr)==0x32) 00904 { 00905 printf("TC_RST_RTC\r\n"); // call PWR_SWCH_ON function 00906 //tm_pointer = new Short_tm; 00907 tm_pointer->TM_string[0] = 0xB0; 00908 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); 00909 tm_pointer->TM_string[2] = ACKCODE; 00910 for(uint8_t i=3;i<11;i++) 00911 { 00912 tm_pointer->TM_string[i] = 0; 00913 } 00914 crc16 = crc16_gen(tm_ptr->TM_string,11); 00915 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); 00916 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); 00917 tm_pointer->next_TM = NULL; return tm_ptr; 00918 break; 00919 } 00920 else if(GETpid(tc_ptr)==0x33) 00921 { 00922 printf("TC_RST_BAE\r\n"); // call PWR_SWCH_ON function 00923 //tm_pointer = new Short_tm; 00924 tm_pointer->TM_string[0] = 0xB0; 00925 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); 00926 tm_pointer->TM_string[2] = ACKCODE; 00927 for(uint8_t i=3;i<11;i++) 00928 { 00929 tm_pointer->TM_string[i] = 0; 00930 } 00931 crc16 = crc16_gen(tm_ptr->TM_string,11); 00932 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); 00933 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); 00934 tm_pointer->next_TM = NULL; return tm_ptr; 00935 break; 00936 } 00937 else if(GETpid(tc_ptr)==0x34) 00938 { 00939 printf("TC_RST_PL_DL\r\n"); // call PWR_SWCH_ON function 00940 //tm_pointer = new Short_tm; 00941 tm_pointer->TM_string[0] = 0xB0; 00942 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); 00943 tm_pointer->TM_string[2] = ACKCODE; 00944 for(uint8_t i=3;i<11;i++) 00945 { 00946 tm_pointer->TM_string[i] = 0; 00947 } 00948 crc16 = crc16_gen(tm_ptr->TM_string,11); 00949 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); 00950 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); 00951 tm_pointer->next_TM = NULL; return tm_ptr; 00952 break; 00953 break; 00954 } 00955 else if(GETpid(tc_ptr)==0xC1) 00956 { 00957 printf("RESET_HK_COUNTER\r\n"); // call PWR_SWCH_ON function 00958 //tm_pointer = new Short_tm; 00959 tm_pointer->TM_string[0] = 0xB0; 00960 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); 00961 tm_pointer->TM_string[2] = ACKCODE; 00962 for(uint8_t i=3;i<11;i++) 00963 { 00964 tm_pointer->TM_string[i] = 0; 00965 } 00966 crc16 = crc16_gen(tm_ptr->TM_string,11); 00967 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); 00968 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); 00969 tm_pointer->next_TM = NULL; return tm_ptr; 00970 break; 00971 } 00972 else if(GETpid(tc_ptr)==0xF1) 00973 { 00974 printf("RD_RTC\r\n"); //call RD_RTC 00975 //tm_pointer = new Short_tm; 00976 tm_pointer->TM_string[0] = 0xD0; 00977 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); 00978 tm_pointer->TM_string[2] = 0x01; 00979 uint64_t time = FCTN_CDMS_RD_RTC(); 00980 tm_pointer->TM_string[3] = (uint8_t)((time&0xFF00000000000000)>>56); 00981 tm_pointer->TM_string[4] = (uint8_t)((time&0x00FF000000000000)>>48); 00982 tm_pointer->TM_string[5] = (uint8_t)((time&0x0000FF0000000000)>>40); 00983 tm_pointer->TM_string[6] = (uint8_t)((time&0x000000FF00000000)>>32); 00984 tm_pointer->TM_string[7] = (uint8_t)((time&0x00000000FF000000)>>24); 00985 tm_pointer->TM_string[8] = (uint8_t)((time&0x0000000000FF0000)>>16); 00986 tm_pointer->TM_string[9] = (uint8_t)((time&0x000000000000FF00)>>8); 00987 tm_pointer->TM_string[10] = (uint8_t)(time&0x00000000000000FF); 00988 crc16 = crc16_gen(tm_ptr->TM_string,11); 00989 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); 00990 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); 00991 tm_pointer->next_TM = NULL; return tm_ptr; 00992 } 00993 else 00994 { 00995 printf("INVALID TC\r\n"); 00996 //tm_pointer = new Short_tm; 00997 tm_pointer->TM_string[0] = 0xB0; 00998 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); 00999 tm_pointer->TM_string[2] = 0x01; 01000 tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided 01001 tm_pointer->TM_string[4] = 0x01; 01002 for(uint8_t i=0;i<6;i++) 01003 { 01004 tm_pointer->TM_string[i+5] = 0; 01005 } 01006 crc16 = crc16_gen(tm_ptr->TM_string,11); 01007 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); 01008 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); 01009 tm_pointer->next_TM = NULL; return tm_ptr; 01010 } 01011 } 01012 01013 01014 } 01015 default: 01016 { 01017 printf("INVALID TC"); //send invalid TC TM 01018 //tm_pointer = new Short_tm; 01019 tm_pointer->TM_string[0] = 0xB0; 01020 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); 01021 tm_pointer->TM_string[2] = 0x01; 01022 tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided 01023 tm_pointer->TM_string[4] = 0x01; 01024 for(uint8_t i=0;i<6;i++) 01025 { 01026 tm_pointer->TM_string[i+5] = 0; 01027 } 01028 crc16 = crc16_gen(tm_ptr->TM_string,11); 01029 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); 01030 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); 01031 tm_pointer->next_TM = NULL; return tm_ptr; 01032 break; 01033 } 01034 } 01035 } 01036 case 3: 01037 { 01038 printf("Telecommand is for PL\r\n"); 01039 // printf("Informing PL about TC using I2C\r\n"); //interrupt to be sent to the bae 01040 // FCTN_I2C_WRITE((char*)tc_ptr->TC_string); 01041 // printf("sent the Telecommand to BAE\r\n"); //packet along with crc will be sent when bae is ready 01042 // wait(1); //wait time is to be optimised 01043 // if(tm_status_4m_slv == 1) 01044 // { 01045 // FCTN_I2C_READ((char*)tm_ptr->TM_string); 01046 // received = 1; 01047 // } 01048 // if(received == 1 ) 01049 // { 01050 // printf("Telemetry is received from BAE\r\n"); 01051 // printf("%s", tm_ptr->TM_string); 01052 // received = 0; 01053 // } // similar to BAE functions 01054 break; 01055 } 01056 default: //invalid TC 01057 { 01058 printf("INVALID TC\r\n"); 01059 //tm_pointer = new Short_tm; 01060 tm_pointer->TM_string[0] = 0xB0; 01061 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); 01062 tm_pointer->TM_string[2] = 0x01; 01063 tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided 01064 tm_pointer->TM_string[4] = 0x01; 01065 for(uint8_t i=0;i<6;i++) 01066 { 01067 tm_pointer->TM_string[i+5] = 0; 01068 } 01069 crc16 = crc16_gen(tm_ptr->TM_string,11); 01070 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); 01071 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); 01072 tm_pointer->next_TM = NULL; return tm_ptr; 01073 break; 01074 } 01075 } 01076 } 01077 // CDMS TEAM CODE END 01078 // EXECUTE OBOSC 01079 #define execute_obosc_core(tc_ptr, tm_ptr, reset_flag) {\ 01080 uint8_t service_subtype = (tc_ptr->TC_string[2]) & 0x0F;\ 01081 uint8_t temp8 = 0x00;\ 01082 Base_tc *modify_this = gHEAD_NODE_TCL;\ 01083 int modify_overflow = 0x00;\ 01084 switch( service_subtype ){\ 01085 case OBOSC_SUB_DISABLE:\ 01086 /*gPC.puts("target psc are ");*/\ 01087 for(int i = 3 ; i < 9 ; ++i){\ 01088 /*gPC.printf("%u ", tc_ptr->TC_string[i]);*/\ 01089 }\ 01090 /*gPC.puts("\r\n");*/\ 01091 /*gPC.puts("disable type obosc\r\n");*/\ 01092 while( modify_this != NULL ){\ 01093 if( modify_overflow < TCL_OVERFLOW_CONSTANT ){\ 01094 uint8_t modify_psc = GETpacket_seq_count(modify_this);\ 01095 /*gPC.printf("mosify_psc = %u\r\n", modify_psc);*/\ 01096 for( int i = 3 ; i < 9 ; ++i ){\ 01097 uint8_t target_psc = tc_ptr->TC_string[i];\ 01098 if( (target_psc == modify_psc) && (target_psc != 0) ){\ 01099 uint16_t tempExec = TC_STATE_DISABLED;\ 01100 PUTexec_status( modify_this, tempExec );\ 01101 break;\ 01102 }\ 01103 }\ 01104 modify_this = modify_this->next_TC;\ 01105 ++modify_overflow;\ 01106 }\ 01107 else{\ 01108 /*PENDING: RESET CDMS*/\ 01109 break;\ 01110 }\ 01111 }\ 01112 break;\ 01113 case OBOSC_SUB_RETRY:\ 01114 /*gPC.puts("retry type obosc\r\n");*/\ 01115 while( modify_this != NULL ){\ 01116 if( modify_overflow < TCL_OVERFLOW_CONSTANT ){\ 01117 uint8_t modify_psc = GETpacket_seq_count(modify_this);\ 01118 for( int i = 3 ; i < 9 ; ++i ){\ 01119 uint8_t target_psc = tc_ptr->TC_string[i];\ 01120 if( (target_psc == modify_psc) && (target_psc != 0) ){\ 01121 uint16_t tempExec = TC_STATE_MARKED_RETRY;\ 01122 PUTexec_status( modify_this, tempExec );\ 01123 /*gPC.puts("reqquired tc found: disable\r\n");*/\ 01124 break;\ 01125 }\ 01126 }\ 01127 modify_this = modify_this->next_TC;\ 01128 ++modify_overflow;\ 01129 }\ 01130 else{\ 01131 /*PENDING: RESET CDMS*/\ 01132 break;\ 01133 }\ 01134 }\ 01135 break;\ 01136 }\ 01137 Base_tm *ackl234new = new Short_tm;\ 01138 ackl234new->next_TM = NULL;\ 01139 /*return telemetry pointer here*/\ 01140 tm_ptr = ackl234new;\ 01141 temp8 = SHORT_TM_CODE;\ 01142 PUTshort_or_long_tm(ackl234new->fields, temp8);\ 01143 temp8 = TMID_ACK_L234;\ 01144 PUTtmid((ackl234new->fields), temp8);\ 01145 ackl234new->TM_string[0] = TMID_ACK_L234 << 4;\ 01146 ackl234new->TM_string[1] = GETpacket_seq_count(tc_ptr);\ 01147 ackl234new->TM_string[2] = 0xA0;\ 01148 for(int i = 3; i < 11; ++i){\ 01149 ackl234new->TM_string[i] = 0x00;\ 01150 }\ 01151 uint16_t crc = crc16_gen(ackl234new->TM_string, TM_SHORT_SIZE-2);\ 01152 ackl234new->TM_string[11] = (crc & 0xFF00) >> 8;\ 01153 ackl234new->TM_string[12] = crc & 0x00FF;\ 01154 /*ack l234 old*/\ 01155 if( service_subtype == OBOSC_SUB_REP_LE ){\ 01156 if( gLAST_TM_SHORT_OR_LONG == SHORT_TM_CODE ){\ 01157 Base_tm *ackl234old = new Short_tm;\ 01158 ackl234old->next_TM = NULL;\ 01159 /*APPEND TO ACK L234 NEW HERE*/\ 01160 ackl234new->next_TM = ackl234old;\ 01161 uint8_t temp82 = TM_SHORT_SIZE;\ 01162 PUTshort_or_long_tm(ackl234old->fields, temp82);\ 01163 /*TMID FOR SHORT TM*/\ 01164 uint8_t y = (gLAST_TM[0] & 0xF0) >> 4;\ 01165 PUTtmid((ackl234old->fields), y);\ 01166 for( int i = 0 ; i < TM_SHORT_SIZE ; ++i ){\ 01167 ackl234old->TM_string[i] = gLAST_TM[i];\ 01168 }\ 01169 }\ 01170 else{\ 01171 Base_tm *tempLongTM = new Long_tm;\ 01172 tempLongTM->next_TM = NULL;\ 01173 /*APPEND TO ACK L234 NEW HERE*/\ 01174 ackl234new->next_TM = tempLongTM;\ 01175 uint8_t temp82 = TM_LONG_SIZE;\ 01176 PUTshort_or_long_tm(tempLongTM->fields, temp82);\ 01177 /*TMID FOR LONG TM*/\ 01178 uint8_t y = (gLAST_TM[0] & 0x78) >> 3;\ 01179 PUTtmid((tempLongTM->fields), y);\ 01180 for( int i = 0 ; i < TM_LONG_SIZE ; ++i ){\ 01181 tempLongTM->TM_string[i] = gLAST_TM[i];\ 01182 }\ 01183 }\ 01184 }\ 01185 else if( service_subtype == OBOSC_SUB_REP_TCLD ){\ 01186 get_tc_list(ackl234new->next_TM, GETpacket_seq_count(tc_ptr));\ 01187 }\ 01188 else if( service_subtype == OBOSC_SUB_RESET ){\ 01189 /*reset_all;*/\ 01190 reset_flag = 1;\ 01191 /*PENDING: VERIFY reset_all, RESET CDMS*/\ 01192 }\ 01193 else if( (service_subtype != OBOSC_SUB_DISABLE) && (service_subtype != OBOSC_SUB_RETRY) ){\ 01194 /*CHANGE THE ACK CODE TO INVALID TC*/\ 01195 ackl234new->TM_string[2] = 0xA2;\ 01196 }\ 01197 /*gPC.puts("completed obosc\r\n");*/\ 01198 } 01199 01200 /*tm_ptr is the next_TM of a linked list, and should have the value NULL, i.e. tm_ptr should be the next_TM pointer of thte last node */ 01201 #define get_call_sign(tm_ptr) {\ 01202 Base_tm* call_sign_tm = new Short_tm;\ 01203 call_sign_tm->next_TM = NULL;\ 01204 tm_ptr = call_sign_tm;\ 01205 uint8_t temp8 = TMID_CALL_SIGN;\ 01206 PUTtmid(call_sign_tm->fields, temp8);\ 01207 temp8 = SHORT_TM_CODE;\ 01208 PUTshort_or_long_tm(call_sign_tm->fields, temp8);\ 01209 for( int i = 0 ; i < TM_SHORT_SIZE ; ++i ){\ 01210 call_sign_tm->TM_string[i] = gCALL_SIGN_STRING[i];\ 01211 }\ 01212 } 01213 01214 #define EXECUTE_OBOSC_ONLY {\ 01215 int reset_flag = 0;\ 01216 Base_tm *obosc_tm_head = NULL;\ 01217 get_call_sign(obosc_tm_head);\ 01218 Base_tm *obosc_tm_current = obosc_tm_head;\ 01219 get_ack_l1(obosc_tm_current->next_TM);\ 01220 int overflowCountOBONLY = 0;\ 01221 while( obosc_tm_current->next_TM != NULL ){\ 01222 if( overflowCountOBONLY < TM_OVERFLOW_CONSTANT ){\ 01223 obosc_tm_current = obosc_tm_current->next_TM;\ 01224 ++overflowCountOBONLY;\ 01225 }\ 01226 else{\ 01227 /*PENDING: RESET CDMS*/\ 01228 break;\ 01229 }\ 01230 }\ 01231 uint8_t obosc_executed_count = 0;\ 01232 for(uint8_t execute_psc = PSC_START_VALUE ; execute_psc < gTOTAL_VALID_TC ; ++execute_psc){\ 01233 Base_tc* current_TC = gHEAD_NODE_TCL;\ 01234 int overCount = 0;\ 01235 while( current_TC != NULL ){\ 01236 if( overCount < TCL_OVERFLOW_CONSTANT ){\ 01237 if( (GETcrc_pass(current_TC) == 1) && (GETpacket_seq_count(current_TC) == execute_psc) ){\ 01238 /*CHECK FOR OBOSC*/\ 01239 uint8_t temp82 = 0x00;\ 01240 isit_obosc(current_TC, temp82);\ 01241 if(temp82 == 0x01){\ 01242 uint16_t current_exec_status = GETexec_status(current_TC);\ 01243 if( (current_exec_status == TC_STATE_SUCCESSFULLY_EXECUTED) || (current_exec_status == TC_STATE_DISABLED) )\ 01244 break;\ 01245 else if( (current_exec_status == TC_STATE_UNEXECUTED) || (current_exec_status == TC_STATE_MARKED_RETRY) ){\ 01246 /*gPC.printf("It is obosc: %u\r\n", execute_psc);*/\ 01247 /*EXECUTION OF OBOSC TC*/\ 01248 /*WARNING: LARGE MEMORY UTILIZATION FOR TC-LIST-REPORT */\ 01249 execute_obosc_core(current_TC, obosc_tm_current->next_TM, reset_flag);\ 01250 ++obosc_executed_count;\ 01251 /*INCREMENT POINTER TO THE LAST NODE*/\ 01252 int overflowCountOBinside = 0;\ 01253 while( obosc_tm_current->next_TM != NULL ){\ 01254 if( overflowCountOBinside < TM_OVERFLOW_CONSTANT ){\ 01255 obosc_tm_current = obosc_tm_current->next_TM;\ 01256 ++overflowCountOBinside;\ 01257 }\ 01258 else{\ 01259 /*PENDING: RESET CDMS*/\ 01260 break;\ 01261 }\ 01262 }\ 01263 uint16_t temp16 = TC_STATE_SUCCESSFULLY_EXECUTED;\ 01264 PUTexec_status(current_TC, temp16);\ 01265 }\ 01266 }\ 01267 }\ 01268 current_TC = current_TC->next_TC;\ 01269 ++overCount;\ 01270 }\ 01271 else{\ 01272 /*PENDING: REST CDMS: MEMORY LEAK FOUND*/\ 01273 break;\ 01274 }\ 01275 }\ 01276 }\ 01277 if( obosc_executed_count != 0 ){\ 01278 print_all_tm(obosc_tm_head);\ 01279 /*adf_not_SDcard();*/\ 01280 }\ 01281 delete_all_tm(obosc_tm_head);\ 01282 if ( reset_flag == 1 ){\ 01283 reset_all;\ 01284 break;\ 01285 }\ 01286 } 01287 01288 #define EXECUTE_TC {\ 01289 gMASTER_STATE = TCL_STATE_EXECUTING;\ 01290 /*gPC.printf("%u\r\n", gTOTAL_VALID_TC);*/\ 01291 for(uint8_t execute_psc = PSC_START_VALUE ; execute_psc < gTOTAL_VALID_TC ; ++execute_psc ){\ 01292 /*gPC.printf("executing normal %u\r\n", execute_psc);*/\ 01293 /*gLEDG = !gLEDG;*/\ 01294 /*gLEDR = !gLEDR;*/\ 01295 Base_tc* current_TC = gHEAD_NODE_TCL;\ 01296 int overflowCount = 0;\ 01297 while(current_TC != NULL){\ 01298 if( overflowCount < TCL_OVERFLOW_CONSTANT ){\ 01299 if( (GETcrc_pass(current_TC) == 1) && (GETpacket_seq_count(current_TC) == execute_psc) ){\ 01300 uint8_t current_exec_status = GETexec_status(current_TC);\ 01301 if( (current_exec_status == TC_STATE_SUCCESSFULLY_EXECUTED) || (current_exec_status == TC_STATE_DISABLED) ){\ 01302 /*gPC.printf("disabled or completed at %u\n", execute_psc);*/\ 01303 if( execute_psc == (gTOTAL_VALID_TC-1) ){\ 01304 gMASTER_STATE = TCL_STATE_COMPLETED;\ 01305 Base_tm *tm_ptr_head = NULL;\ 01306 get_call_sign(tm_ptr_head);\ 01307 Base_tm *tm_ptr = tm_ptr_head;\ 01308 get_ack_l1(tm_ptr->next_TM);\ 01309 print_all_tm(tm_ptr_head);\ 01310 delete_all_tm(tm_ptr_head);\ 01311 }\ 01312 break;\ 01313 }\ 01314 else if( (current_exec_status == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\ 01315 /*gPC.printf("abort on nack at %u psc\r\n", execute_psc);*/\ 01316 gMASTER_STATE = TCL_STATE_ABORTED;\ 01317 Base_tm *tm_ptr_head = NULL;\ 01318 get_call_sign(tm_ptr_head);\ 01319 Base_tm *tm_ptr = tm_ptr_head;\ 01320 get_ack_l1(tm_ptr->next_TM);\ 01321 print_all_tm(tm_ptr_head);\ 01322 delete_all_tm(tm_ptr_head);\ 01323 break;\ 01324 }\ 01325 else if( (current_exec_status == TC_STATE_UNEXECUTED) || (current_exec_status == TC_STATE_MARKED_RETRY) ){\ 01326 /*EXECUTION OF TC START*/\ 01327 uint8_t temp81 = 0x00;\ 01328 isit_sdcard(current_TC, temp81);\ 01329 if( temp81 == 0x00 ){\ 01330 /*gPC.printf("non sd card at %u\r\n", execute_psc);*/\ 01331 /*EXECUTION OF NON SD-CARD (BOTH OBOSC and CDMS functions)*/\ 01332 Base_tm *tm_ptr_head = NULL;\ 01333 get_call_sign(tm_ptr_head);\ 01334 Base_tm *put_tm_here = NULL;\ 01335 uint8_t temp82 = 0x00;\ 01336 uint8_t tempPAhot = 0x00;\ 01337 isit_obosc(current_TC, temp82);\ 01338 if(temp82 == 0x01){\ 01339 /*gPC.printf("obosc tc inside normal tc at %u\r\n", execute_psc);*/\ 01340 /*EXECUTION OF OBOSC TC*/\ 01341 /*SKIP EXECUTION OF OBOSC HERE*/\ 01342 if( execute_psc == (gTOTAL_VALID_TC-1) ){\ 01343 gMASTER_STATE = TCL_STATE_COMPLETED;\ 01344 }\ 01345 break;\ 01346 }\ 01347 else{\ 01348 /*gPC.printf("cdms relay tmtc at %u\r\n", execute_psc);*/\ 01349 /*call CDMS_RLY_TMTC*/\ 01350 /*CDMS_RLY_TMTC(current_TC, put_tm_here);*/\ 01351 put_tm_here = FCTN_CDMS_RLY_TMTC(current_TC);\ 01352 }\ 01353 /*DETECT ACK OR NACK*/\ 01354 uint8_t temp83 = 0x00;\ 01355 uint8_t temp84 = GETpacket_seq_count(current_TC);\ 01356 detect_ack(put_tm_here, temp83, temp84);\ 01357 if( temp83 == 0x01){\ 01358 uint16_t temp16 = TC_STATE_SUCCESSFULLY_EXECUTED;\ 01359 PUTexec_status(current_TC, temp16);\ 01360 }\ 01361 else{\ 01362 /*gPC.puts("TC_STATE_EXECUTION_FAILED");*/\ 01363 uint16_t temp16 = TC_STATE_EXECUTION_FAILED;\ 01364 PUTexec_status(current_TC, temp16);\ 01365 }\ 01366 /*ABORT ON NACK AND TC LIST COMPLETED: UPDATE IN gMASTERSTATE*/\ 01367 if( (GETexec_status(current_TC) == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\ 01368 gMASTER_STATE = TCL_STATE_ABORTED;\ 01369 }\ 01370 else if( execute_psc == (gTOTAL_VALID_TC-1) ){\ 01371 /*LAST TC IS EXECUTED*/\ 01372 gMASTER_STATE = TCL_STATE_COMPLETED;\ 01373 }\ 01374 /*update last executed L1_ack*/\ 01375 if( put_tm_here != NULL ){\ 01376 if( GETshort_or_long_tm(put_tm_here->fields) == SHORT_TM_CODE ){\ 01377 for(int i = 0 ; i < TM_SHORT_SIZE ; ++i){\ 01378 gLAST_TM[i] = put_tm_here->TM_string[i];\ 01379 gLAST_TM_SHORT_OR_LONG = SHORT_TM_CODE;\ 01380 }\ 01381 }\ 01382 else{\ 01383 for( int i = 0 ; i < TM_LONG_SIZE ; ++i ){\ 01384 gLAST_TM[i] = put_tm_here->TM_string[i];\ 01385 gLAST_TM_SHORT_OR_LONG = LONG_TM_CODE;\ 01386 }\ 01387 }\ 01388 }\ 01389 /*PENDING: APPEND ACK L1*/\ 01390 Base_tm *tm_ptr = tm_ptr_head;\ 01391 get_ack_l1(tm_ptr->next_TM);\ 01392 int overflowCountExecute = 0;\ 01393 while( tm_ptr->next_TM != NULL ){\ 01394 if( overflowCountExecute < TM_OVERFLOW_CONSTANT ){\ 01395 tm_ptr = tm_ptr->next_TM;\ 01396 ++overflowCountExecute;\ 01397 }\ 01398 else{\ 01399 /*PENDING: RESET CDMS*/\ 01400 break;\ 01401 }\ 01402 }\ 01403 tm_ptr->next_TM = put_tm_here;\ 01404 /*CHECK FOR HOT PA*/\ 01405 isPAhot(tempPAhot);\ 01406 if( tempPAhot == 0x00 ){\ 01407 gFLAGS = gFLAGS | COM_PA_HOT_FLAG;\ 01408 }\ 01409 print_all_tm(tm_ptr_head);\ 01410 adf_not_SDcard;\ 01411 delete_all_tm(tm_ptr_head);\ 01412 }\ 01413 else{\ 01414 gPC.printf("sd card at %u\r\n", execute_psc);\ 01415 /*EXECUTION OF SD-CARD DATA SENDING (OBSRS)*/\ 01416 Base_tm *tm_ptr_head = NULL;\ 01417 get_call_sign(tm_ptr_head);\ 01418 Base_tm *put_tm_here = NULL;\ 01419 /*execute_obsrs(current_TC, put_tm_here)*/\ 01420 execute_OBSRS_TC(current_TC);\ 01421 /*adf_SND_SDCard;*/\ 01422 uint8_t tempExec = TC_STATE_SUCCESSFULLY_EXECUTED;\ 01423 PUTexec_status(current_TC, tempExec);\ 01424 /*PENDING: ABORT ON NACK CHECK, gMASTER_STATE VERIFICATION WITH SD CARD,PA hot and session timeout, last executed ack l234*/\ 01425 if( (GETexec_status(current_TC) == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\ 01426 gMASTER_STATE = TCL_STATE_ABORTED;\ 01427 }\ 01428 else if( execute_psc == (gTOTAL_VALID_TC-1) ){\ 01429 gMASTER_STATE = TCL_STATE_COMPLETED;\ 01430 }\ 01431 /*PENDING: APPEND ACK L1*/\ 01432 Base_tm *tm_ptr = tm_ptr_head;\ 01433 get_ack_l1(tm_ptr->next_TM);\ 01434 int overflowCountExecute = 0;\ 01435 while( tm_ptr->next_TM != NULL ){\ 01436 if( overflowCountExecute < TM_OVERFLOW_CONSTANT ){\ 01437 tm_ptr = tm_ptr->next_TM;\ 01438 ++overflowCountExecute;\ 01439 }\ 01440 else{\ 01441 /*PENDING: RESET CDMS*/\ 01442 break;\ 01443 }\ 01444 }\ 01445 tm_ptr->next_TM = put_tm_here;\ 01446 /*CHECK FOR HOT PA*/\ 01447 uint8_t tempPAhot = 0x00;\ 01448 isPAhot(tempPAhot);\ 01449 if( tempPAhot == 0x00 ){\ 01450 gFLAGS = gFLAGS | COM_PA_HOT_FLAG;\ 01451 }\ 01452 print_all_tm(tm_ptr_head);\ 01453 delete_all_tm(tm_ptr_head);\ 01454 }\ 01455 }\ 01456 break;\ 01457 }\ 01458 current_TC = current_TC->next_TC;\ 01459 ++overflowCount;\ 01460 }\ 01461 else{\ 01462 /*PENDING: RESET CDMS*/\ 01463 break;\ 01464 }\ 01465 }\ 01466 if( gFLAGS & COM_SESSION_TIMEOUT_FLAG ){\ 01467 break;\ 01468 }\ 01469 else if( gMASTER_STATE == TCL_STATE_ABORTED ){\ 01470 /*gPC.puts("ABORTING DUE TO ABORT ON NACK\r\n");*/\ 01471 /*EXITED DUE TO ABORT ON NACK:*/\ 01472 /*PENDING : POWER OFF COM TX*/\ 01473 RX1M.attach(&rx_read, Serial::RxIrq);\ 01474 gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\ 01475 break;\ 01476 }\ 01477 else if( gFLAGS & COM_PA_HOT_FLAG ){\ 01478 /*PA HOT: WAIT FOR TIMEOUT*/\ 01479 gCOM_PA_COOLING_TIMEOUT.attach(&after_cooling_pa, COM_PA_COOLING_TIME_LIMIT);\ 01480 /*PENDING : POWER OFF COMM TX*/\ 01481 RX1M.attach(&rx_read, Serial::RxIrq);\ 01482 gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\ 01483 break;\ 01484 }\ 01485 /*gPC.printf("successflly executed %u tc\r\n", execute_psc);*/\ 01486 }\ 01487 if( (gMASTER_STATE == TCL_STATE_COMPLETED) || (gFLAGS & COM_SESSION_TIMEOUT_FLAG) ){\ 01488 /*gPC.printf("completed or session timed out: %x\r\n", gMASTER_STATE);*/\ 01489 /*COMPLETED EXECUTION OF TC*/\ 01490 gMASTER_STATE = TCL_STATE_COMPLETED;\ 01491 COM_POWER_OFF_TX;\ 01492 reset_all;\ 01493 /*PENDING : ENABLE THREADS*/\ 01494 gSESSION_TIMEOUT.detach();\ 01495 gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\ 01496 gFLAGS = gFLAGS & (~COM_SESSION_FLAG);\ 01497 }\ 01498 }
Generated on Tue Jul 12 2022 10:59:21 by 1.7.2