Latest FM Code with EEPROM

Dependencies:   FreescaleIAP SimpleDMA eeprom mbed-rtos mbed

Fork of CDMS_QM_03MAR2017_Flash_with_obsrs by Team Fox

Committer:
aniruddhv
Date:
Sat Jun 18 09:07:28 2016 +0000
Revision:
211:77bee0cbebfe
Parent:
180:ccc21cc163f8
Child:
212:3d13a06bcd3a
delete CDMS TC, update unknown TC_STATUS,

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shreeshas95 0:f016e9e8d48b 1 // 8 Jul
shreeshas95 0:f016e9e8d48b 2 // did flowchart of states
shreeshas95 0:f016e9e8d48b 3
shreeshas95 0:f016e9e8d48b 4 // handle sd card with cdms team
shreeshas95 0:f016e9e8d48b 5
shreeshas95 0:f016e9e8d48b 6 // Jun 6
shreeshas95 0:f016e9e8d48b 7 // WHAT IS TC exec code in L1 ack ?
shreeshas95 0:f016e9e8d48b 8
aniruddhv 52:0bd68655c651 9 //Jan 7
aniruddhv 52:0bd68655c651 10 //added RLY_TMTC function
aniruddhv 52:0bd68655c651 11 //added included related files
aniruddhv 52:0bd68655c651 12
ee12b079 94:611c066467a1 13 //#include "Flash.h"
aniruddhv 52:0bd68655c651 14 #include "cdms_rtc.h"
aniruddhv 52:0bd68655c651 15
aniruddhv 52:0bd68655c651 16 DigitalIn tm_status_4m_slv(PIN39); //I2C interrupt to CDMS from BAE
aniruddhv 52:0bd68655c651 17 //DigitalIn tm_status_4m_pl(PIN61); //I2C interrupt to CDMS from PL
aniruddhv 52:0bd68655c651 18
aniruddhv 52:0bd68655c651 19 uint8_t received = 0;
aniruddhv 52:0bd68655c651 20 uint16_t mid1;
aniruddhv 52:0bd68655c651 21 uint16_t mid2;
aniruddhv 52:0bd68655c651 22 uint16_t Nbytes;
aniruddhv 52:0bd68655c651 23 uint32_t Data[2];
aniruddhv 52:0bd68655c651 24 uint16_t nbytes;
aniruddhv 52:0bd68655c651 25 uint8_t flash_counter = 0;
aniruddhv 52:0bd68655c651 26 uint16_t crc16;
aniruddhv 52:0bd68655c651 27 uint16_t mid;
aniruddhv 52:0bd68655c651 28 uint32_t block;
aniruddhv 52:0bd68655c651 29
shreeshas95 0:f016e9e8d48b 30 #define delete_TC(tc_ptr) {\
shreeshas95 0:f016e9e8d48b 31 if(tc_ptr == gHEAD_NODE_TCL){\
shreeshas95 0:f016e9e8d48b 32 gHEAD_NODE_TCL = tc_ptr->next_TC;\
shreeshas95 0:f016e9e8d48b 33 }\
shreeshas95 0:f016e9e8d48b 34 delete tc_ptr;\
shreeshas95 0:f016e9e8d48b 35 }
shreeshas95 0:f016e9e8d48b 36
shreeshas95 0:f016e9e8d48b 37 // typeof tm_ptr: Base_tm
shreeshas95 0:f016e9e8d48b 38 // typeof tc_ptr: Base_tc
shreeshas95 0:f016e9e8d48b 39 // typeof temp_xxxx: uint8_t
krishanprajapat 122:b99f8be0a51a 40
shreeshas95 0:f016e9e8d48b 41
krishanprajapat 122:b99f8be0a51a 42
shreeshas95 0:f016e9e8d48b 43
shreeshas95 4:104dd82c99b8 44 #define detect_ack(tm_ptr, temp_ack, tc_psc) {\
shreeshas95 5:ab276a17ca07 45 if( tm_ptr != NULL ){\
aniruddhv 14:08c2c887ea09 46 int length = TM_SHORT_SIZE;\
shreeshas95 102:80c911a6e736 47 if( GETshort_or_long_tm(tm_ptr) == SHORT_TM_CODE ){\
aniruddhv 14:08c2c887ea09 48 length = TM_SHORT_SIZE;\
aniruddhv 14:08c2c887ea09 49 }\
aniruddhv 14:08c2c887ea09 50 else{\
aniruddhv 14:08c2c887ea09 51 length = TM_LONG_SIZE;\
aniruddhv 14:08c2c887ea09 52 }\
aniruddhv 14:08c2c887ea09 53 uint16_t crc = crc16_gen(tm_ptr->TM_string, length-2);\
shreeshas95 5:ab276a17ca07 54 if( (((crc & 0xFF00) >> 8) == tm_ptr->TM_string[length-2]) && ( (crc & 0x00FF) == tm_ptr->TM_string[length-1] ) ){\
shreeshas95 4:104dd82c99b8 55 uint8_t temp8;\
shreeshas95 4:104dd82c99b8 56 temp8 = tm_ptr->TM_string[TM_ACK_CODE_INDEX];\
shreeshas95 4:104dd82c99b8 57 temp8 = temp8 & 0xE0;\
shreeshas95 4:104dd82c99b8 58 if( (temp8 == 0xC0) || (temp8 == 0xA0) )\
shreeshas95 4:104dd82c99b8 59 temp_ack = 0x01;\
shreeshas95 4:104dd82c99b8 60 else{\
shreeshas95 4:104dd82c99b8 61 temp_ack = 0x00;\
shreeshas95 4:104dd82c99b8 62 /*CHECK FOR NACK CODE: CRC FAIL NACK*/\
shreeshas95 4:104dd82c99b8 63 temp8 = tm_ptr->TM_string[TM_ACK_CODE_INDEX];\
shreeshas95 4:104dd82c99b8 64 temp8 = temp8 & 0x0F;\
shreeshas95 5:ab276a17ca07 65 if( temp8 == CRC_FAIL_NACK_CODE ){\
aniruddhv 211:77bee0cbebfe 66 temp_ack = 0x02;
shreeshas95 4:104dd82c99b8 67 tm_ptr->TM_string[2] = tc_psc;\
shreeshas95 4:104dd82c99b8 68 }\
shreeshas95 4:104dd82c99b8 69 }\
shreeshas95 4:104dd82c99b8 70 }\
shreeshas95 0:f016e9e8d48b 71 else\
shreeshas95 0:f016e9e8d48b 72 temp_ack = 0x00;\
shreeshas95 0:f016e9e8d48b 73 }\
shreeshas95 4:104dd82c99b8 74 else{\
shreeshas95 0:f016e9e8d48b 75 temp_ack = 0x00;\
shreeshas95 4:104dd82c99b8 76 }\
shreeshas95 0:f016e9e8d48b 77 }
shreeshas95 0:f016e9e8d48b 78
shreeshas95 0:f016e9e8d48b 79 #define isit_obosc(tc_ptr, temp_obosc) {\
shreeshas95 0:f016e9e8d48b 80 temp_obosc = 0x00;\
aniruddhv 52:0bd68655c651 81 if( GETapid(tc_ptr) == APID_COM ){\
aniruddhv 52:0bd68655c651 82 if( ((tc_ptr->TC_string[2]) >> 4) == SERVICE_OBOSC ){\
aniruddhv 52:0bd68655c651 83 temp_obosc = 0x01;\
shreeshas95 0:f016e9e8d48b 84 }\
shreeshas95 0:f016e9e8d48b 85 }\
shreeshas95 0:f016e9e8d48b 86 }
shreeshas95 0:f016e9e8d48b 87
shreeshas95 0:f016e9e8d48b 88 #define isit_sdcard(tc_ptr, temp_sdcard) {\
shreeshas95 0:f016e9e8d48b 89 temp_sdcard = 0x00;\
aniruddhv 52:0bd68655c651 90 if( GETapid(tc_ptr) == APID_COM ){\
aniruddhv 52:0bd68655c651 91 if( ( (tc_ptr->TC_string[2]) >> 4) == SERVICE_OBSRS ){\
aniruddhv 52:0bd68655c651 92 temp_sdcard = 0x01;\
shreeshas95 0:f016e9e8d48b 93 }\
shreeshas95 0:f016e9e8d48b 94 }\
shreeshas95 0:f016e9e8d48b 95 }
shreeshas95 0:f016e9e8d48b 96
krishanprajapat 122:b99f8be0a51a 97
shreeshas95 2:2caf2a9a13aa 98
shreeshas95 2:2caf2a9a13aa 99 void after_cooling_pa(){
shreeshas95 2:2caf2a9a13aa 100 gCOM_MNG_TMTC_THREAD->signal_set(COM_MNG_TMTC_SIGNAL_UART_INT);
shreeshas95 2:2caf2a9a13aa 101 }
shreeshas95 2:2caf2a9a13aa 102
shreeshas95 0:f016e9e8d48b 103 /*
shreeshas95 0:f016e9e8d48b 104 @brief: check for missing tc, also check crc, i.e.
shreeshas95 0:f016e9e8d48b 105 if true execution can be started else have to wait
shreeshas95 0:f016e9e8d48b 106 decide the next state
shreeshas95 0:f016e9e8d48b 107 @param: none
shreeshas95 0:f016e9e8d48b 108 @return: bool indicating whether there are missing tc
shreeshas95 0:f016e9e8d48b 109 */
shreeshas95 0:f016e9e8d48b 110 // PENDING: LAST FRAME BIT
shreeshas95 0:f016e9e8d48b 111 /*
shreeshas95 0:f016e9e8d48b 112 for loop: check for missing tc
shreeshas95 0:f016e9e8d48b 113 if: check for incorrect sized tc
shreeshas95 0:f016e9e8d48b 114 if: check for last frame bit
shreeshas95 0:f016e9e8d48b 115 */
shreeshas95 0:f016e9e8d48b 116 #define continueToExecute(returnHere) {\
shreeshas95 0:f016e9e8d48b 117 uint8_t tempReturn = 0x00;\
shreeshas95 5:ab276a17ca07 118 /*search for missing psc*/\
shreeshas95 15:1c1ca992b43b 119 for(uint8_t p = 0x00 ; p < (gTOTAL_VALID_TC) ; ++p){\
shreeshas95 0:f016e9e8d48b 120 bool flag = false;\
shreeshas95 0:f016e9e8d48b 121 Base_tc *node_ptr = gHEAD_NODE_TCL;\
shreeshas95 0:f016e9e8d48b 122 while(node_ptr != NULL){\
shreeshas95 0:f016e9e8d48b 123 if( (GETpacket_seq_count(node_ptr) == p) && (GETcrc_pass(node_ptr) == 1) ){\
shreeshas95 0:f016e9e8d48b 124 flag = true;\
shreeshas95 0:f016e9e8d48b 125 break;\
shreeshas95 0:f016e9e8d48b 126 }\
shreeshas95 0:f016e9e8d48b 127 else{\
shreeshas95 0:f016e9e8d48b 128 node_ptr = node_ptr->next_TC;\
shreeshas95 0:f016e9e8d48b 129 }\
shreeshas95 0:f016e9e8d48b 130 }\
shreeshas95 0:f016e9e8d48b 131 if(flag == false){\
shreeshas95 0:f016e9e8d48b 132 tempReturn = 0x02;\
shreeshas95 0:f016e9e8d48b 133 break;\
shreeshas95 0:f016e9e8d48b 134 }\
shreeshas95 0:f016e9e8d48b 135 }\
shreeshas95 5:ab276a17ca07 136 /*search for last packet bit*/\
shreeshas95 5:ab276a17ca07 137 tempReturn = tempReturn + 0x01;\
shreeshas95 0:f016e9e8d48b 138 Base_tc *tcp = gHEAD_NODE_TCL;\
shreeshas95 0:f016e9e8d48b 139 while(tcp != NULL){\
rohit3342 16:538de1b20b3a 140 if(GETpacket_seq_count(tcp) == (gTOTAL_VALID_TC - 1)){\
shreeshas95 5:ab276a17ca07 141 if( ( (tcp->TC_string[1]) & 0x20 ) == 0x20 ){\
shreeshas95 5:ab276a17ca07 142 tempReturn = tempReturn - 0x01;\
shreeshas95 0:f016e9e8d48b 143 }\
shreeshas95 0:f016e9e8d48b 144 break;\
shreeshas95 0:f016e9e8d48b 145 }\
shreeshas95 0:f016e9e8d48b 146 tcp = tcp->next_TC;\
shreeshas95 0:f016e9e8d48b 147 }\
shreeshas95 0:f016e9e8d48b 148 returnHere = tempReturn;\
shreeshas95 5:ab276a17ca07 149 /*UPDATE gMASTER STATE*/\
shreeshas95 5:ab276a17ca07 150 if( (returnHere == 0x00) ){\
aniruddhv 37:c9a739750806 151 if( (gMASTER_STATE == TCL_STATE_INCOMPLETE) || (gMASTER_STATE == TCL_STATE_COMPLETED) || (gMASTER_STATE == TCL_STATE_ABORTED) ){\
aniruddhv 37:c9a739750806 152 gMASTER_STATE = TCL_STATE_EXECUTING;\
shreeshas95 5:ab276a17ca07 153 }\
shreeshas95 5:ab276a17ca07 154 }\
shreeshas95 5:ab276a17ca07 155 else{\
aniruddhv 180:ccc21cc163f8 156 if( (gMASTER_STATE == TCL_STATE_INCOMPLETE) || (gMASTER_STATE == TCL_STATE_COMPLETED) || (gMASTER_STATE == TCL_STATE_ABORTED) ){\
shreeshas95 5:ab276a17ca07 157 gMASTER_STATE = TCL_STATE_INCOMPLETE;\
shreeshas95 5:ab276a17ca07 158 }\
shreeshas95 5:ab276a17ca07 159 }\
shreeshas95 0:f016e9e8d48b 160 }
shreeshas95 0:f016e9e8d48b 161
shreeshas95 0:f016e9e8d48b 162 /*
shreeshas95 2:2caf2a9a13aa 163 return 1 if code match
shreeshas95 2:2caf2a9a13aa 164 return 0 if code mismatch
shreeshas95 2:2caf2a9a13aa 165 */
shreeshas95 2:2caf2a9a13aa 166 #define GScodeVerification(returnHere){\
shreeshas95 2:2caf2a9a13aa 167 Base_tc *testTC = gHEAD_NODE_TCL;\
shreeshas95 2:2caf2a9a13aa 168 uint16_t overflowCount = 0;\
shreeshas95 15:1c1ca992b43b 169 returnHere = 0xFF;\
shreeshas95 2:2caf2a9a13aa 170 while( (overflowCount < TCL_OVERFLOW_CONSTANT) && (testTC != NULL) ){\
shreeshas95 2:2caf2a9a13aa 171 if( (GETpacket_seq_count(testTC) == PSC_CALLSIGN) && (GETapid(testTC) == APID_CALLSIGN) ){\
aniruddhv 37:c9a739750806 172 /*uint8_t temp8 = testTC->TC_string[1];*/\
aniruddhv 37:c9a739750806 173 if( true ){\
shreeshas95 2:2caf2a9a13aa 174 for( int i = 2 ; i <= 8 ; ++i ){\
shreeshas95 2:2caf2a9a13aa 175 if( testTC->TC_string[i] != gGSCODE[i-2] ){\
shreeshas95 2:2caf2a9a13aa 176 returnHere = 0;\
shreeshas95 2:2caf2a9a13aa 177 break;\
shreeshas95 2:2caf2a9a13aa 178 }\
shreeshas95 2:2caf2a9a13aa 179 }\
shreeshas95 2:2caf2a9a13aa 180 }\
shreeshas95 2:2caf2a9a13aa 181 break;\
shreeshas95 2:2caf2a9a13aa 182 }\
shreeshas95 2:2caf2a9a13aa 183 testTC = testTC->next_TC;\
shreeshas95 2:2caf2a9a13aa 184 ++overflowCount;\
shreeshas95 2:2caf2a9a13aa 185 }\
shreeshas95 2:2caf2a9a13aa 186 }
shreeshas95 2:2caf2a9a13aa 187
shreeshas95 2:2caf2a9a13aa 188 /*
shreeshas95 0:f016e9e8d48b 189 @brief: DELETE THE CRC FAILED TC FROM THE LIST TO FREE-UP MEMORY AND UPDATE
shreeshas95 0:f016e9e8d48b 190 THE TOTAL VALID TC AND GENERATE L1_ACK_TM
shreeshas95 0:f016e9e8d48b 191 @param: none
shreeshas95 0:f016e9e8d48b 192 @return: none
shreeshas95 0:f016e9e8d48b 193 */
shreeshas95 4:104dd82c99b8 194 /*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 */
shreeshas95 4:104dd82c99b8 195
shreeshas95 4:104dd82c99b8 196 /*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 */
shreeshas95 0:f016e9e8d48b 197
shreeshas95 0:f016e9e8d48b 198 // CDMS TEAM CODE START
aniruddhv 52:0bd68655c651 199 inline Base_tm* FCTN_CDMS_RLY_TMTC(Base_tc *tc_ptr){
aniruddhv 52:0bd68655c651 200 uint8_t ACKCODE = 0x00;
ee12b079 73:6c99294b7802 201 //printf("\rTC execution in progress\r\n");
aniruddhv 52:0bd68655c651 202 Base_tm *tm_pointer = new Long_tm;
aniruddhv 52:0bd68655c651 203 Base_tm *tm_ptr = tm_pointer;
aniruddhv 52:0bd68655c651 204 received = 0;
aniruddhv 52:0bd68655c651 205 switch(GETapid(tc_ptr))
aniruddhv 52:0bd68655c651 206 {
aniruddhv 52:0bd68655c651 207 case 1: //apid=01 implies it corresponds to bae
aniruddhv 52:0bd68655c651 208 {
ee12b079 73:6c99294b7802 209 //printf("Telecommand is for BAE\r\n");
ee12b079 73:6c99294b7802 210 //printf("Sending TC to BAE...\r\n"); //interrupt to be sent to the bae
aniruddhv 52:0bd68655c651 211 FCTN_I2C_WRITE((char*)tc_ptr->TC_string);
aniruddhv 52:0bd68655c651 212 while(1)
aniruddhv 52:0bd68655c651 213 {
aniruddhv 52:0bd68655c651 214 wait(1); //TimeOut instead of wait
aniruddhv 52:0bd68655c651 215 if(tm_status_4m_slv == 1)
aniruddhv 52:0bd68655c651 216 {
ee12b079 73:6c99294b7802 217 //printf("receiving...\r\n");
shreeshas95 103:b55559925dc1 218 FCTN_I2C_READ((char*)tm_pointer->TM_string,134);
ee12b079 73:6c99294b7802 219 //printf("%s", tm_pointer->TM_string);
aniruddhv 52:0bd68655c651 220 received+=1;
aniruddhv 52:0bd68655c651 221 tm_pointer = tm_pointer->next_TM;
aniruddhv 52:0bd68655c651 222 break; //only for testing purpose
aniruddhv 52:0bd68655c651 223 }
aniruddhv 52:0bd68655c651 224 else
aniruddhv 52:0bd68655c651 225 {
aniruddhv 52:0bd68655c651 226 break;
aniruddhv 52:0bd68655c651 227 }
aniruddhv 52:0bd68655c651 228 }
aniruddhv 52:0bd68655c651 229 if(received >= 1 )
aniruddhv 52:0bd68655c651 230 {
ee12b079 73:6c99294b7802 231 //printf("Telemetry is received from BAE\r\n");
aniruddhv 52:0bd68655c651 232 Base_tm *tm_print = tm_ptr;
aniruddhv 52:0bd68655c651 233 for(uint8_t i=0;i<received;i++)
aniruddhv 52:0bd68655c651 234 {
ee12b079 73:6c99294b7802 235 //printf("%s", tm_print->TM_string);
aniruddhv 52:0bd68655c651 236 tm_print = tm_print->next_TM; //for check
aniruddhv 52:0bd68655c651 237 }
aniruddhv 52:0bd68655c651 238 received = 0;
ee12b079 53:18db568f1098 239 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 240 }
aniruddhv 52:0bd68655c651 241 else
aniruddhv 52:0bd68655c651 242 {
ee12b079 73:6c99294b7802 243 //printf("Telemetry is not received from BAE\r\n");
aniruddhv 52:0bd68655c651 244 //tm_pointer = new Short_tm;
aniruddhv 52:0bd68655c651 245 tm_pointer->TM_string[0] = 0xB0;
aniruddhv 52:0bd68655c651 246 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
aniruddhv 52:0bd68655c651 247 tm_pointer->TM_string[2] = 0x01;
aniruddhv 52:0bd68655c651 248 tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided
aniruddhv 52:0bd68655c651 249 tm_pointer->TM_string[4] = 0x01;
aniruddhv 52:0bd68655c651 250 for(uint8_t i=0;i<6;i++)
aniruddhv 52:0bd68655c651 251 {
aniruddhv 52:0bd68655c651 252 tm_pointer->TM_string[i+5] = 0;
aniruddhv 52:0bd68655c651 253 }
aniruddhv 52:0bd68655c651 254 crc16 = crc16_gen(tm_ptr->TM_string,11);
aniruddhv 52:0bd68655c651 255 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
aniruddhv 52:0bd68655c651 256 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 53:18db568f1098 257 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 258 }
aniruddhv 52:0bd68655c651 259 break;
aniruddhv 52:0bd68655c651 260 }
aniruddhv 52:0bd68655c651 261 case 2:
aniruddhv 52:0bd68655c651 262 {
ee12b079 88:b9beee1a7a3e 263 //gPC.printf("Telecommand is for CDMS\r\n"); //apid = 10 corresponds to cdms
aniruddhv 52:0bd68655c651 264 switch(GETservice_type(tc_ptr))
aniruddhv 52:0bd68655c651 265 {
aniruddhv 52:0bd68655c651 266 case 0x60:
aniruddhv 52:0bd68655c651 267 {
aniruddhv 69:20f09a0c3fd2 268 //gPC.printf("service:MMS\r\n");
aniruddhv 52:0bd68655c651 269 switch(GETservice_subtype(tc_ptr))
aniruddhv 52:0bd68655c651 270 {
aniruddhv 52:0bd68655c651 271 case 0x1:
aniruddhv 52:0bd68655c651 272 {
ee12b079 73:6c99294b7802 273 //printf("sub_service:Read from RAM_Memory\r\n");
aniruddhv 52:0bd68655c651 274 mid=(uint16_t)(tc_ptr->TC_string[3]<<4)+(uint16_t)(tc_ptr->TC_string[4]);
aniruddhv 52:0bd68655c651 275
ee12b079 94:611c066467a1 276 //Data[0] = FCTN_CDMS_RD_FLASH(0);
ee12b079 94:611c066467a1 277 //Data[1] = FCTN_CDMS_RD_FLASH(1);
aniruddhv 52:0bd68655c651 278 //tm_pointer = new Long_tm;
aniruddhv 52:0bd68655c651 279 tm_pointer->TM_string[0] = 0x30;
aniruddhv 52:0bd68655c651 280 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
aniruddhv 52:0bd68655c651 281 tm_pointer->TM_string[2] = (uint8_t)(flash_counter);
aniruddhv 52:0bd68655c651 282 for(uint8_t i=0;i<4;i++)
aniruddhv 52:0bd68655c651 283 {
aniruddhv 52:0bd68655c651 284 tm_pointer->TM_string[3+i] = (uint8_t)((Data[0]>>(8*i))&0x00FF);
aniruddhv 52:0bd68655c651 285 }
aniruddhv 52:0bd68655c651 286 for(uint8_t i=4;i<8;i++)
aniruddhv 52:0bd68655c651 287 {
aniruddhv 52:0bd68655c651 288 tm_pointer->TM_string[3+i] = (uint8_t)((Data[1]>>(8*i))&0x00FF);
aniruddhv 52:0bd68655c651 289 }
aniruddhv 52:0bd68655c651 290 crc16 = crc16_gen(tm_ptr->TM_string,9);
aniruddhv 52:0bd68655c651 291 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
aniruddhv 52:0bd68655c651 292 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 53:18db568f1098 293 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 294 }
aniruddhv 52:0bd68655c651 295 case 0x2:
aniruddhv 52:0bd68655c651 296 {
ee12b079 73:6c99294b7802 297 //printf("sub_service:Read from Flash_Memory\r\n");
aniruddhv 52:0bd68655c651 298 mid=(uint16_t)(tc_ptr->TC_string[3]<<4)+(uint16_t)(tc_ptr->TC_string[4]);
aniruddhv 52:0bd68655c651 299
ee12b079 94:611c066467a1 300 //Data[0] = FCTN_CDMS_RD_FLASH(0);
ee12b079 94:611c066467a1 301 //Data[1] = FCTN_CDMS_RD_FLASH(1);
aniruddhv 52:0bd68655c651 302 //tm_pointer = new Long_tm;
aniruddhv 52:0bd68655c651 303 tm_pointer->TM_string[0] = 0x30;
aniruddhv 52:0bd68655c651 304 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
aniruddhv 52:0bd68655c651 305 tm_pointer->TM_string[2] = (uint8_t)(flash_counter);
aniruddhv 52:0bd68655c651 306 for(uint8_t i=0;i<4;i++)
aniruddhv 52:0bd68655c651 307 {
aniruddhv 52:0bd68655c651 308 tm_pointer->TM_string[3+i] = (uint8_t)((Data[0]>>(8*i))&0x00FF);
aniruddhv 52:0bd68655c651 309 }
aniruddhv 52:0bd68655c651 310 for(uint8_t i=4;i<8;i++)
aniruddhv 52:0bd68655c651 311 {
aniruddhv 52:0bd68655c651 312 tm_pointer->TM_string[3+i] = (uint8_t)((Data[1]>>(8*i))&0x00FF);
aniruddhv 52:0bd68655c651 313 }
aniruddhv 52:0bd68655c651 314 crc16 = crc16_gen(tm_ptr->TM_string,9);
aniruddhv 52:0bd68655c651 315 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
aniruddhv 52:0bd68655c651 316 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 53:18db568f1098 317 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 318 }
aniruddhv 52:0bd68655c651 319 case 0x5:
aniruddhv 52:0bd68655c651 320 {
ee12b079 73:6c99294b7802 321 //printf("WRITE ON FLASH_MEMORY\r\n");
aniruddhv 52:0bd68655c651 322 mid=(uint16_t)(tc_ptr->TC_string[3]<<4)+(uint16_t)(tc_ptr->TC_string[4]);
aniruddhv 52:0bd68655c651 323 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])));
ee12b079 94:611c066467a1 324 //FCTN_CDMS_WR_FLASH(mid,block);
aniruddhv 52:0bd68655c651 325 //tm_pointer = new Short_tm;
aniruddhv 52:0bd68655c651 326 tm_pointer->TM_string[0] = 0xB0;
aniruddhv 52:0bd68655c651 327 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
aniruddhv 52:0bd68655c651 328 tm_pointer->TM_string[2] = 0x01;
aniruddhv 52:0bd68655c651 329 tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided
aniruddhv 52:0bd68655c651 330 tm_pointer->TM_string[4] = 0x01;
aniruddhv 52:0bd68655c651 331 for(uint8_t i=0;i<6;i++)
aniruddhv 52:0bd68655c651 332 {
aniruddhv 52:0bd68655c651 333 tm_pointer->TM_string[i+5] = 0;
aniruddhv 52:0bd68655c651 334 }
aniruddhv 52:0bd68655c651 335 crc16 = crc16_gen(tm_ptr->TM_string,11);
aniruddhv 52:0bd68655c651 336 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
aniruddhv 52:0bd68655c651 337 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 53:18db568f1098 338 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 339 break;
aniruddhv 52:0bd68655c651 340 }
aniruddhv 52:0bd68655c651 341 default:
aniruddhv 52:0bd68655c651 342 {
ee12b079 73:6c99294b7802 343 //printf("INVALID TC\r\n"); //Send Invalid TC Telemetry
aniruddhv 52:0bd68655c651 344 //tm_pointer = new Short_tm;
aniruddhv 52:0bd68655c651 345 tm_pointer->TM_string[0] = 0xB0;
aniruddhv 52:0bd68655c651 346 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
aniruddhv 52:0bd68655c651 347 tm_pointer->TM_string[2] = 0x01;
aniruddhv 52:0bd68655c651 348 tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided
aniruddhv 52:0bd68655c651 349 tm_pointer->TM_string[4] = 0x01;
aniruddhv 52:0bd68655c651 350 for(uint8_t i=0;i<6;i++)
aniruddhv 52:0bd68655c651 351 {
aniruddhv 52:0bd68655c651 352 tm_pointer->TM_string[i+5] = 0;
aniruddhv 52:0bd68655c651 353 }
aniruddhv 52:0bd68655c651 354 crc16 = crc16_gen(tm_ptr->TM_string,11);
aniruddhv 52:0bd68655c651 355 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
aniruddhv 52:0bd68655c651 356 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 53:18db568f1098 357 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 358 }
aniruddhv 52:0bd68655c651 359 break;
aniruddhv 52:0bd68655c651 360 }
aniruddhv 52:0bd68655c651 361 }
aniruddhv 52:0bd68655c651 362 case 0x8:
aniruddhv 52:0bd68655c651 363 {
ee12b079 73:6c99294b7802 364 //printf("service:FUNCTION MANAGEMENT SERVICE\r\n");
aniruddhv 52:0bd68655c651 365 if(GETservice_subtype(tc_ptr)==0x1)
aniruddhv 52:0bd68655c651 366 {
aniruddhv 52:0bd68655c651 367 if(GETpid(tc_ptr)==0x01)
aniruddhv 52:0bd68655c651 368 {
ee12b079 73:6c99294b7802 369 //printf("TC_PL_INIT\r\n"); // call PWR_SWCH_ON function
aniruddhv 52:0bd68655c651 370 //tm_pointer = new Short_tm;
aniruddhv 52:0bd68655c651 371 tm_pointer->TM_string[0] = 0xB0;
aniruddhv 52:0bd68655c651 372 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
aniruddhv 52:0bd68655c651 373 tm_pointer->TM_string[2] = ACKCODE;
aniruddhv 52:0bd68655c651 374 for(uint8_t i=3;i<11;i++)
aniruddhv 52:0bd68655c651 375 {
aniruddhv 52:0bd68655c651 376 tm_pointer->TM_string[i] = 0;
aniruddhv 52:0bd68655c651 377 }
aniruddhv 52:0bd68655c651 378 crc16 = crc16_gen(tm_ptr->TM_string,11);
aniruddhv 52:0bd68655c651 379 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
aniruddhv 52:0bd68655c651 380 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 53:18db568f1098 381 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 382 break;
aniruddhv 52:0bd68655c651 383 }
aniruddhv 52:0bd68655c651 384 else if(GETpid(tc_ptr)==0x02)
aniruddhv 52:0bd68655c651 385 {
ee12b079 73:6c99294b7802 386 //printf("TC_PL_MAIN\r\n"); // call PWR_SWCH_ON function
aniruddhv 52:0bd68655c651 387 //tm_pointer = new Short_tm;
aniruddhv 52:0bd68655c651 388 tm_pointer->TM_string[0] = 0xB0;
aniruddhv 52:0bd68655c651 389 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
aniruddhv 52:0bd68655c651 390 tm_pointer->TM_string[2] = ACKCODE;
aniruddhv 52:0bd68655c651 391 for(uint8_t i=3;i<11;i++)
aniruddhv 52:0bd68655c651 392 {
aniruddhv 52:0bd68655c651 393 tm_pointer->TM_string[i] = 0;
aniruddhv 52:0bd68655c651 394 }
aniruddhv 52:0bd68655c651 395 crc16 = crc16_gen(tm_ptr->TM_string,11);
aniruddhv 52:0bd68655c651 396 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
aniruddhv 52:0bd68655c651 397 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 53:18db568f1098 398 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 399 break;
aniruddhv 52:0bd68655c651 400 }
aniruddhv 52:0bd68655c651 401 else if(GETpid(tc_ptr)==0x03)
aniruddhv 52:0bd68655c651 402 {
ee12b079 73:6c99294b7802 403 //printf("TC_COM_INIT\r\n"); // call PWR_SWCH_ON function
aniruddhv 52:0bd68655c651 404 //tm_pointer = new Short_tm;
aniruddhv 52:0bd68655c651 405 tm_pointer->TM_string[0] = 0xB0;
aniruddhv 52:0bd68655c651 406 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
aniruddhv 52:0bd68655c651 407 tm_pointer->TM_string[2] = ACKCODE;
aniruddhv 52:0bd68655c651 408 for(uint8_t i=3;i<11;i++)
aniruddhv 52:0bd68655c651 409 {
aniruddhv 52:0bd68655c651 410 tm_pointer->TM_string[i] = 0;
aniruddhv 52:0bd68655c651 411 }
aniruddhv 52:0bd68655c651 412 crc16 = crc16_gen(tm_ptr->TM_string,11);
aniruddhv 52:0bd68655c651 413 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
aniruddhv 52:0bd68655c651 414 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 53:18db568f1098 415 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 416 break;
aniruddhv 52:0bd68655c651 417 }
aniruddhv 52:0bd68655c651 418 else if(GETpid(tc_ptr)==0x04)
aniruddhv 52:0bd68655c651 419 {
ee12b079 73:6c99294b7802 420 //printf("TC_CDMS_HK_MAIN\r\n"); // call PWR_SWCH_ON function
aniruddhv 52:0bd68655c651 421 //tm_pointer = new Short_tm;
aniruddhv 52:0bd68655c651 422 tm_pointer->TM_string[0] = 0xB0;
aniruddhv 52:0bd68655c651 423 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
aniruddhv 52:0bd68655c651 424 tm_pointer->TM_string[2] = ACKCODE;
aniruddhv 52:0bd68655c651 425 for(uint8_t i=3;i<11;i++)
aniruddhv 52:0bd68655c651 426 {
aniruddhv 52:0bd68655c651 427 tm_pointer->TM_string[i] = 0;
aniruddhv 52:0bd68655c651 428 }
aniruddhv 52:0bd68655c651 429 crc16 = crc16_gen(tm_ptr->TM_string,11);
aniruddhv 52:0bd68655c651 430 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
aniruddhv 52:0bd68655c651 431 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 53:18db568f1098 432 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 433 break;
aniruddhv 52:0bd68655c651 434 }
aniruddhv 52:0bd68655c651 435 else if(GETpid(tc_ptr)==0x11)
aniruddhv 52:0bd68655c651 436 {
ee12b079 73:6c99294b7802 437 //printf("TC_SW_ON_SD\r\n"); // call PWR_SWCH_ON function
aniruddhv 52:0bd68655c651 438 //tm_pointer = new Short_tm;
aniruddhv 52:0bd68655c651 439 tm_pointer->TM_string[0] = 0xB0;
aniruddhv 52:0bd68655c651 440 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
aniruddhv 52:0bd68655c651 441 tm_pointer->TM_string[2] = ACKCODE;
aniruddhv 52:0bd68655c651 442 for(uint8_t i=3;i<11;i++)
aniruddhv 52:0bd68655c651 443 {
aniruddhv 52:0bd68655c651 444 tm_pointer->TM_string[i] = 0;
aniruddhv 52:0bd68655c651 445 }
aniruddhv 52:0bd68655c651 446 crc16 = crc16_gen(tm_ptr->TM_string,11);
aniruddhv 52:0bd68655c651 447 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
aniruddhv 52:0bd68655c651 448 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 53:18db568f1098 449 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 450 break;
aniruddhv 52:0bd68655c651 451 }
aniruddhv 52:0bd68655c651 452 else if(GETpid(tc_ptr)==0x12)
aniruddhv 52:0bd68655c651 453 {
ee12b079 73:6c99294b7802 454 //printf("TC_SW_ON_RTC\r\n"); // call PWR_SWCH_ON function
aniruddhv 52:0bd68655c651 455 //tm_pointer = new Short_tm;
aniruddhv 52:0bd68655c651 456 tm_pointer->TM_string[0] = 0xB0;
aniruddhv 52:0bd68655c651 457 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
aniruddhv 52:0bd68655c651 458 tm_pointer->TM_string[2] = ACKCODE;
aniruddhv 52:0bd68655c651 459 for(uint8_t i=3;i<11;i++)
aniruddhv 52:0bd68655c651 460 {
aniruddhv 52:0bd68655c651 461 tm_pointer->TM_string[i] = 0;
aniruddhv 52:0bd68655c651 462 }
aniruddhv 52:0bd68655c651 463 crc16 = crc16_gen(tm_ptr->TM_string,11);
aniruddhv 52:0bd68655c651 464 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
aniruddhv 52:0bd68655c651 465 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 53:18db568f1098 466 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 467 break;
aniruddhv 52:0bd68655c651 468 }
aniruddhv 52:0bd68655c651 469 else if(GETpid(tc_ptr)==0x13)
aniruddhv 52:0bd68655c651 470 {
ee12b079 73:6c99294b7802 471 //printf("TC_SW_ON_BAE\r\n"); // call PWR_SWCH_ON function
aniruddhv 52:0bd68655c651 472 //tm_pointer = new Short_tm;
aniruddhv 52:0bd68655c651 473 tm_pointer->TM_string[0] = 0xB0;
aniruddhv 52:0bd68655c651 474 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
aniruddhv 52:0bd68655c651 475 tm_pointer->TM_string[2] = ACKCODE;
aniruddhv 52:0bd68655c651 476 for(uint8_t i=3;i<11;i++)
aniruddhv 52:0bd68655c651 477 {
aniruddhv 52:0bd68655c651 478 tm_pointer->TM_string[i] = 0;
aniruddhv 52:0bd68655c651 479 }
aniruddhv 52:0bd68655c651 480 crc16 = crc16_gen(tm_ptr->TM_string,11);
aniruddhv 52:0bd68655c651 481 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
aniruddhv 52:0bd68655c651 482 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 53:18db568f1098 483 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 484 break;
aniruddhv 52:0bd68655c651 485 }
aniruddhv 52:0bd68655c651 486 else if(GETpid(tc_ptr)==0x14)
aniruddhv 52:0bd68655c651 487 {
ee12b079 73:6c99294b7802 488 //printf("TC_SW_ON_PL_DL\r\n"); // call PWR_SWCH_ON function
aniruddhv 52:0bd68655c651 489 //tm_pointer = new Short_tm;
aniruddhv 52:0bd68655c651 490 tm_pointer->TM_string[0] = 0xB0;
aniruddhv 52:0bd68655c651 491 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
aniruddhv 52:0bd68655c651 492 tm_pointer->TM_string[2] = ACKCODE;
aniruddhv 52:0bd68655c651 493 for(uint8_t i=3;i<11;i++)
aniruddhv 52:0bd68655c651 494 {
aniruddhv 52:0bd68655c651 495 tm_pointer->TM_string[i] = 0;
aniruddhv 52:0bd68655c651 496 }
aniruddhv 52:0bd68655c651 497 crc16 = crc16_gen(tm_ptr->TM_string,11);
aniruddhv 52:0bd68655c651 498 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
aniruddhv 52:0bd68655c651 499 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 53:18db568f1098 500 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 501 break;
aniruddhv 52:0bd68655c651 502 }
aniruddhv 52:0bd68655c651 503 else if(GETpid(tc_ptr)==0x15)
aniruddhv 52:0bd68655c651 504 {
ee12b079 73:6c99294b7802 505 //printf("TC_SW_ON_PL_AG_HV\r\n"); // call PWR_SWCH_ON function
aniruddhv 52:0bd68655c651 506 //tm_pointer = new Short_tm;
aniruddhv 52:0bd68655c651 507 tm_pointer->TM_string[0] = 0xB0;
aniruddhv 52:0bd68655c651 508 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
aniruddhv 52:0bd68655c651 509 tm_pointer->TM_string[2] = ACKCODE;
aniruddhv 52:0bd68655c651 510 for(uint8_t i=3;i<11;i++)
aniruddhv 52:0bd68655c651 511 {
aniruddhv 52:0bd68655c651 512 tm_pointer->TM_string[i] = 0;
aniruddhv 52:0bd68655c651 513 }
aniruddhv 52:0bd68655c651 514 crc16 = crc16_gen(tm_ptr->TM_string,11);
aniruddhv 52:0bd68655c651 515 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
aniruddhv 52:0bd68655c651 516 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 53:18db568f1098 517 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 518 break;
aniruddhv 52:0bd68655c651 519 }
aniruddhv 52:0bd68655c651 520 else if(GETpid(tc_ptr)==0x16)
aniruddhv 52:0bd68655c651 521 {
ee12b079 73:6c99294b7802 522 //printf("TC_SW_ON_V_A_EN\r\n"); // call PWR_SWCH_ON function
aniruddhv 52:0bd68655c651 523 //tm_pointer = new Short_tm;
aniruddhv 52:0bd68655c651 524 tm_pointer->TM_string[0] = 0xB0;
aniruddhv 52:0bd68655c651 525 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
aniruddhv 52:0bd68655c651 526 tm_pointer->TM_string[2] = ACKCODE;
aniruddhv 52:0bd68655c651 527 for(uint8_t i=3;i<11;i++)
aniruddhv 52:0bd68655c651 528 {
aniruddhv 52:0bd68655c651 529 tm_pointer->TM_string[i] = 0;
aniruddhv 52:0bd68655c651 530 }
aniruddhv 52:0bd68655c651 531 crc16 = crc16_gen(tm_ptr->TM_string,11);
aniruddhv 52:0bd68655c651 532 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
aniruddhv 52:0bd68655c651 533 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 53:18db568f1098 534 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 535 break;
aniruddhv 52:0bd68655c651 536 }
aniruddhv 52:0bd68655c651 537 else if(GETpid(tc_ptr)==0x21)
aniruddhv 52:0bd68655c651 538 {
ee12b079 73:6c99294b7802 539 //printf("TC_SW_OFF_SD\r\n"); // call PWR_SWCH_ON function
aniruddhv 52:0bd68655c651 540 //tm_pointer = new Short_tm;
aniruddhv 52:0bd68655c651 541 tm_pointer->TM_string[0] = 0xB0;
aniruddhv 52:0bd68655c651 542 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
aniruddhv 52:0bd68655c651 543 tm_pointer->TM_string[2] = ACKCODE;
aniruddhv 52:0bd68655c651 544 for(uint8_t i=3;i<11;i++)
aniruddhv 52:0bd68655c651 545 {
aniruddhv 52:0bd68655c651 546 tm_pointer->TM_string[i] = 0;
aniruddhv 52:0bd68655c651 547 }
aniruddhv 52:0bd68655c651 548 crc16 = crc16_gen(tm_ptr->TM_string,11);
aniruddhv 52:0bd68655c651 549 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
aniruddhv 52:0bd68655c651 550 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 53:18db568f1098 551 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 552 break;
aniruddhv 52:0bd68655c651 553 }
aniruddhv 52:0bd68655c651 554 else if(GETpid(tc_ptr)==0x22)
aniruddhv 52:0bd68655c651 555 {
ee12b079 73:6c99294b7802 556 //printf("TC_SW_OFF_RTC\r\n"); // call PWR_SWCH_ON function
aniruddhv 52:0bd68655c651 557 //tm_pointer = new Short_tm;
aniruddhv 52:0bd68655c651 558 tm_pointer->TM_string[0] = 0xB0;
aniruddhv 52:0bd68655c651 559 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
aniruddhv 52:0bd68655c651 560 tm_pointer->TM_string[2] = ACKCODE;
aniruddhv 52:0bd68655c651 561 for(uint8_t i=3;i<11;i++)
aniruddhv 52:0bd68655c651 562 {
aniruddhv 52:0bd68655c651 563 tm_pointer->TM_string[i] = 0;
aniruddhv 52:0bd68655c651 564 }
aniruddhv 52:0bd68655c651 565 crc16 = crc16_gen(tm_ptr->TM_string,11);
aniruddhv 52:0bd68655c651 566 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
aniruddhv 52:0bd68655c651 567 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 53:18db568f1098 568 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 569 break;
aniruddhv 52:0bd68655c651 570 }
aniruddhv 52:0bd68655c651 571 else if(GETpid(tc_ptr)==0x23)
aniruddhv 52:0bd68655c651 572 {
ee12b079 73:6c99294b7802 573 //printf("TC_SW_OFF_BAE\r\n"); // call PWR_SWCH_ON function
aniruddhv 52:0bd68655c651 574 //tm_pointer = new Short_tm;
aniruddhv 52:0bd68655c651 575 tm_pointer->TM_string[0] = 0xB0;
aniruddhv 52:0bd68655c651 576 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
aniruddhv 52:0bd68655c651 577 tm_pointer->TM_string[2] = ACKCODE;
aniruddhv 52:0bd68655c651 578 for(uint8_t i=3;i<11;i++)
aniruddhv 52:0bd68655c651 579 {
aniruddhv 52:0bd68655c651 580 tm_pointer->TM_string[i] = 0;
aniruddhv 52:0bd68655c651 581 }
aniruddhv 52:0bd68655c651 582 crc16 = crc16_gen(tm_ptr->TM_string,11);
aniruddhv 52:0bd68655c651 583 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
aniruddhv 52:0bd68655c651 584 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 53:18db568f1098 585 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 586 break;
aniruddhv 52:0bd68655c651 587 }
aniruddhv 52:0bd68655c651 588 else if(GETpid(tc_ptr)==0x24)
aniruddhv 52:0bd68655c651 589 {
ee12b079 73:6c99294b7802 590 //printf("TC_SW_OFF_PL_DL\r\n"); // call PWR_SWCH_ON function
aniruddhv 52:0bd68655c651 591 //tm_pointer = new Short_tm;
aniruddhv 52:0bd68655c651 592 tm_pointer->TM_string[0] = 0xB0;
aniruddhv 52:0bd68655c651 593 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
aniruddhv 52:0bd68655c651 594 tm_pointer->TM_string[2] = ACKCODE;
aniruddhv 52:0bd68655c651 595 for(uint8_t i=3;i<11;i++)
aniruddhv 52:0bd68655c651 596 {
aniruddhv 52:0bd68655c651 597 tm_pointer->TM_string[i] = 0;
aniruddhv 52:0bd68655c651 598 }
aniruddhv 52:0bd68655c651 599 crc16 = crc16_gen(tm_ptr->TM_string,11);
aniruddhv 52:0bd68655c651 600 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
aniruddhv 52:0bd68655c651 601 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 53:18db568f1098 602 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 603 break;
aniruddhv 52:0bd68655c651 604 }
aniruddhv 52:0bd68655c651 605 else if(GETpid(tc_ptr)==0x25)
aniruddhv 52:0bd68655c651 606 {
ee12b079 73:6c99294b7802 607 //printf("TC_SW_OFF_PL_AG_HV\r\n"); // call PWR_SWCH_ON function
aniruddhv 52:0bd68655c651 608 //tm_pointer = new Short_tm;
aniruddhv 52:0bd68655c651 609 tm_pointer->TM_string[0] = 0xB0;
aniruddhv 52:0bd68655c651 610 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
aniruddhv 52:0bd68655c651 611 tm_pointer->TM_string[2] = ACKCODE;
aniruddhv 52:0bd68655c651 612 for(uint8_t i=3;i<11;i++)
aniruddhv 52:0bd68655c651 613 {
aniruddhv 52:0bd68655c651 614 tm_pointer->TM_string[i] = 0;
aniruddhv 52:0bd68655c651 615 }
aniruddhv 52:0bd68655c651 616 crc16 = crc16_gen(tm_ptr->TM_string,11);
aniruddhv 52:0bd68655c651 617 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
aniruddhv 52:0bd68655c651 618 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 53:18db568f1098 619 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 620 break;
aniruddhv 52:0bd68655c651 621 }
aniruddhv 52:0bd68655c651 622 else if(GETpid(tc_ptr)==0x26)
aniruddhv 52:0bd68655c651 623 {
ee12b079 73:6c99294b7802 624 //printf("TC_SW_OFF_V_A_EN\r\n"); // call PWR_SWCH_ON function
aniruddhv 52:0bd68655c651 625 //tm_pointer = new Short_tm;
aniruddhv 52:0bd68655c651 626 tm_pointer->TM_string[0] = 0xB0;
aniruddhv 52:0bd68655c651 627 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
aniruddhv 52:0bd68655c651 628 tm_pointer->TM_string[2] = ACKCODE;
aniruddhv 52:0bd68655c651 629 for(uint8_t i=3;i<11;i++)
aniruddhv 52:0bd68655c651 630 {
aniruddhv 52:0bd68655c651 631 tm_pointer->TM_string[i] = 0;
aniruddhv 52:0bd68655c651 632 }
aniruddhv 52:0bd68655c651 633 crc16 = crc16_gen(tm_ptr->TM_string,11);
aniruddhv 52:0bd68655c651 634 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
aniruddhv 52:0bd68655c651 635 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 53:18db568f1098 636 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 637 break;
aniruddhv 52:0bd68655c651 638 }
aniruddhv 52:0bd68655c651 639 else if(GETpid(tc_ptr)==0x31)
aniruddhv 52:0bd68655c651 640 {
ee12b079 73:6c99294b7802 641 //printf("TC_RST_SD\r\n"); // call PWR_SWCH_ON function
aniruddhv 52:0bd68655c651 642 //tm_pointer = new Short_tm;
aniruddhv 52:0bd68655c651 643 tm_pointer->TM_string[0] = 0xB0;
aniruddhv 52:0bd68655c651 644 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
aniruddhv 52:0bd68655c651 645 tm_pointer->TM_string[2] = ACKCODE;
aniruddhv 52:0bd68655c651 646 for(uint8_t i=3;i<11;i++)
aniruddhv 52:0bd68655c651 647 {
aniruddhv 52:0bd68655c651 648 tm_pointer->TM_string[i] = 0;
aniruddhv 52:0bd68655c651 649 }
aniruddhv 52:0bd68655c651 650 crc16 = crc16_gen(tm_ptr->TM_string,11);
aniruddhv 52:0bd68655c651 651 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
aniruddhv 52:0bd68655c651 652 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 53:18db568f1098 653 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 654 break;
aniruddhv 52:0bd68655c651 655 }
aniruddhv 52:0bd68655c651 656 else if(GETpid(tc_ptr)==0x32)
aniruddhv 52:0bd68655c651 657 {
ee12b079 73:6c99294b7802 658 //printf("TC_RST_RTC\r\n"); // call PWR_SWCH_ON function
aniruddhv 52:0bd68655c651 659 //tm_pointer = new Short_tm;
aniruddhv 52:0bd68655c651 660 tm_pointer->TM_string[0] = 0xB0;
aniruddhv 52:0bd68655c651 661 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
aniruddhv 52:0bd68655c651 662 tm_pointer->TM_string[2] = ACKCODE;
aniruddhv 52:0bd68655c651 663 for(uint8_t i=3;i<11;i++)
aniruddhv 52:0bd68655c651 664 {
aniruddhv 52:0bd68655c651 665 tm_pointer->TM_string[i] = 0;
aniruddhv 52:0bd68655c651 666 }
aniruddhv 52:0bd68655c651 667 crc16 = crc16_gen(tm_ptr->TM_string,11);
aniruddhv 52:0bd68655c651 668 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
aniruddhv 52:0bd68655c651 669 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 53:18db568f1098 670 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 671 break;
aniruddhv 52:0bd68655c651 672 }
aniruddhv 52:0bd68655c651 673 else if(GETpid(tc_ptr)==0x33)
aniruddhv 52:0bd68655c651 674 {
ee12b079 73:6c99294b7802 675 //printf("TC_RST_BAE\r\n"); // call PWR_SWCH_ON function
aniruddhv 52:0bd68655c651 676 //tm_pointer = new Short_tm;
aniruddhv 52:0bd68655c651 677 tm_pointer->TM_string[0] = 0xB0;
aniruddhv 52:0bd68655c651 678 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
aniruddhv 52:0bd68655c651 679 tm_pointer->TM_string[2] = ACKCODE;
aniruddhv 52:0bd68655c651 680 for(uint8_t i=3;i<11;i++)
aniruddhv 52:0bd68655c651 681 {
aniruddhv 52:0bd68655c651 682 tm_pointer->TM_string[i] = 0;
aniruddhv 52:0bd68655c651 683 }
aniruddhv 52:0bd68655c651 684 crc16 = crc16_gen(tm_ptr->TM_string,11);
aniruddhv 52:0bd68655c651 685 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
aniruddhv 52:0bd68655c651 686 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 53:18db568f1098 687 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 688 break;
aniruddhv 52:0bd68655c651 689 }
aniruddhv 52:0bd68655c651 690 else if(GETpid(tc_ptr)==0x34)
aniruddhv 52:0bd68655c651 691 {
ee12b079 73:6c99294b7802 692 //printf("TC_RST_PL_DL\r\n"); // call PWR_SWCH_ON function
aniruddhv 52:0bd68655c651 693 //tm_pointer = new Short_tm;
aniruddhv 52:0bd68655c651 694 tm_pointer->TM_string[0] = 0xB0;
aniruddhv 52:0bd68655c651 695 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
aniruddhv 52:0bd68655c651 696 tm_pointer->TM_string[2] = ACKCODE;
aniruddhv 52:0bd68655c651 697 for(uint8_t i=3;i<11;i++)
aniruddhv 52:0bd68655c651 698 {
aniruddhv 52:0bd68655c651 699 tm_pointer->TM_string[i] = 0;
aniruddhv 52:0bd68655c651 700 }
aniruddhv 52:0bd68655c651 701 crc16 = crc16_gen(tm_ptr->TM_string,11);
aniruddhv 52:0bd68655c651 702 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
aniruddhv 52:0bd68655c651 703 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 53:18db568f1098 704 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 705 break;
aniruddhv 52:0bd68655c651 706 break;
aniruddhv 52:0bd68655c651 707 }
aniruddhv 52:0bd68655c651 708 else if(GETpid(tc_ptr)==0xC1)
aniruddhv 52:0bd68655c651 709 {
ee12b079 73:6c99294b7802 710 //printf("RESET_HK_COUNTER\r\n"); // call PWR_SWCH_ON function
aniruddhv 52:0bd68655c651 711 //tm_pointer = new Short_tm;
aniruddhv 52:0bd68655c651 712 tm_pointer->TM_string[0] = 0xB0;
aniruddhv 52:0bd68655c651 713 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
aniruddhv 52:0bd68655c651 714 tm_pointer->TM_string[2] = ACKCODE;
aniruddhv 52:0bd68655c651 715 for(uint8_t i=3;i<11;i++)
aniruddhv 52:0bd68655c651 716 {
aniruddhv 52:0bd68655c651 717 tm_pointer->TM_string[i] = 0;
aniruddhv 52:0bd68655c651 718 }
aniruddhv 52:0bd68655c651 719 crc16 = crc16_gen(tm_ptr->TM_string,11);
aniruddhv 52:0bd68655c651 720 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
aniruddhv 52:0bd68655c651 721 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 53:18db568f1098 722 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 723 break;
aniruddhv 52:0bd68655c651 724 }
aniruddhv 52:0bd68655c651 725 else if(GETpid(tc_ptr)==0xF1)
aniruddhv 52:0bd68655c651 726 {
ee12b079 73:6c99294b7802 727 //printf("RD_RTC\r\n"); //call RD_RTC
aniruddhv 52:0bd68655c651 728 //tm_pointer = new Short_tm;
aniruddhv 52:0bd68655c651 729 tm_pointer->TM_string[0] = 0xD0;
aniruddhv 52:0bd68655c651 730 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
aniruddhv 52:0bd68655c651 731 tm_pointer->TM_string[2] = 0x01;
aniruddhv 52:0bd68655c651 732 uint64_t time = FCTN_CDMS_RD_RTC();
aniruddhv 52:0bd68655c651 733 tm_pointer->TM_string[3] = (uint8_t)((time&0xFF00000000000000)>>56);
aniruddhv 52:0bd68655c651 734 tm_pointer->TM_string[4] = (uint8_t)((time&0x00FF000000000000)>>48);
aniruddhv 52:0bd68655c651 735 tm_pointer->TM_string[5] = (uint8_t)((time&0x0000FF0000000000)>>40);
aniruddhv 52:0bd68655c651 736 tm_pointer->TM_string[6] = (uint8_t)((time&0x000000FF00000000)>>32);
aniruddhv 52:0bd68655c651 737 tm_pointer->TM_string[7] = (uint8_t)((time&0x00000000FF000000)>>24);
aniruddhv 52:0bd68655c651 738 tm_pointer->TM_string[8] = (uint8_t)((time&0x0000000000FF0000)>>16);
aniruddhv 52:0bd68655c651 739 tm_pointer->TM_string[9] = (uint8_t)((time&0x000000000000FF00)>>8);
aniruddhv 52:0bd68655c651 740 tm_pointer->TM_string[10] = (uint8_t)(time&0x00000000000000FF);
aniruddhv 52:0bd68655c651 741 crc16 = crc16_gen(tm_ptr->TM_string,11);
aniruddhv 52:0bd68655c651 742 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
aniruddhv 52:0bd68655c651 743 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 53:18db568f1098 744 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 745 }
aniruddhv 52:0bd68655c651 746 else
aniruddhv 52:0bd68655c651 747 {
ee12b079 73:6c99294b7802 748 //printf("INVALID TC\r\n");
aniruddhv 52:0bd68655c651 749 //tm_pointer = new Short_tm;
aniruddhv 52:0bd68655c651 750 tm_pointer->TM_string[0] = 0xB0;
aniruddhv 52:0bd68655c651 751 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
aniruddhv 52:0bd68655c651 752 tm_pointer->TM_string[2] = 0x01;
aniruddhv 52:0bd68655c651 753 tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided
aniruddhv 52:0bd68655c651 754 tm_pointer->TM_string[4] = 0x01;
aniruddhv 52:0bd68655c651 755 for(uint8_t i=0;i<6;i++)
aniruddhv 52:0bd68655c651 756 {
aniruddhv 52:0bd68655c651 757 tm_pointer->TM_string[i+5] = 0;
aniruddhv 52:0bd68655c651 758 }
aniruddhv 52:0bd68655c651 759 crc16 = crc16_gen(tm_ptr->TM_string,11);
aniruddhv 52:0bd68655c651 760 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
aniruddhv 52:0bd68655c651 761 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 53:18db568f1098 762 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 763 }
aniruddhv 52:0bd68655c651 764 }
aniruddhv 52:0bd68655c651 765
aniruddhv 52:0bd68655c651 766
aniruddhv 52:0bd68655c651 767 }
aniruddhv 52:0bd68655c651 768 default:
aniruddhv 52:0bd68655c651 769 {
ee12b079 73:6c99294b7802 770 //printf("INVALID TC"); //send invalid TC TM
aniruddhv 52:0bd68655c651 771 //tm_pointer = new Short_tm;
aniruddhv 52:0bd68655c651 772 tm_pointer->TM_string[0] = 0xB0;
aniruddhv 52:0bd68655c651 773 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
aniruddhv 52:0bd68655c651 774 tm_pointer->TM_string[2] = 0x01;
aniruddhv 52:0bd68655c651 775 tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided
aniruddhv 52:0bd68655c651 776 tm_pointer->TM_string[4] = 0x01;
aniruddhv 52:0bd68655c651 777 for(uint8_t i=0;i<6;i++)
aniruddhv 52:0bd68655c651 778 {
aniruddhv 52:0bd68655c651 779 tm_pointer->TM_string[i+5] = 0;
aniruddhv 52:0bd68655c651 780 }
aniruddhv 52:0bd68655c651 781 crc16 = crc16_gen(tm_ptr->TM_string,11);
aniruddhv 52:0bd68655c651 782 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
aniruddhv 52:0bd68655c651 783 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 53:18db568f1098 784 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 785 break;
aniruddhv 52:0bd68655c651 786 }
aniruddhv 52:0bd68655c651 787 }
aniruddhv 52:0bd68655c651 788 }
aniruddhv 52:0bd68655c651 789 case 3:
aniruddhv 52:0bd68655c651 790 {
ee12b079 73:6c99294b7802 791 //printf("Telecommand is for PL\r\n");
ee12b079 73:6c99294b7802 792 // printf("Informing PL about TC using I2C\r\n"); //interrupt to be sent to the bae
aniruddhv 52:0bd68655c651 793 // FCTN_I2C_WRITE((char*)tc_ptr->TC_string);
ee12b079 73:6c99294b7802 794 // printf("sent the Telecommand to BAE\r\n"); //packet along with crc will be sent when bae is ready
aniruddhv 52:0bd68655c651 795 // wait(1); //wait time is to be optimised
aniruddhv 52:0bd68655c651 796 // if(tm_status_4m_slv == 1)
aniruddhv 52:0bd68655c651 797 // {
aniruddhv 52:0bd68655c651 798 // FCTN_I2C_READ((char*)tm_ptr->TM_string);
aniruddhv 52:0bd68655c651 799 // received = 1;
aniruddhv 52:0bd68655c651 800 // }
aniruddhv 52:0bd68655c651 801 // if(received == 1 )
aniruddhv 52:0bd68655c651 802 // {
ee12b079 73:6c99294b7802 803 // printf("Telemetry is received from BAE\r\n");
ee12b079 73:6c99294b7802 804 // printf("%s", tm_ptr->TM_string);
aniruddhv 52:0bd68655c651 805 // received = 0;
aniruddhv 52:0bd68655c651 806 // } // similar to BAE functions
aniruddhv 52:0bd68655c651 807 break;
aniruddhv 52:0bd68655c651 808 }
aniruddhv 52:0bd68655c651 809 default: //invalid TC
aniruddhv 52:0bd68655c651 810 {
ee12b079 73:6c99294b7802 811 //printf("INVALID TC\r\n");
aniruddhv 52:0bd68655c651 812 //tm_pointer = new Short_tm;
aniruddhv 52:0bd68655c651 813 tm_pointer->TM_string[0] = 0xB0;
aniruddhv 52:0bd68655c651 814 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
aniruddhv 52:0bd68655c651 815 tm_pointer->TM_string[2] = 0x01;
aniruddhv 52:0bd68655c651 816 tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided
aniruddhv 52:0bd68655c651 817 tm_pointer->TM_string[4] = 0x01;
aniruddhv 52:0bd68655c651 818 for(uint8_t i=0;i<6;i++)
aniruddhv 52:0bd68655c651 819 {
aniruddhv 52:0bd68655c651 820 tm_pointer->TM_string[i+5] = 0;
aniruddhv 52:0bd68655c651 821 }
aniruddhv 52:0bd68655c651 822 crc16 = crc16_gen(tm_ptr->TM_string,11);
aniruddhv 52:0bd68655c651 823 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
aniruddhv 52:0bd68655c651 824 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 53:18db568f1098 825 tm_pointer->next_TM = NULL; return tm_ptr;
aniruddhv 52:0bd68655c651 826 break;
aniruddhv 52:0bd68655c651 827 }
aniruddhv 52:0bd68655c651 828 }
aniruddhv 52:0bd68655c651 829 }
shreeshas95 0:f016e9e8d48b 830 // CDMS TEAM CODE END
shreeshas95 0:f016e9e8d48b 831 // EXECUTE OBOSC
aniruddhv 51:da85d84768e2 832 #define execute_obosc_core(tc_ptr, tm_ptr, reset_flag) {\
ee12b079 135:522f7d73d04f 833 if (DEBUG)\
ee12b079 135:522f7d73d04f 834 gPC.puts("Inside execute_obosc_core\r\n");\
shreeshas95 0:f016e9e8d48b 835 uint8_t service_subtype = (tc_ptr->TC_string[2]) & 0x0F;\
shreeshas95 4:104dd82c99b8 836 uint8_t temp8 = 0x00;\
shreeshas95 4:104dd82c99b8 837 Base_tc *modify_this = gHEAD_NODE_TCL;\
shreeshas95 4:104dd82c99b8 838 int modify_overflow = 0x00;\
shreeshas95 4:104dd82c99b8 839 switch( service_subtype ){\
shreeshas95 4:104dd82c99b8 840 case OBOSC_SUB_DISABLE:\
aniruddhv 12:ffdb29353058 841 /*gPC.puts("target psc are ");*/\
shreeshas95 5:ab276a17ca07 842 for(int i = 3 ; i < 9 ; ++i){\
aniruddhv 12:ffdb29353058 843 /*gPC.printf("%u ", tc_ptr->TC_string[i]);*/\
shreeshas95 5:ab276a17ca07 844 }\
aniruddhv 12:ffdb29353058 845 /*gPC.puts("\r\n");*/\
shreeshas95 5:ab276a17ca07 846 /*gPC.puts("disable type obosc\r\n");*/\
shreeshas95 4:104dd82c99b8 847 while( modify_this != NULL ){\
shreeshas95 4:104dd82c99b8 848 if( modify_overflow < TCL_OVERFLOW_CONSTANT ){\
shreeshas95 5:ab276a17ca07 849 uint8_t modify_psc = GETpacket_seq_count(modify_this);\
shreeshas95 5:ab276a17ca07 850 /*gPC.printf("mosify_psc = %u\r\n", modify_psc);*/\
shreeshas95 4:104dd82c99b8 851 for( int i = 3 ; i < 9 ; ++i ){\
shreeshas95 5:ab276a17ca07 852 uint8_t target_psc = tc_ptr->TC_string[i];\
shreeshas95 5:ab276a17ca07 853 if( (target_psc == modify_psc) && (target_psc != 0) ){\
shreeshas95 4:104dd82c99b8 854 uint16_t tempExec = TC_STATE_DISABLED;\
shreeshas95 4:104dd82c99b8 855 PUTexec_status( modify_this, tempExec );\
shreeshas95 4:104dd82c99b8 856 break;\
shreeshas95 4:104dd82c99b8 857 }\
shreeshas95 4:104dd82c99b8 858 }\
shreeshas95 4:104dd82c99b8 859 modify_this = modify_this->next_TC;\
shreeshas95 4:104dd82c99b8 860 ++modify_overflow;\
shreeshas95 4:104dd82c99b8 861 }\
shreeshas95 4:104dd82c99b8 862 else{\
aniruddhv 155:ca7365c03fd7 863 RESET_CDMS;\
shreeshas95 4:104dd82c99b8 864 break;\
shreeshas95 4:104dd82c99b8 865 }\
shreeshas95 4:104dd82c99b8 866 }\
shreeshas95 4:104dd82c99b8 867 break;\
shreeshas95 4:104dd82c99b8 868 case OBOSC_SUB_RETRY:\
aniruddhv 12:ffdb29353058 869 /*gPC.puts("retry type obosc\r\n");*/\
shreeshas95 4:104dd82c99b8 870 while( modify_this != NULL ){\
shreeshas95 4:104dd82c99b8 871 if( modify_overflow < TCL_OVERFLOW_CONSTANT ){\
shreeshas95 5:ab276a17ca07 872 uint8_t modify_psc = GETpacket_seq_count(modify_this);\
shreeshas95 4:104dd82c99b8 873 for( int i = 3 ; i < 9 ; ++i ){\
shreeshas95 5:ab276a17ca07 874 uint8_t target_psc = tc_ptr->TC_string[i];\
shreeshas95 5:ab276a17ca07 875 if( (target_psc == modify_psc) && (target_psc != 0) ){\
shreeshas95 4:104dd82c99b8 876 uint16_t tempExec = TC_STATE_MARKED_RETRY;\
shreeshas95 4:104dd82c99b8 877 PUTexec_status( modify_this, tempExec );\
aniruddhv 12:ffdb29353058 878 /*gPC.puts("reqquired tc found: disable\r\n");*/\
shreeshas95 4:104dd82c99b8 879 break;\
shreeshas95 4:104dd82c99b8 880 }\
shreeshas95 4:104dd82c99b8 881 }\
shreeshas95 4:104dd82c99b8 882 modify_this = modify_this->next_TC;\
shreeshas95 4:104dd82c99b8 883 ++modify_overflow;\
shreeshas95 4:104dd82c99b8 884 }\
shreeshas95 4:104dd82c99b8 885 else{\
aniruddhv 155:ca7365c03fd7 886 RESET_CDMS;\
shreeshas95 4:104dd82c99b8 887 break;\
shreeshas95 4:104dd82c99b8 888 }\
shreeshas95 4:104dd82c99b8 889 }\
shreeshas95 4:104dd82c99b8 890 break;\
shreeshas95 4:104dd82c99b8 891 }\
shreeshas95 4:104dd82c99b8 892 Base_tm *ackl234new = new Short_tm;\
shreeshas95 4:104dd82c99b8 893 ackl234new->next_TM = NULL;\
shreeshas95 4:104dd82c99b8 894 /*return telemetry pointer here*/\
shreeshas95 4:104dd82c99b8 895 tm_ptr = ackl234new;\
shreeshas95 4:104dd82c99b8 896 ackl234new->TM_string[0] = TMID_ACK_L234 << 4;\
shreeshas95 4:104dd82c99b8 897 ackl234new->TM_string[1] = GETpacket_seq_count(tc_ptr);\
shreeshas95 4:104dd82c99b8 898 ackl234new->TM_string[2] = 0xA0;\
shreeshas95 4:104dd82c99b8 899 for(int i = 3; i < 11; ++i){\
shreeshas95 4:104dd82c99b8 900 ackl234new->TM_string[i] = 0x00;\
shreeshas95 4:104dd82c99b8 901 }\
shreeshas95 4:104dd82c99b8 902 uint16_t crc = crc16_gen(ackl234new->TM_string, TM_SHORT_SIZE-2);\
shreeshas95 4:104dd82c99b8 903 ackl234new->TM_string[11] = (crc & 0xFF00) >> 8;\
shreeshas95 4:104dd82c99b8 904 ackl234new->TM_string[12] = crc & 0x00FF;\
shreeshas95 4:104dd82c99b8 905 /*ack l234 old*/\
shreeshas95 4:104dd82c99b8 906 if( service_subtype == OBOSC_SUB_REP_LE ){\
shreeshas95 4:104dd82c99b8 907 if( gLAST_TM_SHORT_OR_LONG == SHORT_TM_CODE ){\
shreeshas95 4:104dd82c99b8 908 Base_tm *ackl234old = new Short_tm;\
shreeshas95 4:104dd82c99b8 909 ackl234old->next_TM = NULL;\
shreeshas95 4:104dd82c99b8 910 /*APPEND TO ACK L234 NEW HERE*/\
shreeshas95 4:104dd82c99b8 911 ackl234new->next_TM = ackl234old;\
shreeshas95 4:104dd82c99b8 912 for( int i = 0 ; i < TM_SHORT_SIZE ; ++i ){\
shreeshas95 4:104dd82c99b8 913 ackl234old->TM_string[i] = gLAST_TM[i];\
shreeshas95 4:104dd82c99b8 914 }\
shreeshas95 0:f016e9e8d48b 915 }\
shreeshas95 4:104dd82c99b8 916 else{\
shreeshas95 4:104dd82c99b8 917 Base_tm *tempLongTM = new Long_tm;\
shreeshas95 4:104dd82c99b8 918 tempLongTM->next_TM = NULL;\
shreeshas95 4:104dd82c99b8 919 /*APPEND TO ACK L234 NEW HERE*/\
shreeshas95 4:104dd82c99b8 920 ackl234new->next_TM = tempLongTM;\
shreeshas95 4:104dd82c99b8 921 for( int i = 0 ; i < TM_LONG_SIZE ; ++i ){\
shreeshas95 4:104dd82c99b8 922 tempLongTM->TM_string[i] = gLAST_TM[i];\
shreeshas95 4:104dd82c99b8 923 }\
shreeshas95 4:104dd82c99b8 924 }\
shreeshas95 4:104dd82c99b8 925 }\
shreeshas95 4:104dd82c99b8 926 else if( service_subtype == OBOSC_SUB_REP_TCLD ){\
shreeshas95 4:104dd82c99b8 927 get_tc_list(ackl234new->next_TM, GETpacket_seq_count(tc_ptr));\
shreeshas95 4:104dd82c99b8 928 }\
shreeshas95 4:104dd82c99b8 929 else if( service_subtype == OBOSC_SUB_RESET ){\
aniruddhv 51:da85d84768e2 930 /*reset_all;*/\
aniruddhv 51:da85d84768e2 931 reset_flag = 1;\
shreeshas95 4:104dd82c99b8 932 /*PENDING: VERIFY reset_all, RESET CDMS*/\
shreeshas95 0:f016e9e8d48b 933 }\
shreeshas95 5:ab276a17ca07 934 else if( (service_subtype != OBOSC_SUB_DISABLE) && (service_subtype != OBOSC_SUB_RETRY) ){\
shreeshas95 4:104dd82c99b8 935 /*CHANGE THE ACK CODE TO INVALID TC*/\
shreeshas95 4:104dd82c99b8 936 ackl234new->TM_string[2] = 0xA2;\
shreeshas95 0:f016e9e8d48b 937 }\
ee12b079 135:522f7d73d04f 938 if (DEBUG)\
ee12b079 135:522f7d73d04f 939 gPC.puts("completed obosc\r\n");\
shreeshas95 4:104dd82c99b8 940 }
shreeshas95 4:104dd82c99b8 941
shreeshas95 4:104dd82c99b8 942 /*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 */
krishanprajapat 117:bfdc807f3d3c 943
shreeshas95 0:f016e9e8d48b 944
shreeshas95 0:f016e9e8d48b 945 #define EXECUTE_OBOSC_ONLY {\
aniruddhv 51:da85d84768e2 946 int reset_flag = 0;\
ee12b079 135:522f7d73d04f 947 if (DEBUG)\
ee12b079 135:522f7d73d04f 948 gPC.puts("iNSIDE EXECUTE_OBOSC_ONLY\r\n");\
aniruddhv 180:ccc21cc163f8 949 Base_tm *obosc_tm_core = NULL;\
aniruddhv 180:ccc21cc163f8 950 Base_tm *obosc_tm = obosc_tm_core;\
shreeshas95 15:1c1ca992b43b 951 for(uint8_t execute_psc = PSC_START_VALUE ; execute_psc < gTOTAL_VALID_TC ; ++execute_psc){\
shreeshas95 4:104dd82c99b8 952 Base_tc* current_TC = gHEAD_NODE_TCL;\
shreeshas95 4:104dd82c99b8 953 int overCount = 0;\
shreeshas95 0:f016e9e8d48b 954 while( current_TC != NULL ){\
shreeshas95 4:104dd82c99b8 955 if( overCount < TCL_OVERFLOW_CONSTANT ){\
shreeshas95 4:104dd82c99b8 956 if( (GETcrc_pass(current_TC) == 1) && (GETpacket_seq_count(current_TC) == execute_psc) ){\
shreeshas95 4:104dd82c99b8 957 /*CHECK FOR OBOSC*/\
shreeshas95 0:f016e9e8d48b 958 uint8_t temp82 = 0x00;\
shreeshas95 0:f016e9e8d48b 959 isit_obosc(current_TC, temp82);\
shreeshas95 0:f016e9e8d48b 960 if(temp82 == 0x01){\
shreeshas95 4:104dd82c99b8 961 uint16_t current_exec_status = GETexec_status(current_TC);\
shreeshas95 4:104dd82c99b8 962 if( (current_exec_status == TC_STATE_SUCCESSFULLY_EXECUTED) || (current_exec_status == TC_STATE_DISABLED) )\
shreeshas95 4:104dd82c99b8 963 break;\
shreeshas95 4:104dd82c99b8 964 else if( (current_exec_status == TC_STATE_UNEXECUTED) || (current_exec_status == TC_STATE_MARKED_RETRY) ){\
ee12b079 134:4694fc291ce1 965 if (DEBUG)\
ee12b079 134:4694fc291ce1 966 gPC.printf("It is obosc: %u\r\n", execute_psc);\
shreeshas95 4:104dd82c99b8 967 /*EXECUTION OF OBOSC TC*/\
shreeshas95 4:104dd82c99b8 968 /*WARNING: LARGE MEMORY UTILIZATION FOR TC-LIST-REPORT */\
ee12b079 73:6c99294b7802 969 execute_obosc_core(current_TC, obosc_tm_core, reset_flag);\
aniruddhv 180:ccc21cc163f8 970 Base_tm *obosc_tm_current = obosc_tm_core;\
aniruddhv 180:ccc21cc163f8 971 while(obosc_tm_core != NULL){\
aniruddhv 180:ccc21cc163f8 972 obosc_tm_core = obosc_tm_core->next_TM;\
aniruddhv 180:ccc21cc163f8 973 }\
ee12b079 73:6c99294b7802 974 uint16_t temp16 = TC_STATE_SUCCESSFULLY_EXECUTED;\
ee12b079 73:6c99294b7802 975 PUTexec_status(current_TC, temp16);\
ee12b079 73:6c99294b7802 976 while( obosc_tm_current != NULL ){\
ee12b079 73:6c99294b7802 977 int length = TM_SHORT_SIZE;\
shreeshas95 102:80c911a6e736 978 if( GETshort_or_long_tm(obosc_tm_current) == SHORT_TM_CODE ){\
ee12b079 73:6c99294b7802 979 length = TM_SHORT_SIZE;\
ee12b079 73:6c99294b7802 980 }\
ee12b079 73:6c99294b7802 981 else{\
ee12b079 73:6c99294b7802 982 length = TM_LONG_SIZE;\
ee12b079 73:6c99294b7802 983 }\
ee12b079 73:6c99294b7802 984 for(int i = 0 ; i < length ; ++i){\
ee12b079 73:6c99294b7802 985 /*gPC.putc(obosc_tm_current->TM_string[i]);*/\
ee12b079 73:6c99294b7802 986 }\
ee12b079 73:6c99294b7802 987 obosc_tm_current = obosc_tm_current->next_TM;\
ee12b079 73:6c99294b7802 988 }\
ee12b079 73:6c99294b7802 989 if ( reset_flag ==1 ){\
ee12b079 73:6c99294b7802 990 reset_all;\
ee12b079 73:6c99294b7802 991 }\
shreeshas95 0:f016e9e8d48b 992 }\
shreeshas95 0:f016e9e8d48b 993 }\
shreeshas95 0:f016e9e8d48b 994 }\
shreeshas95 4:104dd82c99b8 995 current_TC = current_TC->next_TC;\
shreeshas95 4:104dd82c99b8 996 ++overCount;\
shreeshas95 0:f016e9e8d48b 997 }\
shreeshas95 4:104dd82c99b8 998 else{\
shreeshas95 4:104dd82c99b8 999 /*PENDING: REST CDMS: MEMORY LEAK FOUND*/\
shreeshas95 4:104dd82c99b8 1000 break;\
shreeshas95 4:104dd82c99b8 1001 }\
shreeshas95 4:104dd82c99b8 1002 }\
aniruddhv 58:5c59f28620bc 1003 }\
aniruddhv 180:ccc21cc163f8 1004 if(obosc_tm_core != NULL){\
aniruddhv 180:ccc21cc163f8 1005 Base_tm *obosc_tm_head = NULL;\
aniruddhv 180:ccc21cc163f8 1006 get_call_sign(obosc_tm_head);\
aniruddhv 180:ccc21cc163f8 1007 Base_tm *obosc_tm_current = obosc_tm_head;\
aniruddhv 180:ccc21cc163f8 1008 get_ack_l1(obosc_tm_current->next_TM);\
aniruddhv 180:ccc21cc163f8 1009 int overflowCountOBONLY = 0;\
aniruddhv 180:ccc21cc163f8 1010 while( obosc_tm_current->next_TM != NULL ){\
aniruddhv 180:ccc21cc163f8 1011 if( overflowCountOBONLY < TM_OVERFLOW_CONSTANT ){\
aniruddhv 180:ccc21cc163f8 1012 obosc_tm_current = obosc_tm_current->next_TM;\
aniruddhv 180:ccc21cc163f8 1013 ++overflowCountOBONLY;\
aniruddhv 180:ccc21cc163f8 1014 }\
aniruddhv 180:ccc21cc163f8 1015 else{\
aniruddhv 180:ccc21cc163f8 1016 RESET_CDMS;\
aniruddhv 180:ccc21cc163f8 1017 break;\
aniruddhv 180:ccc21cc163f8 1018 }\
aniruddhv 180:ccc21cc163f8 1019 }\
aniruddhv 180:ccc21cc163f8 1020 obosc_tm_current->next_TM = obosc_tm;\
aniruddhv 180:ccc21cc163f8 1021 /*Sending OBOSC TM to GS*/\
aniruddhv 180:ccc21cc163f8 1022 /*snd_tm.head_pointer(obosc_tm_head);*/\
aniruddhv 180:ccc21cc163f8 1023 /*transmit_adf;*/\
aniruddhv 180:ccc21cc163f8 1024 /*DELETE THE TM AFTER USE*/\
aniruddhv 180:ccc21cc163f8 1025 obosc_tm_current = obosc_tm_head;\
aniruddhv 180:ccc21cc163f8 1026 int overCount = 0;\
aniruddhv 180:ccc21cc163f8 1027 while( obosc_tm_current != NULL ){\
aniruddhv 180:ccc21cc163f8 1028 if( (overCount < TM_OVERFLOW_CONSTANT) ){\
aniruddhv 180:ccc21cc163f8 1029 Base_tm *temp = obosc_tm_current->next_TM;\
aniruddhv 180:ccc21cc163f8 1030 delete obosc_tm_current;\
aniruddhv 180:ccc21cc163f8 1031 obosc_tm_current = temp;\
aniruddhv 180:ccc21cc163f8 1032 ++overCount;\
aniruddhv 180:ccc21cc163f8 1033 }\
aniruddhv 180:ccc21cc163f8 1034 else{\
aniruddhv 180:ccc21cc163f8 1035 RESET_CDMS;\
aniruddhv 180:ccc21cc163f8 1036 break;\
aniruddhv 180:ccc21cc163f8 1037 }\
aniruddhv 180:ccc21cc163f8 1038 }\
aniruddhv 180:ccc21cc163f8 1039 }\
shreeshas95 0:f016e9e8d48b 1040 }
shreeshas95 0:f016e9e8d48b 1041
shreeshas95 0:f016e9e8d48b 1042 #define EXECUTE_TC {\
shreeshas95 5:ab276a17ca07 1043 gMASTER_STATE = TCL_STATE_EXECUTING;\
ee12b079 135:522f7d73d04f 1044 if (DEBUG)\
ee12b079 135:522f7d73d04f 1045 gPC.puts("iNSIDE EXECUTE_TC\r\n");\
rohit3342 23:c89376564196 1046 /*gPC.printf("%u\r\n", gTOTAL_VALID_TC);*/\
rohit3342 16:538de1b20b3a 1047 for(uint8_t execute_psc = PSC_START_VALUE ; execute_psc < gTOTAL_VALID_TC ; ++execute_psc ){\
ee12b079 134:4694fc291ce1 1048 if (DEBUG)\
ee12b079 134:4694fc291ce1 1049 gPC.printf("executing normal %u\r\n", execute_psc);\
shreeshas95 2:2caf2a9a13aa 1050 /*gLEDG = !gLEDG;*/\
shreeshas95 2:2caf2a9a13aa 1051 /*gLEDR = !gLEDR;*/\
shreeshas95 0:f016e9e8d48b 1052 Base_tc* current_TC = gHEAD_NODE_TCL;\
shreeshas95 4:104dd82c99b8 1053 int overflowCount = 0;\
shreeshas95 0:f016e9e8d48b 1054 while(current_TC != NULL){\
shreeshas95 4:104dd82c99b8 1055 if( overflowCount < TCL_OVERFLOW_CONSTANT ){\
shreeshas95 4:104dd82c99b8 1056 if( (GETcrc_pass(current_TC) == 1) && (GETpacket_seq_count(current_TC) == execute_psc) ){\
shreeshas95 4:104dd82c99b8 1057 uint8_t current_exec_status = GETexec_status(current_TC);\
shreeshas95 5:ab276a17ca07 1058 if( (current_exec_status == TC_STATE_SUCCESSFULLY_EXECUTED) || (current_exec_status == TC_STATE_DISABLED) ){\
aniruddhv 12:ffdb29353058 1059 /*gPC.printf("disabled or completed at %u\n", execute_psc);*/\
aniruddhv 180:ccc21cc163f8 1060 if( execute_psc == (gTOTAL_VALID_TC-1) ){\
aniruddhv 180:ccc21cc163f8 1061 /*LAST TC IS EXECUTED*/\
aniruddhv 180:ccc21cc163f8 1062 gMASTER_STATE = TCL_STATE_COMPLETED;\
aniruddhv 180:ccc21cc163f8 1063 }\
shreeshas95 4:104dd82c99b8 1064 break;\
shreeshas95 5:ab276a17ca07 1065 }\
shreeshas95 4:104dd82c99b8 1066 else if( (current_exec_status == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\
aniruddhv 12:ffdb29353058 1067 /*gPC.printf("abort on nack at %u psc\r\n", execute_psc);*/\
shreeshas95 4:104dd82c99b8 1068 gMASTER_STATE = TCL_STATE_ABORTED;\
rohit3342 44:b9b067d0559f 1069 Base_tm *tm_ptr_head = NULL;\
rohit3342 44:b9b067d0559f 1070 get_call_sign(tm_ptr_head);\
rohit3342 44:b9b067d0559f 1071 Base_tm *tm_ptr = tm_ptr_head;\
rohit3342 44:b9b067d0559f 1072 get_ack_l1(tm_ptr->next_TM);\
ee12b079 73:6c99294b7802 1073 tm_ptr = tm_ptr_head;\
ee12b079 73:6c99294b7802 1074 while( tm_ptr != NULL ){\
ee12b079 73:6c99294b7802 1075 int length = TM_SHORT_SIZE;\
shreeshas95 102:80c911a6e736 1076 if( GETshort_or_long_tm(tm_ptr) == SHORT_TM_CODE ){\
ee12b079 73:6c99294b7802 1077 length = TM_SHORT_SIZE;\
ee12b079 73:6c99294b7802 1078 }\
ee12b079 73:6c99294b7802 1079 else{\
ee12b079 73:6c99294b7802 1080 length = TM_LONG_SIZE;\
ee12b079 73:6c99294b7802 1081 }\
ee12b079 73:6c99294b7802 1082 /*gPC.puts("Printing Call Sign, ACK_L1, TM list");*/\
ee12b079 73:6c99294b7802 1083 for(int i = 0 ; i < length ; ++i){\
ee12b079 73:6c99294b7802 1084 /*gPC.putc(tm_ptr->TM_string[i]);*/\
ee12b079 73:6c99294b7802 1085 }\
ee12b079 73:6c99294b7802 1086 tm_ptr = tm_ptr->next_TM;\
ee12b079 80:b2155ba726c3 1087 }\
ee12b079 80:b2155ba726c3 1088 /*Send only call sign, ACK_L1 to GS*/\
ee12b079 73:6c99294b7802 1089 /*snd_tm.head_pointer(tm_ptr_head);*/\
ee12b079 95:42d6747900cb 1090 /*transmit_adf;*/\
ee12b079 73:6c99294b7802 1091 /*DELETE THE TM AFTER USE*/\
ee12b079 73:6c99294b7802 1092 tm_ptr = tm_ptr_head;\
ee12b079 73:6c99294b7802 1093 int overflowCountExecute = 0;\
ee12b079 73:6c99294b7802 1094 while(tm_ptr != NULL){\
ee12b079 73:6c99294b7802 1095 if( overflowCountExecute < TM_OVERFLOW_CONSTANT ){\
ee12b079 73:6c99294b7802 1096 Base_tm *temp = tm_ptr->next_TM;\
ee12b079 73:6c99294b7802 1097 delete tm_ptr;\
ee12b079 73:6c99294b7802 1098 tm_ptr = temp;\
ee12b079 73:6c99294b7802 1099 ++overflowCountExecute;\
ee12b079 73:6c99294b7802 1100 }\
ee12b079 73:6c99294b7802 1101 else{\
aniruddhv 155:ca7365c03fd7 1102 RESET_CDMS;\
ee12b079 73:6c99294b7802 1103 break;\
ee12b079 73:6c99294b7802 1104 }\
ee12b079 73:6c99294b7802 1105 }\
shreeshas95 4:104dd82c99b8 1106 break;\
shreeshas95 4:104dd82c99b8 1107 }\
shreeshas95 4:104dd82c99b8 1108 else if( (current_exec_status == TC_STATE_UNEXECUTED) || (current_exec_status == TC_STATE_MARKED_RETRY) ){\
shreeshas95 4:104dd82c99b8 1109 /*EXECUTION OF TC START*/\
shreeshas95 4:104dd82c99b8 1110 uint8_t temp81 = 0x00;\
shreeshas95 4:104dd82c99b8 1111 isit_sdcard(current_TC, temp81);\
shreeshas95 4:104dd82c99b8 1112 if( temp81 == 0x00 ){\
ee12b079 135:522f7d73d04f 1113 if (DEBUG)\
ee12b079 135:522f7d73d04f 1114 gPC.printf("non sd card at %u\r\n", execute_psc);\
shreeshas95 4:104dd82c99b8 1115 /*EXECUTION OF NON SD-CARD (BOTH OBOSC and CDMS functions)*/\
shreeshas95 4:104dd82c99b8 1116 Base_tm *tm_ptr_head = NULL;\
shreeshas95 4:104dd82c99b8 1117 get_call_sign(tm_ptr_head);\
shreeshas95 4:104dd82c99b8 1118 Base_tm *put_tm_here = NULL;\
shreeshas95 4:104dd82c99b8 1119 uint8_t temp82 = 0x00;\
shreeshas95 4:104dd82c99b8 1120 uint8_t tempPAhot = 0x00;\
shreeshas95 4:104dd82c99b8 1121 isit_obosc(current_TC, temp82);\
shreeshas95 4:104dd82c99b8 1122 if(temp82 == 0x01){\
aniruddhv 12:ffdb29353058 1123 /*gPC.printf("obosc tc inside normal tc at %u\r\n", execute_psc);*/\
shreeshas95 4:104dd82c99b8 1124 /*EXECUTION OF OBOSC TC*/\
shreeshas95 4:104dd82c99b8 1125 /*SKIP EXECUTION OF OBOSC HERE*/\
aniruddhv 37:c9a739750806 1126 break;\
shreeshas95 4:104dd82c99b8 1127 }\
shreeshas95 4:104dd82c99b8 1128 else{\
rohit3342 23:c89376564196 1129 /*gPC.printf("cdms relay tmtc at %u\r\n", execute_psc);*/\
shreeshas95 4:104dd82c99b8 1130 /*call CDMS_RLY_TMTC*/\
shreeshas95 4:104dd82c99b8 1131 /*CDMS_RLY_TMTC(current_TC, put_tm_here);*/\
aniruddhv 52:0bd68655c651 1132 put_tm_here = FCTN_CDMS_RLY_TMTC(current_TC);\
shreeshas95 4:104dd82c99b8 1133 }\
shreeshas95 4:104dd82c99b8 1134 /*DETECT ACK OR NACK*/\
shreeshas95 4:104dd82c99b8 1135 uint8_t temp83 = 0x00;\
shreeshas95 4:104dd82c99b8 1136 uint8_t temp84 = GETpacket_seq_count(current_TC);\
shreeshas95 4:104dd82c99b8 1137 detect_ack(put_tm_here, temp83, temp84);\
shreeshas95 4:104dd82c99b8 1138 if( temp83 == 0x01){\
shreeshas95 4:104dd82c99b8 1139 uint16_t temp16 = TC_STATE_SUCCESSFULLY_EXECUTED;\
shreeshas95 4:104dd82c99b8 1140 PUTexec_status(current_TC, temp16);\
shreeshas95 4:104dd82c99b8 1141 }\
aniruddhv 211:77bee0cbebfe 1142 else if( temp83 == 0x02){\
aniruddhv 211:77bee0cbebfe 1143 /*gPC.puts("TC_STATE_EXECUTION_UNKNOWN");*/\
aniruddhv 211:77bee0cbebfe 1144 uint16_t temp16 = TC_STATE_EXECUTION_UNKNOWN;\
aniruddhv 211:77bee0cbebfe 1145 PUTexec_status(current_TC, temp16);\
aniruddhv 211:77bee0cbebfe 1146 }\
shreeshas95 4:104dd82c99b8 1147 else{\
rohit3342 23:c89376564196 1148 /*gPC.puts("TC_STATE_EXECUTION_FAILED");*/\
shreeshas95 4:104dd82c99b8 1149 uint16_t temp16 = TC_STATE_EXECUTION_FAILED;\
shreeshas95 4:104dd82c99b8 1150 PUTexec_status(current_TC, temp16);\
shreeshas95 4:104dd82c99b8 1151 }\
shreeshas95 4:104dd82c99b8 1152 /*ABORT ON NACK AND TC LIST COMPLETED: UPDATE IN gMASTERSTATE*/\
shreeshas95 4:104dd82c99b8 1153 if( (GETexec_status(current_TC) == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\
shreeshas95 4:104dd82c99b8 1154 gMASTER_STATE = TCL_STATE_ABORTED;\
shreeshas95 4:104dd82c99b8 1155 }\
shreeshas95 15:1c1ca992b43b 1156 else if( execute_psc == (gTOTAL_VALID_TC-1) ){\
shreeshas95 4:104dd82c99b8 1157 /*LAST TC IS EXECUTED*/\
shreeshas95 4:104dd82c99b8 1158 gMASTER_STATE = TCL_STATE_COMPLETED;\
shreeshas95 4:104dd82c99b8 1159 }\
shreeshas95 4:104dd82c99b8 1160 /*update last executed L1_ack*/\
shreeshas95 4:104dd82c99b8 1161 if( put_tm_here != NULL ){\
shreeshas95 102:80c911a6e736 1162 if( GETshort_or_long_tm(put_tm_here) == SHORT_TM_CODE ){\
shreeshas95 4:104dd82c99b8 1163 for(int i = 0 ; i < TM_SHORT_SIZE ; ++i){\
shreeshas95 4:104dd82c99b8 1164 gLAST_TM[i] = put_tm_here->TM_string[i];\
shreeshas95 4:104dd82c99b8 1165 gLAST_TM_SHORT_OR_LONG = SHORT_TM_CODE;\
shreeshas95 4:104dd82c99b8 1166 }\
shreeshas95 4:104dd82c99b8 1167 }\
shreeshas95 4:104dd82c99b8 1168 else{\
shreeshas95 4:104dd82c99b8 1169 for( int i = 0 ; i < TM_LONG_SIZE ; ++i ){\
shreeshas95 4:104dd82c99b8 1170 gLAST_TM[i] = put_tm_here->TM_string[i];\
shreeshas95 4:104dd82c99b8 1171 gLAST_TM_SHORT_OR_LONG = LONG_TM_CODE;\
shreeshas95 4:104dd82c99b8 1172 }\
shreeshas95 4:104dd82c99b8 1173 }\
shreeshas95 4:104dd82c99b8 1174 }\
shreeshas95 4:104dd82c99b8 1175 /*PENDING: APPEND ACK L1*/\
shreeshas95 4:104dd82c99b8 1176 Base_tm *tm_ptr = tm_ptr_head;\
shreeshas95 4:104dd82c99b8 1177 get_ack_l1(tm_ptr->next_TM);\
shreeshas95 4:104dd82c99b8 1178 int overflowCountExecute = 0;\
shreeshas95 4:104dd82c99b8 1179 while( tm_ptr->next_TM != NULL ){\
shreeshas95 4:104dd82c99b8 1180 if( overflowCountExecute < TM_OVERFLOW_CONSTANT ){\
shreeshas95 4:104dd82c99b8 1181 tm_ptr = tm_ptr->next_TM;\
shreeshas95 4:104dd82c99b8 1182 ++overflowCountExecute;\
shreeshas95 4:104dd82c99b8 1183 }\
shreeshas95 4:104dd82c99b8 1184 else{\
aniruddhv 155:ca7365c03fd7 1185 RESET_CDMS;\
shreeshas95 4:104dd82c99b8 1186 break;\
shreeshas95 4:104dd82c99b8 1187 }\
shreeshas95 4:104dd82c99b8 1188 }\
shreeshas95 4:104dd82c99b8 1189 tm_ptr->next_TM = put_tm_here;\
shreeshas95 4:104dd82c99b8 1190 /*CHECK FOR HOT PA*/\
shreeshas95 4:104dd82c99b8 1191 isPAhot(tempPAhot);\
shreeshas95 4:104dd82c99b8 1192 if( tempPAhot == 0x00 ){\
shreeshas95 4:104dd82c99b8 1193 gFLAGS = gFLAGS | COM_PA_HOT_FLAG;\
shreeshas95 4:104dd82c99b8 1194 }\
ee12b079 73:6c99294b7802 1195 tm_ptr = tm_ptr_head;\
ee12b079 73:6c99294b7802 1196 while( tm_ptr != NULL ){\
ee12b079 73:6c99294b7802 1197 int length = TM_SHORT_SIZE;\
shreeshas95 102:80c911a6e736 1198 if( GETshort_or_long_tm(tm_ptr) == SHORT_TM_CODE ){\
ee12b079 73:6c99294b7802 1199 length = TM_SHORT_SIZE;\
ee12b079 73:6c99294b7802 1200 }\
ee12b079 73:6c99294b7802 1201 else{\
ee12b079 73:6c99294b7802 1202 length = TM_LONG_SIZE;\
ee12b079 73:6c99294b7802 1203 }\
ee12b079 73:6c99294b7802 1204 /*gPC.puts("Printing Call Sign, ACK_L1, TM list");*/\
ee12b079 73:6c99294b7802 1205 for(int i = 0 ; i < length ; ++i){\
ee12b079 73:6c99294b7802 1206 /*gPC.putc(tm_ptr->TM_string[i]);*/\
ee12b079 73:6c99294b7802 1207 }\
ee12b079 73:6c99294b7802 1208 tm_ptr = tm_ptr->next_TM;\
ee12b079 73:6c99294b7802 1209 }\
ee12b079 80:b2155ba726c3 1210 /*SEND call sign, ACK_L1, NON OBSRS TM TO GS*/\
ee12b079 95:42d6747900cb 1211 snd_tm.head_pointer(tm_ptr_head);\
ee12b079 98:fd99ddc0e0a1 1212 gPC.puts("enter_adf\r\n");\
ee12b079 98:fd99ddc0e0a1 1213 transmit_adf;\
ee12b079 98:fd99ddc0e0a1 1214 gPC.puts("exit_adf\r\n");\
ee12b079 73:6c99294b7802 1215 /*DELETE THE TM AFTER USE*/\
ee12b079 73:6c99294b7802 1216 tm_ptr = tm_ptr_head;\
ee12b079 73:6c99294b7802 1217 overflowCountExecute = 0;\
ee12b079 73:6c99294b7802 1218 while(tm_ptr != NULL){\
ee12b079 73:6c99294b7802 1219 if( overflowCountExecute < TM_OVERFLOW_CONSTANT ){\
ee12b079 73:6c99294b7802 1220 Base_tm *temp = tm_ptr->next_TM;\
ee12b079 73:6c99294b7802 1221 delete tm_ptr;\
ee12b079 73:6c99294b7802 1222 tm_ptr = temp;\
ee12b079 73:6c99294b7802 1223 ++overflowCountExecute;\
ee12b079 73:6c99294b7802 1224 }\
ee12b079 73:6c99294b7802 1225 else{\
aniruddhv 155:ca7365c03fd7 1226 RESET_CDMS;\
ee12b079 73:6c99294b7802 1227 break;\
ee12b079 73:6c99294b7802 1228 }\
ee12b079 73:6c99294b7802 1229 }\
shreeshas95 0:f016e9e8d48b 1230 }\
shreeshas95 0:f016e9e8d48b 1231 else{\
ee12b079 135:522f7d73d04f 1232 if (DEBUG)\
ee12b079 135:522f7d73d04f 1233 gPC.printf("sd card at %u\r\n", execute_psc);\
shreeshas95 4:104dd82c99b8 1234 /*EXECUTION OF SD-CARD DATA SENDING (OBSRS)*/\
aniruddhv 37:c9a739750806 1235 Base_tm *tm_ptr_head = NULL;\
aniruddhv 37:c9a739750806 1236 get_call_sign(tm_ptr_head);\
aniruddhv 37:c9a739750806 1237 Base_tm *put_tm_here = NULL;\
aniruddhv 37:c9a739750806 1238 /*execute_obsrs(current_TC, put_tm_here)*/\
shreeshas95 4:104dd82c99b8 1239 /*read_TC(current_TC);*/\
ee12b079 87:6e154fd43531 1240 execute_OBSRS_TC(current_TC);\
ee12b079 96:4ca92f9775e0 1241 gPC.puts("en_adf");\
ee12b079 95:42d6747900cb 1242 transmit_adf;\
ee12b079 96:4ca92f9775e0 1243 gPC.puts("ex_adf");\
shreeshas95 6:79d422d1ed42 1244 uint8_t tempExec = TC_STATE_SUCCESSFULLY_EXECUTED;\
shreeshas95 6:79d422d1ed42 1245 PUTexec_status(current_TC, tempExec);\
ee12b079 73:6c99294b7802 1246 /*PENDING: ABORT ON NACK CHECK, gMASTER_STATE VERIFICATION WITH SD CARD, session timeout, last executed ack l234*/\
shreeshas95 4:104dd82c99b8 1247 if( (GETexec_status(current_TC) == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\
shreeshas95 4:104dd82c99b8 1248 gMASTER_STATE = TCL_STATE_ABORTED;\
shreeshas95 0:f016e9e8d48b 1249 }\
shreeshas95 15:1c1ca992b43b 1250 else if( execute_psc == (gTOTAL_VALID_TC-1) ){\
shreeshas95 6:79d422d1ed42 1251 gMASTER_STATE = TCL_STATE_COMPLETED;\
shreeshas95 6:79d422d1ed42 1252 }\
ee12b079 73:6c99294b7802 1253 else{\
ee12b079 73:6c99294b7802 1254 uint8_t check1 = 1;\
ee12b079 73:6c99294b7802 1255 for( uint8_t test_psc = execute_psc+1 ; test_psc < gTOTAL_VALID_TC ; ++test_psc ){\
ee12b079 73:6c99294b7802 1256 Base_tc* test_TC = gHEAD_NODE_TCL;\
ee12b079 73:6c99294b7802 1257 while(test_TC != NULL){\
ee12b079 73:6c99294b7802 1258 if( GETpacket_seq_count(test_TC) == test_psc ){\
ee12b079 73:6c99294b7802 1259 uint8_t checkval;\
ee12b079 73:6c99294b7802 1260 isit_obosc(test_TC, checkval);\
ee12b079 73:6c99294b7802 1261 if( checkval == 0 ){\
ee12b079 73:6c99294b7802 1262 check1 = 0;\
ee12b079 73:6c99294b7802 1263 }\
ee12b079 73:6c99294b7802 1264 }\
ee12b079 73:6c99294b7802 1265 test_TC = test_TC->next_TC;\
ee12b079 73:6c99294b7802 1266 }\
ee12b079 73:6c99294b7802 1267 }\
ee12b079 73:6c99294b7802 1268 if( check1 == 0x01 ){\
ee12b079 73:6c99294b7802 1269 gMASTER_STATE = TCL_STATE_COMPLETED;\
ee12b079 73:6c99294b7802 1270 }\
ee12b079 73:6c99294b7802 1271 }\
ee12b079 73:6c99294b7802 1272 /*update last executed L1_ack*/\
ee12b079 73:6c99294b7802 1273 if( put_tm_here != NULL ){\
shreeshas95 102:80c911a6e736 1274 if( GETshort_or_long_tm(put_tm_here) == SHORT_TM_CODE ){\
ee12b079 73:6c99294b7802 1275 for(int i = 0 ; i < TM_SHORT_SIZE ; ++i){\
ee12b079 73:6c99294b7802 1276 gLAST_TM[i] = put_tm_here->TM_string[i];\
ee12b079 73:6c99294b7802 1277 gLAST_TM_SHORT_OR_LONG = SHORT_TM_CODE;\
ee12b079 73:6c99294b7802 1278 }\
ee12b079 73:6c99294b7802 1279 }\
ee12b079 73:6c99294b7802 1280 else{\
ee12b079 73:6c99294b7802 1281 for( int i = 0 ; i < TM_LONG_SIZE ; ++i ){\
ee12b079 73:6c99294b7802 1282 gLAST_TM[i] = put_tm_here->TM_string[i];\
ee12b079 73:6c99294b7802 1283 gLAST_TM_SHORT_OR_LONG = LONG_TM_CODE;\
ee12b079 73:6c99294b7802 1284 }\
ee12b079 73:6c99294b7802 1285 }\
ee12b079 73:6c99294b7802 1286 }\
rohit3342 44:b9b067d0559f 1287 /*PENDING: APPEND ACK L1*/\
rohit3342 44:b9b067d0559f 1288 Base_tm *tm_ptr = tm_ptr_head;\
rohit3342 44:b9b067d0559f 1289 get_ack_l1(tm_ptr->next_TM);\
rohit3342 44:b9b067d0559f 1290 int overflowCountExecute = 0;\
rohit3342 44:b9b067d0559f 1291 while( tm_ptr->next_TM != NULL ){\
rohit3342 44:b9b067d0559f 1292 if( overflowCountExecute < TM_OVERFLOW_CONSTANT ){\
rohit3342 44:b9b067d0559f 1293 tm_ptr = tm_ptr->next_TM;\
rohit3342 44:b9b067d0559f 1294 ++overflowCountExecute;\
rohit3342 44:b9b067d0559f 1295 }\
rohit3342 44:b9b067d0559f 1296 else{\
aniruddhv 155:ca7365c03fd7 1297 RESET_CDMS;\
rohit3342 44:b9b067d0559f 1298 break;\
rohit3342 44:b9b067d0559f 1299 }\
rohit3342 44:b9b067d0559f 1300 }\
rohit3342 44:b9b067d0559f 1301 tm_ptr->next_TM = put_tm_here;\
rohit3342 44:b9b067d0559f 1302 /*CHECK FOR HOT PA*/\
rohit3342 44:b9b067d0559f 1303 uint8_t tempPAhot = 0x00;\
rohit3342 44:b9b067d0559f 1304 isPAhot(tempPAhot);\
rohit3342 44:b9b067d0559f 1305 if( tempPAhot == 0x00 ){\
rohit3342 44:b9b067d0559f 1306 gFLAGS = gFLAGS | COM_PA_HOT_FLAG;\
rohit3342 44:b9b067d0559f 1307 }\
ee12b079 73:6c99294b7802 1308 tm_ptr = tm_ptr_head;\
ee12b079 73:6c99294b7802 1309 while( tm_ptr != NULL ){\
ee12b079 73:6c99294b7802 1310 int length = TM_SHORT_SIZE;\
shreeshas95 102:80c911a6e736 1311 if( GETshort_or_long_tm(tm_ptr) == SHORT_TM_CODE ){\
ee12b079 73:6c99294b7802 1312 length = TM_SHORT_SIZE;\
ee12b079 73:6c99294b7802 1313 }\
ee12b079 73:6c99294b7802 1314 else{\
ee12b079 73:6c99294b7802 1315 length = TM_LONG_SIZE;\
ee12b079 73:6c99294b7802 1316 }\
ee12b079 73:6c99294b7802 1317 /*gPC.puts("Printing Call Sign, ACK_L1, TM list");*/\
ee12b079 73:6c99294b7802 1318 for(int i = 0 ; i < length ; ++i){\
ee12b079 73:6c99294b7802 1319 /*gPC.putc(tm_ptr->TM_string[i]);*/\
ee12b079 73:6c99294b7802 1320 }\
ee12b079 73:6c99294b7802 1321 tm_ptr = tm_ptr->next_TM;\
ee12b079 73:6c99294b7802 1322 }\
ee12b079 80:b2155ba726c3 1323 /*SEND call sign, ACK_L1, OBSRS TO GS*/\
ee12b079 73:6c99294b7802 1324 /*snd_tm.head_pointer(tm_ptr_head);*/\
aniruddhv 169:451b54864992 1325 /*transmit_adf;*/\
ee12b079 73:6c99294b7802 1326 /*DELETE THE TM AFTER USE*/\
ee12b079 73:6c99294b7802 1327 tm_ptr = tm_ptr_head;\
ee12b079 73:6c99294b7802 1328 overflowCountExecute = 0;\
ee12b079 73:6c99294b7802 1329 while(tm_ptr != NULL){\
ee12b079 73:6c99294b7802 1330 if( overflowCountExecute < TM_OVERFLOW_CONSTANT ){\
ee12b079 73:6c99294b7802 1331 Base_tm *temp = tm_ptr->next_TM;\
ee12b079 73:6c99294b7802 1332 delete tm_ptr;\
ee12b079 73:6c99294b7802 1333 tm_ptr = temp;\
ee12b079 73:6c99294b7802 1334 ++overflowCountExecute;\
ee12b079 73:6c99294b7802 1335 }\
ee12b079 73:6c99294b7802 1336 else{\
aniruddhv 155:ca7365c03fd7 1337 RESET_CDMS;\
ee12b079 73:6c99294b7802 1338 break;\
ee12b079 73:6c99294b7802 1339 }\
ee12b079 73:6c99294b7802 1340 }\
shreeshas95 0:f016e9e8d48b 1341 }\
shreeshas95 0:f016e9e8d48b 1342 }\
shreeshas95 4:104dd82c99b8 1343 break;\
shreeshas95 0:f016e9e8d48b 1344 }\
shreeshas95 4:104dd82c99b8 1345 current_TC = current_TC->next_TC;\
shreeshas95 4:104dd82c99b8 1346 ++overflowCount;\
shreeshas95 0:f016e9e8d48b 1347 }\
shreeshas95 4:104dd82c99b8 1348 else{\
aniruddhv 155:ca7365c03fd7 1349 RESET_CDMS;\
shreeshas95 2:2caf2a9a13aa 1350 break;\
shreeshas95 2:2caf2a9a13aa 1351 }\
shreeshas95 2:2caf2a9a13aa 1352 }\
shreeshas95 6:79d422d1ed42 1353 if( gFLAGS & COM_SESSION_TIMEOUT_FLAG ){\
shreeshas95 6:79d422d1ed42 1354 break;\
shreeshas95 6:79d422d1ed42 1355 }\
shreeshas95 6:79d422d1ed42 1356 else if( gMASTER_STATE == TCL_STATE_ABORTED ){\
ee12b079 135:522f7d73d04f 1357 if (DEBUG)\
ee12b079 135:522f7d73d04f 1358 gPC.puts("ABORTING DUE TO ABORT ON NACK\r\n");\
shreeshas95 4:104dd82c99b8 1359 /*EXITED DUE TO ABORT ON NACK:*/\
aniruddhv 180:ccc21cc163f8 1360 /*COM_TX_CNTRL = 0;*/\
shreeshas95 2:2caf2a9a13aa 1361 RX1M.attach(&rx_read, Serial::RxIrq);\
shreeshas95 2:2caf2a9a13aa 1362 gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\
shreeshas95 0:f016e9e8d48b 1363 break;\
shreeshas95 2:2caf2a9a13aa 1364 }\
shreeshas95 4:104dd82c99b8 1365 else if( gFLAGS & COM_PA_HOT_FLAG ){\
shreeshas95 4:104dd82c99b8 1366 /*PA HOT: WAIT FOR TIMEOUT*/\
shreeshas95 4:104dd82c99b8 1367 gCOM_PA_COOLING_TIMEOUT.attach(&after_cooling_pa, COM_PA_COOLING_TIME_LIMIT);\
aniruddhv 180:ccc21cc163f8 1368 /*COM_TX_CNTRL = 0;*/\
shreeshas95 4:104dd82c99b8 1369 RX1M.attach(&rx_read, Serial::RxIrq);\
shreeshas95 4:104dd82c99b8 1370 gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\
shreeshas95 2:2caf2a9a13aa 1371 break;\
shreeshas95 2:2caf2a9a13aa 1372 }\
ee12b079 135:522f7d73d04f 1373 if (DEBUG)\
ee12b079 135:522f7d73d04f 1374 gPC.printf("successflly executed %u tc\r\n", execute_psc);\
shreeshas95 0:f016e9e8d48b 1375 }\
shreeshas95 6:79d422d1ed42 1376 if( (gMASTER_STATE == TCL_STATE_COMPLETED) || (gFLAGS & COM_SESSION_TIMEOUT_FLAG) ){\
ee12b079 135:522f7d73d04f 1377 if (DEBUG)\
ee12b079 135:522f7d73d04f 1378 gPC.printf("completed or session timed out: %x\r\n", gMASTER_STATE);\
shreeshas95 5:ab276a17ca07 1379 /*COMPLETED EXECUTION OF TC*/\
shreeshas95 5:ab276a17ca07 1380 gMASTER_STATE = TCL_STATE_COMPLETED;\
shreeshas95 5:ab276a17ca07 1381 COM_POWER_OFF_TX;\
shreeshas95 5:ab276a17ca07 1382 reset_all;\
shreeshas95 5:ab276a17ca07 1383 /*PENDING : ENABLE THREADS*/\
shreeshas95 124:7f0d823c5881 1384 gPAY_SPI.bulkRead_start();\
shreeshas95 5:ab276a17ca07 1385 gSESSION_TIMEOUT.detach();\
shreeshas95 5:ab276a17ca07 1386 gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\
shreeshas95 5:ab276a17ca07 1387 gFLAGS = gFLAGS & (~COM_SESSION_FLAG);\
shreeshas95 5:ab276a17ca07 1388 }\
shreeshas95 0:f016e9e8d48b 1389 }