CDMS code for testing sbc

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE by shubham c

Committer:
ee12b079
Date:
Fri Jan 15 10:01:45 2016 +0000
Revision:
59:29a37f943ba6
Parent:
57:bf998cb2a104
Child:
61:15a5dfe84945
Printing OBOSC TM, testing left, use revision 56 for other testings

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