CDMS code for testing sbc

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE by shubham c

Committer:
krishanprajapat
Date:
Tue Jan 19 10:30:46 2016 +0000
Revision:
71:9193fbdaa3e1
Parent:
58:5c59f28620bc
Modification of CDMS_sd.h required

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