lkdsnf;

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of COM_MNG_TMTC_SIMPLE_PL_Working by Siva ram

Committer:
shreeshas95
Date:
Mon Dec 14 12:04:01 2015 +0000
Revision:
1:a0055b3280c8
Parent:
0:f016e9e8d48b
Child:
2:2caf2a9a13aa
Simple working version code

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
shreeshas95 0:f016e9e8d48b 9 #define delete_TC(tc_ptr) {\
shreeshas95 0:f016e9e8d48b 10 if(tc_ptr == gHEAD_NODE_TCL){\
shreeshas95 0:f016e9e8d48b 11 gHEAD_NODE_TCL = tc_ptr->next_TC;\
shreeshas95 0:f016e9e8d48b 12 }\
shreeshas95 0:f016e9e8d48b 13 delete tc_ptr;\
shreeshas95 0:f016e9e8d48b 14 }
shreeshas95 0:f016e9e8d48b 15
shreeshas95 0:f016e9e8d48b 16 // typeof tm_ptr: Base_tm
shreeshas95 0:f016e9e8d48b 17 // typeof tc_ptr: Base_tc
shreeshas95 0:f016e9e8d48b 18 // typeof temp_xxxx: uint8_t
shreeshas95 0:f016e9e8d48b 19 #define fill_l1_ack(tm_ptr) {\
shreeshas95 0:f016e9e8d48b 20 uint8_t temp8;\
shreeshas95 0:f016e9e8d48b 21 tm_ptr->next_TM = NULL;\
shreeshas95 0:f016e9e8d48b 22 temp8 = 0xA;\
shreeshas95 0:f016e9e8d48b 23 PUTtmid(tm_ptr->fields, temp8);\
shreeshas95 0:f016e9e8d48b 24 temp8 = 0x00;\
shreeshas95 0:f016e9e8d48b 25 PUTshort_or_long_tm(tm_ptr->fields, temp8);\
shreeshas95 0:f016e9e8d48b 26 tm_ptr->TM_string[0] = TMID_ACK_L1 << 4;\
shreeshas95 0:f016e9e8d48b 27 tm_ptr->TM_string[1] = gTOTAL_INCORRECT_SIZE_TC & 0xFF;\
shreeshas95 0:f016e9e8d48b 28 tm_ptr->TM_string[2] = gTOTAL_CRC_FAIL_TC & 0xFF;\
shreeshas95 0:f016e9e8d48b 29 tm_ptr->TM_string[3] = (gMASTER_STATE << 4) & 0xF0;\
shreeshas95 0:f016e9e8d48b 30 }
shreeshas95 0:f016e9e8d48b 31
shreeshas95 0:f016e9e8d48b 32 #define put_crc_l1_ack(tm_ptr, num_crc) {\
shreeshas95 0:f016e9e8d48b 33 tm_ptr->TM_string[2] = num_crc & 0xFF;\
shreeshas95 0:f016e9e8d48b 34 crc_checksum = crc16_gen(tm_ptr->TM_string, TM_SHORT_SIZE-2);\
shreeshas95 0:f016e9e8d48b 35 tm_ptr->TM_string[TM_SHORT_SIZE-2] = (crc_checksum >> 8) & 0xFF;\
shreeshas95 0:f016e9e8d48b 36 tm_ptr->TM_string[TM_SHORT_SIZE-1] = crc_checksum & 0xFF;\
shreeshas95 0:f016e9e8d48b 37 }
shreeshas95 0:f016e9e8d48b 38
shreeshas95 0:f016e9e8d48b 39 #define detect_ack(tm_ptr, temp_ack) {\
shreeshas95 0:f016e9e8d48b 40 uint8_t temp8;\
shreeshas95 0:f016e9e8d48b 41 if( tm_ptr != NULL ){\
shreeshas95 0:f016e9e8d48b 42 temp8 = tm_ptr->TM_string[3];\
shreeshas95 0:f016e9e8d48b 43 if((temp8 == 0xE0) || (temp8 == 0xA0) || (temp8 == 0xC0))\
shreeshas95 0:f016e9e8d48b 44 temp_ack = 0x01;\
shreeshas95 0:f016e9e8d48b 45 else\
shreeshas95 0:f016e9e8d48b 46 temp_ack = 0x00;\
shreeshas95 0:f016e9e8d48b 47 }\
shreeshas95 0:f016e9e8d48b 48 else\
shreeshas95 0:f016e9e8d48b 49 temp_ack = 0x00;\
shreeshas95 0:f016e9e8d48b 50 }
shreeshas95 0:f016e9e8d48b 51
shreeshas95 0:f016e9e8d48b 52 #define isit_obosc(tc_ptr, temp_obosc) {\
shreeshas95 0:f016e9e8d48b 53 temp_obosc = 0x00;\
shreeshas95 0:f016e9e8d48b 54 if( GETapid(tc_ptr) == 2 ){\
shreeshas95 0:f016e9e8d48b 55 if( ((tc_ptr->TC_string[2]) >> 4) == 0xB ){\
shreeshas95 0:f016e9e8d48b 56 switch( (tc_ptr->TC_string[2]) & 0xf ){\
shreeshas95 0:f016e9e8d48b 57 case 1:\
shreeshas95 0:f016e9e8d48b 58 case 2:\
shreeshas95 0:f016e9e8d48b 59 case 5:\
shreeshas95 0:f016e9e8d48b 60 case 6:\
shreeshas95 0:f016e9e8d48b 61 case 15:\
shreeshas95 0:f016e9e8d48b 62 temp_obosc = 0x01;\
shreeshas95 0:f016e9e8d48b 63 }\
shreeshas95 0:f016e9e8d48b 64 }\
shreeshas95 0:f016e9e8d48b 65 }\
shreeshas95 0:f016e9e8d48b 66 }
shreeshas95 0:f016e9e8d48b 67
shreeshas95 0:f016e9e8d48b 68 #define isit_sdcard(tc_ptr, temp_sdcard) {\
shreeshas95 0:f016e9e8d48b 69 temp_sdcard = 0x00;\
shreeshas95 0:f016e9e8d48b 70 if( GETapid(tc_ptr) == 2 ){\
shreeshas95 0:f016e9e8d48b 71 if( ( (tc_ptr->TC_string[2]) >> 4) == 0xF ){\
shreeshas95 0:f016e9e8d48b 72 switch( (tc_ptr->TC_string[2]) & 0xf ){\
shreeshas95 0:f016e9e8d48b 73 case 0:\
shreeshas95 0:f016e9e8d48b 74 case 1:\
shreeshas95 0:f016e9e8d48b 75 case 2:\
shreeshas95 0:f016e9e8d48b 76 case 3:\
shreeshas95 0:f016e9e8d48b 77 case 4:\
shreeshas95 0:f016e9e8d48b 78 temp_sdcard = 0x01;\
shreeshas95 0:f016e9e8d48b 79 }\
shreeshas95 0:f016e9e8d48b 80 }\
shreeshas95 0:f016e9e8d48b 81 }\
shreeshas95 0:f016e9e8d48b 82 }
shreeshas95 0:f016e9e8d48b 83
shreeshas95 0:f016e9e8d48b 84 /*
shreeshas95 0:f016e9e8d48b 85 @brief: check for missing tc, also check crc, i.e.
shreeshas95 0:f016e9e8d48b 86 if true execution can be started else have to wait
shreeshas95 0:f016e9e8d48b 87 decide the next state
shreeshas95 0:f016e9e8d48b 88 @param: none
shreeshas95 0:f016e9e8d48b 89 @return: bool indicating whether there are missing tc
shreeshas95 0:f016e9e8d48b 90 */
shreeshas95 0:f016e9e8d48b 91 // PENDING: LAST FRAME BIT
shreeshas95 0:f016e9e8d48b 92 /*
shreeshas95 0:f016e9e8d48b 93 for loop: check for missing tc
shreeshas95 0:f016e9e8d48b 94 if: check for incorrect sized tc
shreeshas95 0:f016e9e8d48b 95 if: check for last frame bit
shreeshas95 0:f016e9e8d48b 96 */
shreeshas95 0:f016e9e8d48b 97 #define continueToExecute(returnHere) {\
shreeshas95 0:f016e9e8d48b 98 uint8_t tempReturn = 0x00;\
shreeshas95 0:f016e9e8d48b 99 for(uint8_t p = PSC_START_VALUE ; p < (gTOTAL_VALID_TC + PSC_START_VALUE) ; ++p){\
shreeshas95 0:f016e9e8d48b 100 bool flag = false;\
shreeshas95 0:f016e9e8d48b 101 Base_tc *node_ptr = gHEAD_NODE_TCL;\
shreeshas95 0:f016e9e8d48b 102 while(node_ptr != NULL){\
shreeshas95 0:f016e9e8d48b 103 if( (GETpacket_seq_count(node_ptr) == p) && (GETcrc_pass(node_ptr) == 1) ){\
shreeshas95 0:f016e9e8d48b 104 flag = true;\
shreeshas95 0:f016e9e8d48b 105 break;\
shreeshas95 0:f016e9e8d48b 106 }\
shreeshas95 0:f016e9e8d48b 107 else{\
shreeshas95 0:f016e9e8d48b 108 node_ptr = node_ptr->next_TC;\
shreeshas95 0:f016e9e8d48b 109 }\
shreeshas95 0:f016e9e8d48b 110 }\
shreeshas95 0:f016e9e8d48b 111 if(flag == false){\
shreeshas95 0:f016e9e8d48b 112 tempReturn = 0x02;\
shreeshas95 0:f016e9e8d48b 113 break;\
shreeshas95 0:f016e9e8d48b 114 }\
shreeshas95 0:f016e9e8d48b 115 }\
shreeshas95 0:f016e9e8d48b 116 Base_tc *tcp = gHEAD_NODE_TCL;\
shreeshas95 0:f016e9e8d48b 117 while(tcp != NULL){\
shreeshas95 0:f016e9e8d48b 118 if(GETpacket_seq_count(tcp) == (gTOTAL_VALID_TC + PSC_START_VALUE - 1)){\
shreeshas95 0:f016e9e8d48b 119 if( ( (tcp->TC_string[1]) & 0x20 ) == 0x00 ){\
shreeshas95 0:f016e9e8d48b 120 tempReturn = tempReturn + 0x01;\
shreeshas95 0:f016e9e8d48b 121 }\
shreeshas95 0:f016e9e8d48b 122 break;\
shreeshas95 0:f016e9e8d48b 123 }\
shreeshas95 0:f016e9e8d48b 124 tcp = tcp->next_TC;\
shreeshas95 0:f016e9e8d48b 125 }\
shreeshas95 0:f016e9e8d48b 126 returnHere = tempReturn;\
shreeshas95 0:f016e9e8d48b 127 }
shreeshas95 0:f016e9e8d48b 128
shreeshas95 0:f016e9e8d48b 129 /*
shreeshas95 0:f016e9e8d48b 130 @brief: DELETE THE CRC FAILED TC FROM THE LIST TO FREE-UP MEMORY AND UPDATE
shreeshas95 0:f016e9e8d48b 131 THE TOTAL VALID TC AND GENERATE L1_ACK_TM
shreeshas95 0:f016e9e8d48b 132 @param: none
shreeshas95 0:f016e9e8d48b 133 @return: none
shreeshas95 0:f016e9e8d48b 134 */
shreeshas95 0:f016e9e8d48b 135 #define send_l1_ack {\
shreeshas95 0:f016e9e8d48b 136 Base_tc *current_TC = gHEAD_NODE_TCL;\
shreeshas95 0:f016e9e8d48b 137 Base_tm *l1_ack = new Short_tm;\
shreeshas95 0:f016e9e8d48b 138 Base_tm *l1_ack_head = l1_ack;\
shreeshas95 0:f016e9e8d48b 139 fill_l1_ack(l1_ack);\
shreeshas95 0:f016e9e8d48b 140 int TC_count = 0;\
shreeshas95 0:f016e9e8d48b 141 uint16_t crc_checksum = 0;\
shreeshas95 0:f016e9e8d48b 142 while(current_TC != NULL){\
shreeshas95 0:f016e9e8d48b 143 /*IF CRC PASS*/\
shreeshas95 0:f016e9e8d48b 144 if( (GETcrc_pass(current_TC) == 1) ){\
shreeshas95 0:f016e9e8d48b 145 if(TC_count > 4){\
shreeshas95 0:f016e9e8d48b 146 /*extend the TM linked list*/\
shreeshas95 0:f016e9e8d48b 147 TC_count = 0;\
shreeshas95 0:f016e9e8d48b 148 l1_ack->next_TM = new Short_tm;\
shreeshas95 0:f016e9e8d48b 149 l1_ack = l1_ack->next_TM;\
shreeshas95 0:f016e9e8d48b 150 fill_l1_ack(l1_ack);\
shreeshas95 0:f016e9e8d48b 151 /*PENDING: FILL TC_EXEC_CODE, APPEND CRC TO THE TM*/\
shreeshas95 0:f016e9e8d48b 152 put_crc_l1_ack( l1_ack, gTOTAL_CRC_FAIL_TC );\
shreeshas95 0:f016e9e8d48b 153 }\
shreeshas95 0:f016e9e8d48b 154 /*PSC starts from 7th byte*/\
shreeshas95 0:f016e9e8d48b 155 l1_ack->TM_string[6+TC_count] = current_TC->TC_string[0];\
shreeshas95 0:f016e9e8d48b 156 /*TC exec status*/\
shreeshas95 0:f016e9e8d48b 157 switch(TC_count){\
shreeshas95 0:f016e9e8d48b 158 case 0:\
shreeshas95 0:f016e9e8d48b 159 l1_ack->TM_string[3] |= (GETexec_status(current_TC)) & 0x0F;\
shreeshas95 0:f016e9e8d48b 160 break;\
shreeshas95 0:f016e9e8d48b 161 case 1:\
shreeshas95 0:f016e9e8d48b 162 l1_ack->TM_string[4] = (GETexec_status(current_TC) << 4) & 0xF0;\
shreeshas95 0:f016e9e8d48b 163 break;\
shreeshas95 0:f016e9e8d48b 164 case 2:\
shreeshas95 0:f016e9e8d48b 165 l1_ack->TM_string[4] |= (GETexec_status(current_TC)) & 0x0F;\
shreeshas95 0:f016e9e8d48b 166 break;\
shreeshas95 0:f016e9e8d48b 167 case 3:\
shreeshas95 0:f016e9e8d48b 168 l1_ack->TM_string[5] = (GETexec_status(current_TC) << 4) & 0xF0;\
shreeshas95 0:f016e9e8d48b 169 break;\
shreeshas95 0:f016e9e8d48b 170 case 4:\
shreeshas95 0:f016e9e8d48b 171 l1_ack->TM_string[5] |= (GETexec_status(current_TC)) & 0x0F;\
shreeshas95 0:f016e9e8d48b 172 }\
shreeshas95 0:f016e9e8d48b 173 ++TC_count;\
shreeshas95 0:f016e9e8d48b 174 }\
shreeshas95 0:f016e9e8d48b 175 current_TC = current_TC->next_TC;\
shreeshas95 0:f016e9e8d48b 176 }\
shreeshas95 0:f016e9e8d48b 177 /*FILL UP THE REMAINING FIELDS WITH 0x01: 0x00 => problem with GS*/\
shreeshas95 0:f016e9e8d48b 178 if(TC_count < 5){\
shreeshas95 0:f016e9e8d48b 179 while(TC_count < 5){\
shreeshas95 0:f016e9e8d48b 180 l1_ack->TM_string[6+TC_count] = current_TC->TC_string[0];\
shreeshas95 0:f016e9e8d48b 181 switch(TC_count){\
shreeshas95 0:f016e9e8d48b 182 case 0:\
shreeshas95 0:f016e9e8d48b 183 l1_ack->TM_string[3] |= (GETexec_status(current_TC)) & 0x0F;\
shreeshas95 0:f016e9e8d48b 184 break;\
shreeshas95 0:f016e9e8d48b 185 case 1:\
shreeshas95 0:f016e9e8d48b 186 l1_ack->TM_string[4] = (GETexec_status(current_TC) << 4) & 0xF0;\
shreeshas95 0:f016e9e8d48b 187 break;\
shreeshas95 0:f016e9e8d48b 188 case 2:\
shreeshas95 0:f016e9e8d48b 189 l1_ack->TM_string[4] |= (GETexec_status(current_TC)) & 0x0F;\
shreeshas95 0:f016e9e8d48b 190 break;\
shreeshas95 0:f016e9e8d48b 191 case 3:\
shreeshas95 0:f016e9e8d48b 192 l1_ack->TM_string[5] = (GETexec_status(current_TC) << 4) & 0xF0;\
shreeshas95 0:f016e9e8d48b 193 break;\
shreeshas95 0:f016e9e8d48b 194 case 4:\
shreeshas95 0:f016e9e8d48b 195 l1_ack->TM_string[5] |= (GETexec_status(current_TC)) & 0x0F;\
shreeshas95 0:f016e9e8d48b 196 }\
shreeshas95 0:f016e9e8d48b 197 ++TC_count;\
shreeshas95 0:f016e9e8d48b 198 }\
shreeshas95 0:f016e9e8d48b 199 put_crc_l1_ack(l1_ack, gTOTAL_CRC_FAIL_TC);\
shreeshas95 0:f016e9e8d48b 200 }\
shreeshas95 1:a0055b3280c8 201 gPC.puts("Sending l1 ack\r\n");\
shreeshas95 1:a0055b3280c8 202 snd_tm.head_pointer(l1_ack_head);\
shreeshas95 1:a0055b3280c8 203 adf_not_SDcard();\
shreeshas95 0:f016e9e8d48b 204 /*delete the TM*/\
shreeshas95 0:f016e9e8d48b 205 l1_ack = l1_ack_head;\
shreeshas95 0:f016e9e8d48b 206 while(l1_ack != NULL){\
shreeshas95 0:f016e9e8d48b 207 Base_tm *temp = l1_ack->next_TM;\
shreeshas95 0:f016e9e8d48b 208 delete l1_ack;\
shreeshas95 0:f016e9e8d48b 209 l1_ack = temp;\
shreeshas95 0:f016e9e8d48b 210 }\
shreeshas95 0:f016e9e8d48b 211 }
shreeshas95 0:f016e9e8d48b 212
shreeshas95 0:f016e9e8d48b 213 // CDMS TEAM CODE START
shreeshas95 0:f016e9e8d48b 214 #define CDMS_RLY_TMTC(tc_ptr, tm_ptr){\
shreeshas95 0:f016e9e8d48b 215 tm_ptr = NULL;\
shreeshas95 0:f016e9e8d48b 216 }\
shreeshas95 0:f016e9e8d48b 217 // CDMS TEAM CODE END
shreeshas95 0:f016e9e8d48b 218
shreeshas95 0:f016e9e8d48b 219 // EXECUTE OBOSC
shreeshas95 0:f016e9e8d48b 220 #define execute_obosc_core(tc_ptr, tm_ptr) {\
shreeshas95 0:f016e9e8d48b 221 uint8_t service_subtype = (tc_ptr->TC_string[2]) & 0x0F;\
shreeshas95 0:f016e9e8d48b 222 /*including both lower and upper limits*/\
shreeshas95 0:f016e9e8d48b 223 uint8_t targetL = tc_ptr->TC_string[3];\
shreeshas95 0:f016e9e8d48b 224 uint8_t targetU = targetL + tc_ptr->TC_string[4] - 1;\
shreeshas95 0:f016e9e8d48b 225 if( (targetL == 0x00) && (tc_ptr->TC_string[4] == 0) ){\
shreeshas95 0:f016e9e8d48b 226 /*PENDING: ALL REPORTS BELOW*/\
shreeshas95 0:f016e9e8d48b 227 switch(service_subtype){\
shreeshas95 0:f016e9e8d48b 228 case OBOSC_SUB_REP_TCL_D:\
shreeshas95 0:f016e9e8d48b 229 break;\
shreeshas95 0:f016e9e8d48b 230 case OBOSC_SUB_REP_LE:\
shreeshas95 0:f016e9e8d48b 231 break;\
shreeshas95 0:f016e9e8d48b 232 case OBOSC_SUB_RESET:\
shreeshas95 0:f016e9e8d48b 233 break;\
shreeshas95 0:f016e9e8d48b 234 case OBOSC_SUB_REP_TCL:\
shreeshas95 0:f016e9e8d48b 235 break;\
shreeshas95 0:f016e9e8d48b 236 }\
shreeshas95 0:f016e9e8d48b 237 }\
shreeshas95 0:f016e9e8d48b 238 else{\
shreeshas95 0:f016e9e8d48b 239 uint16_t temp16 = 2;\
shreeshas95 0:f016e9e8d48b 240 switch( service_subtype ){\
shreeshas95 0:f016e9e8d48b 241 case OBOSC_SUB_DISABLE:\
shreeshas95 0:f016e9e8d48b 242 temp16 = 2;\
shreeshas95 0:f016e9e8d48b 243 break;\
shreeshas95 0:f016e9e8d48b 244 case OBOSC_SUB_RETRY:\
shreeshas95 0:f016e9e8d48b 245 temp16 = 3;\
shreeshas95 0:f016e9e8d48b 246 break;\
shreeshas95 0:f016e9e8d48b 247 }\
shreeshas95 0:f016e9e8d48b 248 Base_tc *tcp = gHEAD_NODE_TCL;\
shreeshas95 0:f016e9e8d48b 249 while( tcp != NULL ){\
shreeshas95 0:f016e9e8d48b 250 uint16_t tcPSC = GETpacket_seq_count(tcp);\
shreeshas95 0:f016e9e8d48b 251 if( (tcPSC >= targetL) && (tcPSC <= targetU) ){\
shreeshas95 0:f016e9e8d48b 252 PUTexec_status(tcp, temp16);\
shreeshas95 0:f016e9e8d48b 253 }\
shreeshas95 0:f016e9e8d48b 254 tcp = tcp->next_TC;\
shreeshas95 0:f016e9e8d48b 255 }\
shreeshas95 0:f016e9e8d48b 256 }\
shreeshas95 0:f016e9e8d48b 257 /*PENDING: generate L234 ACK*/\
shreeshas95 0:f016e9e8d48b 258 tm_ptr = NULL;\
shreeshas95 0:f016e9e8d48b 259 }
shreeshas95 0:f016e9e8d48b 260
shreeshas95 0:f016e9e8d48b 261 #define EXECUTE_OBOSC_ONLY {\
shreeshas95 0:f016e9e8d48b 262 for(uint8_t execute_psc = gOBOSC_PSC ; execute_psc < (gTOTAL_VALID_TC+PSC_START_VALUE) ; ++execute_psc){\
shreeshas95 0:f016e9e8d48b 263 Base_tc* current_TC = gOBOSC_HEAD;\
shreeshas95 0:f016e9e8d48b 264 while( current_TC != NULL ){\
shreeshas95 0:f016e9e8d48b 265 if( (GETcrc_pass(current_TC) == 1) && (GETpacket_seq_count(current_TC) == execute_psc) ){\
shreeshas95 0:f016e9e8d48b 266 uint8_t current_exec_status = GETexec_status(current_TC);\
shreeshas95 0:f016e9e8d48b 267 if( (current_exec_status == TC_STATE_SUCCESSFULLY_EXECUTED) || (current_exec_status == TC_STATE_DISABLED) )\
shreeshas95 0:f016e9e8d48b 268 break;\
shreeshas95 0:f016e9e8d48b 269 else if( (current_exec_status == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\
shreeshas95 0:f016e9e8d48b 270 gMASTER_STATE = TCL_STATE_ABORTED;\
shreeshas95 0:f016e9e8d48b 271 break;\
shreeshas95 0:f016e9e8d48b 272 }\
shreeshas95 0:f016e9e8d48b 273 else if( (current_exec_status == TC_STATE_UNEXECUTED) || (current_exec_status == TC_STATE_MARKED_RETRY) ){\
shreeshas95 0:f016e9e8d48b 274 Base_tm* tm_ptr = NULL;\
shreeshas95 0:f016e9e8d48b 275 uint8_t temp82 = 0x00;\
shreeshas95 0:f016e9e8d48b 276 isit_obosc(current_TC, temp82);\
shreeshas95 0:f016e9e8d48b 277 if(temp82 == 0x01){\
shreeshas95 0:f016e9e8d48b 278 /*EXECUTION OF OBOSC TC*/\
shreeshas95 0:f016e9e8d48b 279 execute_obosc_core(current_TC, tm_ptr);\
shreeshas95 0:f016e9e8d48b 280 }\
shreeshas95 1:a0055b3280c8 281 snd_tm.head_pointer(tm_ptr);\
shreeshas95 1:a0055b3280c8 282 adf_not_SDcard();\
shreeshas95 0:f016e9e8d48b 283 uint8_t temp83 = 0x00;\
shreeshas95 0:f016e9e8d48b 284 detect_ack(tm_ptr, temp83);\
shreeshas95 0:f016e9e8d48b 285 if( temp83 == 0x01){\
shreeshas95 0:f016e9e8d48b 286 uint16_t temp16 = TC_STATE_SUCCESSFULLY_EXECUTED;\
shreeshas95 0:f016e9e8d48b 287 PUTexec_status(current_TC, temp16);\
shreeshas95 0:f016e9e8d48b 288 }\
shreeshas95 0:f016e9e8d48b 289 else{\
shreeshas95 0:f016e9e8d48b 290 uint16_t temp16 = TC_STATE_EXECUTION_FAILED;\
shreeshas95 0:f016e9e8d48b 291 PUTexec_status(current_TC, temp16);\
shreeshas95 0:f016e9e8d48b 292 }\
shreeshas95 0:f016e9e8d48b 293 /*update last executed L1_ack*/\
shreeshas95 0:f016e9e8d48b 294 if( tm_ptr != NULL ){\
shreeshas95 0:f016e9e8d48b 295 for(int i = 0 ; i < TM_SHORT_SIZE ; ++i){\
shreeshas95 0:f016e9e8d48b 296 gLAST_L1_ACK[i] = gLAST_L1_ACK_BUFFER[i];\
shreeshas95 0:f016e9e8d48b 297 gLAST_L1_ACK_BUFFER[i] = tm_ptr->TM_string[i];\
shreeshas95 0:f016e9e8d48b 298 }\
shreeshas95 0:f016e9e8d48b 299 }\
shreeshas95 0:f016e9e8d48b 300 /*DELETE THE TM AFTER USE*/\
shreeshas95 0:f016e9e8d48b 301 while(tm_ptr != NULL){\
shreeshas95 0:f016e9e8d48b 302 Base_tm *temp = tm_ptr->next_TM;\
shreeshas95 0:f016e9e8d48b 303 delete tm_ptr;\
shreeshas95 0:f016e9e8d48b 304 tm_ptr = temp;\
shreeshas95 0:f016e9e8d48b 305 }\
shreeshas95 0:f016e9e8d48b 306 }\
shreeshas95 0:f016e9e8d48b 307 }\
shreeshas95 0:f016e9e8d48b 308 current_TC = current_TC->next_TC;\
shreeshas95 0:f016e9e8d48b 309 }\
shreeshas95 0:f016e9e8d48b 310 }\
shreeshas95 0:f016e9e8d48b 311 }
shreeshas95 0:f016e9e8d48b 312
shreeshas95 0:f016e9e8d48b 313 #define EXECUTE_TC {\
shreeshas95 0:f016e9e8d48b 314 for(uint8_t execute_psc = PSC_START_VALUE ; execute_psc < (PSC_START_VALUE+gTOTAL_VALID_TC) ; ++execute_psc ){\
shreeshas95 0:f016e9e8d48b 315 gLEDG = !gLEDG;\
shreeshas95 0:f016e9e8d48b 316 gLEDR = !gLEDR;\
shreeshas95 0:f016e9e8d48b 317 Base_tc* current_TC = gHEAD_NODE_TCL;\
shreeshas95 0:f016e9e8d48b 318 while(current_TC != NULL){\
shreeshas95 0:f016e9e8d48b 319 if( (GETcrc_pass(current_TC) == 1) && (GETpacket_seq_count(current_TC) == execute_psc) ){\
shreeshas95 0:f016e9e8d48b 320 uint8_t current_exec_status = GETexec_status(current_TC);\
shreeshas95 0:f016e9e8d48b 321 if( (current_exec_status == TC_STATE_SUCCESSFULLY_EXECUTED) || (current_exec_status == TC_STATE_DISABLED) )\
shreeshas95 0:f016e9e8d48b 322 break;\
shreeshas95 0:f016e9e8d48b 323 else if( (current_exec_status == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\
shreeshas95 0:f016e9e8d48b 324 gMASTER_STATE = TCL_STATE_ABORTED;\
shreeshas95 0:f016e9e8d48b 325 break;\
shreeshas95 0:f016e9e8d48b 326 }\
shreeshas95 0:f016e9e8d48b 327 else if( (current_exec_status == TC_STATE_UNEXECUTED) || (current_exec_status == TC_STATE_MARKED_RETRY) ){\
shreeshas95 0:f016e9e8d48b 328 /*EXECUTION OF TC START*/\
shreeshas95 0:f016e9e8d48b 329 uint8_t temp81 = 0x00;\
shreeshas95 0:f016e9e8d48b 330 isit_sdcard(current_TC, temp81);\
shreeshas95 0:f016e9e8d48b 331 if( temp81 == 0x00 ){\
shreeshas95 0:f016e9e8d48b 332 /*EXECUTION OF NON SD-CARD (BOTH OBOSC and CDMS functions)*/\
shreeshas95 0:f016e9e8d48b 333 Base_tm *tm_ptr;\
shreeshas95 0:f016e9e8d48b 334 uint8_t temp82 = 0x00;\
shreeshas95 0:f016e9e8d48b 335 isit_obosc(current_TC, temp82);\
shreeshas95 0:f016e9e8d48b 336 if(temp82 == 0x01){\
shreeshas95 0:f016e9e8d48b 337 /*EXECUTION OF OBOSC TC*/\
shreeshas95 0:f016e9e8d48b 338 execute_obosc_core(current_TC, tm_ptr);\
shreeshas95 0:f016e9e8d48b 339 }\
shreeshas95 0:f016e9e8d48b 340 else{\
shreeshas95 0:f016e9e8d48b 341 /*call CDMS_RLY_TMTC*/\
shreeshas95 0:f016e9e8d48b 342 CDMS_RLY_TMTC(current_TC, tm_ptr);\
shreeshas95 0:f016e9e8d48b 343 }\
shreeshas95 1:a0055b3280c8 344 snd_tm.head_pointer(tm_ptr);\
shreeshas95 0:f016e9e8d48b 345 /*adf_not_SDcard();*/\
shreeshas95 0:f016e9e8d48b 346 uint8_t temp83 = 0x00;\
shreeshas95 0:f016e9e8d48b 347 detect_ack(tm_ptr, temp83);\
shreeshas95 0:f016e9e8d48b 348 if( temp83 == 0x01){\
shreeshas95 0:f016e9e8d48b 349 uint16_t temp16 = TC_STATE_SUCCESSFULLY_EXECUTED;\
shreeshas95 0:f016e9e8d48b 350 PUTexec_status(current_TC, temp16);\
shreeshas95 0:f016e9e8d48b 351 }\
shreeshas95 0:f016e9e8d48b 352 else{\
shreeshas95 0:f016e9e8d48b 353 uint16_t temp16 = TC_STATE_EXECUTION_FAILED;\
shreeshas95 0:f016e9e8d48b 354 PUTexec_status(current_TC, temp16);\
shreeshas95 0:f016e9e8d48b 355 }\
shreeshas95 0:f016e9e8d48b 356 /*update last executed L1_ack*/\
shreeshas95 0:f016e9e8d48b 357 if( tm_ptr != NULL ){\
shreeshas95 0:f016e9e8d48b 358 for(int i = 0 ; i < TM_SHORT_SIZE ; ++i){\
shreeshas95 0:f016e9e8d48b 359 gLAST_L1_ACK[i] = gLAST_L1_ACK_BUFFER[i];\
shreeshas95 0:f016e9e8d48b 360 gLAST_L1_ACK_BUFFER[i] = tm_ptr->TM_string[i];\
shreeshas95 0:f016e9e8d48b 361 }\
shreeshas95 0:f016e9e8d48b 362 }\
shreeshas95 0:f016e9e8d48b 363 /*DELETE THE TM AFTER USE*/\
shreeshas95 0:f016e9e8d48b 364 while(tm_ptr != NULL){\
shreeshas95 0:f016e9e8d48b 365 Base_tm *temp = tm_ptr->next_TM;\
shreeshas95 0:f016e9e8d48b 366 delete tm_ptr;\
shreeshas95 0:f016e9e8d48b 367 tm_ptr = temp;\
shreeshas95 0:f016e9e8d48b 368 }\
shreeshas95 0:f016e9e8d48b 369 }\
shreeshas95 0:f016e9e8d48b 370 else{\
shreeshas95 0:f016e9e8d48b 371 /*EXECUTION OF SD-CARD DATA SENDING (OBSRS)*/\
shreeshas95 1:a0055b3280c8 372 read_TC(current_TC);\
shreeshas95 0:f016e9e8d48b 373 }\
shreeshas95 0:f016e9e8d48b 374 /*ABORT ON NACK*/\
shreeshas95 0:f016e9e8d48b 375 if( (GETexec_status(current_TC) == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\
shreeshas95 0:f016e9e8d48b 376 gMASTER_STATE = TCL_STATE_ABORTED;\
shreeshas95 0:f016e9e8d48b 377 }\
shreeshas95 0:f016e9e8d48b 378 }\
shreeshas95 0:f016e9e8d48b 379 }\
shreeshas95 0:f016e9e8d48b 380 current_TC = current_TC->next_TC;\
shreeshas95 0:f016e9e8d48b 381 }\
shreeshas95 0:f016e9e8d48b 382 if( gMASTER_STATE == TCL_STATE_ABORTED )\
shreeshas95 0:f016e9e8d48b 383 break;\
shreeshas95 0:f016e9e8d48b 384 }\
shreeshas95 0:f016e9e8d48b 385 }