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