Latest FM Code with EEPROM

Dependencies:   FreescaleIAP SimpleDMA eeprom mbed-rtos mbed

Fork of CDMS_QM_03MAR2017_Flash_with_obsrs by Team Fox

Committer:
Shashank7906
Date:
Sat Jan 09 10:40:09 2016 +0000
Revision:
42:b7a4aac53314
Parent:
41:7e06018f6a1c
Child:
43:4bc440bbad2f
Removed unwanted braces

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