lkdsnf;
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of COM_MNG_TMTC_SIMPLE_PL_Working by
COM_MNG_TMTC.h@17:6eb9387f1fb8, 2016-01-01 (annotated)
- Committer:
- shreeshas95
- Date:
- Fri Jan 01 06:36:18 2016 +0000
- Revision:
- 17:6eb9387f1fb8
- Parent:
- 16:538de1b20b3a
testing Rtos timer in adf interrupt
Who changed what in which revision?
User | Revision | Line number | New 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 | 4:104dd82c99b8 | 22 | temp8 = TMID_ACK_L1;\ |
shreeshas95 | 0:f016e9e8d48b | 23 | PUTtmid(tm_ptr->fields, temp8);\ |
shreeshas95 | 4:104dd82c99b8 | 24 | temp8 = SHORT_TM_CODE;\ |
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 | 4:104dd82c99b8 | 27 | /*PENDING: PA TEMPERATURE*/\ |
shreeshas95 | 0:f016e9e8d48b | 28 | tm_ptr->TM_string[1] = gTOTAL_INCORRECT_SIZE_TC & 0xFF;\ |
shreeshas95 | 0:f016e9e8d48b | 29 | tm_ptr->TM_string[2] = gTOTAL_CRC_FAIL_TC & 0xFF;\ |
shreeshas95 | 0:f016e9e8d48b | 30 | } |
shreeshas95 | 0:f016e9e8d48b | 31 | |
shreeshas95 | 4:104dd82c99b8 | 32 | #define put_crc_l1_ack(tm_ptr) {\ |
shreeshas95 | 4:104dd82c99b8 | 33 | tm_ptr->TM_string[2] = gTOTAL_CRC_FAIL_TC & 0xFF;\ |
shreeshas95 | 4:104dd82c99b8 | 34 | /*TC LIST STATUS*/\ |
shreeshas95 | 4:104dd82c99b8 | 35 | tm_ptr->TM_string[3] |= (gMASTER_STATE << 5) & 0xE0;\ |
shreeshas95 | 4:104dd82c99b8 | 36 | /*PA HOT*/\ |
shreeshas95 | 4:104dd82c99b8 | 37 | if( gFLAGS & COM_PA_HOT_FLAG ){\ |
shreeshas95 | 4:104dd82c99b8 | 38 | tm_ptr->TM_string[3] |= (1 << 4);\ |
shreeshas95 | 4:104dd82c99b8 | 39 | }\ |
shreeshas95 | 4:104dd82c99b8 | 40 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 41 | tm_ptr->TM_string[3] &= ~(1 << 4);\ |
shreeshas95 | 4:104dd82c99b8 | 42 | }\ |
shreeshas95 | 4:104dd82c99b8 | 43 | uint16_t crc_checksum = crc16_gen(tm_ptr->TM_string, TM_SHORT_SIZE-2);\ |
shreeshas95 | 0:f016e9e8d48b | 44 | tm_ptr->TM_string[TM_SHORT_SIZE-2] = (crc_checksum >> 8) & 0xFF;\ |
shreeshas95 | 0:f016e9e8d48b | 45 | tm_ptr->TM_string[TM_SHORT_SIZE-1] = crc_checksum & 0xFF;\ |
shreeshas95 | 0:f016e9e8d48b | 46 | } |
shreeshas95 | 0:f016e9e8d48b | 47 | |
shreeshas95 | 4:104dd82c99b8 | 48 | #define detect_ack(tm_ptr, temp_ack, tc_psc) {\ |
shreeshas95 | 5:ab276a17ca07 | 49 | if( tm_ptr != NULL ){\ |
aniruddhv | 14:08c2c887ea09 | 50 | int length = TM_SHORT_SIZE;\ |
aniruddhv | 14:08c2c887ea09 | 51 | if( GETshort_or_long_tm(tm_ptr->fields) == SHORT_TM_CODE ){\ |
aniruddhv | 14:08c2c887ea09 | 52 | length = TM_SHORT_SIZE;\ |
aniruddhv | 14:08c2c887ea09 | 53 | }\ |
aniruddhv | 14:08c2c887ea09 | 54 | else{\ |
aniruddhv | 14:08c2c887ea09 | 55 | length = TM_LONG_SIZE;\ |
aniruddhv | 14:08c2c887ea09 | 56 | }\ |
aniruddhv | 14:08c2c887ea09 | 57 | uint16_t crc = crc16_gen(tm_ptr->TM_string, length-2);\ |
shreeshas95 | 5:ab276a17ca07 | 58 | if( (((crc & 0xFF00) >> 8) == tm_ptr->TM_string[length-2]) && ( (crc & 0x00FF) == tm_ptr->TM_string[length-1] ) ){\ |
shreeshas95 | 4:104dd82c99b8 | 59 | uint8_t temp8;\ |
shreeshas95 | 4:104dd82c99b8 | 60 | temp8 = tm_ptr->TM_string[TM_ACK_CODE_INDEX];\ |
shreeshas95 | 4:104dd82c99b8 | 61 | temp8 = temp8 & 0xE0;\ |
shreeshas95 | 4:104dd82c99b8 | 62 | if( (temp8 == 0xC0) || (temp8 == 0xA0) )\ |
shreeshas95 | 4:104dd82c99b8 | 63 | temp_ack = 0x01;\ |
shreeshas95 | 4:104dd82c99b8 | 64 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 65 | temp_ack = 0x00;\ |
shreeshas95 | 4:104dd82c99b8 | 66 | /*CHECK FOR NACK CODE: CRC FAIL NACK*/\ |
shreeshas95 | 4:104dd82c99b8 | 67 | temp8 = tm_ptr->TM_string[TM_ACK_CODE_INDEX];\ |
shreeshas95 | 4:104dd82c99b8 | 68 | temp8 = temp8 & 0x0F;\ |
shreeshas95 | 5:ab276a17ca07 | 69 | if( temp8 == CRC_FAIL_NACK_CODE ){\ |
shreeshas95 | 4:104dd82c99b8 | 70 | tm_ptr->TM_string[2] = tc_psc;\ |
shreeshas95 | 4:104dd82c99b8 | 71 | }\ |
shreeshas95 | 4:104dd82c99b8 | 72 | }\ |
shreeshas95 | 4:104dd82c99b8 | 73 | }\ |
shreeshas95 | 0:f016e9e8d48b | 74 | else\ |
shreeshas95 | 0:f016e9e8d48b | 75 | temp_ack = 0x00;\ |
shreeshas95 | 0:f016e9e8d48b | 76 | }\ |
shreeshas95 | 4:104dd82c99b8 | 77 | else{\ |
shreeshas95 | 0:f016e9e8d48b | 78 | temp_ack = 0x00;\ |
shreeshas95 | 4:104dd82c99b8 | 79 | }\ |
shreeshas95 | 0:f016e9e8d48b | 80 | } |
shreeshas95 | 0:f016e9e8d48b | 81 | |
shreeshas95 | 0:f016e9e8d48b | 82 | #define isit_obosc(tc_ptr, temp_obosc) {\ |
shreeshas95 | 0:f016e9e8d48b | 83 | temp_obosc = 0x00;\ |
shreeshas95 | 17:6eb9387f1fb8 | 84 | if( GETapid(tc_ptr) == APID_COM ){\ |
shreeshas95 | 17:6eb9387f1fb8 | 85 | /*CHECK FOR SERVICE TYPE*/\ |
shreeshas95 | 17:6eb9387f1fb8 | 86 | if( ((tc_ptr->TC_string[2]) >> 4) == SERVICE_OBOSC ){\ |
shreeshas95 | 17:6eb9387f1fb8 | 87 | /*IRRESPECTIVE OF SERVICE SUBTYPE*/\ |
shreeshas95 | 17:6eb9387f1fb8 | 88 | temp_obosc = 0x01;\ |
shreeshas95 | 0:f016e9e8d48b | 89 | }\ |
shreeshas95 | 0:f016e9e8d48b | 90 | }\ |
shreeshas95 | 0:f016e9e8d48b | 91 | } |
shreeshas95 | 0:f016e9e8d48b | 92 | |
shreeshas95 | 0:f016e9e8d48b | 93 | #define isit_sdcard(tc_ptr, temp_sdcard) {\ |
shreeshas95 | 0:f016e9e8d48b | 94 | temp_sdcard = 0x00;\ |
shreeshas95 | 17:6eb9387f1fb8 | 95 | if( GETapid(tc_ptr) == APID_COM ){\ |
shreeshas95 | 17:6eb9387f1fb8 | 96 | if( ( (tc_ptr->TC_string[2]) >> 4) == SERVICE_OBSRS ){\ |
shreeshas95 | 17:6eb9387f1fb8 | 97 | /*IRRESPECTIVE OF SERVICE SUBTYPE*/\ |
shreeshas95 | 17:6eb9387f1fb8 | 98 | temp_sdcard = 0x01;\ |
shreeshas95 | 0:f016e9e8d48b | 99 | }\ |
shreeshas95 | 0:f016e9e8d48b | 100 | }\ |
shreeshas95 | 0:f016e9e8d48b | 101 | } |
shreeshas95 | 0:f016e9e8d48b | 102 | |
shreeshas95 | 2:2caf2a9a13aa | 103 | #define isPAhot(returnHere){\ |
shreeshas95 | 2:2caf2a9a13aa | 104 | /*PENDING : COMPLETE THIS FUNCTION*/\ |
shreeshas95 | 2:2caf2a9a13aa | 105 | returnHere = 0xFF;\ |
shreeshas95 | 2:2caf2a9a13aa | 106 | } |
shreeshas95 | 2:2caf2a9a13aa | 107 | |
shreeshas95 | 2:2caf2a9a13aa | 108 | void after_cooling_pa(){ |
shreeshas95 | 2:2caf2a9a13aa | 109 | gCOM_MNG_TMTC_THREAD->signal_set(COM_MNG_TMTC_SIGNAL_UART_INT); |
shreeshas95 | 2:2caf2a9a13aa | 110 | } |
shreeshas95 | 2:2caf2a9a13aa | 111 | |
shreeshas95 | 0:f016e9e8d48b | 112 | /* |
shreeshas95 | 0:f016e9e8d48b | 113 | @brief: check for missing tc, also check crc, i.e. |
shreeshas95 | 0:f016e9e8d48b | 114 | if true execution can be started else have to wait |
shreeshas95 | 0:f016e9e8d48b | 115 | decide the next state |
shreeshas95 | 0:f016e9e8d48b | 116 | @param: none |
shreeshas95 | 0:f016e9e8d48b | 117 | @return: bool indicating whether there are missing tc |
shreeshas95 | 0:f016e9e8d48b | 118 | */ |
shreeshas95 | 0:f016e9e8d48b | 119 | // PENDING: LAST FRAME BIT |
shreeshas95 | 0:f016e9e8d48b | 120 | /* |
shreeshas95 | 0:f016e9e8d48b | 121 | for loop: check for missing tc |
shreeshas95 | 0:f016e9e8d48b | 122 | if: check for incorrect sized tc |
shreeshas95 | 0:f016e9e8d48b | 123 | if: check for last frame bit |
shreeshas95 | 0:f016e9e8d48b | 124 | */ |
shreeshas95 | 0:f016e9e8d48b | 125 | #define continueToExecute(returnHere) {\ |
shreeshas95 | 0:f016e9e8d48b | 126 | uint8_t tempReturn = 0x00;\ |
shreeshas95 | 5:ab276a17ca07 | 127 | /*search for missing psc*/\ |
shreeshas95 | 15:1c1ca992b43b | 128 | for(uint8_t p = 0x00 ; p < (gTOTAL_VALID_TC) ; ++p){\ |
shreeshas95 | 0:f016e9e8d48b | 129 | bool flag = false;\ |
shreeshas95 | 0:f016e9e8d48b | 130 | Base_tc *node_ptr = gHEAD_NODE_TCL;\ |
shreeshas95 | 0:f016e9e8d48b | 131 | while(node_ptr != NULL){\ |
shreeshas95 | 0:f016e9e8d48b | 132 | if( (GETpacket_seq_count(node_ptr) == p) && (GETcrc_pass(node_ptr) == 1) ){\ |
shreeshas95 | 0:f016e9e8d48b | 133 | flag = true;\ |
shreeshas95 | 0:f016e9e8d48b | 134 | break;\ |
shreeshas95 | 0:f016e9e8d48b | 135 | }\ |
shreeshas95 | 0:f016e9e8d48b | 136 | else{\ |
shreeshas95 | 0:f016e9e8d48b | 137 | node_ptr = node_ptr->next_TC;\ |
shreeshas95 | 0:f016e9e8d48b | 138 | }\ |
shreeshas95 | 0:f016e9e8d48b | 139 | }\ |
shreeshas95 | 0:f016e9e8d48b | 140 | if(flag == false){\ |
shreeshas95 | 0:f016e9e8d48b | 141 | tempReturn = 0x02;\ |
shreeshas95 | 0:f016e9e8d48b | 142 | break;\ |
shreeshas95 | 0:f016e9e8d48b | 143 | }\ |
shreeshas95 | 0:f016e9e8d48b | 144 | }\ |
shreeshas95 | 5:ab276a17ca07 | 145 | /*search for last packet bit*/\ |
shreeshas95 | 5:ab276a17ca07 | 146 | tempReturn = tempReturn + 0x01;\ |
shreeshas95 | 0:f016e9e8d48b | 147 | Base_tc *tcp = gHEAD_NODE_TCL;\ |
shreeshas95 | 0:f016e9e8d48b | 148 | while(tcp != NULL){\ |
rohit3342 | 16:538de1b20b3a | 149 | if(GETpacket_seq_count(tcp) == (gTOTAL_VALID_TC - 1)){\ |
shreeshas95 | 5:ab276a17ca07 | 150 | if( ( (tcp->TC_string[1]) & 0x20 ) == 0x20 ){\ |
shreeshas95 | 5:ab276a17ca07 | 151 | tempReturn = tempReturn - 0x01;\ |
shreeshas95 | 0:f016e9e8d48b | 152 | }\ |
shreeshas95 | 0:f016e9e8d48b | 153 | break;\ |
shreeshas95 | 0:f016e9e8d48b | 154 | }\ |
shreeshas95 | 0:f016e9e8d48b | 155 | tcp = tcp->next_TC;\ |
shreeshas95 | 0:f016e9e8d48b | 156 | }\ |
shreeshas95 | 0:f016e9e8d48b | 157 | returnHere = tempReturn;\ |
shreeshas95 | 5:ab276a17ca07 | 158 | /*UPDATE gMASTER STATE*/\ |
shreeshas95 | 5:ab276a17ca07 | 159 | if( (returnHere == 0x00) ){\ |
shreeshas95 | 5:ab276a17ca07 | 160 | if( (gMASTER_STATE == TCL_STATE_INCOMPLETE) || (gMASTER_STATE == TCL_STATE_COMPLETED) ){\ |
shreeshas95 | 5:ab276a17ca07 | 161 | gMASTER_STATE = TCL_STATE_COMPLETED;\ |
shreeshas95 | 5:ab276a17ca07 | 162 | }\ |
shreeshas95 | 5:ab276a17ca07 | 163 | }\ |
shreeshas95 | 5:ab276a17ca07 | 164 | else{\ |
shreeshas95 | 5:ab276a17ca07 | 165 | if( (gMASTER_STATE == TCL_STATE_INCOMPLETE) || (gMASTER_STATE == TCL_STATE_COMPLETED) ){\ |
shreeshas95 | 5:ab276a17ca07 | 166 | gMASTER_STATE = TCL_STATE_INCOMPLETE;\ |
shreeshas95 | 5:ab276a17ca07 | 167 | }\ |
shreeshas95 | 5:ab276a17ca07 | 168 | }\ |
shreeshas95 | 0:f016e9e8d48b | 169 | } |
shreeshas95 | 0:f016e9e8d48b | 170 | |
shreeshas95 | 0:f016e9e8d48b | 171 | /* |
shreeshas95 | 2:2caf2a9a13aa | 172 | return 1 if code match |
shreeshas95 | 2:2caf2a9a13aa | 173 | return 0 if code mismatch |
shreeshas95 | 2:2caf2a9a13aa | 174 | */ |
shreeshas95 | 2:2caf2a9a13aa | 175 | #define GScodeVerification(returnHere){\ |
shreeshas95 | 2:2caf2a9a13aa | 176 | Base_tc *testTC = gHEAD_NODE_TCL;\ |
shreeshas95 | 2:2caf2a9a13aa | 177 | uint16_t overflowCount = 0;\ |
shreeshas95 | 15:1c1ca992b43b | 178 | returnHere = 0xFF;\ |
shreeshas95 | 2:2caf2a9a13aa | 179 | while( (overflowCount < TCL_OVERFLOW_CONSTANT) && (testTC != NULL) ){\ |
shreeshas95 | 17:6eb9387f1fb8 | 180 | if( (GETpacket_seq_count(testTC) == PSC_CALLSIGN) && (GETapid(testTC) == APID_COM) ){\ |
shreeshas95 | 2:2caf2a9a13aa | 181 | uint8_t temp8 = testTC->TC_string[1];\ |
shreeshas95 | 2:2caf2a9a13aa | 182 | if( temp8 & 0x04 ){\ |
shreeshas95 | 2:2caf2a9a13aa | 183 | for( int i = 2 ; i <= 8 ; ++i ){\ |
shreeshas95 | 2:2caf2a9a13aa | 184 | if( testTC->TC_string[i] != gGSCODE[i-2] ){\ |
shreeshas95 | 2:2caf2a9a13aa | 185 | returnHere = 0;\ |
shreeshas95 | 2:2caf2a9a13aa | 186 | break;\ |
shreeshas95 | 2:2caf2a9a13aa | 187 | }\ |
shreeshas95 | 2:2caf2a9a13aa | 188 | }\ |
shreeshas95 | 2:2caf2a9a13aa | 189 | }\ |
shreeshas95 | 2:2caf2a9a13aa | 190 | break;\ |
shreeshas95 | 2:2caf2a9a13aa | 191 | }\ |
shreeshas95 | 2:2caf2a9a13aa | 192 | testTC = testTC->next_TC;\ |
shreeshas95 | 2:2caf2a9a13aa | 193 | ++overflowCount;\ |
shreeshas95 | 2:2caf2a9a13aa | 194 | }\ |
shreeshas95 | 2:2caf2a9a13aa | 195 | } |
shreeshas95 | 2:2caf2a9a13aa | 196 | |
shreeshas95 | 2:2caf2a9a13aa | 197 | /* |
shreeshas95 | 0:f016e9e8d48b | 198 | @brief: DELETE THE CRC FAILED TC FROM THE LIST TO FREE-UP MEMORY AND UPDATE |
shreeshas95 | 0:f016e9e8d48b | 199 | THE TOTAL VALID TC AND GENERATE L1_ACK_TM |
shreeshas95 | 0:f016e9e8d48b | 200 | @param: none |
shreeshas95 | 0:f016e9e8d48b | 201 | @return: none |
shreeshas95 | 0:f016e9e8d48b | 202 | */ |
shreeshas95 | 4:104dd82c99b8 | 203 | /*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 | 204 | #define get_ack_l1( tm_ptr ){\ |
shreeshas95 | 0:f016e9e8d48b | 205 | Base_tc *current_TC = gHEAD_NODE_TCL;\ |
shreeshas95 | 0:f016e9e8d48b | 206 | Base_tm *l1_ack = new Short_tm;\ |
shreeshas95 | 4:104dd82c99b8 | 207 | /*APPEND TO THE tm_ptr HERE*/\ |
shreeshas95 | 4:104dd82c99b8 | 208 | tm_ptr = l1_ack;\ |
shreeshas95 | 0:f016e9e8d48b | 209 | fill_l1_ack(l1_ack);\ |
shreeshas95 | 0:f016e9e8d48b | 210 | int TC_count = 0;\ |
shreeshas95 | 4:104dd82c99b8 | 211 | int overflowCountL1 = 0;\ |
shreeshas95 | 0:f016e9e8d48b | 212 | while(current_TC != NULL){\ |
shreeshas95 | 4:104dd82c99b8 | 213 | if( overflowCountL1 < TCL_OVERFLOW_CONSTANT ){\ |
shreeshas95 | 4:104dd82c99b8 | 214 | /*IF CRC PASS*/\ |
shreeshas95 | 4:104dd82c99b8 | 215 | if( (GETcrc_pass(current_TC) == 1) ){\ |
shreeshas95 | 4:104dd82c99b8 | 216 | if(TC_count > 4){\ |
shreeshas95 | 5:ab276a17ca07 | 217 | /*PENDING: FILL TC_EXEC_CODE, APPEND CRC TO THE TM*/\ |
shreeshas95 | 5:ab276a17ca07 | 218 | put_crc_l1_ack( l1_ack );\ |
shreeshas95 | 4:104dd82c99b8 | 219 | /*extend the TM linked list*/\ |
shreeshas95 | 4:104dd82c99b8 | 220 | TC_count = 0;\ |
shreeshas95 | 4:104dd82c99b8 | 221 | l1_ack->next_TM = new Short_tm;\ |
shreeshas95 | 4:104dd82c99b8 | 222 | l1_ack = l1_ack->next_TM;\ |
shreeshas95 | 4:104dd82c99b8 | 223 | fill_l1_ack(l1_ack);\ |
shreeshas95 | 4:104dd82c99b8 | 224 | }\ |
shreeshas95 | 4:104dd82c99b8 | 225 | /*PSC starts from 7th byte*/\ |
shreeshas95 | 4:104dd82c99b8 | 226 | l1_ack->TM_string[6+TC_count] = GETpacket_seq_count(current_TC);\ |
shreeshas95 | 4:104dd82c99b8 | 227 | /*TC exec status*/\ |
shreeshas95 | 4:104dd82c99b8 | 228 | switch(TC_count){\ |
shreeshas95 | 4:104dd82c99b8 | 229 | case 0:\ |
shreeshas95 | 4:104dd82c99b8 | 230 | l1_ack->TM_string[3] = (GETexec_status(current_TC)) & 0x0F;\ |
shreeshas95 | 4:104dd82c99b8 | 231 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 232 | case 1:\ |
shreeshas95 | 4:104dd82c99b8 | 233 | l1_ack->TM_string[4] = (GETexec_status(current_TC) << 4) & 0xF0;\ |
shreeshas95 | 4:104dd82c99b8 | 234 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 235 | case 2:\ |
shreeshas95 | 4:104dd82c99b8 | 236 | l1_ack->TM_string[4] |= (GETexec_status(current_TC)) & 0x0F;\ |
shreeshas95 | 4:104dd82c99b8 | 237 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 238 | case 3:\ |
shreeshas95 | 4:104dd82c99b8 | 239 | l1_ack->TM_string[5] = (GETexec_status(current_TC) << 4) & 0xF0;\ |
shreeshas95 | 4:104dd82c99b8 | 240 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 241 | case 4:\ |
shreeshas95 | 4:104dd82c99b8 | 242 | l1_ack->TM_string[5] |= (GETexec_status(current_TC)) & 0x0F;\ |
shreeshas95 | 4:104dd82c99b8 | 243 | }\ |
shreeshas95 | 4:104dd82c99b8 | 244 | ++TC_count;\ |
shreeshas95 | 0:f016e9e8d48b | 245 | }\ |
shreeshas95 | 4:104dd82c99b8 | 246 | current_TC = current_TC->next_TC;\ |
shreeshas95 | 4:104dd82c99b8 | 247 | ++overflowCountL1;\ |
shreeshas95 | 4:104dd82c99b8 | 248 | }\ |
shreeshas95 | 4:104dd82c99b8 | 249 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 250 | /*PENDING: RESET CDMS*/\ |
shreeshas95 | 4:104dd82c99b8 | 251 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 252 | }\ |
shreeshas95 | 4:104dd82c99b8 | 253 | }\ |
shreeshas95 | 4:104dd82c99b8 | 254 | /*FILL UP THE REMAINING FIELDS WITH 0x00 as PSC, AND 0xF as tc exec status*/\ |
shreeshas95 | 4:104dd82c99b8 | 255 | if( (TC_count < 5) && (TC_count != 0) ){\ |
shreeshas95 | 4:104dd82c99b8 | 256 | while(TC_count < 5){\ |
shreeshas95 | 4:104dd82c99b8 | 257 | l1_ack->TM_string[6+TC_count] = 0x00;\ |
shreeshas95 | 0:f016e9e8d48b | 258 | switch(TC_count){\ |
shreeshas95 | 0:f016e9e8d48b | 259 | case 1:\ |
shreeshas95 | 4:104dd82c99b8 | 260 | l1_ack->TM_string[4] = 0xF0;\ |
shreeshas95 | 0:f016e9e8d48b | 261 | break;\ |
shreeshas95 | 0:f016e9e8d48b | 262 | case 2:\ |
shreeshas95 | 4:104dd82c99b8 | 263 | l1_ack->TM_string[4] |= 0x0F;\ |
shreeshas95 | 0:f016e9e8d48b | 264 | break;\ |
shreeshas95 | 0:f016e9e8d48b | 265 | case 3:\ |
shreeshas95 | 4:104dd82c99b8 | 266 | l1_ack->TM_string[5] = 0xF0;\ |
shreeshas95 | 0:f016e9e8d48b | 267 | break;\ |
shreeshas95 | 0:f016e9e8d48b | 268 | case 4:\ |
shreeshas95 | 4:104dd82c99b8 | 269 | l1_ack->TM_string[5] |= 0x0F;\ |
shreeshas95 | 0:f016e9e8d48b | 270 | }\ |
shreeshas95 | 0:f016e9e8d48b | 271 | ++TC_count;\ |
shreeshas95 | 0:f016e9e8d48b | 272 | }\ |
shreeshas95 | 0:f016e9e8d48b | 273 | }\ |
shreeshas95 | 5:ab276a17ca07 | 274 | put_crc_l1_ack(l1_ack);\ |
shreeshas95 | 4:104dd82c99b8 | 275 | } |
shreeshas95 | 4:104dd82c99b8 | 276 | |
shreeshas95 | 4:104dd82c99b8 | 277 | /*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 | 278 | #define get_tc_list(tm_ptr, thePSC){\ |
shreeshas95 | 5:ab276a17ca07 | 279 | uint8_t TM_PSC = 0xFF;\ |
shreeshas95 | 4:104dd82c99b8 | 280 | uint8_t TC_PSC = thePSC;\ |
shreeshas95 | 4:104dd82c99b8 | 281 | int overflowCount = 0;\ |
shreeshas95 | 4:104dd82c99b8 | 282 | uint8_t TC_LIST_TAG = 0x00;\ |
shreeshas95 | 4:104dd82c99b8 | 283 | Base_tc *temp_tc = gHEAD_NODE_TCL;\ |
shreeshas95 | 4:104dd82c99b8 | 284 | bool first_time = true;\ |
shreeshas95 | 5:ab276a17ca07 | 285 | Base_tm *current_tm = NULL;\ |
shreeshas95 | 4:104dd82c99b8 | 286 | while( temp_tc != NULL ){\ |
shreeshas95 | 4:104dd82c99b8 | 287 | if( overflowCount < TCL_OVERFLOW_CONSTANT ){\ |
shreeshas95 | 4:104dd82c99b8 | 288 | TM_PSC = TM_PSC + 1;\ |
shreeshas95 | 4:104dd82c99b8 | 289 | /*Increment TM_PSC for every new TM pointer created*/\ |
shreeshas95 | 4:104dd82c99b8 | 290 | Base_tm *temp_tm = new Long_tm;\ |
shreeshas95 | 4:104dd82c99b8 | 291 | temp_tm->next_TM = NULL;\ |
shreeshas95 | 4:104dd82c99b8 | 292 | uint8_t temp8 = LONG_TM_CODE;\ |
shreeshas95 | 4:104dd82c99b8 | 293 | PUTshort_or_long_tm(temp_tm->fields, temp8);\ |
shreeshas95 | 4:104dd82c99b8 | 294 | temp8 = TMID_TCL;\ |
shreeshas95 | 4:104dd82c99b8 | 295 | PUTtmid((temp_tm->fields), temp8);\ |
shreeshas95 | 4:104dd82c99b8 | 296 | temp_tm->TM_string[0] = 0x38;\ |
shreeshas95 | 4:104dd82c99b8 | 297 | /*Frame type(1) = 0; TMID = 0111; Spare = 000*/\ |
shreeshas95 | 4:104dd82c99b8 | 298 | temp_tm->TM_string[1] = TC_PSC;\ |
shreeshas95 | 4:104dd82c99b8 | 299 | temp_tm->TM_string[3] = TM_PSC;\ |
shreeshas95 | 5:ab276a17ca07 | 300 | int indexCustom = 4, num_of_short_tc = 0;\ |
shreeshas95 | 4:104dd82c99b8 | 301 | while(temp_tc != NULL){\ |
shreeshas95 | 4:104dd82c99b8 | 302 | if( overflowCount < TCL_OVERFLOW_CONSTANT ){\ |
shreeshas95 | 4:104dd82c99b8 | 303 | if( GETshort_or_long_tc(temp_tc) == SHORT_TC_CODE ){\ |
shreeshas95 | 4:104dd82c99b8 | 304 | for( int i = 0 ; i < TC_SHORT_SIZE ; ++i ){\ |
shreeshas95 | 5:ab276a17ca07 | 305 | temp_tm->TM_string[indexCustom + i] = temp_tc->TC_string[i];\ |
shreeshas95 | 4:104dd82c99b8 | 306 | }\ |
shreeshas95 | 5:ab276a17ca07 | 307 | indexCustom = indexCustom + TC_SHORT_SIZE;\ |
shreeshas95 | 4:104dd82c99b8 | 308 | ++overflowCount;\ |
shreeshas95 | 4:104dd82c99b8 | 309 | /*INCREMENT STUFF*/\ |
shreeshas95 | 4:104dd82c99b8 | 310 | temp_tc = temp_tc->next_TC;\ |
shreeshas95 | 4:104dd82c99b8 | 311 | num_of_short_tc = num_of_short_tc + 1;\ |
shreeshas95 | 4:104dd82c99b8 | 312 | if (temp_tc == NULL){\ |
shreeshas95 | 5:ab276a17ca07 | 313 | for (int i = indexCustom ; i < TM_LONG_SIZE-2 ; ++i){\ |
shreeshas95 | 4:104dd82c99b8 | 314 | temp_tm->TM_string[i] = 0;\ |
shreeshas95 | 4:104dd82c99b8 | 315 | /*Fill remaining values with 0*/\ |
shreeshas95 | 4:104dd82c99b8 | 316 | }\ |
shreeshas95 | 4:104dd82c99b8 | 317 | TC_LIST_TAG = num_of_short_tc;\ |
shreeshas95 | 4:104dd82c99b8 | 318 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 319 | }\ |
shreeshas95 | 4:104dd82c99b8 | 320 | if( (GETshort_or_long_tc(temp_tc) == LONG_TC_CODE) || (num_of_short_tc == OBOSC_TCL_MAX_SHORT_SIZE) ){\ |
shreeshas95 | 4:104dd82c99b8 | 321 | /*Next TC is long or memory is filled*/\ |
shreeshas95 | 5:ab276a17ca07 | 322 | for(int i = indexCustom; i < TM_LONG_SIZE-2 ; ++i){\ |
shreeshas95 | 4:104dd82c99b8 | 323 | temp_tm->TM_string[i] = 0;\ |
shreeshas95 | 4:104dd82c99b8 | 324 | /*Fill remaining values with 0*/\ |
shreeshas95 | 4:104dd82c99b8 | 325 | }\ |
shreeshas95 | 4:104dd82c99b8 | 326 | TC_LIST_TAG = num_of_short_tc;\ |
shreeshas95 | 4:104dd82c99b8 | 327 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 328 | }\ |
shreeshas95 | 4:104dd82c99b8 | 329 | }\ |
shreeshas95 | 4:104dd82c99b8 | 330 | else if (TC_LIST_TAG == OBOSC_TCL_TAG_LONG_FIRST_HALF){\ |
shreeshas95 | 4:104dd82c99b8 | 331 | /*Long TC, 2nd half*/\ |
shreeshas95 | 4:104dd82c99b8 | 332 | for (int i = 0; i < OBOSC_LONG_TC_SECOND_HALF_SIZE ; ++i){\ |
shreeshas95 | 5:ab276a17ca07 | 333 | temp_tm->TM_string[indexCustom + i] = temp_tc->TC_string[OBOSC_LONG_TC_FIRST_HALF_SIZE + i];\ |
shreeshas95 | 4:104dd82c99b8 | 334 | /*Fill the TM with TC_values*/\ |
shreeshas95 | 4:104dd82c99b8 | 335 | }\ |
shreeshas95 | 5:ab276a17ca07 | 336 | for (int i = OBOSC_LONG_TC_SECOND_HALF_SIZE + indexCustom ; i < TM_LONG_SIZE-2 ; ++i ){\ |
shreeshas95 | 4:104dd82c99b8 | 337 | temp_tm->TM_string[i] = 0;\ |
shreeshas95 | 4:104dd82c99b8 | 338 | /*Fill remaining values with 0*/\ |
shreeshas95 | 4:104dd82c99b8 | 339 | }\ |
shreeshas95 | 4:104dd82c99b8 | 340 | temp_tc = temp_tc->next_TC;\ |
shreeshas95 | 4:104dd82c99b8 | 341 | TC_LIST_TAG = OBOSC_TCL_TAG_LONG_SECOND_HALF;\ |
shreeshas95 | 4:104dd82c99b8 | 342 | ++overflowCount;\ |
shreeshas95 | 4:104dd82c99b8 | 343 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 344 | }\ |
shreeshas95 | 4:104dd82c99b8 | 345 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 346 | /*Long TC, 1st half */\ |
shreeshas95 | 4:104dd82c99b8 | 347 | for (int i = 0; i < OBOSC_LONG_TC_FIRST_HALF_SIZE; ++i){\ |
shreeshas95 | 5:ab276a17ca07 | 348 | /*gPC.printf("indexCustom = %d\r\n", indexCustom);*/\ |
shreeshas95 | 5:ab276a17ca07 | 349 | temp_tm->TM_string[indexCustom + i] = temp_tc->TC_string[i];\ |
shreeshas95 | 4:104dd82c99b8 | 350 | /*Fill the TM with TC_values*/\ |
shreeshas95 | 4:104dd82c99b8 | 351 | }\ |
shreeshas95 | 5:ab276a17ca07 | 352 | for (int i = OBOSC_LONG_TC_FIRST_HALF_SIZE + indexCustom ; i < TM_LONG_SIZE-2 ; ++i ){\ |
shreeshas95 | 5:ab276a17ca07 | 353 | temp_tm->TM_string[i] = 0;\ |
shreeshas95 | 4:104dd82c99b8 | 354 | /*Fill remaining values with 0*/\ |
shreeshas95 | 4:104dd82c99b8 | 355 | }\ |
shreeshas95 | 4:104dd82c99b8 | 356 | TC_LIST_TAG = OBOSC_TCL_TAG_LONG_FIRST_HALF;\ |
shreeshas95 | 4:104dd82c99b8 | 357 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 358 | }\ |
shreeshas95 | 4:104dd82c99b8 | 359 | }\ |
shreeshas95 | 4:104dd82c99b8 | 360 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 361 | /*PENDING: reset cdms*/\ |
shreeshas95 | 0:f016e9e8d48b | 362 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 363 | }\ |
shreeshas95 | 0:f016e9e8d48b | 364 | }\ |
shreeshas95 | 4:104dd82c99b8 | 365 | temp_tm->TM_string[2] = TC_LIST_TAG;\ |
shreeshas95 | 4:104dd82c99b8 | 366 | /*TC_LIST_TAG as is updated in the inner while loop*/\ |
shreeshas95 | 4:104dd82c99b8 | 367 | uint16_t crc16 = crc16_gen(temp_tm->TM_string, TM_LONG_SIZE-2);\ |
shreeshas95 | 4:104dd82c99b8 | 368 | temp_tm->TM_string[TM_LONG_SIZE-2] = (crc16 & 0xFF00) >> 8 ;\ |
shreeshas95 | 4:104dd82c99b8 | 369 | temp_tm->TM_string[TM_LONG_SIZE-1] = crc16 & 0x00FF;\ |
shreeshas95 | 4:104dd82c99b8 | 370 | /*Attach this new node to the TM linked list*/\ |
shreeshas95 | 5:ab276a17ca07 | 371 | if( first_time ){\ |
shreeshas95 | 5:ab276a17ca07 | 372 | first_time = false;\ |
shreeshas95 | 5:ab276a17ca07 | 373 | tm_ptr = temp_tm;\ |
shreeshas95 | 5:ab276a17ca07 | 374 | current_tm = temp_tm;\ |
shreeshas95 | 5:ab276a17ca07 | 375 | }\ |
shreeshas95 | 5:ab276a17ca07 | 376 | else{\ |
shreeshas95 | 5:ab276a17ca07 | 377 | current_tm->next_TM = temp_tm;\ |
shreeshas95 | 5:ab276a17ca07 | 378 | current_tm = current_tm->next_TM;\ |
shreeshas95 | 5:ab276a17ca07 | 379 | }\ |
shreeshas95 | 4:104dd82c99b8 | 380 | /*Attach this new node at the end*/\ |
shreeshas95 | 0:f016e9e8d48b | 381 | }\ |
shreeshas95 | 4:104dd82c99b8 | 382 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 383 | /*PENDING: reset CDMS*/\ |
shreeshas95 | 4:104dd82c99b8 | 384 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 385 | }\ |
shreeshas95 | 0:f016e9e8d48b | 386 | }\ |
shreeshas95 | 0:f016e9e8d48b | 387 | } |
shreeshas95 | 0:f016e9e8d48b | 388 | |
shreeshas95 | 0:f016e9e8d48b | 389 | // CDMS TEAM CODE START |
shreeshas95 | 0:f016e9e8d48b | 390 | #define CDMS_RLY_TMTC(tc_ptr, tm_ptr){\ |
shreeshas95 | 0:f016e9e8d48b | 391 | tm_ptr = NULL;\ |
shreeshas95 | 0:f016e9e8d48b | 392 | }\ |
shreeshas95 | 0:f016e9e8d48b | 393 | // CDMS TEAM CODE END |
shreeshas95 | 0:f016e9e8d48b | 394 | |
shreeshas95 | 0:f016e9e8d48b | 395 | // EXECUTE OBOSC |
shreeshas95 | 0:f016e9e8d48b | 396 | #define execute_obosc_core(tc_ptr, tm_ptr) {\ |
shreeshas95 | 0:f016e9e8d48b | 397 | uint8_t service_subtype = (tc_ptr->TC_string[2]) & 0x0F;\ |
shreeshas95 | 4:104dd82c99b8 | 398 | uint8_t temp8 = 0x00;\ |
shreeshas95 | 4:104dd82c99b8 | 399 | Base_tc *modify_this = gHEAD_NODE_TCL;\ |
shreeshas95 | 4:104dd82c99b8 | 400 | int modify_overflow = 0x00;\ |
shreeshas95 | 4:104dd82c99b8 | 401 | switch( service_subtype ){\ |
shreeshas95 | 4:104dd82c99b8 | 402 | case OBOSC_SUB_DISABLE:\ |
aniruddhv | 12:ffdb29353058 | 403 | /*gPC.puts("target psc are ");*/\ |
shreeshas95 | 5:ab276a17ca07 | 404 | for(int i = 3 ; i < 9 ; ++i){\ |
aniruddhv | 12:ffdb29353058 | 405 | /*gPC.printf("%u ", tc_ptr->TC_string[i]);*/\ |
shreeshas95 | 5:ab276a17ca07 | 406 | }\ |
aniruddhv | 12:ffdb29353058 | 407 | /*gPC.puts("\r\n");*/\ |
shreeshas95 | 5:ab276a17ca07 | 408 | /*gPC.puts("disable type obosc\r\n");*/\ |
shreeshas95 | 4:104dd82c99b8 | 409 | while( modify_this != NULL ){\ |
shreeshas95 | 4:104dd82c99b8 | 410 | if( modify_overflow < TCL_OVERFLOW_CONSTANT ){\ |
shreeshas95 | 5:ab276a17ca07 | 411 | uint8_t modify_psc = GETpacket_seq_count(modify_this);\ |
shreeshas95 | 5:ab276a17ca07 | 412 | /*gPC.printf("mosify_psc = %u\r\n", modify_psc);*/\ |
shreeshas95 | 4:104dd82c99b8 | 413 | for( int i = 3 ; i < 9 ; ++i ){\ |
shreeshas95 | 5:ab276a17ca07 | 414 | uint8_t target_psc = tc_ptr->TC_string[i];\ |
shreeshas95 | 5:ab276a17ca07 | 415 | if( (target_psc == modify_psc) && (target_psc != 0) ){\ |
shreeshas95 | 4:104dd82c99b8 | 416 | uint16_t tempExec = TC_STATE_DISABLED;\ |
shreeshas95 | 4:104dd82c99b8 | 417 | PUTexec_status( modify_this, tempExec );\ |
shreeshas95 | 4:104dd82c99b8 | 418 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 419 | }\ |
shreeshas95 | 4:104dd82c99b8 | 420 | }\ |
shreeshas95 | 4:104dd82c99b8 | 421 | modify_this = modify_this->next_TC;\ |
shreeshas95 | 4:104dd82c99b8 | 422 | ++modify_overflow;\ |
shreeshas95 | 4:104dd82c99b8 | 423 | }\ |
shreeshas95 | 4:104dd82c99b8 | 424 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 425 | /*PENDING: RESET CDMS*/\ |
shreeshas95 | 4:104dd82c99b8 | 426 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 427 | }\ |
shreeshas95 | 4:104dd82c99b8 | 428 | }\ |
shreeshas95 | 4:104dd82c99b8 | 429 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 430 | case OBOSC_SUB_RETRY:\ |
aniruddhv | 12:ffdb29353058 | 431 | /*gPC.puts("retry type obosc\r\n");*/\ |
shreeshas95 | 4:104dd82c99b8 | 432 | while( modify_this != NULL ){\ |
shreeshas95 | 4:104dd82c99b8 | 433 | if( modify_overflow < TCL_OVERFLOW_CONSTANT ){\ |
shreeshas95 | 5:ab276a17ca07 | 434 | uint8_t modify_psc = GETpacket_seq_count(modify_this);\ |
shreeshas95 | 4:104dd82c99b8 | 435 | for( int i = 3 ; i < 9 ; ++i ){\ |
shreeshas95 | 5:ab276a17ca07 | 436 | uint8_t target_psc = tc_ptr->TC_string[i];\ |
shreeshas95 | 5:ab276a17ca07 | 437 | if( (target_psc == modify_psc) && (target_psc != 0) ){\ |
shreeshas95 | 4:104dd82c99b8 | 438 | uint16_t tempExec = TC_STATE_MARKED_RETRY;\ |
shreeshas95 | 4:104dd82c99b8 | 439 | PUTexec_status( modify_this, tempExec );\ |
aniruddhv | 12:ffdb29353058 | 440 | /*gPC.puts("reqquired tc found: disable\r\n");*/\ |
shreeshas95 | 4:104dd82c99b8 | 441 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 442 | }\ |
shreeshas95 | 4:104dd82c99b8 | 443 | }\ |
shreeshas95 | 4:104dd82c99b8 | 444 | modify_this = modify_this->next_TC;\ |
shreeshas95 | 4:104dd82c99b8 | 445 | ++modify_overflow;\ |
shreeshas95 | 4:104dd82c99b8 | 446 | }\ |
shreeshas95 | 4:104dd82c99b8 | 447 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 448 | /*PENDING: RESET CDMS*/\ |
shreeshas95 | 4:104dd82c99b8 | 449 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 450 | }\ |
shreeshas95 | 4:104dd82c99b8 | 451 | }\ |
shreeshas95 | 4:104dd82c99b8 | 452 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 453 | }\ |
shreeshas95 | 4:104dd82c99b8 | 454 | Base_tm *ackl234new = new Short_tm;\ |
shreeshas95 | 4:104dd82c99b8 | 455 | ackl234new->next_TM = NULL;\ |
shreeshas95 | 4:104dd82c99b8 | 456 | /*return telemetry pointer here*/\ |
shreeshas95 | 4:104dd82c99b8 | 457 | tm_ptr = ackl234new;\ |
shreeshas95 | 4:104dd82c99b8 | 458 | temp8 = SHORT_TM_CODE;\ |
shreeshas95 | 4:104dd82c99b8 | 459 | PUTshort_or_long_tm(ackl234new->fields, temp8);\ |
shreeshas95 | 4:104dd82c99b8 | 460 | temp8 = TMID_ACK_L234;\ |
shreeshas95 | 4:104dd82c99b8 | 461 | PUTtmid((ackl234new->fields), temp8);\ |
shreeshas95 | 4:104dd82c99b8 | 462 | ackl234new->TM_string[0] = TMID_ACK_L234 << 4;\ |
shreeshas95 | 4:104dd82c99b8 | 463 | ackl234new->TM_string[1] = GETpacket_seq_count(tc_ptr);\ |
shreeshas95 | 4:104dd82c99b8 | 464 | ackl234new->TM_string[2] = 0xA0;\ |
shreeshas95 | 4:104dd82c99b8 | 465 | for(int i = 3; i < 11; ++i){\ |
shreeshas95 | 4:104dd82c99b8 | 466 | ackl234new->TM_string[i] = 0x00;\ |
shreeshas95 | 4:104dd82c99b8 | 467 | }\ |
shreeshas95 | 4:104dd82c99b8 | 468 | uint16_t crc = crc16_gen(ackl234new->TM_string, TM_SHORT_SIZE-2);\ |
shreeshas95 | 4:104dd82c99b8 | 469 | ackl234new->TM_string[11] = (crc & 0xFF00) >> 8;\ |
shreeshas95 | 4:104dd82c99b8 | 470 | ackl234new->TM_string[12] = crc & 0x00FF;\ |
shreeshas95 | 4:104dd82c99b8 | 471 | /*ack l234 old*/\ |
shreeshas95 | 4:104dd82c99b8 | 472 | if( service_subtype == OBOSC_SUB_REP_LE ){\ |
shreeshas95 | 4:104dd82c99b8 | 473 | if( gLAST_TM_SHORT_OR_LONG == SHORT_TM_CODE ){\ |
shreeshas95 | 4:104dd82c99b8 | 474 | Base_tm *ackl234old = new Short_tm;\ |
shreeshas95 | 4:104dd82c99b8 | 475 | ackl234old->next_TM = NULL;\ |
shreeshas95 | 4:104dd82c99b8 | 476 | /*APPEND TO ACK L234 NEW HERE*/\ |
shreeshas95 | 4:104dd82c99b8 | 477 | ackl234new->next_TM = ackl234old;\ |
shreeshas95 | 4:104dd82c99b8 | 478 | uint8_t temp82 = TM_SHORT_SIZE;\ |
shreeshas95 | 4:104dd82c99b8 | 479 | PUTshort_or_long_tm(ackl234old->fields, temp82);\ |
shreeshas95 | 4:104dd82c99b8 | 480 | /*TMID FOR SHORT TM*/\ |
shreeshas95 | 4:104dd82c99b8 | 481 | uint8_t y = (gLAST_TM[0] & 0xF0) >> 4;\ |
shreeshas95 | 4:104dd82c99b8 | 482 | PUTtmid((ackl234old->fields), y);\ |
shreeshas95 | 4:104dd82c99b8 | 483 | for( int i = 0 ; i < TM_SHORT_SIZE ; ++i ){\ |
shreeshas95 | 4:104dd82c99b8 | 484 | ackl234old->TM_string[i] = gLAST_TM[i];\ |
shreeshas95 | 4:104dd82c99b8 | 485 | }\ |
shreeshas95 | 0:f016e9e8d48b | 486 | }\ |
shreeshas95 | 4:104dd82c99b8 | 487 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 488 | Base_tm *tempLongTM = new Long_tm;\ |
shreeshas95 | 4:104dd82c99b8 | 489 | tempLongTM->next_TM = NULL;\ |
shreeshas95 | 4:104dd82c99b8 | 490 | /*APPEND TO ACK L234 NEW HERE*/\ |
shreeshas95 | 4:104dd82c99b8 | 491 | ackl234new->next_TM = tempLongTM;\ |
shreeshas95 | 4:104dd82c99b8 | 492 | uint8_t temp82 = TM_LONG_SIZE;\ |
shreeshas95 | 4:104dd82c99b8 | 493 | PUTshort_or_long_tm(tempLongTM->fields, temp82);\ |
shreeshas95 | 4:104dd82c99b8 | 494 | /*TMID FOR LONG TM*/\ |
shreeshas95 | 4:104dd82c99b8 | 495 | uint8_t y = (gLAST_TM[0] & 0x78) >> 3;\ |
shreeshas95 | 4:104dd82c99b8 | 496 | PUTtmid((tempLongTM->fields), y);\ |
shreeshas95 | 4:104dd82c99b8 | 497 | for( int i = 0 ; i < TM_LONG_SIZE ; ++i ){\ |
shreeshas95 | 4:104dd82c99b8 | 498 | tempLongTM->TM_string[i] = gLAST_TM[i];\ |
shreeshas95 | 4:104dd82c99b8 | 499 | }\ |
shreeshas95 | 4:104dd82c99b8 | 500 | }\ |
shreeshas95 | 4:104dd82c99b8 | 501 | }\ |
shreeshas95 | 4:104dd82c99b8 | 502 | else if( service_subtype == OBOSC_SUB_REP_TCLD ){\ |
shreeshas95 | 4:104dd82c99b8 | 503 | get_tc_list(ackl234new->next_TM, GETpacket_seq_count(tc_ptr));\ |
shreeshas95 | 4:104dd82c99b8 | 504 | }\ |
shreeshas95 | 4:104dd82c99b8 | 505 | else if( service_subtype == OBOSC_SUB_RESET ){\ |
shreeshas95 | 4:104dd82c99b8 | 506 | reset_all;\ |
shreeshas95 | 4:104dd82c99b8 | 507 | /*PENDING: VERIFY reset_all, RESET CDMS*/\ |
shreeshas95 | 0:f016e9e8d48b | 508 | }\ |
shreeshas95 | 5:ab276a17ca07 | 509 | else if( (service_subtype != OBOSC_SUB_DISABLE) && (service_subtype != OBOSC_SUB_RETRY) ){\ |
shreeshas95 | 4:104dd82c99b8 | 510 | /*CHANGE THE ACK CODE TO INVALID TC*/\ |
shreeshas95 | 4:104dd82c99b8 | 511 | ackl234new->TM_string[2] = 0xA2;\ |
shreeshas95 | 0:f016e9e8d48b | 512 | }\ |
aniruddhv | 12:ffdb29353058 | 513 | /*gPC.puts("completed obosc\r\n");*/\ |
shreeshas95 | 4:104dd82c99b8 | 514 | } |
shreeshas95 | 4:104dd82c99b8 | 515 | |
shreeshas95 | 4:104dd82c99b8 | 516 | /*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 | 517 | #define get_call_sign(tm_ptr) {\ |
shreeshas95 | 4:104dd82c99b8 | 518 | Base_tm* call_sign_tm = new Short_tm;\ |
shreeshas95 | 4:104dd82c99b8 | 519 | call_sign_tm->next_TM = NULL;\ |
shreeshas95 | 4:104dd82c99b8 | 520 | tm_ptr = call_sign_tm;\ |
shreeshas95 | 4:104dd82c99b8 | 521 | uint8_t temp8 = TMID_CALL_SIGN;\ |
shreeshas95 | 4:104dd82c99b8 | 522 | PUTtmid(call_sign_tm->fields, temp8);\ |
shreeshas95 | 4:104dd82c99b8 | 523 | temp8 = SHORT_TM_CODE;\ |
shreeshas95 | 4:104dd82c99b8 | 524 | PUTshort_or_long_tm(call_sign_tm->fields, temp8);\ |
shreeshas95 | 4:104dd82c99b8 | 525 | for( int i = 0 ; i < TM_SHORT_SIZE ; ++i ){\ |
shreeshas95 | 4:104dd82c99b8 | 526 | call_sign_tm->TM_string[i] = gCALL_SIGN_STRING[i];\ |
shreeshas95 | 4:104dd82c99b8 | 527 | }\ |
shreeshas95 | 0:f016e9e8d48b | 528 | } |
shreeshas95 | 0:f016e9e8d48b | 529 | |
shreeshas95 | 0:f016e9e8d48b | 530 | #define EXECUTE_OBOSC_ONLY {\ |
shreeshas95 | 4:104dd82c99b8 | 531 | Base_tm *obosc_tm_head = NULL;\ |
shreeshas95 | 4:104dd82c99b8 | 532 | get_call_sign(obosc_tm_head);\ |
shreeshas95 | 4:104dd82c99b8 | 533 | Base_tm *obosc_tm_current = obosc_tm_head;\ |
shreeshas95 | 4:104dd82c99b8 | 534 | get_ack_l1(obosc_tm_current->next_TM);\ |
shreeshas95 | 4:104dd82c99b8 | 535 | int overflowCountOBONLY = 0;\ |
shreeshas95 | 4:104dd82c99b8 | 536 | while( obosc_tm_current->next_TM != NULL ){\ |
shreeshas95 | 4:104dd82c99b8 | 537 | if( overflowCountOBONLY < TM_OVERFLOW_CONSTANT ){\ |
shreeshas95 | 4:104dd82c99b8 | 538 | obosc_tm_current = obosc_tm_current->next_TM;\ |
shreeshas95 | 4:104dd82c99b8 | 539 | ++overflowCountOBONLY;\ |
shreeshas95 | 4:104dd82c99b8 | 540 | }\ |
shreeshas95 | 4:104dd82c99b8 | 541 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 542 | /*PENDING: RESET CDMS*/\ |
shreeshas95 | 4:104dd82c99b8 | 543 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 544 | }\ |
shreeshas95 | 4:104dd82c99b8 | 545 | }\ |
shreeshas95 | 17:6eb9387f1fb8 | 546 | uint8_t obosc_executed_count = 0;\ |
shreeshas95 | 15:1c1ca992b43b | 547 | for(uint8_t execute_psc = PSC_START_VALUE ; execute_psc < gTOTAL_VALID_TC ; ++execute_psc){\ |
shreeshas95 | 4:104dd82c99b8 | 548 | Base_tc* current_TC = gHEAD_NODE_TCL;\ |
shreeshas95 | 4:104dd82c99b8 | 549 | int overCount = 0;\ |
shreeshas95 | 0:f016e9e8d48b | 550 | while( current_TC != NULL ){\ |
shreeshas95 | 4:104dd82c99b8 | 551 | if( overCount < TCL_OVERFLOW_CONSTANT ){\ |
shreeshas95 | 4:104dd82c99b8 | 552 | if( (GETcrc_pass(current_TC) == 1) && (GETpacket_seq_count(current_TC) == execute_psc) ){\ |
shreeshas95 | 4:104dd82c99b8 | 553 | /*CHECK FOR OBOSC*/\ |
shreeshas95 | 0:f016e9e8d48b | 554 | uint8_t temp82 = 0x00;\ |
shreeshas95 | 0:f016e9e8d48b | 555 | isit_obosc(current_TC, temp82);\ |
shreeshas95 | 0:f016e9e8d48b | 556 | if(temp82 == 0x01){\ |
shreeshas95 | 4:104dd82c99b8 | 557 | uint16_t current_exec_status = GETexec_status(current_TC);\ |
shreeshas95 | 4:104dd82c99b8 | 558 | if( (current_exec_status == TC_STATE_SUCCESSFULLY_EXECUTED) || (current_exec_status == TC_STATE_DISABLED) )\ |
shreeshas95 | 4:104dd82c99b8 | 559 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 560 | else if( (current_exec_status == TC_STATE_UNEXECUTED) || (current_exec_status == TC_STATE_MARKED_RETRY) ){\ |
aniruddhv | 12:ffdb29353058 | 561 | /*gPC.printf("It is obosc: %u\r\n", execute_psc);*/\ |
shreeshas95 | 4:104dd82c99b8 | 562 | /*EXECUTION OF OBOSC TC*/\ |
shreeshas95 | 4:104dd82c99b8 | 563 | /*WARNING: LARGE MEMORY UTILIZATION FOR TC-LIST-REPORT */\ |
shreeshas95 | 4:104dd82c99b8 | 564 | execute_obosc_core(current_TC, obosc_tm_current->next_TM);\ |
shreeshas95 | 17:6eb9387f1fb8 | 565 | ++obosc_executed_count;\ |
shreeshas95 | 4:104dd82c99b8 | 566 | /*INCREMENT POINTER TO THE LAST NODE*/\ |
shreeshas95 | 4:104dd82c99b8 | 567 | int overflowCountOBinside = 0;\ |
shreeshas95 | 4:104dd82c99b8 | 568 | while( obosc_tm_current->next_TM != NULL ){\ |
shreeshas95 | 4:104dd82c99b8 | 569 | if( overflowCountOBinside < TM_OVERFLOW_CONSTANT ){\ |
shreeshas95 | 4:104dd82c99b8 | 570 | obosc_tm_current = obosc_tm_current->next_TM;\ |
shreeshas95 | 4:104dd82c99b8 | 571 | ++overflowCountOBinside;\ |
shreeshas95 | 4:104dd82c99b8 | 572 | }\ |
shreeshas95 | 4:104dd82c99b8 | 573 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 574 | /*PENDING: RESET CDMS*/\ |
shreeshas95 | 4:104dd82c99b8 | 575 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 576 | }\ |
shreeshas95 | 4:104dd82c99b8 | 577 | }\ |
shreeshas95 | 4:104dd82c99b8 | 578 | uint16_t temp16 = TC_STATE_SUCCESSFULLY_EXECUTED;\ |
shreeshas95 | 4:104dd82c99b8 | 579 | PUTexec_status(current_TC, temp16);\ |
shreeshas95 | 0:f016e9e8d48b | 580 | }\ |
shreeshas95 | 0:f016e9e8d48b | 581 | }\ |
shreeshas95 | 0:f016e9e8d48b | 582 | }\ |
shreeshas95 | 4:104dd82c99b8 | 583 | current_TC = current_TC->next_TC;\ |
shreeshas95 | 4:104dd82c99b8 | 584 | ++overCount;\ |
shreeshas95 | 0:f016e9e8d48b | 585 | }\ |
shreeshas95 | 4:104dd82c99b8 | 586 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 587 | /*PENDING: REST CDMS: MEMORY LEAK FOUND*/\ |
shreeshas95 | 4:104dd82c99b8 | 588 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 589 | }\ |
shreeshas95 | 4:104dd82c99b8 | 590 | }\ |
shreeshas95 | 4:104dd82c99b8 | 591 | }\ |
shreeshas95 | 17:6eb9387f1fb8 | 592 | if( obosc_executed_count != 0 ){\ |
shreeshas95 | 17:6eb9387f1fb8 | 593 | obosc_tm_current = obosc_tm_head;\ |
shreeshas95 | 17:6eb9387f1fb8 | 594 | while( obosc_tm_current != NULL ){\ |
shreeshas95 | 17:6eb9387f1fb8 | 595 | int length = TM_SHORT_SIZE;\ |
shreeshas95 | 17:6eb9387f1fb8 | 596 | if( GETshort_or_long_tm(obosc_tm_current->fields) == SHORT_TM_CODE ){\ |
shreeshas95 | 17:6eb9387f1fb8 | 597 | length = TM_SHORT_SIZE;\ |
shreeshas95 | 17:6eb9387f1fb8 | 598 | }\ |
shreeshas95 | 17:6eb9387f1fb8 | 599 | else{\ |
shreeshas95 | 17:6eb9387f1fb8 | 600 | length = TM_LONG_SIZE;\ |
shreeshas95 | 17:6eb9387f1fb8 | 601 | }\ |
shreeshas95 | 17:6eb9387f1fb8 | 602 | for(int i = 0 ; i < length ; ++i){\ |
shreeshas95 | 17:6eb9387f1fb8 | 603 | gPC.putc(obosc_tm_current->TM_string[i]);\ |
shreeshas95 | 17:6eb9387f1fb8 | 604 | }\ |
shreeshas95 | 17:6eb9387f1fb8 | 605 | obosc_tm_current = obosc_tm_current->next_TM;\ |
shreeshas95 | 15:1c1ca992b43b | 606 | }\ |
shreeshas95 | 17:6eb9387f1fb8 | 607 | /*snd_tm.head_pointer(obosc_tm_head);*/\ |
shreeshas95 | 17:6eb9387f1fb8 | 608 | /*adf_not_SDcard();*/\ |
shreeshas95 | 15:1c1ca992b43b | 609 | }\ |
shreeshas95 | 4:104dd82c99b8 | 610 | /*DELETE THE TM AFTER USE*/\ |
shreeshas95 | 4:104dd82c99b8 | 611 | obosc_tm_current = obosc_tm_head;\ |
shreeshas95 | 4:104dd82c99b8 | 612 | int overCount = 0;\ |
shreeshas95 | 4:104dd82c99b8 | 613 | while( obosc_tm_current != NULL ){\ |
shreeshas95 | 4:104dd82c99b8 | 614 | if( (overCount < TM_OVERFLOW_CONSTANT) ){\ |
shreeshas95 | 4:104dd82c99b8 | 615 | Base_tm *temp = obosc_tm_current->next_TM;\ |
shreeshas95 | 4:104dd82c99b8 | 616 | delete obosc_tm_current;\ |
shreeshas95 | 4:104dd82c99b8 | 617 | obosc_tm_current = temp;\ |
shreeshas95 | 5:ab276a17ca07 | 618 | ++overCount;\ |
shreeshas95 | 4:104dd82c99b8 | 619 | }\ |
shreeshas95 | 4:104dd82c99b8 | 620 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 621 | /*PENDING: RESET CDMS: MEMORY LEAK FOUND*/\ |
shreeshas95 | 4:104dd82c99b8 | 622 | break;\ |
shreeshas95 | 0:f016e9e8d48b | 623 | }\ |
shreeshas95 | 0:f016e9e8d48b | 624 | }\ |
shreeshas95 | 0:f016e9e8d48b | 625 | } |
shreeshas95 | 0:f016e9e8d48b | 626 | |
shreeshas95 | 0:f016e9e8d48b | 627 | #define EXECUTE_TC {\ |
shreeshas95 | 5:ab276a17ca07 | 628 | gMASTER_STATE = TCL_STATE_EXECUTING;\ |
rohit3342 | 16:538de1b20b3a | 629 | for(uint8_t execute_psc = PSC_START_VALUE ; execute_psc < gTOTAL_VALID_TC ; ++execute_psc ){\ |
rohit3342 | 16:538de1b20b3a | 630 | gPC.printf("executing normal %u\r\n", execute_psc);\ |
shreeshas95 | 2:2caf2a9a13aa | 631 | /*gLEDG = !gLEDG;*/\ |
shreeshas95 | 2:2caf2a9a13aa | 632 | /*gLEDR = !gLEDR;*/\ |
shreeshas95 | 0:f016e9e8d48b | 633 | Base_tc* current_TC = gHEAD_NODE_TCL;\ |
shreeshas95 | 4:104dd82c99b8 | 634 | int overflowCount = 0;\ |
shreeshas95 | 0:f016e9e8d48b | 635 | while(current_TC != NULL){\ |
shreeshas95 | 4:104dd82c99b8 | 636 | if( overflowCount < TCL_OVERFLOW_CONSTANT ){\ |
shreeshas95 | 4:104dd82c99b8 | 637 | if( (GETcrc_pass(current_TC) == 1) && (GETpacket_seq_count(current_TC) == execute_psc) ){\ |
shreeshas95 | 4:104dd82c99b8 | 638 | uint8_t current_exec_status = GETexec_status(current_TC);\ |
shreeshas95 | 5:ab276a17ca07 | 639 | if( (current_exec_status == TC_STATE_SUCCESSFULLY_EXECUTED) || (current_exec_status == TC_STATE_DISABLED) ){\ |
aniruddhv | 12:ffdb29353058 | 640 | /*gPC.printf("disabled or completed at %u\n", execute_psc);*/\ |
shreeshas95 | 4:104dd82c99b8 | 641 | break;\ |
shreeshas95 | 5:ab276a17ca07 | 642 | }\ |
shreeshas95 | 17:6eb9387f1fb8 | 643 | else if( ((current_exec_status == TC_STATE_EXECUTION_FAILED) || (current_exec_status == TC_STATE_EXECUTION_UNKNOWN)) && (GETabort_on_nack(current_TC) == 1) ){\ |
aniruddhv | 12:ffdb29353058 | 644 | /*gPC.printf("abort on nack at %u psc\r\n", execute_psc);*/\ |
shreeshas95 | 4:104dd82c99b8 | 645 | gMASTER_STATE = TCL_STATE_ABORTED;\ |
shreeshas95 | 4:104dd82c99b8 | 646 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 647 | }\ |
shreeshas95 | 4:104dd82c99b8 | 648 | else if( (current_exec_status == TC_STATE_UNEXECUTED) || (current_exec_status == TC_STATE_MARKED_RETRY) ){\ |
shreeshas95 | 4:104dd82c99b8 | 649 | /*EXECUTION OF TC START*/\ |
shreeshas95 | 4:104dd82c99b8 | 650 | uint8_t temp81 = 0x00;\ |
shreeshas95 | 4:104dd82c99b8 | 651 | isit_sdcard(current_TC, temp81);\ |
shreeshas95 | 4:104dd82c99b8 | 652 | if( temp81 == 0x00 ){\ |
aniruddhv | 12:ffdb29353058 | 653 | /*gPC.printf("non sd card at %u\r\n", execute_psc);*/\ |
shreeshas95 | 4:104dd82c99b8 | 654 | /*EXECUTION OF NON SD-CARD (BOTH OBOSC and CDMS functions)*/\ |
shreeshas95 | 4:104dd82c99b8 | 655 | Base_tm *tm_ptr_head = NULL;\ |
shreeshas95 | 4:104dd82c99b8 | 656 | get_call_sign(tm_ptr_head);\ |
shreeshas95 | 4:104dd82c99b8 | 657 | Base_tm *put_tm_here = NULL;\ |
shreeshas95 | 4:104dd82c99b8 | 658 | uint8_t temp82 = 0x00;\ |
shreeshas95 | 4:104dd82c99b8 | 659 | uint8_t tempPAhot = 0x00;\ |
shreeshas95 | 4:104dd82c99b8 | 660 | isit_obosc(current_TC, temp82);\ |
shreeshas95 | 4:104dd82c99b8 | 661 | if(temp82 == 0x01){\ |
aniruddhv | 12:ffdb29353058 | 662 | /*gPC.printf("obosc tc inside normal tc at %u\r\n", execute_psc);*/\ |
shreeshas95 | 4:104dd82c99b8 | 663 | /*EXECUTION OF OBOSC TC*/\ |
shreeshas95 | 4:104dd82c99b8 | 664 | /*SKIP EXECUTION OF OBOSC HERE*/\ |
shreeshas95 | 4:104dd82c99b8 | 665 | }\ |
shreeshas95 | 4:104dd82c99b8 | 666 | else{\ |
aniruddhv | 12:ffdb29353058 | 667 | /*gPC.printf("cdms relay tmtc at %u\r\n", execute_psc);*/\ |
shreeshas95 | 4:104dd82c99b8 | 668 | /*call CDMS_RLY_TMTC*/\ |
shreeshas95 | 4:104dd82c99b8 | 669 | /*CDMS_RLY_TMTC(current_TC, put_tm_here);*/\ |
shreeshas95 | 4:104dd82c99b8 | 670 | }\ |
shreeshas95 | 4:104dd82c99b8 | 671 | /*DETECT ACK OR NACK*/\ |
shreeshas95 | 4:104dd82c99b8 | 672 | uint8_t temp83 = 0x00;\ |
shreeshas95 | 4:104dd82c99b8 | 673 | uint8_t temp84 = GETpacket_seq_count(current_TC);\ |
shreeshas95 | 4:104dd82c99b8 | 674 | detect_ack(put_tm_here, temp83, temp84);\ |
shreeshas95 | 4:104dd82c99b8 | 675 | if( temp83 == 0x01){\ |
shreeshas95 | 4:104dd82c99b8 | 676 | uint16_t temp16 = TC_STATE_SUCCESSFULLY_EXECUTED;\ |
shreeshas95 | 4:104dd82c99b8 | 677 | PUTexec_status(current_TC, temp16);\ |
shreeshas95 | 4:104dd82c99b8 | 678 | }\ |
shreeshas95 | 4:104dd82c99b8 | 679 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 680 | uint16_t temp16 = TC_STATE_EXECUTION_FAILED;\ |
shreeshas95 | 4:104dd82c99b8 | 681 | PUTexec_status(current_TC, temp16);\ |
shreeshas95 | 4:104dd82c99b8 | 682 | }\ |
shreeshas95 | 4:104dd82c99b8 | 683 | /*ABORT ON NACK AND TC LIST COMPLETED: UPDATE IN gMASTERSTATE*/\ |
shreeshas95 | 4:104dd82c99b8 | 684 | if( (GETexec_status(current_TC) == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\ |
shreeshas95 | 4:104dd82c99b8 | 685 | gMASTER_STATE = TCL_STATE_ABORTED;\ |
shreeshas95 | 4:104dd82c99b8 | 686 | }\ |
shreeshas95 | 15:1c1ca992b43b | 687 | else if( execute_psc == (gTOTAL_VALID_TC-1) ){\ |
shreeshas95 | 4:104dd82c99b8 | 688 | /*LAST TC IS EXECUTED*/\ |
shreeshas95 | 4:104dd82c99b8 | 689 | gMASTER_STATE = TCL_STATE_COMPLETED;\ |
shreeshas95 | 4:104dd82c99b8 | 690 | }\ |
shreeshas95 | 4:104dd82c99b8 | 691 | /*update last executed L1_ack*/\ |
shreeshas95 | 4:104dd82c99b8 | 692 | if( put_tm_here != NULL ){\ |
shreeshas95 | 4:104dd82c99b8 | 693 | if( GETshort_or_long_tm(put_tm_here->fields) == SHORT_TM_CODE ){\ |
shreeshas95 | 4:104dd82c99b8 | 694 | for(int i = 0 ; i < TM_SHORT_SIZE ; ++i){\ |
shreeshas95 | 4:104dd82c99b8 | 695 | gLAST_TM[i] = put_tm_here->TM_string[i];\ |
shreeshas95 | 4:104dd82c99b8 | 696 | gLAST_TM_SHORT_OR_LONG = SHORT_TM_CODE;\ |
shreeshas95 | 4:104dd82c99b8 | 697 | }\ |
shreeshas95 | 4:104dd82c99b8 | 698 | }\ |
shreeshas95 | 4:104dd82c99b8 | 699 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 700 | for( int i = 0 ; i < TM_LONG_SIZE ; ++i ){\ |
shreeshas95 | 4:104dd82c99b8 | 701 | gLAST_TM[i] = put_tm_here->TM_string[i];\ |
shreeshas95 | 4:104dd82c99b8 | 702 | gLAST_TM_SHORT_OR_LONG = LONG_TM_CODE;\ |
shreeshas95 | 4:104dd82c99b8 | 703 | }\ |
shreeshas95 | 4:104dd82c99b8 | 704 | }\ |
shreeshas95 | 4:104dd82c99b8 | 705 | }\ |
shreeshas95 | 4:104dd82c99b8 | 706 | /*PENDING: APPEND ACK L1*/\ |
shreeshas95 | 4:104dd82c99b8 | 707 | Base_tm *tm_ptr = tm_ptr_head;\ |
shreeshas95 | 4:104dd82c99b8 | 708 | get_ack_l1(tm_ptr->next_TM);\ |
shreeshas95 | 4:104dd82c99b8 | 709 | int overflowCountExecute = 0;\ |
shreeshas95 | 4:104dd82c99b8 | 710 | while( tm_ptr->next_TM != NULL ){\ |
shreeshas95 | 4:104dd82c99b8 | 711 | if( overflowCountExecute < TM_OVERFLOW_CONSTANT ){\ |
shreeshas95 | 4:104dd82c99b8 | 712 | tm_ptr = tm_ptr->next_TM;\ |
shreeshas95 | 4:104dd82c99b8 | 713 | ++overflowCountExecute;\ |
shreeshas95 | 4:104dd82c99b8 | 714 | }\ |
shreeshas95 | 4:104dd82c99b8 | 715 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 716 | /*PENDING: RESET CDMS*/\ |
shreeshas95 | 4:104dd82c99b8 | 717 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 718 | }\ |
shreeshas95 | 4:104dd82c99b8 | 719 | }\ |
shreeshas95 | 4:104dd82c99b8 | 720 | tm_ptr->next_TM = put_tm_here;\ |
shreeshas95 | 4:104dd82c99b8 | 721 | /*CHECK FOR HOT PA*/\ |
shreeshas95 | 4:104dd82c99b8 | 722 | isPAhot(tempPAhot);\ |
shreeshas95 | 4:104dd82c99b8 | 723 | if( tempPAhot == 0x00 ){\ |
shreeshas95 | 4:104dd82c99b8 | 724 | gFLAGS = gFLAGS | COM_PA_HOT_FLAG;\ |
shreeshas95 | 4:104dd82c99b8 | 725 | }\ |
shreeshas95 | 15:1c1ca992b43b | 726 | tm_ptr = tm_ptr_head;\ |
shreeshas95 | 15:1c1ca992b43b | 727 | while( tm_ptr != NULL ){\ |
shreeshas95 | 15:1c1ca992b43b | 728 | int length = TM_SHORT_SIZE;\ |
shreeshas95 | 15:1c1ca992b43b | 729 | if( GETshort_or_long_tm(tm_ptr->fields) == SHORT_TM_CODE ){\ |
shreeshas95 | 15:1c1ca992b43b | 730 | length = TM_SHORT_SIZE;\ |
shreeshas95 | 15:1c1ca992b43b | 731 | }\ |
shreeshas95 | 15:1c1ca992b43b | 732 | else{\ |
shreeshas95 | 15:1c1ca992b43b | 733 | length = TM_LONG_SIZE;\ |
shreeshas95 | 15:1c1ca992b43b | 734 | }\ |
shreeshas95 | 15:1c1ca992b43b | 735 | for(int i = 0 ; i < length ; ++i){\ |
shreeshas95 | 15:1c1ca992b43b | 736 | gPC.putc(tm_ptr->TM_string[i]);\ |
shreeshas95 | 15:1c1ca992b43b | 737 | }\ |
shreeshas95 | 15:1c1ca992b43b | 738 | tm_ptr = tm_ptr->next_TM;\ |
shreeshas95 | 15:1c1ca992b43b | 739 | }\ |
shreeshas95 | 4:104dd82c99b8 | 740 | /*SEND DATA TO GS*/\ |
shreeshas95 | 4:104dd82c99b8 | 741 | /*snd_tm.head_pointer(tm_ptr_head);*/\ |
shreeshas95 | 4:104dd82c99b8 | 742 | /*adf_not_SDcard();*/\ |
shreeshas95 | 4:104dd82c99b8 | 743 | /*DELETE THE TM AFTER USE*/\ |
shreeshas95 | 4:104dd82c99b8 | 744 | tm_ptr = tm_ptr_head;\ |
shreeshas95 | 4:104dd82c99b8 | 745 | overflowCountExecute = 0;\ |
shreeshas95 | 4:104dd82c99b8 | 746 | while(tm_ptr != NULL){\ |
shreeshas95 | 4:104dd82c99b8 | 747 | if( overflowCountExecute < TM_OVERFLOW_CONSTANT ){\ |
shreeshas95 | 4:104dd82c99b8 | 748 | Base_tm *temp = tm_ptr->next_TM;\ |
shreeshas95 | 4:104dd82c99b8 | 749 | delete tm_ptr;\ |
shreeshas95 | 4:104dd82c99b8 | 750 | tm_ptr = temp;\ |
shreeshas95 | 4:104dd82c99b8 | 751 | ++overflowCountExecute;\ |
shreeshas95 | 4:104dd82c99b8 | 752 | }\ |
shreeshas95 | 4:104dd82c99b8 | 753 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 754 | /*PENDING: RESET CDMS*/\ |
shreeshas95 | 4:104dd82c99b8 | 755 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 756 | }\ |
shreeshas95 | 4:104dd82c99b8 | 757 | }\ |
shreeshas95 | 0:f016e9e8d48b | 758 | }\ |
shreeshas95 | 0:f016e9e8d48b | 759 | else{\ |
aniruddhv | 12:ffdb29353058 | 760 | /*gPC.printf("sd card at %u\r\n", execute_psc);*/\ |
shreeshas95 | 4:104dd82c99b8 | 761 | /*EXECUTION OF SD-CARD DATA SENDING (OBSRS)*/\ |
shreeshas95 | 4:104dd82c99b8 | 762 | /*CHECK FOR HOT PA*/\ |
shreeshas95 | 4:104dd82c99b8 | 763 | uint8_t tempPAhot = 0x00;\ |
shreeshas95 | 4:104dd82c99b8 | 764 | isPAhot(tempPAhot);\ |
shreeshas95 | 4:104dd82c99b8 | 765 | if( tempPAhot == 0x00 ){\ |
shreeshas95 | 4:104dd82c99b8 | 766 | gFLAGS = gFLAGS | COM_PA_HOT_FLAG;\ |
shreeshas95 | 4:104dd82c99b8 | 767 | }\ |
shreeshas95 | 4:104dd82c99b8 | 768 | /*read_TC(current_TC);*/\ |
shreeshas95 | 6:79d422d1ed42 | 769 | uint8_t tempExec = TC_STATE_SUCCESSFULLY_EXECUTED;\ |
shreeshas95 | 6:79d422d1ed42 | 770 | PUTexec_status(current_TC, tempExec);\ |
shreeshas95 | 6:79d422d1ed42 | 771 | /*PENDING: ABORT ON NACK CHECK, gMASTER_STATE VERIFICATION WITH SD CARD, session timeout, last executed ack l234*/\ |
shreeshas95 | 4:104dd82c99b8 | 772 | if( (GETexec_status(current_TC) == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\ |
shreeshas95 | 4:104dd82c99b8 | 773 | gMASTER_STATE = TCL_STATE_ABORTED;\ |
shreeshas95 | 0:f016e9e8d48b | 774 | }\ |
shreeshas95 | 15:1c1ca992b43b | 775 | else if( execute_psc == (gTOTAL_VALID_TC-1) ){\ |
shreeshas95 | 6:79d422d1ed42 | 776 | gMASTER_STATE = TCL_STATE_COMPLETED;\ |
shreeshas95 | 6:79d422d1ed42 | 777 | }\ |
shreeshas95 | 0:f016e9e8d48b | 778 | }\ |
shreeshas95 | 0:f016e9e8d48b | 779 | }\ |
shreeshas95 | 4:104dd82c99b8 | 780 | break;\ |
shreeshas95 | 0:f016e9e8d48b | 781 | }\ |
shreeshas95 | 4:104dd82c99b8 | 782 | current_TC = current_TC->next_TC;\ |
shreeshas95 | 4:104dd82c99b8 | 783 | ++overflowCount;\ |
shreeshas95 | 0:f016e9e8d48b | 784 | }\ |
shreeshas95 | 4:104dd82c99b8 | 785 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 786 | /*PENDING: RESET CDMS*/\ |
shreeshas95 | 2:2caf2a9a13aa | 787 | break;\ |
shreeshas95 | 2:2caf2a9a13aa | 788 | }\ |
shreeshas95 | 2:2caf2a9a13aa | 789 | }\ |
shreeshas95 | 6:79d422d1ed42 | 790 | if( gFLAGS & COM_SESSION_TIMEOUT_FLAG ){\ |
shreeshas95 | 6:79d422d1ed42 | 791 | break;\ |
shreeshas95 | 6:79d422d1ed42 | 792 | }\ |
shreeshas95 | 6:79d422d1ed42 | 793 | else if( gMASTER_STATE == TCL_STATE_ABORTED ){\ |
aniruddhv | 12:ffdb29353058 | 794 | /*gPC.puts("ABORTING DUE TO ABORT ON NACK\r\n");*/\ |
shreeshas95 | 4:104dd82c99b8 | 795 | /*EXITED DUE TO ABORT ON NACK:*/\ |
shreeshas95 | 2:2caf2a9a13aa | 796 | /*PENDING : POWER OFF COM TX*/\ |
shreeshas95 | 2:2caf2a9a13aa | 797 | RX1M.attach(&rx_read, Serial::RxIrq);\ |
shreeshas95 | 2:2caf2a9a13aa | 798 | gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\ |
shreeshas95 | 0:f016e9e8d48b | 799 | break;\ |
shreeshas95 | 2:2caf2a9a13aa | 800 | }\ |
shreeshas95 | 4:104dd82c99b8 | 801 | else if( gFLAGS & COM_PA_HOT_FLAG ){\ |
shreeshas95 | 4:104dd82c99b8 | 802 | /*PA HOT: WAIT FOR TIMEOUT*/\ |
shreeshas95 | 4:104dd82c99b8 | 803 | gCOM_PA_COOLING_TIMEOUT.attach(&after_cooling_pa, COM_PA_COOLING_TIME_LIMIT);\ |
shreeshas95 | 4:104dd82c99b8 | 804 | /*PENDING : POWER OFF COMM TX*/\ |
shreeshas95 | 4:104dd82c99b8 | 805 | RX1M.attach(&rx_read, Serial::RxIrq);\ |
shreeshas95 | 4:104dd82c99b8 | 806 | gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\ |
shreeshas95 | 2:2caf2a9a13aa | 807 | break;\ |
shreeshas95 | 2:2caf2a9a13aa | 808 | }\ |
aniruddhv | 12:ffdb29353058 | 809 | /*gPC.printf("successflly executed %u tc\r\n", execute_psc);*/\ |
shreeshas95 | 0:f016e9e8d48b | 810 | }\ |
shreeshas95 | 6:79d422d1ed42 | 811 | if( (gMASTER_STATE == TCL_STATE_COMPLETED) || (gFLAGS & COM_SESSION_TIMEOUT_FLAG) ){\ |
aniruddhv | 12:ffdb29353058 | 812 | /*gPC.printf("completed or session timed out: %x\r\n", gMASTER_STATE);*/\ |
shreeshas95 | 5:ab276a17ca07 | 813 | /*COMPLETED EXECUTION OF TC*/\ |
shreeshas95 | 5:ab276a17ca07 | 814 | gMASTER_STATE = TCL_STATE_COMPLETED;\ |
shreeshas95 | 5:ab276a17ca07 | 815 | COM_POWER_OFF_TX;\ |
shreeshas95 | 5:ab276a17ca07 | 816 | reset_all;\ |
shreeshas95 | 5:ab276a17ca07 | 817 | /*PENDING : ENABLE THREADS*/\ |
shreeshas95 | 5:ab276a17ca07 | 818 | gSESSION_TIMEOUT.detach();\ |
shreeshas95 | 5:ab276a17ca07 | 819 | gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\ |
shreeshas95 | 5:ab276a17ca07 | 820 | gFLAGS = gFLAGS & (~COM_SESSION_FLAG);\ |
shreeshas95 | 5:ab276a17ca07 | 821 | }\ |
shreeshas95 | 0:f016e9e8d48b | 822 | } |