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