Latest FM Code with EEPROM

Dependencies:   FreescaleIAP SimpleDMA eeprom mbed-rtos mbed

Fork of CDMS_QM_03MAR2017_Flash_with_obsrs by Team Fox

Committer:
ee12b079
Date:
Tue Jul 05 11:27:29 2016 +0000
Revision:
231:e2bd2a990bfe
Parent:
228:335da5b0d3e4
Added Aniruddh's changes, to be tested, use earlier revisions for testing BAE, CDMS

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