FM

Dependencies:   SimpleDMA eeprom mbed-rtos mbed FreescaleIAP

Fork of CDMS_CODE by shubham c

Committer:
chaithanyarss
Date:
Wed Jul 27 12:14:58 2016 +0000
Revision:
281:d1c9ae3605a3
Parent:
266:ae588e75cfa4
Child:
282:74a04dec4b95
some extra changes;

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