Latest FM Code with EEPROM

Dependencies:   FreescaleIAP SimpleDMA eeprom mbed-rtos mbed

Fork of CDMS_QM_03MAR2017_Flash_with_obsrs by Team Fox

Committer:
ee12b079
Date:
Tue Jul 12 17:03:01 2016 +0000
Revision:
258:bb889bc2e9f5
Parent:
254:22d97475ca79
Latest working code

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);
ee12b079 210:f4acf895b598 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
shreeshas95 4:104dd82c99b8 50 #define detect_ack(tm_ptr, temp_ack, tc_psc) {\
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{\
shreeshas95 4:104dd82c99b8 67 temp_ack = 0x00;\
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 ){\
shreeshas95 4:104dd82c99b8 72 tm_ptr->TM_string[2] = tc_psc;\
shreeshas95 4:104dd82c99b8 73 }\
shreeshas95 4:104dd82c99b8 74 }\
shreeshas95 4:104dd82c99b8 75 }\
shreeshas95 0:f016e9e8d48b 76 else\
shreeshas95 0:f016e9e8d48b 77 temp_ack = 0x00;\
shreeshas95 0:f016e9e8d48b 78 }\
shreeshas95 4:104dd82c99b8 79 else{\
shreeshas95 0:f016e9e8d48b 80 temp_ack = 0x00;\
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
ee12b079 210:f4acf895b598 204 void ACK_L234(Base_tm* tm_pointer_short1,uint8_t ackCode,uint8_t psc)
ee12b079 210:f4acf895b598 205 {
ee12b079 210:f4acf895b598 206 tm_pointer_short1->TM_string[0] = 0xB0;
ee12b079 210:f4acf895b598 207 tm_pointer_short1->TM_string[1] = psc;
ee12b079 210:f4acf895b598 208 tm_pointer_short1->TM_string[2] = ackCode;
ee12b079 210:f4acf895b598 209 tm_pointer_short1->TM_string[3] = 0x00;
ee12b079 210:f4acf895b598 210 tm_pointer_short1->TM_string[4] = 0x00;
ee12b079 210:f4acf895b598 211 for(uint8_t i=0;i<6;i++)
ee12b079 210:f4acf895b598 212 tm_pointer_short1->TM_string[i+5] = 0;
ee12b079 210:f4acf895b598 213 crc16 = crc16_gen(tm_pointer_short1->TM_string,11);
ee12b079 210:f4acf895b598 214 tm_pointer_short1->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
ee12b079 210:f4acf895b598 215 tm_pointer_short1->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 210:f4acf895b598 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 Base_tm *tm_pointer = new Long_tm;
aniruddhv 52:0bd68655c651 352 Base_tm *tm_ptr = tm_pointer;
ee12b079 210:f4acf895b598 353 //Base_tm *tm_ptr = new Long_tm;
ee12b079 210:f4acf895b598 354 Base_tm *tm_pointer_short = new Short_tm;
ee12b079 210:f4acf895b598 355 Base_tm *tm_ptr_short = tm_pointer_short;
aniruddhv 52:0bd68655c651 356 received = 0;
ee12b079 210:f4acf895b598 357 switch(GETapid(tc_ptr)) //checking APID's
aniruddhv 52:0bd68655c651 358 {
aniruddhv 52:0bd68655c651 359 case 1: //apid=01 implies it corresponds to bae
aniruddhv 52:0bd68655c651 360 {
ee12b079 210:f4acf895b598 361 BAE_I2C_mutex.lock();
ee12b079 243:29625f5fc745 362 //BAE_TC;
ee12b079 161:a63672bf4423 363 gPC.printf("Telecommand is for BAE\r\n");
ee12b079 210:f4acf895b598 364 gPC.printf("Sending TC to BAE...\r\n"); //interrupt to be sent to the bae
ee12b079 210:f4acf895b598 365 y = FCTN_I2C_WRITE((char*)tc_ptr->TC_string,TC_LONG_SIZE); // Check for SHORT and LONG TC and then send
ee12b079 210:f4acf895b598 366
ee12b079 210:f4acf895b598 367 if(y==1)
ee12b079 210:f4acf895b598 368 {
ee12b079 210:f4acf895b598 369 ACK_L234(tm_ptr_short,0x03,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 370 return tm_ptr_short;
ee12b079 210:f4acf895b598 371 }
ee12b079 210:f4acf895b598 372 else if(y==0)
aniruddhv 52:0bd68655c651 373 {
ee12b079 210:f4acf895b598 374 //wait(0.2);
ee12b079 210:f4acf895b598 375 uint8_t poll=0;
ee12b079 210:f4acf895b598 376 while(poll<60 && BAE_I2C_GPIO==0)
aniruddhv 52:0bd68655c651 377 {
ee12b079 210:f4acf895b598 378 wait_ms(50);
ee12b079 210:f4acf895b598 379 poll+=1;
ee12b079 210:f4acf895b598 380 }
ee12b079 210:f4acf895b598 381 if(BAE_I2C_GPIO == 1) //name to be changed later
ee12b079 210:f4acf895b598 382 {
ee12b079 210:f4acf895b598 383 gPC.printf("BAE_I2C_GPIO is high\r\n");
ee12b079 162:48fda0b8d573 384
ee12b079 210:f4acf895b598 385 y=FCTN_I2C_READ((char*)tm_pointer->TM_string,TM_LONG_SIZE); //rify later about the size
ee12b079 210:f4acf895b598 386 if(y==0)
ee12b079 210:f4acf895b598 387 {
ee12b079 210:f4acf895b598 388 tm_pointer->next_TM=NULL;
ee12b079 210:f4acf895b598 389 return tm_ptr;
ee12b079 210:f4acf895b598 390 }
ee12b079 210:f4acf895b598 391 else if(y==1)
ee12b079 198:17200a427e71 392 {
ee12b079 210:f4acf895b598 393 ACK_L234(tm_ptr_short,0x85,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 394 //gPC.printf("\n\rPTE->PDIR = 0x%08X",PTE->PDIR);
ee12b079 210:f4acf895b598 395 return tm_ptr_short;
ee12b079 210:f4acf895b598 396 break;
ee12b079 210:f4acf895b598 397 }
aniruddhv 52:0bd68655c651 398 }
ee12b079 210:f4acf895b598 399 else if(BAE_I2C_GPIO == 0) //name to be changed later
aniruddhv 52:0bd68655c651 400 {
ee12b079 210:f4acf895b598 401 gPC.printf("BAE_I2C_GPIO is not high\r\n");
ee12b079 210:f4acf895b598 402 ACK_L234(tm_ptr_short,0x84,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 403 return tm_ptr_short;
aniruddhv 52:0bd68655c651 404 }
aniruddhv 52:0bd68655c651 405 }
ee12b079 210:f4acf895b598 406 BAE_I2C_mutex.unlock();
aniruddhv 52:0bd68655c651 407 }
ee12b079 210:f4acf895b598 408
ee12b079 210:f4acf895b598 409 case 2: // APID = 2 corresponds to CDMS
aniruddhv 52:0bd68655c651 410 {
ee12b079 88:b9beee1a7a3e 411 //gPC.printf("Telecommand is for CDMS\r\n"); //apid = 10 corresponds to cdms
aniruddhv 52:0bd68655c651 412 switch(GETservice_type(tc_ptr))
aniruddhv 52:0bd68655c651 413 {
ee12b079 210:f4acf895b598 414 /*case 0x60: //service type = 0x6
aniruddhv 52:0bd68655c651 415 {
ee12b079 210:f4acf895b598 416 gPC.printf("service:MMS\r\n");
ee12b079 210:f4acf895b598 417 switch(GETservice_subtype(tc_ptr))
aniruddhv 52:0bd68655c651 418 {
ee12b079 210:f4acf895b598 419 case 0x2: //service subtye
ee12b079 210:f4acf895b598 420 {
ee12b079 210:f4acf895b598 421 //gPC.printf("sub_service:Read LONG_RAM_Memory\r\n");
ee12b079 210:f4acf895b598 422 mid=((uint16_t)(tc_ptr->TC_string[3]<<4))+((uint16_t)(tc_ptr->TC_string[4]));
ee12b079 210:f4acf895b598 423 if(mid!=0x0000 && mid!=0x0001)
ee12b079 210:f4acf895b598 424 {
ee12b079 210:f4acf895b598 425 ACK_L234(tm_ptr_short,0x02,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 426 return tm_ptr_short;
ee12b079 210:f4acf895b598 427 }
ee12b079 210:f4acf895b598 428 FCTN_CDMS_RD_L_RAM(tm_pointer);
ee12b079 210:f4acf895b598 429
ee12b079 210:f4acf895b598 430 tm_pointer->TM_string[0] = 0x30;
ee12b079 210:f4acf895b598 431 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
ee12b079 210:f4acf895b598 432 tm_pointer->TM_string[2] = 0xA0;
ee12b079 210:f4acf895b598 433 tm_pointer->TM_string[3] = 0x00; //spare bits
ee12b079 210:f4acf895b598 434
ee12b079 210:f4acf895b598 435 crc16 = crc16_gen(tm_ptr->TM_string,132);
ee12b079 210:f4acf895b598 436 tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);
ee12b079 210:f4acf895b598 437 tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);
ee12b079 210:f4acf895b598 438 tm_pointer->next_TM = NULL;
ee12b079 210:f4acf895b598 439 return tm_ptr;
ee12b079 210:f4acf895b598 440 }
ee12b079 210:f4acf895b598 441 case 0x5: // change the cases appropriately
ee12b079 210:f4acf895b598 442 {
ee12b079 210:f4acf895b598 443 //gPC.printf("WRITE ON SHORT_FLASH_MEMORY\r\n");
ee12b079 210:f4acf895b598 444 mid=(uint16_t)(tc_ptr->TC_string[3]<<4)+(uint16_t)(tc_ptr->TC_string[4]);
ee12b079 210:f4acf895b598 445 //32 bits at a time
ee12b079 210:f4acf895b598 446
ee12b079 210:f4acf895b598 447 if(mid!= && mid!=) //allowable MID values?
ee12b079 210:f4acf895b598 448 {
ee12b079 210:f4acf895b598 449 ACK_L234(tm_ptr_short,0x02,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 450 return tm_ptr_short;
ee12b079 210:f4acf895b598 451 }
ee12b079 210:f4acf895b598 452
ee12b079 210:f4acf895b598 453 FCTN_CDMS_WR_S_FLASH(tc_ptr);
ee12b079 210:f4acf895b598 454
ee12b079 210:f4acf895b598 455 ACK_L234(tm_ptr_short,???,GETpacket_seq_count(tc_ptr)); //ackCode = ? for success
ee12b079 210:f4acf895b598 456
ee12b079 210:f4acf895b598 457 return tm_ptr_short;
ee12b079 210:f4acf895b598 458 }
ee12b079 210:f4acf895b598 459 case 0x6:
ee12b079 210:f4acf895b598 460 {
ee12b079 210:f4acf895b598 461 //gPC.printf("WRITE ON LONG_FLASH_MEMORY\r\n");
ee12b079 210:f4acf895b598 462 mid=(uint16_t)(tc_ptr->TC_string[3]<<4)+(uint16_t)(tc_ptr->TC_string[4]);
ee12b079 210:f4acf895b598 463 //1024 bits at a time
ee12b079 210:f4acf895b598 464
ee12b079 210:f4acf895b598 465 if(mid<0x0002 || mid>0x000A) //allowable MID values?
ee12b079 210:f4acf895b598 466 {
ee12b079 210:f4acf895b598 467 ACK_L234(tm_ptr_short,0x02,GETpacket_seq_count(tc_ptr)); //ackCode = ? for invalid mid
ee12b079 210:f4acf895b598 468 return tm_ptr_short;
ee12b079 210:f4acf895b598 469 }
ee12b079 210:f4acf895b598 470
ee12b079 210:f4acf895b598 471 ///Send TM for success after writing onto flash
ee12b079 210:f4acf895b598 472 FCTN_CDMS_WR_L_FLASH(mid);
ee12b079 210:f4acf895b598 473
ee12b079 210:f4acf895b598 474 return tm_ptr_short;
ee12b079 210:f4acf895b598 475 }
ee12b079 210:f4acf895b598 476 default:
ee12b079 210:f4acf895b598 477 {
ee12b079 210:f4acf895b598 478 gPC.printf("INVALID SERVICE SUBTYPE\r\n");
ee12b079 210:f4acf895b598 479 ACK_L234(tm_ptr_short,0x02,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 480 return tm_ptr_short;
ee12b079 210:f4acf895b598 481 }
ee12b079 210:f4acf895b598 482 }
ee12b079 210:f4acf895b598 483 } */
ee12b079 210:f4acf895b598 484 case 0x80:
ee12b079 210:f4acf895b598 485 {
ee12b079 210:f4acf895b598 486 gPC.printf("service:FUNCTION MANAGEMENT SERVICE\r\n");
ee12b079 210:f4acf895b598 487 if(GETservice_subtype(tc_ptr)==0x1)
ee12b079 210:f4acf895b598 488 {
ee12b079 210:f4acf895b598 489 if(GETpid(tc_ptr)==0x01)
ee12b079 210:f4acf895b598 490 {
ee12b079 210:f4acf895b598 491 if(CDMS_STANDBY==1)
ee12b079 210:f4acf895b598 492 {
ee12b079 210:f4acf895b598 493 //gPC.printf("TC_PL_INIT\r\n"); // call PWR_SWCH_ON function
ee12b079 210:f4acf895b598 494
ee12b079 210:f4acf895b598 495 P_PL_INIT();
ee12b079 210:f4acf895b598 496
ee12b079 210:f4acf895b598 497 ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 498 return tm_ptr_short;
ee12b079 210:f4acf895b598 499 }
ee12b079 210:f4acf895b598 500 else if(CDMS_STANDBY==0)
ee12b079 210:f4acf895b598 501 {
ee12b079 210:f4acf895b598 502 ACK_L234(tm_ptr_short,0x87,GETpacket_seq_count(tc_ptr)); //TC cannot be processed now
ee12b079 210:f4acf895b598 503 return tm_ptr_short;
ee12b079 210:f4acf895b598 504 }
ee12b079 210:f4acf895b598 505 }
ee12b079 210:f4acf895b598 506 else if(GETpid(tc_ptr)==0x02)
ee12b079 210:f4acf895b598 507 {
ee12b079 210:f4acf895b598 508 if(CDMS_STANDBY==1)
ee12b079 210:f4acf895b598 509 {
ee12b079 210:f4acf895b598 510 //gPC.printf("TC_PL_MAIN\r\n"); // call PWR_SWCH_ON function
ee12b079 210:f4acf895b598 511
ee12b079 210:f4acf895b598 512 P_PL_MAIN();
ee12b079 210:f4acf895b598 513
ee12b079 210:f4acf895b598 514 ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 515 return tm_ptr_short;
ee12b079 210:f4acf895b598 516 }
ee12b079 210:f4acf895b598 517 else if(CDMS_STANDBY==0)
ee12b079 210:f4acf895b598 518 {
ee12b079 210:f4acf895b598 519 ACK_L234(tm_ptr_short,0x87,GETpacket_seq_count(tc_ptr)); //TC cannot be processed now
ee12b079 210:f4acf895b598 520 return tm_ptr_short;
ee12b079 210:f4acf895b598 521 }
ee12b079 210:f4acf895b598 522 }
ee12b079 210:f4acf895b598 523 else if(GETpid(tc_ptr)==0x03)
ee12b079 210:f4acf895b598 524 {
ee12b079 210:f4acf895b598 525 if(CDMS_STANDBY==1)
ee12b079 210:f4acf895b598 526 {
ee12b079 210:f4acf895b598 527 //gPC.printf("PL_COM_INIT\r\n"); // call PWR_SWCH_ON function
ee12b079 210:f4acf895b598 528
ee12b079 210:f4acf895b598 529 P_COM_INIT();
ee12b079 210:f4acf895b598 530
ee12b079 210:f4acf895b598 531 ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 532 return tm_ptr_short;
ee12b079 210:f4acf895b598 533 }
ee12b079 210:f4acf895b598 534 else if(CDMS_STANDBY==0)
ee12b079 210:f4acf895b598 535 {
ee12b079 210:f4acf895b598 536 ACK_L234(tm_ptr_short,0x87,GETpacket_seq_count(tc_ptr)); //TC cannot be processed now
ee12b079 210:f4acf895b598 537 return tm_ptr_short;
ee12b079 210:f4acf895b598 538 }
ee12b079 210:f4acf895b598 539 }
ee12b079 210:f4acf895b598 540 else if(GETpid(tc_ptr)==0x04)
ee12b079 210:f4acf895b598 541 {
ee12b079 210:f4acf895b598 542 if(CDMS_STANDBY==1)
ee12b079 210:f4acf895b598 543 {
ee12b079 210:f4acf895b598 544 //gPC.printf("TC_P_CDMS_HK_MAIN\r\n"); // call PWR_SWCH_ON function
ee12b079 210:f4acf895b598 545
ee12b079 210:f4acf895b598 546 P_CDMS_HK_MAIN();
ee12b079 210:f4acf895b598 547
ee12b079 210:f4acf895b598 548 ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 549 return tm_ptr_short;
ee12b079 210:f4acf895b598 550 }
ee12b079 210:f4acf895b598 551 else if(CDMS_STANDBY==0)
ee12b079 210:f4acf895b598 552 {
ee12b079 210:f4acf895b598 553 ACK_L234(tm_ptr_short,0x87,GETpacket_seq_count(tc_ptr)); //TC cannot be processed now
ee12b079 210:f4acf895b598 554 return tm_ptr_short;
ee12b079 210:f4acf895b598 555 }
ee12b079 210:f4acf895b598 556 }
ee12b079 210:f4acf895b598 557 else if(GETpid(tc_ptr)==0x05)
ee12b079 210:f4acf895b598 558 {
ee12b079 210:f4acf895b598 559 if(CDMS_STANDBY==1)
ee12b079 210:f4acf895b598 560 {
ee12b079 210:f4acf895b598 561 //gPC.printf("TC_SW_ON_SD\r\n"); // call PWR_SWCH_ON function
ee12b079 210:f4acf895b598 562
ee12b079 210:f4acf895b598 563 P_PL_RCV_SC_DATA();
ee12b079 210:f4acf895b598 564
ee12b079 210:f4acf895b598 565 ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 566 return tm_ptr_short;
ee12b079 210:f4acf895b598 567 }
ee12b079 210:f4acf895b598 568 else if(CDMS_STANDBY==0)
ee12b079 210:f4acf895b598 569 {
ee12b079 210:f4acf895b598 570 ACK_L234(tm_ptr_short,0x87,GETpacket_seq_count(tc_ptr)); //TC cannot be processed now
ee12b079 210:f4acf895b598 571 return tm_ptr_short;
ee12b079 210:f4acf895b598 572 }
ee12b079 210:f4acf895b598 573 }
ee12b079 210:f4acf895b598 574 else if(GETpid(tc_ptr)==0x06)
ee12b079 210:f4acf895b598 575 {
ee12b079 210:f4acf895b598 576 if(CDMS_STANDBY==1)
ee12b079 210:f4acf895b598 577 {
ee12b079 210:f4acf895b598 578 //gPC.printf("TC_SW_ON_RTC\r\n"); // call PWR_SWCH_ON function
ee12b079 210:f4acf895b598 579
ee12b079 210:f4acf895b598 580 P_CDMS_INIT_SD();
ee12b079 210:f4acf895b598 581
ee12b079 210:f4acf895b598 582 ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 583 return tm_ptr_short;
ee12b079 210:f4acf895b598 584 }
ee12b079 210:f4acf895b598 585 else if(CDMS_STANDBY==0)
ee12b079 210:f4acf895b598 586 {
ee12b079 210:f4acf895b598 587 ACK_L234(tm_ptr_short,0x87,GETpacket_seq_count(tc_ptr)); //TC cannot be processed now
ee12b079 210:f4acf895b598 588 return tm_ptr_short;
ee12b079 210:f4acf895b598 589 }
ee12b079 210:f4acf895b598 590 }
ee12b079 210:f4acf895b598 591 else if(GETpid(tc_ptr)==0x11)
ee12b079 210:f4acf895b598 592 {
ee12b079 210:f4acf895b598 593 //gPC.printf("TC_SW_ON_SD\r\n"); // call PWR_SWCH_ON function
ee12b079 210:f4acf895b598 594
ee12b079 210:f4acf895b598 595 CDMS_SD_SW_ON();
ee12b079 210:f4acf895b598 596
ee12b079 210:f4acf895b598 597 ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 598 return tm_ptr_short;
ee12b079 210:f4acf895b598 599 }
ee12b079 210:f4acf895b598 600 else if(GETpid(tc_ptr)==0x21)
ee12b079 210:f4acf895b598 601 {
ee12b079 210:f4acf895b598 602 //gPC.printf("TC_SW_ON_SD\r\n"); // call PWR_SWCH_ON function
ee12b079 210:f4acf895b598 603
ee12b079 210:f4acf895b598 604 CDMS_SD_SW_OFF();
ee12b079 210:f4acf895b598 605
ee12b079 210:f4acf895b598 606 ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 607 return tm_ptr_short;
ee12b079 210:f4acf895b598 608 }
ee12b079 210:f4acf895b598 609 else if(GETpid(tc_ptr)==0x13)
ee12b079 210:f4acf895b598 610 {
ee12b079 210:f4acf895b598 611 //gPC.printf("TC_SW_ON_BAE\r\n"); // call PWR_SWCH_ON function
ee12b079 210:f4acf895b598 612
ee12b079 210:f4acf895b598 613 SW_ON_BAE();
ee12b079 210:f4acf895b598 614
ee12b079 210:f4acf895b598 615 ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 616 return tm_ptr_short;
ee12b079 210:f4acf895b598 617 }
ee12b079 210:f4acf895b598 618 else if(GETpid(tc_ptr)==0x23)
ee12b079 210:f4acf895b598 619 {
ee12b079 210:f4acf895b598 620 //gPC.printf("TC_SW_OFF_BAE\r\n"); // call PWR_SWCH_ON function
ee12b079 210:f4acf895b598 621
ee12b079 210:f4acf895b598 622 SW_OFF_BAE();
ee12b079 210:f4acf895b598 623
ee12b079 210:f4acf895b598 624 ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 625 return tm_ptr_short;
ee12b079 210:f4acf895b598 626 }
ee12b079 210:f4acf895b598 627 else if(GETpid(tc_ptr)==0x14)
ee12b079 210:f4acf895b598 628 {
ee12b079 210:f4acf895b598 629 //gPC.printf("TC_SW_ON_PL_BEE\r\n"); // call PWR_SWCH_ON function
ee12b079 210:f4acf895b598 630
ee12b079 210:f4acf895b598 631 SW_ON_PL_BEE();
ee12b079 210:f4acf895b598 632
ee12b079 210:f4acf895b598 633 ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 634 return tm_ptr_short;
ee12b079 210:f4acf895b598 635 }
ee12b079 210:f4acf895b598 636 else if(GETpid(tc_ptr)==0x24)
ee12b079 210:f4acf895b598 637 {
ee12b079 210:f4acf895b598 638 //gPC.printf("TC_SW_OFF_PL_BEE\r\n"); // call PWR_SWCH_ON function
ee12b079 210:f4acf895b598 639
ee12b079 210:f4acf895b598 640 SW_OFF_PL_BEE();
ee12b079 210:f4acf895b598 641
ee12b079 210:f4acf895b598 642 ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 643 return tm_ptr_short;
ee12b079 210:f4acf895b598 644 }
ee12b079 210:f4acf895b598 645 else if(GETpid(tc_ptr)==0x15)
ee12b079 210:f4acf895b598 646 {
ee12b079 210:f4acf895b598 647 //gPC.printf("TC_SW_ON_PL_EPS\r\n"); // call PWR_SWCH_ON function
ee12b079 210:f4acf895b598 648
ee12b079 210:f4acf895b598 649 SW_ON_PL_EPS();
ee12b079 210:f4acf895b598 650
ee12b079 210:f4acf895b598 651 ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 652 return tm_ptr_short;
ee12b079 210:f4acf895b598 653 }
ee12b079 210:f4acf895b598 654 else if(GETpid(tc_ptr)==0x25)
ee12b079 210:f4acf895b598 655 {
ee12b079 210:f4acf895b598 656 //gPC.printf("TC_SW_OFF_PL_EPS\r\n"); // call PWR_SWCH_ON function
ee12b079 210:f4acf895b598 657
ee12b079 210:f4acf895b598 658 SW_OFF_PL_EPS();
ee12b079 210:f4acf895b598 659
ee12b079 210:f4acf895b598 660 ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 661 return tm_ptr_short;
ee12b079 210:f4acf895b598 662 }
ee12b079 210:f4acf895b598 663 else if(GETpid(tc_ptr)==0x16)
ee12b079 210:f4acf895b598 664 {
ee12b079 210:f4acf895b598 665
ee12b079 210:f4acf895b598 666 //gPC.printf("TC_SW_ON_V_A_EN\r\n"); // call PWR_SWCH_ON function
ee12b079 210:f4acf895b598 667
ee12b079 210:f4acf895b598 668 SW_ON_V_A_EN();
ee12b079 210:f4acf895b598 669
ee12b079 210:f4acf895b598 670 ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 671 return tm_ptr_short;
ee12b079 210:f4acf895b598 672 }
ee12b079 210:f4acf895b598 673 else if(GETpid(tc_ptr)==0x26)
ee12b079 210:f4acf895b598 674 {
ee12b079 210:f4acf895b598 675 //gPC.printf("TC_SW_OFF_V_A_EN\r\n"); // call PWR_SWCH_ON function
ee12b079 210:f4acf895b598 676
ee12b079 210:f4acf895b598 677 SW_OFF_V_A_EN();
ee12b079 210:f4acf895b598 678
ee12b079 210:f4acf895b598 679 ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 680 return tm_ptr_short;
ee12b079 210:f4acf895b598 681 }
ee12b079 210:f4acf895b598 682 else if(GETpid(tc_ptr)==0x31)
ee12b079 210:f4acf895b598 683 {
ee12b079 210:f4acf895b598 684 //gPC.printf("TC_RST_SD\r\n"); // call PWR_SWCH_ON function
ee12b079 210:f4acf895b598 685
ee12b079 210:f4acf895b598 686 RST_SD();
ee12b079 210:f4acf895b598 687
ee12b079 210:f4acf895b598 688 ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 689 return tm_ptr_short;
ee12b079 210:f4acf895b598 690 }
ee12b079 210:f4acf895b598 691 else if(GETpid(tc_ptr)==0x33)
ee12b079 210:f4acf895b598 692 {
ee12b079 210:f4acf895b598 693 //gPC.printf("TC_RST_BAE\r\n"); // call PWR_SWCH_ON function
ee12b079 210:f4acf895b598 694
ee12b079 210:f4acf895b598 695 RST_BAE();
ee12b079 210:f4acf895b598 696
ee12b079 210:f4acf895b598 697 ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 698 return tm_ptr_short;
ee12b079 210:f4acf895b598 699 }
ee12b079 210:f4acf895b598 700 else if(GETpid(tc_ptr)==0x34)
ee12b079 210:f4acf895b598 701 {
ee12b079 210:f4acf895b598 702 //gPC.printf("TC_RST_PL_BEE\r\n"); // call PWR_SWCH_ON function
ee12b079 210:f4acf895b598 703
ee12b079 210:f4acf895b598 704 RST_PL_BEE();
ee12b079 210:f4acf895b598 705
ee12b079 210:f4acf895b598 706 ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 707 return tm_ptr_short;
ee12b079 210:f4acf895b598 708 }
ee12b079 210:f4acf895b598 709 else if(GETpid(tc_ptr)==0x38)
ee12b079 210:f4acf895b598 710 {
ee12b079 210:f4acf895b598 711 //gPC.printf()
ee12b079 210:f4acf895b598 712
ee12b079 210:f4acf895b598 713 CDMS_INTERNAL_RESET();
ee12b079 210:f4acf895b598 714 ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 715 }
ee12b079 210:f4acf895b598 716 else if(GETpid(tc_ptr)==0x40)
ee12b079 210:f4acf895b598 717 {
ee12b079 210:f4acf895b598 718 //gPC.printf("RESET_HK_COUNTER\r\n"); // call PWR_SWCH_ON function
ee12b079 210:f4acf895b598 719
ee12b079 210:f4acf895b598 720 RST_HK_COUNTER();
ee12b079 210:f4acf895b598 721
ee12b079 210:f4acf895b598 722 ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 723 return tm_ptr_short;
ee12b079 210:f4acf895b598 724 }
ee12b079 210:f4acf895b598 725 else if(GETpid(tc_ptr)==0x41)
ee12b079 210:f4acf895b598 726 {
ee12b079 210:f4acf895b598 727 //gPC.printf("RESET_HK_COUNTER\r\n"); // call PWR_SWCH_ON function
ee12b079 210:f4acf895b598 728
ee12b079 210:f4acf895b598 729 RST_HK_COUNTER();
ee12b079 210:f4acf895b598 730
ee12b079 210:f4acf895b598 731 ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 732 return tm_ptr_short;
ee12b079 210:f4acf895b598 733 }
ee12b079 210:f4acf895b598 734 else if(GETpid(tc_ptr)==0xF1)
ee12b079 210:f4acf895b598 735 {
ee12b079 210:f4acf895b598 736 //gPC.printf("TC_CDMS_RD_RTC\r\n"); // call PWR_SWCH_ON function
ee12b079 210:f4acf895b598 737
ee12b079 210:f4acf895b598 738 /*uint32_t time_temp = FCTN_CDMS_RD_RTC(); //RTC_RD_EROR has to incorporated
ee12b079 210:f4acf895b598 739 tm_pointer->TM_string[0] = 0x78;
ee12b079 210:f4acf895b598 740 tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);
ee12b079 210:f4acf895b598 741 tm_pointer->TM_string[2] = 0xA0;
ee12b079 210:f4acf895b598 742 tm_pointer->TM_string[3] = 0x00;
ee12b079 210:f4acf895b598 743 tm_pointer->TM_string[4] = (uint8_t)((time & 0xFF000000)>>24);
ee12b079 210:f4acf895b598 744 tm_pointer->TM_string[5] = (uint8_t)((time & 0x00FF0000)>>16);
ee12b079 210:f4acf895b598 745 tm_pointer->TM_string[6] = (uint8_t)((time & 0x0000FF00)>>8);
ee12b079 210:f4acf895b598 746 tm_pointer->TM_string[7] = (uint8_t)((time & 0x000000FF));
ee12b079 210:f4acf895b598 747 for(uint8_t i=0;i<124;i++)
ee12b079 210:f4acf895b598 748 {
ee12b079 210:f4acf895b598 749 tm_pointer->TM_string[i+8] = 0x00;
ee12b079 210:f4acf895b598 750 }
ee12b079 210:f4acf895b598 751 crc16 = crc16_gen(tm_ptr->TM_string,132);
ee12b079 210:f4acf895b598 752 tm_pointer->TM_string[132] = (uint8_t)((crc16&0xFF00)>>8);
ee12b079 210:f4acf895b598 753 tm_pointer->TM_string[133] = (uint8_t)(crc16&0x00FF);
ee12b079 210:f4acf895b598 754 tm_pointer->next_TM = NULL;
ee12b079 210:f4acf895b598 755 return tm_ptr; */ //incomplete
ee12b079 210:f4acf895b598 756 }
ee12b079 210:f4acf895b598 757 else if(GETpid(tc_ptr)==0xF0)
ee12b079 210:f4acf895b598 758 {
ee12b079 210:f4acf895b598 759 uint8_t statusbits[64];
ee12b079 210:f4acf895b598 760 CDMS_RD_SD_HK(statusbits);
ee12b079 210:f4acf895b598 761 ACK_L234(tm_ptr_short,0xC0,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 762 }
ee12b079 210:f4acf895b598 763 else
ee12b079 210:f4acf895b598 764 {
ee12b079 210:f4acf895b598 765 gPC.printf("INVALID FID\r\n");
ee12b079 210:f4acf895b598 766 ACK_L234(tm_ptr_short,0x02,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 767 return tm_ptr_short;
ee12b079 210:f4acf895b598 768 }
ee12b079 210:f4acf895b598 769 }
ee12b079 210:f4acf895b598 770 else
ee12b079 210:f4acf895b598 771 {
ee12b079 210:f4acf895b598 772 gPC.printf("INVALID SERVICE SUBTYPE\r\n");
ee12b079 210:f4acf895b598 773 ACK_L234(tm_ptr_short,0x02,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 774 return tm_ptr_short;
ee12b079 210:f4acf895b598 775 }
ee12b079 210:f4acf895b598 776 }
ee12b079 210:f4acf895b598 777 case 0x70:
ee12b079 210:f4acf895b598 778 {
ee12b079 210:f4acf895b598 779 gPC.printf("\n\n\rService:PAYLOAD MANAGEMENT SERVICE");
ee12b079 210:f4acf895b598 780 if(GETservice_subtype(tc_ptr)==0x1) //make sure it is LONG TC before executing else INVALID TC
ee12b079 210:f4acf895b598 781 {
ee12b079 210:f4acf895b598 782 gPC.printf("\n\rTC with subtype = 0x1");
ee12b079 210:f4acf895b598 783 TM_PMS_PL_SCHEDULE(tm_ptr,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 784 for(uint8_t i=0,j=0;i<32;i++)
ee12b079 210:f4acf895b598 785 {
ee12b079 210:f4acf895b598 786 pl_block[i] &= 0x00000000;
ee12b079 210:f4acf895b598 787 pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[3+j]))<<24);
ee12b079 210:f4acf895b598 788 pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[4+j]))<<16);
ee12b079 210:f4acf895b598 789 pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[5+j]))<<8);
ee12b079 210:f4acf895b598 790 pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[6+j])));
ee12b079 210:f4acf895b598 791 j+=4;
ee12b079 210:f4acf895b598 792 }
ee12b079 210:f4acf895b598 793 return tm_ptr;
ee12b079 210:f4acf895b598 794 }
ee12b079 210:f4acf895b598 795 else if(GETservice_subtype(tc_ptr)==0x2)
ee12b079 210:f4acf895b598 796 {
ee12b079 210:f4acf895b598 797 gPC.printf("\n\rTC with subtype = 0x2");
ee12b079 210:f4acf895b598 798 TM_PMS_PL_SCHEDULE(tm_ptr,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 799 for(uint8_t i=32,j=0;i<64;i++,j+=4)
ee12b079 210:f4acf895b598 800 {
ee12b079 210:f4acf895b598 801 pl_block[i] &= 0x00000000;
ee12b079 210:f4acf895b598 802 pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[3+j]))<<24);
ee12b079 210:f4acf895b598 803 pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[4+j]))<<16);
ee12b079 210:f4acf895b598 804 pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[5+j]))<<8);
ee12b079 210:f4acf895b598 805 pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[6+j])));
ee12b079 210:f4acf895b598 806 }
ee12b079 210:f4acf895b598 807 return tm_ptr;
ee12b079 210:f4acf895b598 808 }
ee12b079 210:f4acf895b598 809 else if(GETservice_subtype(tc_ptr)==0x3)
ee12b079 210:f4acf895b598 810 {
ee12b079 210:f4acf895b598 811 gPC.printf("\n\rTC with subtype = 0x3");
ee12b079 210:f4acf895b598 812 TM_PMS_PL_SCHEDULE(tm_ptr,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 813 for(uint8_t i=64,j=0;i<96;i++,j+=4)
ee12b079 210:f4acf895b598 814 {
ee12b079 210:f4acf895b598 815 pl_block[i] &= 0x00000000;
ee12b079 210:f4acf895b598 816 pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[3+j]))<<24);
ee12b079 210:f4acf895b598 817 pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[4+j]))<<16);
ee12b079 210:f4acf895b598 818 pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[5+j]))<<8);
ee12b079 210:f4acf895b598 819 pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[6+j])));
ee12b079 210:f4acf895b598 820 }
ee12b079 210:f4acf895b598 821 return tm_ptr;
ee12b079 210:f4acf895b598 822 }
ee12b079 210:f4acf895b598 823 else if(GETservice_subtype(tc_ptr)==0x4)
ee12b079 210:f4acf895b598 824 {
ee12b079 210:f4acf895b598 825 gPC.printf("\n\rTC with subtype = 0x4");
ee12b079 210:f4acf895b598 826 TM_PMS_PL_SCHEDULE(tm_ptr,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 827 for(uint8_t i=96,j=0;i<128;i++,j+=4)
ee12b079 210:f4acf895b598 828 {
ee12b079 210:f4acf895b598 829 pl_block[i] &= 0x00000000;
ee12b079 210:f4acf895b598 830 pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[3+j]))<<24);
ee12b079 210:f4acf895b598 831 pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[4+j]))<<16);
ee12b079 210:f4acf895b598 832 pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[5+j]))<<8);
ee12b079 210:f4acf895b598 833 pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[6+j])));
ee12b079 210:f4acf895b598 834 }
ee12b079 210:f4acf895b598 835 return tm_ptr;
ee12b079 210:f4acf895b598 836 }
ee12b079 210:f4acf895b598 837 else if(GETservice_subtype(tc_ptr)==0x5)
ee12b079 210:f4acf895b598 838 {
ee12b079 210:f4acf895b598 839 gPC.printf("\n\rTC with subtype = 0x5");
ee12b079 210:f4acf895b598 840 TM_PMS_PL_SCHEDULE(tm_ptr,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 841 for(uint8_t i=128,j=0;i<160;i++,j+=4)
ee12b079 210:f4acf895b598 842 {
ee12b079 210:f4acf895b598 843 pl_block[i] &= 0x00000000;
ee12b079 210:f4acf895b598 844 pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[3+j]))<<24);
ee12b079 210:f4acf895b598 845 pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[4+j]))<<16);
ee12b079 210:f4acf895b598 846 pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[5+j]))<<8);
ee12b079 210:f4acf895b598 847 pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[6+j])));
ee12b079 210:f4acf895b598 848 }
ee12b079 210:f4acf895b598 849 return tm_ptr;
ee12b079 210:f4acf895b598 850 }
ee12b079 210:f4acf895b598 851 else if(GETservice_subtype(tc_ptr)==0x6)
ee12b079 210:f4acf895b598 852 {
ee12b079 210:f4acf895b598 853 gPC.printf("\n\rTC with subtype = 0x6");
ee12b079 210:f4acf895b598 854 TM_PMS_PL_SCHEDULE(tm_ptr,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 855 for(uint8_t i=160,j=0;i<192;i++,j+=4)
ee12b079 210:f4acf895b598 856 {
ee12b079 210:f4acf895b598 857 pl_block[i] &= 0x00000000;
ee12b079 210:f4acf895b598 858 pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[3+j]))<<24);
ee12b079 210:f4acf895b598 859 pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[4+j]))<<16);
ee12b079 210:f4acf895b598 860 pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[5+j]))<<8);
ee12b079 210:f4acf895b598 861 pl_block[i] |= (((uint32_t)(tc_ptr->TC_string[6+j])));
ee12b079 210:f4acf895b598 862 }
ee12b079 210:f4acf895b598 863 return tm_ptr;
ee12b079 210:f4acf895b598 864 }
ee12b079 210:f4acf895b598 865 else if(GETservice_subtype(tc_ptr)==0xF)
ee12b079 210:f4acf895b598 866 {
ee12b079 210:f4acf895b598 867 gPC.printf("\n\rTC with subtype = 0xF");
ee12b079 210:f4acf895b598 868 TM_PMS_PL_SCHEDULE(tm_ptr,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 869 return tm_ptr;
ee12b079 210:f4acf895b598 870 }
ee12b079 210:f4acf895b598 871 else
ee12b079 210:f4acf895b598 872 {
ee12b079 210:f4acf895b598 873 gPC.printf("INVALID SERVICE SUBTYPE\r\n");
ee12b079 210:f4acf895b598 874 ACK_L234(tm_ptr_short,0x02,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 875 return tm_ptr_short;
ee12b079 210:f4acf895b598 876 }
aniruddhv 52:0bd68655c651 877 }
aniruddhv 52:0bd68655c651 878 default:
aniruddhv 52:0bd68655c651 879 {
ee12b079 210:f4acf895b598 880 gPC.printf("ILLEGAL TC");
ee12b079 210:f4acf895b598 881 ACK_L234(tm_ptr_short,0x02,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 882 return tm_ptr_short;
aniruddhv 52:0bd68655c651 883 }
aniruddhv 52:0bd68655c651 884 }
aniruddhv 52:0bd68655c651 885 }
aniruddhv 52:0bd68655c651 886 case 3:
aniruddhv 52:0bd68655c651 887 {
ee12b079 210:f4acf895b598 888 //#if DEBUG
ee12b079 210:f4acf895b598 889 gPC.printf("\n\rTelecommand is for PL\r\n");
ee12b079 210:f4acf895b598 890 //#endif
ee12b079 161:a63672bf4423 891 if(GETshort_or_long_tc(tc_ptr) == LONG_TC_CODE)
ee12b079 210:f4acf895b598 892 y=FCTN_I2C_WRITE_PL((char*)tc_ptr->TC_string,TC_LONG_SIZE);
ee12b079 210:f4acf895b598 893 else if(GETshort_or_long_tc(tc_ptr) == SHORT_TC_CODE)
ee12b079 210:f4acf895b598 894 y=FCTN_I2C_WRITE_PL((char*)tc_ptr->TC_string,TC_SHORT_SIZE);
ee12b079 210:f4acf895b598 895
ee12b079 210:f4acf895b598 896 if(y==1)
ee12b079 210:f4acf895b598 897 {
ee12b079 210:f4acf895b598 898 ACK_L234(tm_ptr_short,0x03,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 899 return tm_ptr_short;
ee12b079 210:f4acf895b598 900 break;
ee12b079 210:f4acf895b598 901 }
ee12b079 210:f4acf895b598 902 else if(y==0)
ee12b079 171:31bdf83591a1 903 {
ee12b079 210:f4acf895b598 904 //wait(0.2);
ee12b079 210:f4acf895b598 905 uint8_t poll=0;
ee12b079 210:f4acf895b598 906 while(poll<60 && PL_I2C_Intr==0)
ee12b079 210:f4acf895b598 907 {
ee12b079 210:f4acf895b598 908 wait_ms(50);
ee12b079 210:f4acf895b598 909 poll+=1;
ee12b079 210:f4acf895b598 910 }
ee12b079 210:f4acf895b598 911 if(PL_I2C_Intr == 1) //name to be changed later
ee12b079 171:31bdf83591a1 912 {
ee12b079 210:f4acf895b598 913 gPC.printf("PL_I2C_Intr is high\r\n");
ee12b079 210:f4acf895b598 914
ee12b079 210:f4acf895b598 915 y=FCTN_I2C_READ_PL((char*)tm_pointer->TM_string,TM_LONG_SIZE); //rify later about the size
ee12b079 210:f4acf895b598 916 if(y==0)
ee12b079 210:f4acf895b598 917 {
ee12b079 210:f4acf895b598 918 tm_pointer->next_TM=NULL;
ee12b079 210:f4acf895b598 919 return tm_ptr;
ee12b079 210:f4acf895b598 920 break;
ee12b079 210:f4acf895b598 921 }
ee12b079 210:f4acf895b598 922 else if(y==1)
ee12b079 210:f4acf895b598 923 {
ee12b079 210:f4acf895b598 924 ACK_L234(tm_ptr_short,0x85,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 925 //gPC.printf("\n\rPTE->PDIR = 0x%08X",PTE->PDIR);
ee12b079 210:f4acf895b598 926 return tm_ptr_short;
ee12b079 210:f4acf895b598 927 break;
ee12b079 210:f4acf895b598 928 }
ee12b079 171:31bdf83591a1 929 }
ee12b079 210:f4acf895b598 930 else if(PL_I2C_Intr == 0) //name to be changed later
ee12b079 210:f4acf895b598 931 {
ee12b079 210:f4acf895b598 932 gPC.printf("PL_I2C_Intr is not high\r\n");
ee12b079 210:f4acf895b598 933 ACK_L234(tm_ptr_short,0x84,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 934 return tm_ptr_short;
ee12b079 210:f4acf895b598 935 }
ee12b079 210:f4acf895b598 936 }
aniruddhv 52:0bd68655c651 937 }
ee12b079 210:f4acf895b598 938 default: //invalid TC
aniruddhv 52:0bd68655c651 939 {
ee12b079 210:f4acf895b598 940 gPC.printf("INVALID TC\r\n");
ee12b079 210:f4acf895b598 941 ACK_L234(tm_ptr_short,0x02,GETpacket_seq_count(tc_ptr));
ee12b079 210:f4acf895b598 942 return tm_ptr_short;
aniruddhv 52:0bd68655c651 943 }
ee12b079 210:f4acf895b598 944 }
ee12b079 210:f4acf895b598 945 return;
aniruddhv 52:0bd68655c651 946 }
shreeshas95 0:f016e9e8d48b 947 // CDMS TEAM CODE END
shreeshas95 0:f016e9e8d48b 948 // EXECUTE OBOSC
aniruddhv 51:da85d84768e2 949 #define execute_obosc_core(tc_ptr, tm_ptr, reset_flag) {\
ee12b079 210:f4acf895b598 950 if (DEBUG)\
ee12b079 210:f4acf895b598 951 gPC.puts("Inside execute_obosc_core\r\n");\
shreeshas95 0:f016e9e8d48b 952 uint8_t service_subtype = (tc_ptr->TC_string[2]) & 0x0F;\
shreeshas95 4:104dd82c99b8 953 uint8_t temp8 = 0x00;\
shreeshas95 4:104dd82c99b8 954 Base_tc *modify_this = gHEAD_NODE_TCL;\
shreeshas95 4:104dd82c99b8 955 int modify_overflow = 0x00;\
shreeshas95 4:104dd82c99b8 956 switch( service_subtype ){\
shreeshas95 4:104dd82c99b8 957 case OBOSC_SUB_DISABLE:\
aniruddhv 12:ffdb29353058 958 /*gPC.puts("target psc are ");*/\
shreeshas95 5:ab276a17ca07 959 for(int i = 3 ; i < 9 ; ++i){\
aniruddhv 12:ffdb29353058 960 /*gPC.printf("%u ", tc_ptr->TC_string[i]);*/\
shreeshas95 5:ab276a17ca07 961 }\
aniruddhv 12:ffdb29353058 962 /*gPC.puts("\r\n");*/\
shreeshas95 5:ab276a17ca07 963 /*gPC.puts("disable type obosc\r\n");*/\
shreeshas95 4:104dd82c99b8 964 while( modify_this != NULL ){\
shreeshas95 4:104dd82c99b8 965 if( modify_overflow < TCL_OVERFLOW_CONSTANT ){\
shreeshas95 5:ab276a17ca07 966 uint8_t modify_psc = GETpacket_seq_count(modify_this);\
shreeshas95 5:ab276a17ca07 967 /*gPC.printf("mosify_psc = %u\r\n", modify_psc);*/\
shreeshas95 4:104dd82c99b8 968 for( int i = 3 ; i < 9 ; ++i ){\
shreeshas95 5:ab276a17ca07 969 uint8_t target_psc = tc_ptr->TC_string[i];\
shreeshas95 5:ab276a17ca07 970 if( (target_psc == modify_psc) && (target_psc != 0) ){\
shreeshas95 4:104dd82c99b8 971 uint16_t tempExec = TC_STATE_DISABLED;\
shreeshas95 4:104dd82c99b8 972 PUTexec_status( modify_this, tempExec );\
shreeshas95 4:104dd82c99b8 973 break;\
shreeshas95 4:104dd82c99b8 974 }\
shreeshas95 4:104dd82c99b8 975 }\
shreeshas95 4:104dd82c99b8 976 modify_this = modify_this->next_TC;\
shreeshas95 4:104dd82c99b8 977 ++modify_overflow;\
shreeshas95 4:104dd82c99b8 978 }\
shreeshas95 4:104dd82c99b8 979 else{\
ee12b079 210:f4acf895b598 980 RESET_CDMS;\
shreeshas95 4:104dd82c99b8 981 break;\
shreeshas95 4:104dd82c99b8 982 }\
shreeshas95 4:104dd82c99b8 983 }\
shreeshas95 4:104dd82c99b8 984 break;\
shreeshas95 4:104dd82c99b8 985 case OBOSC_SUB_RETRY:\
aniruddhv 12:ffdb29353058 986 /*gPC.puts("retry type obosc\r\n");*/\
shreeshas95 4:104dd82c99b8 987 while( modify_this != NULL ){\
shreeshas95 4:104dd82c99b8 988 if( modify_overflow < TCL_OVERFLOW_CONSTANT ){\
shreeshas95 5:ab276a17ca07 989 uint8_t modify_psc = GETpacket_seq_count(modify_this);\
shreeshas95 4:104dd82c99b8 990 for( int i = 3 ; i < 9 ; ++i ){\
shreeshas95 5:ab276a17ca07 991 uint8_t target_psc = tc_ptr->TC_string[i];\
shreeshas95 5:ab276a17ca07 992 if( (target_psc == modify_psc) && (target_psc != 0) ){\
shreeshas95 4:104dd82c99b8 993 uint16_t tempExec = TC_STATE_MARKED_RETRY;\
shreeshas95 4:104dd82c99b8 994 PUTexec_status( modify_this, tempExec );\
aniruddhv 12:ffdb29353058 995 /*gPC.puts("reqquired tc found: disable\r\n");*/\
shreeshas95 4:104dd82c99b8 996 break;\
shreeshas95 4:104dd82c99b8 997 }\
shreeshas95 4:104dd82c99b8 998 }\
shreeshas95 4:104dd82c99b8 999 modify_this = modify_this->next_TC;\
shreeshas95 4:104dd82c99b8 1000 ++modify_overflow;\
shreeshas95 4:104dd82c99b8 1001 }\
shreeshas95 4:104dd82c99b8 1002 else{\
ee12b079 210:f4acf895b598 1003 RESET_CDMS;\
shreeshas95 4:104dd82c99b8 1004 break;\
shreeshas95 4:104dd82c99b8 1005 }\
shreeshas95 4:104dd82c99b8 1006 }\
shreeshas95 4:104dd82c99b8 1007 break;\
shreeshas95 4:104dd82c99b8 1008 }\
shreeshas95 4:104dd82c99b8 1009 Base_tm *ackl234new = new Short_tm;\
shreeshas95 4:104dd82c99b8 1010 ackl234new->next_TM = NULL;\
shreeshas95 4:104dd82c99b8 1011 /*return telemetry pointer here*/\
shreeshas95 4:104dd82c99b8 1012 tm_ptr = ackl234new;\
shreeshas95 4:104dd82c99b8 1013 ackl234new->TM_string[0] = TMID_ACK_L234 << 4;\
shreeshas95 4:104dd82c99b8 1014 ackl234new->TM_string[1] = GETpacket_seq_count(tc_ptr);\
shreeshas95 4:104dd82c99b8 1015 ackl234new->TM_string[2] = 0xA0;\
shreeshas95 4:104dd82c99b8 1016 for(int i = 3; i < 11; ++i){\
shreeshas95 4:104dd82c99b8 1017 ackl234new->TM_string[i] = 0x00;\
shreeshas95 4:104dd82c99b8 1018 }\
shreeshas95 4:104dd82c99b8 1019 uint16_t crc = crc16_gen(ackl234new->TM_string, TM_SHORT_SIZE-2);\
shreeshas95 4:104dd82c99b8 1020 ackl234new->TM_string[11] = (crc & 0xFF00) >> 8;\
shreeshas95 4:104dd82c99b8 1021 ackl234new->TM_string[12] = crc & 0x00FF;\
shreeshas95 4:104dd82c99b8 1022 /*ack l234 old*/\
shreeshas95 4:104dd82c99b8 1023 if( service_subtype == OBOSC_SUB_REP_LE ){\
shreeshas95 4:104dd82c99b8 1024 if( gLAST_TM_SHORT_OR_LONG == SHORT_TM_CODE ){\
shreeshas95 4:104dd82c99b8 1025 Base_tm *ackl234old = new Short_tm;\
shreeshas95 4:104dd82c99b8 1026 ackl234old->next_TM = NULL;\
shreeshas95 4:104dd82c99b8 1027 /*APPEND TO ACK L234 NEW HERE*/\
shreeshas95 4:104dd82c99b8 1028 ackl234new->next_TM = ackl234old;\
shreeshas95 4:104dd82c99b8 1029 for( int i = 0 ; i < TM_SHORT_SIZE ; ++i ){\
shreeshas95 4:104dd82c99b8 1030 ackl234old->TM_string[i] = gLAST_TM[i];\
shreeshas95 4:104dd82c99b8 1031 }\
shreeshas95 0:f016e9e8d48b 1032 }\
shreeshas95 4:104dd82c99b8 1033 else{\
shreeshas95 4:104dd82c99b8 1034 Base_tm *tempLongTM = new Long_tm;\
shreeshas95 4:104dd82c99b8 1035 tempLongTM->next_TM = NULL;\
shreeshas95 4:104dd82c99b8 1036 /*APPEND TO ACK L234 NEW HERE*/\
shreeshas95 4:104dd82c99b8 1037 ackl234new->next_TM = tempLongTM;\
shreeshas95 4:104dd82c99b8 1038 for( int i = 0 ; i < TM_LONG_SIZE ; ++i ){\
shreeshas95 4:104dd82c99b8 1039 tempLongTM->TM_string[i] = gLAST_TM[i];\
shreeshas95 4:104dd82c99b8 1040 }\
shreeshas95 4:104dd82c99b8 1041 }\
shreeshas95 4:104dd82c99b8 1042 }\
shreeshas95 4:104dd82c99b8 1043 else if( service_subtype == OBOSC_SUB_REP_TCLD ){\
shreeshas95 4:104dd82c99b8 1044 get_tc_list(ackl234new->next_TM, GETpacket_seq_count(tc_ptr));\
shreeshas95 4:104dd82c99b8 1045 }\
shreeshas95 4:104dd82c99b8 1046 else if( service_subtype == OBOSC_SUB_RESET ){\
aniruddhv 51:da85d84768e2 1047 /*reset_all;*/\
aniruddhv 51:da85d84768e2 1048 reset_flag = 1;\
shreeshas95 4:104dd82c99b8 1049 /*PENDING: VERIFY reset_all, RESET CDMS*/\
shreeshas95 0:f016e9e8d48b 1050 }\
shreeshas95 5:ab276a17ca07 1051 else if( (service_subtype != OBOSC_SUB_DISABLE) && (service_subtype != OBOSC_SUB_RETRY) ){\
shreeshas95 4:104dd82c99b8 1052 /*CHANGE THE ACK CODE TO INVALID TC*/\
shreeshas95 4:104dd82c99b8 1053 ackl234new->TM_string[2] = 0xA2;\
shreeshas95 0:f016e9e8d48b 1054 }\
ee12b079 210:f4acf895b598 1055 if (DEBUG)\
ee12b079 210:f4acf895b598 1056 gPC.puts("completed obosc\r\n");\
shreeshas95 4:104dd82c99b8 1057 }
shreeshas95 4:104dd82c99b8 1058
shreeshas95 4:104dd82c99b8 1059 /*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 1060
shreeshas95 0:f016e9e8d48b 1061
shreeshas95 0:f016e9e8d48b 1062 #define EXECUTE_OBOSC_ONLY {\
aniruddhv 51:da85d84768e2 1063 int reset_flag = 0;\
ee12b079 210:f4acf895b598 1064 if (DEBUG)\
ee12b079 210:f4acf895b598 1065 gPC.puts("iNSIDE EXECUTE_OBOSC_ONLY\r\n");\
ee12b079 210:f4acf895b598 1066 Base_tm *obosc_tm_core = NULL;\
ee12b079 210:f4acf895b598 1067 Base_tm *obosc_tm = obosc_tm_core;\
shreeshas95 15:1c1ca992b43b 1068 for(uint8_t execute_psc = PSC_START_VALUE ; execute_psc < gTOTAL_VALID_TC ; ++execute_psc){\
shreeshas95 4:104dd82c99b8 1069 Base_tc* current_TC = gHEAD_NODE_TCL;\
shreeshas95 4:104dd82c99b8 1070 int overCount = 0;\
shreeshas95 0:f016e9e8d48b 1071 while( current_TC != NULL ){\
shreeshas95 4:104dd82c99b8 1072 if( overCount < TCL_OVERFLOW_CONSTANT ){\
shreeshas95 4:104dd82c99b8 1073 if( (GETcrc_pass(current_TC) == 1) && (GETpacket_seq_count(current_TC) == execute_psc) ){\
shreeshas95 4:104dd82c99b8 1074 /*CHECK FOR OBOSC*/\
shreeshas95 0:f016e9e8d48b 1075 uint8_t temp82 = 0x00;\
shreeshas95 0:f016e9e8d48b 1076 isit_obosc(current_TC, temp82);\
shreeshas95 0:f016e9e8d48b 1077 if(temp82 == 0x01){\
shreeshas95 4:104dd82c99b8 1078 uint16_t current_exec_status = GETexec_status(current_TC);\
shreeshas95 4:104dd82c99b8 1079 if( (current_exec_status == TC_STATE_SUCCESSFULLY_EXECUTED) || (current_exec_status == TC_STATE_DISABLED) )\
shreeshas95 4:104dd82c99b8 1080 break;\
shreeshas95 4:104dd82c99b8 1081 else if( (current_exec_status == TC_STATE_UNEXECUTED) || (current_exec_status == TC_STATE_MARKED_RETRY) ){\
ee12b079 210:f4acf895b598 1082 if (DEBUG)\
ee12b079 210:f4acf895b598 1083 gPC.printf("It is obosc: %u\r\n", execute_psc);\
shreeshas95 4:104dd82c99b8 1084 /*EXECUTION OF OBOSC TC*/\
shreeshas95 4:104dd82c99b8 1085 /*WARNING: LARGE MEMORY UTILIZATION FOR TC-LIST-REPORT */\
ee12b079 73:6c99294b7802 1086 execute_obosc_core(current_TC, obosc_tm_core, reset_flag);\
ee12b079 210:f4acf895b598 1087 Base_tm *obosc_tm_current = obosc_tm_core;\
ee12b079 210:f4acf895b598 1088 while(obosc_tm_core != NULL){\
ee12b079 210:f4acf895b598 1089 obosc_tm_core = obosc_tm_core->next_TM;\
ee12b079 210:f4acf895b598 1090 }\
ee12b079 73:6c99294b7802 1091 uint16_t temp16 = TC_STATE_SUCCESSFULLY_EXECUTED;\
ee12b079 73:6c99294b7802 1092 PUTexec_status(current_TC, temp16);\
ee12b079 73:6c99294b7802 1093 while( obosc_tm_current != NULL ){\
ee12b079 73:6c99294b7802 1094 int length = TM_SHORT_SIZE;\
shreeshas95 102:80c911a6e736 1095 if( GETshort_or_long_tm(obosc_tm_current) == SHORT_TM_CODE ){\
ee12b079 73:6c99294b7802 1096 length = TM_SHORT_SIZE;\
ee12b079 73:6c99294b7802 1097 }\
ee12b079 73:6c99294b7802 1098 else{\
ee12b079 73:6c99294b7802 1099 length = TM_LONG_SIZE;\
ee12b079 73:6c99294b7802 1100 }\
ee12b079 73:6c99294b7802 1101 for(int i = 0 ; i < length ; ++i){\
ee12b079 73:6c99294b7802 1102 /*gPC.putc(obosc_tm_current->TM_string[i]);*/\
ee12b079 73:6c99294b7802 1103 }\
ee12b079 73:6c99294b7802 1104 obosc_tm_current = obosc_tm_current->next_TM;\
ee12b079 73:6c99294b7802 1105 }\
ee12b079 73:6c99294b7802 1106 if ( reset_flag ==1 ){\
ee12b079 73:6c99294b7802 1107 reset_all;\
ee12b079 73:6c99294b7802 1108 }\
shreeshas95 0:f016e9e8d48b 1109 }\
shreeshas95 0:f016e9e8d48b 1110 }\
shreeshas95 0:f016e9e8d48b 1111 }\
shreeshas95 4:104dd82c99b8 1112 current_TC = current_TC->next_TC;\
shreeshas95 4:104dd82c99b8 1113 ++overCount;\
shreeshas95 0:f016e9e8d48b 1114 }\
shreeshas95 4:104dd82c99b8 1115 else{\
shreeshas95 4:104dd82c99b8 1116 /*PENDING: REST CDMS: MEMORY LEAK FOUND*/\
shreeshas95 4:104dd82c99b8 1117 break;\
shreeshas95 4:104dd82c99b8 1118 }\
shreeshas95 4:104dd82c99b8 1119 }\
aniruddhv 58:5c59f28620bc 1120 }\
ee12b079 210:f4acf895b598 1121 if(obosc_tm_core != NULL){\
ee12b079 210:f4acf895b598 1122 Base_tm *obosc_tm_head = NULL;\
ee12b079 210:f4acf895b598 1123 get_call_sign(obosc_tm_head);\
ee12b079 210:f4acf895b598 1124 Base_tm *obosc_tm_current = obosc_tm_head;\
ee12b079 210:f4acf895b598 1125 get_ack_l1(obosc_tm_current->next_TM);\
ee12b079 210:f4acf895b598 1126 int overflowCountOBONLY = 0;\
ee12b079 210:f4acf895b598 1127 while( obosc_tm_current->next_TM != NULL ){\
ee12b079 210:f4acf895b598 1128 if( overflowCountOBONLY < TM_OVERFLOW_CONSTANT ){\
ee12b079 210:f4acf895b598 1129 obosc_tm_current = obosc_tm_current->next_TM;\
ee12b079 210:f4acf895b598 1130 ++overflowCountOBONLY;\
ee12b079 210:f4acf895b598 1131 }\
ee12b079 210:f4acf895b598 1132 else{\
ee12b079 210:f4acf895b598 1133 RESET_CDMS;\
ee12b079 210:f4acf895b598 1134 break;\
ee12b079 210:f4acf895b598 1135 }\
ee12b079 210:f4acf895b598 1136 }\
ee12b079 210:f4acf895b598 1137 obosc_tm_current->next_TM = obosc_tm;\
ee12b079 210:f4acf895b598 1138 /*Sending OBOSC TM to GS*/\
ee12b079 210:f4acf895b598 1139 /*snd_tm.head_pointer(obosc_tm_head);*/\
ee12b079 210:f4acf895b598 1140 /*transmit_adf;*/\
ee12b079 210:f4acf895b598 1141 /*DELETE THE TM AFTER USE*/\
ee12b079 210:f4acf895b598 1142 obosc_tm_current = obosc_tm_head;\
ee12b079 210:f4acf895b598 1143 int overCount = 0;\
ee12b079 210:f4acf895b598 1144 while( obosc_tm_current != NULL ){\
ee12b079 210:f4acf895b598 1145 if( (overCount < TM_OVERFLOW_CONSTANT) ){\
ee12b079 210:f4acf895b598 1146 Base_tm *temp = obosc_tm_current->next_TM;\
ee12b079 210:f4acf895b598 1147 delete obosc_tm_current;\
ee12b079 210:f4acf895b598 1148 obosc_tm_current = temp;\
ee12b079 210:f4acf895b598 1149 ++overCount;\
ee12b079 210:f4acf895b598 1150 }\
ee12b079 210:f4acf895b598 1151 else{\
ee12b079 210:f4acf895b598 1152 RESET_CDMS;\
ee12b079 210:f4acf895b598 1153 break;\
ee12b079 210:f4acf895b598 1154 }\
ee12b079 210:f4acf895b598 1155 }\
ee12b079 210:f4acf895b598 1156 }\
shreeshas95 0:f016e9e8d48b 1157 }
shreeshas95 0:f016e9e8d48b 1158
shreeshas95 0:f016e9e8d48b 1159 #define EXECUTE_TC {\
shreeshas95 5:ab276a17ca07 1160 gMASTER_STATE = TCL_STATE_EXECUTING;\
ee12b079 210:f4acf895b598 1161 if (DEBUG)\
ee12b079 210:f4acf895b598 1162 gPC.puts("iNSIDE EXECUTE_TC\r\n");\
rohit3342 23:c89376564196 1163 /*gPC.printf("%u\r\n", gTOTAL_VALID_TC);*/\
rohit3342 16:538de1b20b3a 1164 for(uint8_t execute_psc = PSC_START_VALUE ; execute_psc < gTOTAL_VALID_TC ; ++execute_psc ){\
ee12b079 210:f4acf895b598 1165 if (DEBUG)\
ee12b079 210:f4acf895b598 1166 gPC.printf("executing normal %u\r\n", execute_psc);\
shreeshas95 2:2caf2a9a13aa 1167 /*gLEDG = !gLEDG;*/\
shreeshas95 2:2caf2a9a13aa 1168 /*gLEDR = !gLEDR;*/\
shreeshas95 0:f016e9e8d48b 1169 Base_tc* current_TC = gHEAD_NODE_TCL;\
shreeshas95 4:104dd82c99b8 1170 int overflowCount = 0;\
shreeshas95 0:f016e9e8d48b 1171 while(current_TC != NULL){\
shreeshas95 4:104dd82c99b8 1172 if( overflowCount < TCL_OVERFLOW_CONSTANT ){\
shreeshas95 4:104dd82c99b8 1173 if( (GETcrc_pass(current_TC) == 1) && (GETpacket_seq_count(current_TC) == execute_psc) ){\
shreeshas95 4:104dd82c99b8 1174 uint8_t current_exec_status = GETexec_status(current_TC);\
shreeshas95 5:ab276a17ca07 1175 if( (current_exec_status == TC_STATE_SUCCESSFULLY_EXECUTED) || (current_exec_status == TC_STATE_DISABLED) ){\
aniruddhv 12:ffdb29353058 1176 /*gPC.printf("disabled or completed at %u\n", execute_psc);*/\
ee12b079 210:f4acf895b598 1177 if( execute_psc == (gTOTAL_VALID_TC-1) ){\
ee12b079 210:f4acf895b598 1178 /*LAST TC IS EXECUTED*/\
ee12b079 210:f4acf895b598 1179 gMASTER_STATE = TCL_STATE_COMPLETED;\
ee12b079 210:f4acf895b598 1180 }\
shreeshas95 4:104dd82c99b8 1181 break;\
shreeshas95 5:ab276a17ca07 1182 }\
shreeshas95 4:104dd82c99b8 1183 else if( (current_exec_status == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\
aniruddhv 12:ffdb29353058 1184 /*gPC.printf("abort on nack at %u psc\r\n", execute_psc);*/\
shreeshas95 4:104dd82c99b8 1185 gMASTER_STATE = TCL_STATE_ABORTED;\
rohit3342 44:b9b067d0559f 1186 Base_tm *tm_ptr_head = NULL;\
rohit3342 44:b9b067d0559f 1187 get_call_sign(tm_ptr_head);\
rohit3342 44:b9b067d0559f 1188 Base_tm *tm_ptr = tm_ptr_head;\
rohit3342 44:b9b067d0559f 1189 get_ack_l1(tm_ptr->next_TM);\
ee12b079 73:6c99294b7802 1190 tm_ptr = tm_ptr_head;\
ee12b079 73:6c99294b7802 1191 while( tm_ptr != NULL ){\
ee12b079 73:6c99294b7802 1192 int length = TM_SHORT_SIZE;\
shreeshas95 102:80c911a6e736 1193 if( GETshort_or_long_tm(tm_ptr) == SHORT_TM_CODE ){\
ee12b079 73:6c99294b7802 1194 length = TM_SHORT_SIZE;\
ee12b079 73:6c99294b7802 1195 }\
ee12b079 73:6c99294b7802 1196 else{\
ee12b079 73:6c99294b7802 1197 length = TM_LONG_SIZE;\
ee12b079 73:6c99294b7802 1198 }\
ee12b079 73:6c99294b7802 1199 /*gPC.puts("Printing Call Sign, ACK_L1, TM list");*/\
ee12b079 73:6c99294b7802 1200 for(int i = 0 ; i < length ; ++i){\
ee12b079 73:6c99294b7802 1201 /*gPC.putc(tm_ptr->TM_string[i]);*/\
ee12b079 73:6c99294b7802 1202 }\
ee12b079 73:6c99294b7802 1203 tm_ptr = tm_ptr->next_TM;\
ee12b079 80:b2155ba726c3 1204 }\
ee12b079 80:b2155ba726c3 1205 /*Send only call sign, ACK_L1 to GS*/\
ee12b079 73:6c99294b7802 1206 /*snd_tm.head_pointer(tm_ptr_head);*/\
ee12b079 95:42d6747900cb 1207 /*transmit_adf;*/\
ee12b079 73:6c99294b7802 1208 /*DELETE THE TM AFTER USE*/\
ee12b079 73:6c99294b7802 1209 tm_ptr = tm_ptr_head;\
ee12b079 73:6c99294b7802 1210 int overflowCountExecute = 0;\
ee12b079 73:6c99294b7802 1211 while(tm_ptr != NULL){\
ee12b079 73:6c99294b7802 1212 if( overflowCountExecute < TM_OVERFLOW_CONSTANT ){\
ee12b079 73:6c99294b7802 1213 Base_tm *temp = tm_ptr->next_TM;\
ee12b079 73:6c99294b7802 1214 delete tm_ptr;\
ee12b079 73:6c99294b7802 1215 tm_ptr = temp;\
ee12b079 73:6c99294b7802 1216 ++overflowCountExecute;\
ee12b079 73:6c99294b7802 1217 }\
ee12b079 73:6c99294b7802 1218 else{\
ee12b079 210:f4acf895b598 1219 RESET_CDMS;\
ee12b079 73:6c99294b7802 1220 break;\
ee12b079 73:6c99294b7802 1221 }\
ee12b079 73:6c99294b7802 1222 }\
shreeshas95 4:104dd82c99b8 1223 break;\
shreeshas95 4:104dd82c99b8 1224 }\
shreeshas95 4:104dd82c99b8 1225 else if( (current_exec_status == TC_STATE_UNEXECUTED) || (current_exec_status == TC_STATE_MARKED_RETRY) ){\
shreeshas95 4:104dd82c99b8 1226 /*EXECUTION OF TC START*/\
shreeshas95 4:104dd82c99b8 1227 uint8_t temp81 = 0x00;\
shreeshas95 4:104dd82c99b8 1228 isit_sdcard(current_TC, temp81);\
shreeshas95 4:104dd82c99b8 1229 if( temp81 == 0x00 ){\
ee12b079 210:f4acf895b598 1230 if (DEBUG)\
ee12b079 210:f4acf895b598 1231 gPC.printf("non sd card at %u\r\n", execute_psc);\
shreeshas95 4:104dd82c99b8 1232 /*EXECUTION OF NON SD-CARD (BOTH OBOSC and CDMS functions)*/\
shreeshas95 4:104dd82c99b8 1233 Base_tm *tm_ptr_head = NULL;\
shreeshas95 4:104dd82c99b8 1234 get_call_sign(tm_ptr_head);\
shreeshas95 4:104dd82c99b8 1235 Base_tm *put_tm_here = NULL;\
shreeshas95 4:104dd82c99b8 1236 uint8_t temp82 = 0x00;\
shreeshas95 4:104dd82c99b8 1237 uint8_t tempPAhot = 0x00;\
shreeshas95 4:104dd82c99b8 1238 isit_obosc(current_TC, temp82);\
shreeshas95 4:104dd82c99b8 1239 if(temp82 == 0x01){\
aniruddhv 12:ffdb29353058 1240 /*gPC.printf("obosc tc inside normal tc at %u\r\n", execute_psc);*/\
shreeshas95 4:104dd82c99b8 1241 /*EXECUTION OF OBOSC TC*/\
shreeshas95 4:104dd82c99b8 1242 /*SKIP EXECUTION OF OBOSC HERE*/\
aniruddhv 37:c9a739750806 1243 break;\
shreeshas95 4:104dd82c99b8 1244 }\
shreeshas95 4:104dd82c99b8 1245 else{\
rohit3342 23:c89376564196 1246 /*gPC.printf("cdms relay tmtc at %u\r\n", execute_psc);*/\
shreeshas95 4:104dd82c99b8 1247 /*call CDMS_RLY_TMTC*/\
shreeshas95 4:104dd82c99b8 1248 /*CDMS_RLY_TMTC(current_TC, put_tm_here);*/\
aniruddhv 52:0bd68655c651 1249 put_tm_here = FCTN_CDMS_RLY_TMTC(current_TC);\
shreeshas95 4:104dd82c99b8 1250 }\
shreeshas95 4:104dd82c99b8 1251 /*DETECT ACK OR NACK*/\
shreeshas95 4:104dd82c99b8 1252 uint8_t temp83 = 0x00;\
shreeshas95 4:104dd82c99b8 1253 uint8_t temp84 = GETpacket_seq_count(current_TC);\
shreeshas95 4:104dd82c99b8 1254 detect_ack(put_tm_here, temp83, temp84);\
shreeshas95 4:104dd82c99b8 1255 if( temp83 == 0x01){\
shreeshas95 4:104dd82c99b8 1256 uint16_t temp16 = TC_STATE_SUCCESSFULLY_EXECUTED;\
shreeshas95 4:104dd82c99b8 1257 PUTexec_status(current_TC, temp16);\
shreeshas95 4:104dd82c99b8 1258 }\
shreeshas95 4:104dd82c99b8 1259 else{\
rohit3342 23:c89376564196 1260 /*gPC.puts("TC_STATE_EXECUTION_FAILED");*/\
shreeshas95 4:104dd82c99b8 1261 uint16_t temp16 = TC_STATE_EXECUTION_FAILED;\
shreeshas95 4:104dd82c99b8 1262 PUTexec_status(current_TC, temp16);\
shreeshas95 4:104dd82c99b8 1263 }\
shreeshas95 4:104dd82c99b8 1264 /*ABORT ON NACK AND TC LIST COMPLETED: UPDATE IN gMASTERSTATE*/\
shreeshas95 4:104dd82c99b8 1265 if( (GETexec_status(current_TC) == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\
shreeshas95 4:104dd82c99b8 1266 gMASTER_STATE = TCL_STATE_ABORTED;\
shreeshas95 4:104dd82c99b8 1267 }\
shreeshas95 15:1c1ca992b43b 1268 else if( execute_psc == (gTOTAL_VALID_TC-1) ){\
shreeshas95 4:104dd82c99b8 1269 /*LAST TC IS EXECUTED*/\
shreeshas95 4:104dd82c99b8 1270 gMASTER_STATE = TCL_STATE_COMPLETED;\
shreeshas95 4:104dd82c99b8 1271 }\
shreeshas95 4:104dd82c99b8 1272 /*update last executed L1_ack*/\
shreeshas95 4:104dd82c99b8 1273 if( put_tm_here != NULL ){\
shreeshas95 102:80c911a6e736 1274 if( GETshort_or_long_tm(put_tm_here) == SHORT_TM_CODE ){\
shreeshas95 4:104dd82c99b8 1275 for(int i = 0 ; i < TM_SHORT_SIZE ; ++i){\
shreeshas95 4:104dd82c99b8 1276 gLAST_TM[i] = put_tm_here->TM_string[i];\
shreeshas95 4:104dd82c99b8 1277 gLAST_TM_SHORT_OR_LONG = SHORT_TM_CODE;\
shreeshas95 4:104dd82c99b8 1278 }\
shreeshas95 4:104dd82c99b8 1279 }\
shreeshas95 4:104dd82c99b8 1280 else{\
shreeshas95 4:104dd82c99b8 1281 for( int i = 0 ; i < TM_LONG_SIZE ; ++i ){\
shreeshas95 4:104dd82c99b8 1282 gLAST_TM[i] = put_tm_here->TM_string[i];\
shreeshas95 4:104dd82c99b8 1283 gLAST_TM_SHORT_OR_LONG = LONG_TM_CODE;\
shreeshas95 4:104dd82c99b8 1284 }\
shreeshas95 4:104dd82c99b8 1285 }\
shreeshas95 4:104dd82c99b8 1286 }\
shreeshas95 4:104dd82c99b8 1287 /*PENDING: APPEND ACK L1*/\
shreeshas95 4:104dd82c99b8 1288 Base_tm *tm_ptr = tm_ptr_head;\
shreeshas95 4:104dd82c99b8 1289 get_ack_l1(tm_ptr->next_TM);\
shreeshas95 4:104dd82c99b8 1290 int overflowCountExecute = 0;\
shreeshas95 4:104dd82c99b8 1291 while( tm_ptr->next_TM != NULL ){\
shreeshas95 4:104dd82c99b8 1292 if( overflowCountExecute < TM_OVERFLOW_CONSTANT ){\
shreeshas95 4:104dd82c99b8 1293 tm_ptr = tm_ptr->next_TM;\
shreeshas95 4:104dd82c99b8 1294 ++overflowCountExecute;\
shreeshas95 4:104dd82c99b8 1295 }\
shreeshas95 4:104dd82c99b8 1296 else{\
ee12b079 210:f4acf895b598 1297 RESET_CDMS;\
shreeshas95 4:104dd82c99b8 1298 break;\
shreeshas95 4:104dd82c99b8 1299 }\
shreeshas95 4:104dd82c99b8 1300 }\
shreeshas95 4:104dd82c99b8 1301 tm_ptr->next_TM = put_tm_here;\
shreeshas95 4:104dd82c99b8 1302 /*CHECK FOR HOT PA*/\
shreeshas95 4:104dd82c99b8 1303 isPAhot(tempPAhot);\
shreeshas95 4:104dd82c99b8 1304 if( tempPAhot == 0x00 ){\
shreeshas95 4:104dd82c99b8 1305 gFLAGS = gFLAGS | COM_PA_HOT_FLAG;\
shreeshas95 4:104dd82c99b8 1306 }\
ee12b079 73:6c99294b7802 1307 tm_ptr = tm_ptr_head;\
ee12b079 73:6c99294b7802 1308 while( tm_ptr != NULL ){\
ee12b079 73:6c99294b7802 1309 int length = TM_SHORT_SIZE;\
shreeshas95 102:80c911a6e736 1310 if( GETshort_or_long_tm(tm_ptr) == SHORT_TM_CODE ){\
ee12b079 73:6c99294b7802 1311 length = TM_SHORT_SIZE;\
ee12b079 73:6c99294b7802 1312 }\
ee12b079 73:6c99294b7802 1313 else{\
ee12b079 73:6c99294b7802 1314 length = TM_LONG_SIZE;\
ee12b079 73:6c99294b7802 1315 }\
ee12b079 73:6c99294b7802 1316 /*gPC.puts("Printing Call Sign, ACK_L1, TM list");*/\
ee12b079 73:6c99294b7802 1317 for(int i = 0 ; i < length ; ++i){\
ee12b079 73:6c99294b7802 1318 /*gPC.putc(tm_ptr->TM_string[i]);*/\
ee12b079 73:6c99294b7802 1319 }\
ee12b079 73:6c99294b7802 1320 tm_ptr = tm_ptr->next_TM;\
ee12b079 73:6c99294b7802 1321 }\
ee12b079 80:b2155ba726c3 1322 /*SEND call sign, ACK_L1, NON OBSRS TM TO GS*/\
ee12b079 95:42d6747900cb 1323 snd_tm.head_pointer(tm_ptr_head);\
ee12b079 98:fd99ddc0e0a1 1324 gPC.puts("enter_adf\r\n");\
ee12b079 254:22d97475ca79 1325 transmit_adf;\
ee12b079 98:fd99ddc0e0a1 1326 gPC.puts("exit_adf\r\n");\
ee12b079 73:6c99294b7802 1327 /*DELETE THE TM AFTER USE*/\
ee12b079 73:6c99294b7802 1328 tm_ptr = tm_ptr_head;\
ee12b079 73:6c99294b7802 1329 overflowCountExecute = 0;\
ee12b079 73:6c99294b7802 1330 while(tm_ptr != NULL){\
ee12b079 73:6c99294b7802 1331 if( overflowCountExecute < TM_OVERFLOW_CONSTANT ){\
ee12b079 73:6c99294b7802 1332 Base_tm *temp = tm_ptr->next_TM;\
ee12b079 73:6c99294b7802 1333 delete tm_ptr;\
ee12b079 73:6c99294b7802 1334 tm_ptr = temp;\
ee12b079 73:6c99294b7802 1335 ++overflowCountExecute;\
ee12b079 73:6c99294b7802 1336 }\
ee12b079 73:6c99294b7802 1337 else{\
ee12b079 210:f4acf895b598 1338 RESET_CDMS;\
ee12b079 73:6c99294b7802 1339 break;\
ee12b079 73:6c99294b7802 1340 }\
ee12b079 73:6c99294b7802 1341 }\
shreeshas95 0:f016e9e8d48b 1342 }\
shreeshas95 0:f016e9e8d48b 1343 else{\
ee12b079 210:f4acf895b598 1344 if (DEBUG)\
ee12b079 210:f4acf895b598 1345 gPC.printf("sd card at %u\r\n", execute_psc);\
shreeshas95 4:104dd82c99b8 1346 /*EXECUTION OF SD-CARD DATA SENDING (OBSRS)*/\
aniruddhv 37:c9a739750806 1347 Base_tm *tm_ptr_head = NULL;\
aniruddhv 37:c9a739750806 1348 get_call_sign(tm_ptr_head);\
aniruddhv 37:c9a739750806 1349 Base_tm *put_tm_here = NULL;\
aniruddhv 37:c9a739750806 1350 /*execute_obsrs(current_TC, put_tm_here)*/\
shreeshas95 4:104dd82c99b8 1351 /*read_TC(current_TC);*/\
ee12b079 87:6e154fd43531 1352 execute_OBSRS_TC(current_TC);\
ee12b079 210:f4acf895b598 1353 gPC.puts("en_adf");\
ee12b079 254:22d97475ca79 1354 transmit_adf;\
ee12b079 210:f4acf895b598 1355 gPC.puts("ex_adf");\
shreeshas95 6:79d422d1ed42 1356 uint8_t tempExec = TC_STATE_SUCCESSFULLY_EXECUTED;\
shreeshas95 6:79d422d1ed42 1357 PUTexec_status(current_TC, tempExec);\
ee12b079 73:6c99294b7802 1358 /*PENDING: ABORT ON NACK CHECK, gMASTER_STATE VERIFICATION WITH SD CARD, session timeout, last executed ack l234*/\
shreeshas95 4:104dd82c99b8 1359 if( (GETexec_status(current_TC) == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\
shreeshas95 4:104dd82c99b8 1360 gMASTER_STATE = TCL_STATE_ABORTED;\
shreeshas95 0:f016e9e8d48b 1361 }\
shreeshas95 15:1c1ca992b43b 1362 else if( execute_psc == (gTOTAL_VALID_TC-1) ){\
shreeshas95 6:79d422d1ed42 1363 gMASTER_STATE = TCL_STATE_COMPLETED;\
shreeshas95 6:79d422d1ed42 1364 }\
ee12b079 73:6c99294b7802 1365 else{\
ee12b079 73:6c99294b7802 1366 uint8_t check1 = 1;\
ee12b079 73:6c99294b7802 1367 for( uint8_t test_psc = execute_psc+1 ; test_psc < gTOTAL_VALID_TC ; ++test_psc ){\
ee12b079 73:6c99294b7802 1368 Base_tc* test_TC = gHEAD_NODE_TCL;\
ee12b079 73:6c99294b7802 1369 while(test_TC != NULL){\
ee12b079 73:6c99294b7802 1370 if( GETpacket_seq_count(test_TC) == test_psc ){\
ee12b079 73:6c99294b7802 1371 uint8_t checkval;\
ee12b079 73:6c99294b7802 1372 isit_obosc(test_TC, checkval);\
ee12b079 73:6c99294b7802 1373 if( checkval == 0 ){\
ee12b079 73:6c99294b7802 1374 check1 = 0;\
ee12b079 73:6c99294b7802 1375 }\
ee12b079 73:6c99294b7802 1376 }\
ee12b079 73:6c99294b7802 1377 test_TC = test_TC->next_TC;\
ee12b079 73:6c99294b7802 1378 }\
ee12b079 73:6c99294b7802 1379 }\
ee12b079 73:6c99294b7802 1380 if( check1 == 0x01 ){\
ee12b079 73:6c99294b7802 1381 gMASTER_STATE = TCL_STATE_COMPLETED;\
ee12b079 73:6c99294b7802 1382 }\
ee12b079 73:6c99294b7802 1383 }\
ee12b079 73:6c99294b7802 1384 /*update last executed L1_ack*/\
ee12b079 73:6c99294b7802 1385 if( put_tm_here != NULL ){\
shreeshas95 102:80c911a6e736 1386 if( GETshort_or_long_tm(put_tm_here) == SHORT_TM_CODE ){\
ee12b079 73:6c99294b7802 1387 for(int i = 0 ; i < TM_SHORT_SIZE ; ++i){\
ee12b079 73:6c99294b7802 1388 gLAST_TM[i] = put_tm_here->TM_string[i];\
ee12b079 73:6c99294b7802 1389 gLAST_TM_SHORT_OR_LONG = SHORT_TM_CODE;\
ee12b079 73:6c99294b7802 1390 }\
ee12b079 73:6c99294b7802 1391 }\
ee12b079 73:6c99294b7802 1392 else{\
ee12b079 73:6c99294b7802 1393 for( int i = 0 ; i < TM_LONG_SIZE ; ++i ){\
ee12b079 73:6c99294b7802 1394 gLAST_TM[i] = put_tm_here->TM_string[i];\
ee12b079 73:6c99294b7802 1395 gLAST_TM_SHORT_OR_LONG = LONG_TM_CODE;\
ee12b079 73:6c99294b7802 1396 }\
ee12b079 73:6c99294b7802 1397 }\
ee12b079 73:6c99294b7802 1398 }\
rohit3342 44:b9b067d0559f 1399 /*PENDING: APPEND ACK L1*/\
rohit3342 44:b9b067d0559f 1400 Base_tm *tm_ptr = tm_ptr_head;\
rohit3342 44:b9b067d0559f 1401 get_ack_l1(tm_ptr->next_TM);\
rohit3342 44:b9b067d0559f 1402 int overflowCountExecute = 0;\
rohit3342 44:b9b067d0559f 1403 while( tm_ptr->next_TM != NULL ){\
rohit3342 44:b9b067d0559f 1404 if( overflowCountExecute < TM_OVERFLOW_CONSTANT ){\
rohit3342 44:b9b067d0559f 1405 tm_ptr = tm_ptr->next_TM;\
rohit3342 44:b9b067d0559f 1406 ++overflowCountExecute;\
rohit3342 44:b9b067d0559f 1407 }\
rohit3342 44:b9b067d0559f 1408 else{\
ee12b079 210:f4acf895b598 1409 RESET_CDMS;\
rohit3342 44:b9b067d0559f 1410 break;\
rohit3342 44:b9b067d0559f 1411 }\
rohit3342 44:b9b067d0559f 1412 }\
rohit3342 44:b9b067d0559f 1413 tm_ptr->next_TM = put_tm_here;\
rohit3342 44:b9b067d0559f 1414 /*CHECK FOR HOT PA*/\
rohit3342 44:b9b067d0559f 1415 uint8_t tempPAhot = 0x00;\
rohit3342 44:b9b067d0559f 1416 isPAhot(tempPAhot);\
rohit3342 44:b9b067d0559f 1417 if( tempPAhot == 0x00 ){\
rohit3342 44:b9b067d0559f 1418 gFLAGS = gFLAGS | COM_PA_HOT_FLAG;\
rohit3342 44:b9b067d0559f 1419 }\
ee12b079 73:6c99294b7802 1420 tm_ptr = tm_ptr_head;\
ee12b079 73:6c99294b7802 1421 while( tm_ptr != NULL ){\
ee12b079 73:6c99294b7802 1422 int length = TM_SHORT_SIZE;\
shreeshas95 102:80c911a6e736 1423 if( GETshort_or_long_tm(tm_ptr) == SHORT_TM_CODE ){\
ee12b079 73:6c99294b7802 1424 length = TM_SHORT_SIZE;\
ee12b079 73:6c99294b7802 1425 }\
ee12b079 73:6c99294b7802 1426 else{\
ee12b079 73:6c99294b7802 1427 length = TM_LONG_SIZE;\
ee12b079 73:6c99294b7802 1428 }\
ee12b079 73:6c99294b7802 1429 /*gPC.puts("Printing Call Sign, ACK_L1, TM list");*/\
ee12b079 73:6c99294b7802 1430 for(int i = 0 ; i < length ; ++i){\
ee12b079 73:6c99294b7802 1431 /*gPC.putc(tm_ptr->TM_string[i]);*/\
ee12b079 73:6c99294b7802 1432 }\
ee12b079 73:6c99294b7802 1433 tm_ptr = tm_ptr->next_TM;\
ee12b079 73:6c99294b7802 1434 }\
ee12b079 80:b2155ba726c3 1435 /*SEND call sign, ACK_L1, OBSRS TO GS*/\
ee12b079 73:6c99294b7802 1436 /*snd_tm.head_pointer(tm_ptr_head);*/\
ee12b079 210:f4acf895b598 1437 /*transmit_adf;*/\
ee12b079 73:6c99294b7802 1438 /*DELETE THE TM AFTER USE*/\
ee12b079 73:6c99294b7802 1439 tm_ptr = tm_ptr_head;\
ee12b079 73:6c99294b7802 1440 overflowCountExecute = 0;\
ee12b079 73:6c99294b7802 1441 while(tm_ptr != NULL){\
ee12b079 73:6c99294b7802 1442 if( overflowCountExecute < TM_OVERFLOW_CONSTANT ){\
ee12b079 73:6c99294b7802 1443 Base_tm *temp = tm_ptr->next_TM;\
ee12b079 73:6c99294b7802 1444 delete tm_ptr;\
ee12b079 73:6c99294b7802 1445 tm_ptr = temp;\
ee12b079 73:6c99294b7802 1446 ++overflowCountExecute;\
ee12b079 73:6c99294b7802 1447 }\
ee12b079 73:6c99294b7802 1448 else{\
ee12b079 210:f4acf895b598 1449 RESET_CDMS;\
ee12b079 73:6c99294b7802 1450 break;\
ee12b079 73:6c99294b7802 1451 }\
ee12b079 73:6c99294b7802 1452 }\
shreeshas95 0:f016e9e8d48b 1453 }\
shreeshas95 0:f016e9e8d48b 1454 }\
shreeshas95 4:104dd82c99b8 1455 break;\
shreeshas95 0:f016e9e8d48b 1456 }\
shreeshas95 4:104dd82c99b8 1457 current_TC = current_TC->next_TC;\
shreeshas95 4:104dd82c99b8 1458 ++overflowCount;\
shreeshas95 0:f016e9e8d48b 1459 }\
shreeshas95 4:104dd82c99b8 1460 else{\
ee12b079 210:f4acf895b598 1461 RESET_CDMS;\
shreeshas95 2:2caf2a9a13aa 1462 break;\
shreeshas95 2:2caf2a9a13aa 1463 }\
shreeshas95 2:2caf2a9a13aa 1464 }\
shreeshas95 6:79d422d1ed42 1465 if( gFLAGS & COM_SESSION_TIMEOUT_FLAG ){\
shreeshas95 6:79d422d1ed42 1466 break;\
shreeshas95 6:79d422d1ed42 1467 }\
shreeshas95 6:79d422d1ed42 1468 else if( gMASTER_STATE == TCL_STATE_ABORTED ){\
ee12b079 210:f4acf895b598 1469 if (DEBUG)\
ee12b079 210:f4acf895b598 1470 gPC.puts("ABORTING DUE TO ABORT ON NACK\r\n");\
shreeshas95 4:104dd82c99b8 1471 /*EXITED DUE TO ABORT ON NACK:*/\
ee12b079 210:f4acf895b598 1472 /*COM_TX_CNTRL = 0;*/\
shreeshas95 2:2caf2a9a13aa 1473 RX1M.attach(&rx_read, Serial::RxIrq);\
shreeshas95 2:2caf2a9a13aa 1474 gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\
shreeshas95 0:f016e9e8d48b 1475 break;\
shreeshas95 2:2caf2a9a13aa 1476 }\
shreeshas95 4:104dd82c99b8 1477 else if( gFLAGS & COM_PA_HOT_FLAG ){\
shreeshas95 4:104dd82c99b8 1478 /*PA HOT: WAIT FOR TIMEOUT*/\
shreeshas95 4:104dd82c99b8 1479 gCOM_PA_COOLING_TIMEOUT.attach(&after_cooling_pa, COM_PA_COOLING_TIME_LIMIT);\
ee12b079 210:f4acf895b598 1480 /*COM_TX_CNTRL = 0;*/\
shreeshas95 4:104dd82c99b8 1481 RX1M.attach(&rx_read, Serial::RxIrq);\
shreeshas95 4:104dd82c99b8 1482 gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\
shreeshas95 2:2caf2a9a13aa 1483 break;\
shreeshas95 2:2caf2a9a13aa 1484 }\
ee12b079 210:f4acf895b598 1485 if (DEBUG)\
ee12b079 210:f4acf895b598 1486 gPC.printf("successflly executed %u tc\r\n", execute_psc);\
shreeshas95 0:f016e9e8d48b 1487 }\
shreeshas95 6:79d422d1ed42 1488 if( (gMASTER_STATE == TCL_STATE_COMPLETED) || (gFLAGS & COM_SESSION_TIMEOUT_FLAG) ){\
ee12b079 210:f4acf895b598 1489 if (DEBUG)\
ee12b079 210:f4acf895b598 1490 gPC.printf("completed or session timed out: %x\r\n", gMASTER_STATE);\
shreeshas95 5:ab276a17ca07 1491 /*COMPLETED EXECUTION OF TC*/\
shreeshas95 5:ab276a17ca07 1492 gMASTER_STATE = TCL_STATE_COMPLETED;\
ee12b079 258:bb889bc2e9f5 1493 COM_POWER_OFF_TX;\
shreeshas95 5:ab276a17ca07 1494 reset_all;\
shreeshas95 5:ab276a17ca07 1495 /*PENDING : ENABLE THREADS*/\
ee12b079 245:da9d1bd999da 1496 gPAY_SPI->bulkRead_resume(&payload_isr_fun);\
ee12b079 246:565458eefd94 1497 HK_counter->start(10000);\
shreeshas95 5:ab276a17ca07 1498 gSESSION_TIMEOUT.detach();\
shreeshas95 5:ab276a17ca07 1499 gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\
shreeshas95 5:ab276a17ca07 1500 gFLAGS = gFLAGS & (~COM_SESSION_FLAG);\
shreeshas95 5:ab276a17ca07 1501 }\
shreeshas95 0:f016e9e8d48b 1502 }