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