Latest FM Code with EEPROM

Dependencies:   FreescaleIAP SimpleDMA eeprom mbed-rtos mbed

Fork of CDMS_QM_03MAR2017_Flash_with_obsrs by Team Fox

Committer:
chaithanyarss
Date:
Sun Jul 03 15:25:24 2016 +0000
Revision:
218:c63cdba0550f
Parent:
216:93505a6f8db7
Flash Completed;

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