publishing to check changes in cdms code

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE_samp_23SEP_DMA_flag by samp Srinivasan

Committer:
ee12b079
Date:
Tue Jan 19 05:56:28 2016 +0000
Revision:
76:adba77e6bdb5
Parent:
75:d03b5d6ef269
Child:
77:11318af9b144
testing3

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