June 30

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE by shubham c

Committer:
chaithanyarss
Date:
Sat Jul 02 13:36:18 2016 +0000
Revision:
191:d14b1c783736
Parent:
190:28a07943dded
;

Who changed what in which revision?

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