Latest FM Code with EEPROM
Dependencies: FreescaleIAP SimpleDMA eeprom mbed-rtos mbed
Fork of CDMS_QM_03MAR2017_Flash_with_obsrs by
COM_MNG_TMTC.h@186:eb19a02f83d6, 2016-06-17 (annotated)
- Committer:
- ee12b079
- Date:
- Fri Jun 17 13:41:43 2016 +0000
- Revision:
- 186:eb19a02f83d6
- Parent:
- 184:d75cea6f5d49
- Child:
- 197:1369ef45b49e
Testing spi ..
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 | 183:fba74e465e1a | 804 | |
ee12b079 | 161:a63672bf4423 | 805 | while(1) |
ee12b079 | 161:a63672bf4423 | 806 | { |
ee12b079 | 183:fba74e465e1a | 807 | if(PYLD_I2C_Int == 1) |
ee12b079 | 161:a63672bf4423 | 808 | { |
ee12b079 | 184:d75cea6f5d49 | 809 | |
ee12b079 | 184:d75cea6f5d49 | 810 | //printf("receiving...\r\n"); |
ee12b079 | 184:d75cea6f5d49 | 811 | FCTN_I2C_READ_PL((char*)tm_pointer->TM_string,134); |
ee12b079 | 184:d75cea6f5d49 | 812 | gPC.printf("%s", tm_pointer->TM_string); |
ee12b079 | 184:d75cea6f5d49 | 813 | received+=1; |
ee12b079 | 184:d75cea6f5d49 | 814 | break; //only for testing purpose |
ee12b079 | 161:a63672bf4423 | 815 | } |
ee12b079 | 183:fba74e465e1a | 816 | } |
ee12b079 | 171:31bdf83591a1 | 817 | if(received < 1 ) |
ee12b079 | 171:31bdf83591a1 | 818 | { |
ee12b079 | 183:fba74e465e1a | 819 | printf("Telemetry is not received from BAE\r\n"); |
ee12b079 | 183:fba74e465e1a | 820 | tm_pointer = new Short_tm; |
ee12b079 | 171:31bdf83591a1 | 821 | tm_pointer->TM_string[0] = 0xB0; |
ee12b079 | 171:31bdf83591a1 | 822 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
ee12b079 | 171:31bdf83591a1 | 823 | tm_pointer->TM_string[2] = 0x00; |
ee12b079 | 171:31bdf83591a1 | 824 | tm_pointer->TM_string[3] = 0x00; //ackcode to be decided |
ee12b079 | 171:31bdf83591a1 | 825 | tm_pointer->TM_string[4] = 0x00; |
ee12b079 | 171:31bdf83591a1 | 826 | for(uint8_t i=0;i<6;i++) |
ee12b079 | 171:31bdf83591a1 | 827 | { |
ee12b079 | 171:31bdf83591a1 | 828 | tm_pointer->TM_string[i+5] = 0; |
ee12b079 | 171:31bdf83591a1 | 829 | } |
ee12b079 | 171:31bdf83591a1 | 830 | crc16 = crc16_gen(tm_ptr->TM_string,11); |
ee12b079 | 171:31bdf83591a1 | 831 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
ee12b079 | 171:31bdf83591a1 | 832 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
ee12b079 | 161:a63672bf4423 | 833 | } |
ee12b079 | 161:a63672bf4423 | 834 | tm_pointer->next_TM = NULL; return tm_ptr; |
aniruddhv | 52:0bd68655c651 | 835 | break; |
aniruddhv | 52:0bd68655c651 | 836 | } |
aniruddhv | 52:0bd68655c651 | 837 | default: //invalid TC |
aniruddhv | 52:0bd68655c651 | 838 | { |
ee12b079 | 73:6c99294b7802 | 839 | //printf("INVALID TC\r\n"); |
aniruddhv | 52:0bd68655c651 | 840 | //tm_pointer = new Short_tm; |
aniruddhv | 52:0bd68655c651 | 841 | tm_pointer->TM_string[0] = 0xB0; |
aniruddhv | 52:0bd68655c651 | 842 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
aniruddhv | 52:0bd68655c651 | 843 | tm_pointer->TM_string[2] = 0x01; |
aniruddhv | 52:0bd68655c651 | 844 | tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided |
aniruddhv | 52:0bd68655c651 | 845 | tm_pointer->TM_string[4] = 0x01; |
aniruddhv | 52:0bd68655c651 | 846 | for(uint8_t i=0;i<6;i++) |
aniruddhv | 52:0bd68655c651 | 847 | { |
aniruddhv | 52:0bd68655c651 | 848 | tm_pointer->TM_string[i+5] = 0; |
aniruddhv | 52:0bd68655c651 | 849 | } |
aniruddhv | 52:0bd68655c651 | 850 | crc16 = crc16_gen(tm_ptr->TM_string,11); |
aniruddhv | 52:0bd68655c651 | 851 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
aniruddhv | 52:0bd68655c651 | 852 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
ee12b079 | 53:18db568f1098 | 853 | tm_pointer->next_TM = NULL; return tm_ptr; |
aniruddhv | 52:0bd68655c651 | 854 | break; |
aniruddhv | 52:0bd68655c651 | 855 | } |
aniruddhv | 52:0bd68655c651 | 856 | } |
aniruddhv | 52:0bd68655c651 | 857 | } |
shreeshas95 | 0:f016e9e8d48b | 858 | // CDMS TEAM CODE END |
shreeshas95 | 0:f016e9e8d48b | 859 | // EXECUTE OBOSC |
aniruddhv | 51:da85d84768e2 | 860 | #define execute_obosc_core(tc_ptr, tm_ptr, reset_flag) {\ |
shreeshas95 | 0:f016e9e8d48b | 861 | uint8_t service_subtype = (tc_ptr->TC_string[2]) & 0x0F;\ |
shreeshas95 | 4:104dd82c99b8 | 862 | uint8_t temp8 = 0x00;\ |
shreeshas95 | 4:104dd82c99b8 | 863 | Base_tc *modify_this = gHEAD_NODE_TCL;\ |
shreeshas95 | 4:104dd82c99b8 | 864 | int modify_overflow = 0x00;\ |
shreeshas95 | 4:104dd82c99b8 | 865 | switch( service_subtype ){\ |
shreeshas95 | 4:104dd82c99b8 | 866 | case OBOSC_SUB_DISABLE:\ |
aniruddhv | 12:ffdb29353058 | 867 | /*gPC.puts("target psc are ");*/\ |
shreeshas95 | 5:ab276a17ca07 | 868 | for(int i = 3 ; i < 9 ; ++i){\ |
aniruddhv | 12:ffdb29353058 | 869 | /*gPC.printf("%u ", tc_ptr->TC_string[i]);*/\ |
shreeshas95 | 5:ab276a17ca07 | 870 | }\ |
aniruddhv | 12:ffdb29353058 | 871 | /*gPC.puts("\r\n");*/\ |
shreeshas95 | 5:ab276a17ca07 | 872 | /*gPC.puts("disable type obosc\r\n");*/\ |
shreeshas95 | 4:104dd82c99b8 | 873 | while( modify_this != NULL ){\ |
shreeshas95 | 4:104dd82c99b8 | 874 | if( modify_overflow < TCL_OVERFLOW_CONSTANT ){\ |
shreeshas95 | 5:ab276a17ca07 | 875 | uint8_t modify_psc = GETpacket_seq_count(modify_this);\ |
shreeshas95 | 5:ab276a17ca07 | 876 | /*gPC.printf("mosify_psc = %u\r\n", modify_psc);*/\ |
shreeshas95 | 4:104dd82c99b8 | 877 | for( int i = 3 ; i < 9 ; ++i ){\ |
shreeshas95 | 5:ab276a17ca07 | 878 | uint8_t target_psc = tc_ptr->TC_string[i];\ |
shreeshas95 | 5:ab276a17ca07 | 879 | if( (target_psc == modify_psc) && (target_psc != 0) ){\ |
shreeshas95 | 4:104dd82c99b8 | 880 | uint16_t tempExec = TC_STATE_DISABLED;\ |
shreeshas95 | 4:104dd82c99b8 | 881 | PUTexec_status( modify_this, tempExec );\ |
shreeshas95 | 4:104dd82c99b8 | 882 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 883 | }\ |
shreeshas95 | 4:104dd82c99b8 | 884 | }\ |
shreeshas95 | 4:104dd82c99b8 | 885 | modify_this = modify_this->next_TC;\ |
shreeshas95 | 4:104dd82c99b8 | 886 | ++modify_overflow;\ |
shreeshas95 | 4:104dd82c99b8 | 887 | }\ |
shreeshas95 | 4:104dd82c99b8 | 888 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 889 | /*PENDING: RESET CDMS*/\ |
shreeshas95 | 4:104dd82c99b8 | 890 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 891 | }\ |
shreeshas95 | 4:104dd82c99b8 | 892 | }\ |
shreeshas95 | 4:104dd82c99b8 | 893 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 894 | case OBOSC_SUB_RETRY:\ |
aniruddhv | 12:ffdb29353058 | 895 | /*gPC.puts("retry type obosc\r\n");*/\ |
shreeshas95 | 4:104dd82c99b8 | 896 | while( modify_this != NULL ){\ |
shreeshas95 | 4:104dd82c99b8 | 897 | if( modify_overflow < TCL_OVERFLOW_CONSTANT ){\ |
shreeshas95 | 5:ab276a17ca07 | 898 | uint8_t modify_psc = GETpacket_seq_count(modify_this);\ |
shreeshas95 | 4:104dd82c99b8 | 899 | for( int i = 3 ; i < 9 ; ++i ){\ |
shreeshas95 | 5:ab276a17ca07 | 900 | uint8_t target_psc = tc_ptr->TC_string[i];\ |
shreeshas95 | 5:ab276a17ca07 | 901 | if( (target_psc == modify_psc) && (target_psc != 0) ){\ |
shreeshas95 | 4:104dd82c99b8 | 902 | uint16_t tempExec = TC_STATE_MARKED_RETRY;\ |
shreeshas95 | 4:104dd82c99b8 | 903 | PUTexec_status( modify_this, tempExec );\ |
aniruddhv | 12:ffdb29353058 | 904 | /*gPC.puts("reqquired tc found: disable\r\n");*/\ |
shreeshas95 | 4:104dd82c99b8 | 905 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 906 | }\ |
shreeshas95 | 4:104dd82c99b8 | 907 | }\ |
shreeshas95 | 4:104dd82c99b8 | 908 | modify_this = modify_this->next_TC;\ |
shreeshas95 | 4:104dd82c99b8 | 909 | ++modify_overflow;\ |
shreeshas95 | 4:104dd82c99b8 | 910 | }\ |
shreeshas95 | 4:104dd82c99b8 | 911 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 912 | /*PENDING: RESET CDMS*/\ |
shreeshas95 | 4:104dd82c99b8 | 913 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 914 | }\ |
shreeshas95 | 4:104dd82c99b8 | 915 | }\ |
shreeshas95 | 4:104dd82c99b8 | 916 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 917 | }\ |
shreeshas95 | 4:104dd82c99b8 | 918 | Base_tm *ackl234new = new Short_tm;\ |
shreeshas95 | 4:104dd82c99b8 | 919 | ackl234new->next_TM = NULL;\ |
shreeshas95 | 4:104dd82c99b8 | 920 | /*return telemetry pointer here*/\ |
shreeshas95 | 4:104dd82c99b8 | 921 | tm_ptr = ackl234new;\ |
shreeshas95 | 4:104dd82c99b8 | 922 | ackl234new->TM_string[0] = TMID_ACK_L234 << 4;\ |
shreeshas95 | 4:104dd82c99b8 | 923 | ackl234new->TM_string[1] = GETpacket_seq_count(tc_ptr);\ |
shreeshas95 | 4:104dd82c99b8 | 924 | ackl234new->TM_string[2] = 0xA0;\ |
shreeshas95 | 4:104dd82c99b8 | 925 | for(int i = 3; i < 11; ++i){\ |
shreeshas95 | 4:104dd82c99b8 | 926 | ackl234new->TM_string[i] = 0x00;\ |
shreeshas95 | 4:104dd82c99b8 | 927 | }\ |
shreeshas95 | 4:104dd82c99b8 | 928 | uint16_t crc = crc16_gen(ackl234new->TM_string, TM_SHORT_SIZE-2);\ |
shreeshas95 | 4:104dd82c99b8 | 929 | ackl234new->TM_string[11] = (crc & 0xFF00) >> 8;\ |
shreeshas95 | 4:104dd82c99b8 | 930 | ackl234new->TM_string[12] = crc & 0x00FF;\ |
shreeshas95 | 4:104dd82c99b8 | 931 | /*ack l234 old*/\ |
shreeshas95 | 4:104dd82c99b8 | 932 | if( service_subtype == OBOSC_SUB_REP_LE ){\ |
shreeshas95 | 4:104dd82c99b8 | 933 | if( gLAST_TM_SHORT_OR_LONG == SHORT_TM_CODE ){\ |
shreeshas95 | 4:104dd82c99b8 | 934 | Base_tm *ackl234old = new Short_tm;\ |
shreeshas95 | 4:104dd82c99b8 | 935 | ackl234old->next_TM = NULL;\ |
shreeshas95 | 4:104dd82c99b8 | 936 | /*APPEND TO ACK L234 NEW HERE*/\ |
shreeshas95 | 4:104dd82c99b8 | 937 | ackl234new->next_TM = ackl234old;\ |
shreeshas95 | 4:104dd82c99b8 | 938 | for( int i = 0 ; i < TM_SHORT_SIZE ; ++i ){\ |
shreeshas95 | 4:104dd82c99b8 | 939 | ackl234old->TM_string[i] = gLAST_TM[i];\ |
shreeshas95 | 4:104dd82c99b8 | 940 | }\ |
shreeshas95 | 0:f016e9e8d48b | 941 | }\ |
shreeshas95 | 4:104dd82c99b8 | 942 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 943 | Base_tm *tempLongTM = new Long_tm;\ |
shreeshas95 | 4:104dd82c99b8 | 944 | tempLongTM->next_TM = NULL;\ |
shreeshas95 | 4:104dd82c99b8 | 945 | /*APPEND TO ACK L234 NEW HERE*/\ |
shreeshas95 | 4:104dd82c99b8 | 946 | ackl234new->next_TM = tempLongTM;\ |
shreeshas95 | 4:104dd82c99b8 | 947 | for( int i = 0 ; i < TM_LONG_SIZE ; ++i ){\ |
shreeshas95 | 4:104dd82c99b8 | 948 | tempLongTM->TM_string[i] = gLAST_TM[i];\ |
shreeshas95 | 4:104dd82c99b8 | 949 | }\ |
shreeshas95 | 4:104dd82c99b8 | 950 | }\ |
shreeshas95 | 4:104dd82c99b8 | 951 | }\ |
shreeshas95 | 4:104dd82c99b8 | 952 | else if( service_subtype == OBOSC_SUB_REP_TCLD ){\ |
shreeshas95 | 4:104dd82c99b8 | 953 | get_tc_list(ackl234new->next_TM, GETpacket_seq_count(tc_ptr));\ |
shreeshas95 | 4:104dd82c99b8 | 954 | }\ |
shreeshas95 | 4:104dd82c99b8 | 955 | else if( service_subtype == OBOSC_SUB_RESET ){\ |
aniruddhv | 51:da85d84768e2 | 956 | /*reset_all;*/\ |
aniruddhv | 51:da85d84768e2 | 957 | reset_flag = 1;\ |
shreeshas95 | 4:104dd82c99b8 | 958 | /*PENDING: VERIFY reset_all, RESET CDMS*/\ |
shreeshas95 | 0:f016e9e8d48b | 959 | }\ |
shreeshas95 | 5:ab276a17ca07 | 960 | else if( (service_subtype != OBOSC_SUB_DISABLE) && (service_subtype != OBOSC_SUB_RETRY) ){\ |
shreeshas95 | 4:104dd82c99b8 | 961 | /*CHANGE THE ACK CODE TO INVALID TC*/\ |
shreeshas95 | 4:104dd82c99b8 | 962 | ackl234new->TM_string[2] = 0xA2;\ |
shreeshas95 | 0:f016e9e8d48b | 963 | }\ |
aniruddhv | 12:ffdb29353058 | 964 | /*gPC.puts("completed obosc\r\n");*/\ |
shreeshas95 | 4:104dd82c99b8 | 965 | } |
shreeshas95 | 4:104dd82c99b8 | 966 | |
shreeshas95 | 4:104dd82c99b8 | 967 | /*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 | 968 | |
shreeshas95 | 0:f016e9e8d48b | 969 | |
shreeshas95 | 0:f016e9e8d48b | 970 | #define EXECUTE_OBOSC_ONLY {\ |
aniruddhv | 51:da85d84768e2 | 971 | int reset_flag = 0;\ |
shreeshas95 | 15:1c1ca992b43b | 972 | for(uint8_t execute_psc = PSC_START_VALUE ; execute_psc < gTOTAL_VALID_TC ; ++execute_psc){\ |
shreeshas95 | 4:104dd82c99b8 | 973 | Base_tc* current_TC = gHEAD_NODE_TCL;\ |
shreeshas95 | 4:104dd82c99b8 | 974 | int overCount = 0;\ |
shreeshas95 | 0:f016e9e8d48b | 975 | while( current_TC != NULL ){\ |
shreeshas95 | 4:104dd82c99b8 | 976 | if( overCount < TCL_OVERFLOW_CONSTANT ){\ |
shreeshas95 | 4:104dd82c99b8 | 977 | if( (GETcrc_pass(current_TC) == 1) && (GETpacket_seq_count(current_TC) == execute_psc) ){\ |
shreeshas95 | 4:104dd82c99b8 | 978 | /*CHECK FOR OBOSC*/\ |
shreeshas95 | 0:f016e9e8d48b | 979 | uint8_t temp82 = 0x00;\ |
shreeshas95 | 0:f016e9e8d48b | 980 | isit_obosc(current_TC, temp82);\ |
shreeshas95 | 0:f016e9e8d48b | 981 | if(temp82 == 0x01){\ |
shreeshas95 | 4:104dd82c99b8 | 982 | uint16_t current_exec_status = GETexec_status(current_TC);\ |
shreeshas95 | 4:104dd82c99b8 | 983 | if( (current_exec_status == TC_STATE_SUCCESSFULLY_EXECUTED) || (current_exec_status == TC_STATE_DISABLED) )\ |
shreeshas95 | 4:104dd82c99b8 | 984 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 985 | else if( (current_exec_status == TC_STATE_UNEXECUTED) || (current_exec_status == TC_STATE_MARKED_RETRY) ){\ |
aniruddhv | 12:ffdb29353058 | 986 | /*gPC.printf("It is obosc: %u\r\n", execute_psc);*/\ |
shreeshas95 | 4:104dd82c99b8 | 987 | /*EXECUTION OF OBOSC TC*/\ |
shreeshas95 | 4:104dd82c99b8 | 988 | /*WARNING: LARGE MEMORY UTILIZATION FOR TC-LIST-REPORT */\ |
ee12b079 | 73:6c99294b7802 | 989 | Base_tm *obosc_tm_head = NULL;\ |
ee12b079 | 73:6c99294b7802 | 990 | get_call_sign(obosc_tm_head);\ |
ee12b079 | 73:6c99294b7802 | 991 | Base_tm *obosc_tm_core = NULL;\ |
ee12b079 | 73:6c99294b7802 | 992 | execute_obosc_core(current_TC, obosc_tm_core, reset_flag);\ |
ee12b079 | 73:6c99294b7802 | 993 | uint16_t temp16 = TC_STATE_SUCCESSFULLY_EXECUTED;\ |
ee12b079 | 73:6c99294b7802 | 994 | PUTexec_status(current_TC, temp16);\ |
ee12b079 | 73:6c99294b7802 | 995 | Base_tm *obosc_tm_current = obosc_tm_head;\ |
ee12b079 | 73:6c99294b7802 | 996 | get_ack_l1(obosc_tm_current->next_TM);\ |
ee12b079 | 73:6c99294b7802 | 997 | int overflowCountOBONLY = 0;\ |
shreeshas95 | 4:104dd82c99b8 | 998 | while( obosc_tm_current->next_TM != NULL ){\ |
ee12b079 | 73:6c99294b7802 | 999 | if( overflowCountOBONLY < TM_OVERFLOW_CONSTANT ){\ |
shreeshas95 | 4:104dd82c99b8 | 1000 | obosc_tm_current = obosc_tm_current->next_TM;\ |
ee12b079 | 73:6c99294b7802 | 1001 | ++overflowCountOBONLY;\ |
shreeshas95 | 4:104dd82c99b8 | 1002 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1003 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 1004 | /*PENDING: RESET CDMS*/\ |
shreeshas95 | 4:104dd82c99b8 | 1005 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 1006 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1007 | }\ |
ee12b079 | 73:6c99294b7802 | 1008 | obosc_tm_current->next_TM = obosc_tm_core;\ |
ee12b079 | 73:6c99294b7802 | 1009 | obosc_tm_current = obosc_tm_head;\ |
ee12b079 | 73:6c99294b7802 | 1010 | while( obosc_tm_current != NULL ){\ |
ee12b079 | 73:6c99294b7802 | 1011 | int length = TM_SHORT_SIZE;\ |
shreeshas95 | 102:80c911a6e736 | 1012 | if( GETshort_or_long_tm(obosc_tm_current) == SHORT_TM_CODE ){\ |
ee12b079 | 73:6c99294b7802 | 1013 | length = TM_SHORT_SIZE;\ |
ee12b079 | 73:6c99294b7802 | 1014 | }\ |
ee12b079 | 73:6c99294b7802 | 1015 | else{\ |
ee12b079 | 73:6c99294b7802 | 1016 | length = TM_LONG_SIZE;\ |
ee12b079 | 73:6c99294b7802 | 1017 | }\ |
ee12b079 | 73:6c99294b7802 | 1018 | for(int i = 0 ; i < length ; ++i){\ |
ee12b079 | 73:6c99294b7802 | 1019 | /*gPC.putc(obosc_tm_current->TM_string[i]);*/\ |
ee12b079 | 73:6c99294b7802 | 1020 | }\ |
ee12b079 | 73:6c99294b7802 | 1021 | obosc_tm_current = obosc_tm_current->next_TM;\ |
ee12b079 | 73:6c99294b7802 | 1022 | }\ |
ee12b079 | 80:b2155ba726c3 | 1023 | /*Sending OBOSC TM to GS*/\ |
ee12b079 | 73:6c99294b7802 | 1024 | /*snd_tm.head_pointer(obosc_tm_head);*/\ |
ee12b079 | 95:42d6747900cb | 1025 | /*transmit_adf;*/\ |
ee12b079 | 73:6c99294b7802 | 1026 | /*DELETE THE TM AFTER USE*/\ |
ee12b079 | 73:6c99294b7802 | 1027 | obosc_tm_current = obosc_tm_head;\ |
ee12b079 | 73:6c99294b7802 | 1028 | int overCount = 0;\ |
ee12b079 | 73:6c99294b7802 | 1029 | while( obosc_tm_current != NULL ){\ |
ee12b079 | 73:6c99294b7802 | 1030 | if( (overCount < TM_OVERFLOW_CONSTANT) ){\ |
ee12b079 | 73:6c99294b7802 | 1031 | Base_tm *temp = obosc_tm_current->next_TM;\ |
ee12b079 | 73:6c99294b7802 | 1032 | delete obosc_tm_current;\ |
ee12b079 | 73:6c99294b7802 | 1033 | obosc_tm_current = temp;\ |
ee12b079 | 73:6c99294b7802 | 1034 | ++overCount;\ |
ee12b079 | 73:6c99294b7802 | 1035 | }\ |
ee12b079 | 73:6c99294b7802 | 1036 | else{\ |
ee12b079 | 73:6c99294b7802 | 1037 | /*PENDING: RESET CDMS: MEMORY LEAK FOUND*/\ |
ee12b079 | 73:6c99294b7802 | 1038 | break;\ |
ee12b079 | 73:6c99294b7802 | 1039 | }\ |
ee12b079 | 73:6c99294b7802 | 1040 | }\ |
ee12b079 | 73:6c99294b7802 | 1041 | if ( reset_flag ==1 ){\ |
ee12b079 | 73:6c99294b7802 | 1042 | reset_all;\ |
ee12b079 | 73:6c99294b7802 | 1043 | }\ |
shreeshas95 | 0:f016e9e8d48b | 1044 | }\ |
shreeshas95 | 0:f016e9e8d48b | 1045 | }\ |
shreeshas95 | 0:f016e9e8d48b | 1046 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1047 | current_TC = current_TC->next_TC;\ |
shreeshas95 | 4:104dd82c99b8 | 1048 | ++overCount;\ |
shreeshas95 | 0:f016e9e8d48b | 1049 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1050 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 1051 | /*PENDING: REST CDMS: MEMORY LEAK FOUND*/\ |
shreeshas95 | 4:104dd82c99b8 | 1052 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 1053 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1054 | }\ |
aniruddhv | 58:5c59f28620bc | 1055 | }\ |
shreeshas95 | 0:f016e9e8d48b | 1056 | } |
shreeshas95 | 0:f016e9e8d48b | 1057 | |
shreeshas95 | 0:f016e9e8d48b | 1058 | #define EXECUTE_TC {\ |
shreeshas95 | 5:ab276a17ca07 | 1059 | gMASTER_STATE = TCL_STATE_EXECUTING;\ |
rohit3342 | 23:c89376564196 | 1060 | /*gPC.printf("%u\r\n", gTOTAL_VALID_TC);*/\ |
rohit3342 | 16:538de1b20b3a | 1061 | for(uint8_t execute_psc = PSC_START_VALUE ; execute_psc < gTOTAL_VALID_TC ; ++execute_psc ){\ |
rohit3342 | 23:c89376564196 | 1062 | /*gPC.printf("executing normal %u\r\n", execute_psc);*/\ |
shreeshas95 | 2:2caf2a9a13aa | 1063 | /*gLEDG = !gLEDG;*/\ |
shreeshas95 | 2:2caf2a9a13aa | 1064 | /*gLEDR = !gLEDR;*/\ |
shreeshas95 | 0:f016e9e8d48b | 1065 | Base_tc* current_TC = gHEAD_NODE_TCL;\ |
shreeshas95 | 4:104dd82c99b8 | 1066 | int overflowCount = 0;\ |
shreeshas95 | 0:f016e9e8d48b | 1067 | while(current_TC != NULL){\ |
shreeshas95 | 4:104dd82c99b8 | 1068 | if( overflowCount < TCL_OVERFLOW_CONSTANT ){\ |
shreeshas95 | 4:104dd82c99b8 | 1069 | if( (GETcrc_pass(current_TC) == 1) && (GETpacket_seq_count(current_TC) == execute_psc) ){\ |
shreeshas95 | 4:104dd82c99b8 | 1070 | uint8_t current_exec_status = GETexec_status(current_TC);\ |
shreeshas95 | 5:ab276a17ca07 | 1071 | if( (current_exec_status == TC_STATE_SUCCESSFULLY_EXECUTED) || (current_exec_status == TC_STATE_DISABLED) ){\ |
aniruddhv | 12:ffdb29353058 | 1072 | /*gPC.printf("disabled or completed at %u\n", execute_psc);*/\ |
shreeshas95 | 4:104dd82c99b8 | 1073 | break;\ |
shreeshas95 | 5:ab276a17ca07 | 1074 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1075 | else if( (current_exec_status == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\ |
aniruddhv | 12:ffdb29353058 | 1076 | /*gPC.printf("abort on nack at %u psc\r\n", execute_psc);*/\ |
shreeshas95 | 4:104dd82c99b8 | 1077 | gMASTER_STATE = TCL_STATE_ABORTED;\ |
rohit3342 | 44:b9b067d0559f | 1078 | Base_tm *tm_ptr_head = NULL;\ |
rohit3342 | 44:b9b067d0559f | 1079 | get_call_sign(tm_ptr_head);\ |
rohit3342 | 44:b9b067d0559f | 1080 | Base_tm *tm_ptr = tm_ptr_head;\ |
rohit3342 | 44:b9b067d0559f | 1081 | get_ack_l1(tm_ptr->next_TM);\ |
ee12b079 | 73:6c99294b7802 | 1082 | tm_ptr = tm_ptr_head;\ |
ee12b079 | 73:6c99294b7802 | 1083 | while( tm_ptr != NULL ){\ |
ee12b079 | 73:6c99294b7802 | 1084 | int length = TM_SHORT_SIZE;\ |
shreeshas95 | 102:80c911a6e736 | 1085 | if( GETshort_or_long_tm(tm_ptr) == SHORT_TM_CODE ){\ |
ee12b079 | 73:6c99294b7802 | 1086 | length = TM_SHORT_SIZE;\ |
ee12b079 | 73:6c99294b7802 | 1087 | }\ |
ee12b079 | 73:6c99294b7802 | 1088 | else{\ |
ee12b079 | 73:6c99294b7802 | 1089 | length = TM_LONG_SIZE;\ |
ee12b079 | 73:6c99294b7802 | 1090 | }\ |
ee12b079 | 73:6c99294b7802 | 1091 | /*gPC.puts("Printing Call Sign, ACK_L1, TM list");*/\ |
ee12b079 | 73:6c99294b7802 | 1092 | for(int i = 0 ; i < length ; ++i){\ |
ee12b079 | 73:6c99294b7802 | 1093 | /*gPC.putc(tm_ptr->TM_string[i]);*/\ |
ee12b079 | 73:6c99294b7802 | 1094 | }\ |
ee12b079 | 73:6c99294b7802 | 1095 | tm_ptr = tm_ptr->next_TM;\ |
ee12b079 | 80:b2155ba726c3 | 1096 | }\ |
ee12b079 | 80:b2155ba726c3 | 1097 | /*Send only call sign, ACK_L1 to GS*/\ |
ee12b079 | 73:6c99294b7802 | 1098 | /*snd_tm.head_pointer(tm_ptr_head);*/\ |
ee12b079 | 95:42d6747900cb | 1099 | /*transmit_adf;*/\ |
ee12b079 | 73:6c99294b7802 | 1100 | /*DELETE THE TM AFTER USE*/\ |
ee12b079 | 73:6c99294b7802 | 1101 | tm_ptr = tm_ptr_head;\ |
ee12b079 | 73:6c99294b7802 | 1102 | int overflowCountExecute = 0;\ |
ee12b079 | 73:6c99294b7802 | 1103 | while(tm_ptr != NULL){\ |
ee12b079 | 73:6c99294b7802 | 1104 | if( overflowCountExecute < TM_OVERFLOW_CONSTANT ){\ |
ee12b079 | 73:6c99294b7802 | 1105 | Base_tm *temp = tm_ptr->next_TM;\ |
ee12b079 | 73:6c99294b7802 | 1106 | delete tm_ptr;\ |
ee12b079 | 73:6c99294b7802 | 1107 | tm_ptr = temp;\ |
ee12b079 | 73:6c99294b7802 | 1108 | ++overflowCountExecute;\ |
ee12b079 | 73:6c99294b7802 | 1109 | }\ |
ee12b079 | 73:6c99294b7802 | 1110 | else{\ |
ee12b079 | 73:6c99294b7802 | 1111 | /*PENDING: RESET CDMS*/\ |
ee12b079 | 73:6c99294b7802 | 1112 | break;\ |
ee12b079 | 73:6c99294b7802 | 1113 | }\ |
ee12b079 | 73:6c99294b7802 | 1114 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1115 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 1116 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1117 | else if( (current_exec_status == TC_STATE_UNEXECUTED) || (current_exec_status == TC_STATE_MARKED_RETRY) ){\ |
shreeshas95 | 4:104dd82c99b8 | 1118 | /*EXECUTION OF TC START*/\ |
shreeshas95 | 4:104dd82c99b8 | 1119 | uint8_t temp81 = 0x00;\ |
shreeshas95 | 4:104dd82c99b8 | 1120 | isit_sdcard(current_TC, temp81);\ |
shreeshas95 | 4:104dd82c99b8 | 1121 | if( temp81 == 0x00 ){\ |
aniruddhv | 12:ffdb29353058 | 1122 | /*gPC.printf("non sd card at %u\r\n", execute_psc);*/\ |
shreeshas95 | 4:104dd82c99b8 | 1123 | /*EXECUTION OF NON SD-CARD (BOTH OBOSC and CDMS functions)*/\ |
shreeshas95 | 4:104dd82c99b8 | 1124 | Base_tm *tm_ptr_head = NULL;\ |
shreeshas95 | 4:104dd82c99b8 | 1125 | get_call_sign(tm_ptr_head);\ |
shreeshas95 | 4:104dd82c99b8 | 1126 | Base_tm *put_tm_here = NULL;\ |
shreeshas95 | 4:104dd82c99b8 | 1127 | uint8_t temp82 = 0x00;\ |
shreeshas95 | 4:104dd82c99b8 | 1128 | uint8_t tempPAhot = 0x00;\ |
shreeshas95 | 4:104dd82c99b8 | 1129 | isit_obosc(current_TC, temp82);\ |
shreeshas95 | 4:104dd82c99b8 | 1130 | if(temp82 == 0x01){\ |
aniruddhv | 12:ffdb29353058 | 1131 | /*gPC.printf("obosc tc inside normal tc at %u\r\n", execute_psc);*/\ |
shreeshas95 | 4:104dd82c99b8 | 1132 | /*EXECUTION OF OBOSC TC*/\ |
shreeshas95 | 4:104dd82c99b8 | 1133 | /*SKIP EXECUTION OF OBOSC HERE*/\ |
aniruddhv | 37:c9a739750806 | 1134 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 1135 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1136 | else{\ |
rohit3342 | 23:c89376564196 | 1137 | /*gPC.printf("cdms relay tmtc at %u\r\n", execute_psc);*/\ |
shreeshas95 | 4:104dd82c99b8 | 1138 | /*call CDMS_RLY_TMTC*/\ |
shreeshas95 | 4:104dd82c99b8 | 1139 | /*CDMS_RLY_TMTC(current_TC, put_tm_here);*/\ |
aniruddhv | 52:0bd68655c651 | 1140 | put_tm_here = FCTN_CDMS_RLY_TMTC(current_TC);\ |
shreeshas95 | 4:104dd82c99b8 | 1141 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1142 | /*DETECT ACK OR NACK*/\ |
shreeshas95 | 4:104dd82c99b8 | 1143 | uint8_t temp83 = 0x00;\ |
shreeshas95 | 4:104dd82c99b8 | 1144 | uint8_t temp84 = GETpacket_seq_count(current_TC);\ |
shreeshas95 | 4:104dd82c99b8 | 1145 | detect_ack(put_tm_here, temp83, temp84);\ |
shreeshas95 | 4:104dd82c99b8 | 1146 | if( temp83 == 0x01){\ |
shreeshas95 | 4:104dd82c99b8 | 1147 | uint16_t temp16 = TC_STATE_SUCCESSFULLY_EXECUTED;\ |
shreeshas95 | 4:104dd82c99b8 | 1148 | PUTexec_status(current_TC, temp16);\ |
shreeshas95 | 4:104dd82c99b8 | 1149 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1150 | else{\ |
rohit3342 | 23:c89376564196 | 1151 | /*gPC.puts("TC_STATE_EXECUTION_FAILED");*/\ |
shreeshas95 | 4:104dd82c99b8 | 1152 | uint16_t temp16 = TC_STATE_EXECUTION_FAILED;\ |
shreeshas95 | 4:104dd82c99b8 | 1153 | PUTexec_status(current_TC, temp16);\ |
shreeshas95 | 4:104dd82c99b8 | 1154 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1155 | /*ABORT ON NACK AND TC LIST COMPLETED: UPDATE IN gMASTERSTATE*/\ |
shreeshas95 | 4:104dd82c99b8 | 1156 | if( (GETexec_status(current_TC) == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\ |
shreeshas95 | 4:104dd82c99b8 | 1157 | gMASTER_STATE = TCL_STATE_ABORTED;\ |
shreeshas95 | 4:104dd82c99b8 | 1158 | }\ |
shreeshas95 | 15:1c1ca992b43b | 1159 | else if( execute_psc == (gTOTAL_VALID_TC-1) ){\ |
shreeshas95 | 4:104dd82c99b8 | 1160 | /*LAST TC IS EXECUTED*/\ |
shreeshas95 | 4:104dd82c99b8 | 1161 | gMASTER_STATE = TCL_STATE_COMPLETED;\ |
shreeshas95 | 4:104dd82c99b8 | 1162 | }\ |
ee12b079 | 73:6c99294b7802 | 1163 | else{\ |
ee12b079 | 73:6c99294b7802 | 1164 | uint8_t check1 = 1;\ |
ee12b079 | 73:6c99294b7802 | 1165 | for( uint8_t test_psc = execute_psc+1 ; test_psc < gTOTAL_VALID_TC ; ++test_psc ){\ |
ee12b079 | 73:6c99294b7802 | 1166 | Base_tc* test_TC = gHEAD_NODE_TCL;\ |
ee12b079 | 73:6c99294b7802 | 1167 | while(test_TC != NULL){\ |
ee12b079 | 73:6c99294b7802 | 1168 | if( GETpacket_seq_count(test_TC) == test_psc ){\ |
ee12b079 | 73:6c99294b7802 | 1169 | uint8_t checkval;\ |
ee12b079 | 73:6c99294b7802 | 1170 | isit_obosc(test_TC, checkval);\ |
ee12b079 | 73:6c99294b7802 | 1171 | if( checkval == 0 ){\ |
ee12b079 | 73:6c99294b7802 | 1172 | check1 = 0;\ |
ee12b079 | 73:6c99294b7802 | 1173 | }\ |
ee12b079 | 73:6c99294b7802 | 1174 | }\ |
ee12b079 | 73:6c99294b7802 | 1175 | test_TC = test_TC->next_TC;\ |
ee12b079 | 73:6c99294b7802 | 1176 | }\ |
ee12b079 | 73:6c99294b7802 | 1177 | }\ |
ee12b079 | 73:6c99294b7802 | 1178 | if( check1 == 0x01 ){\ |
ee12b079 | 73:6c99294b7802 | 1179 | gMASTER_STATE = TCL_STATE_COMPLETED;\ |
ee12b079 | 73:6c99294b7802 | 1180 | }\ |
ee12b079 | 73:6c99294b7802 | 1181 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1182 | /*update last executed L1_ack*/\ |
shreeshas95 | 4:104dd82c99b8 | 1183 | if( put_tm_here != NULL ){\ |
shreeshas95 | 102:80c911a6e736 | 1184 | if( GETshort_or_long_tm(put_tm_here) == SHORT_TM_CODE ){\ |
shreeshas95 | 4:104dd82c99b8 | 1185 | for(int i = 0 ; i < TM_SHORT_SIZE ; ++i){\ |
shreeshas95 | 4:104dd82c99b8 | 1186 | gLAST_TM[i] = put_tm_here->TM_string[i];\ |
shreeshas95 | 4:104dd82c99b8 | 1187 | gLAST_TM_SHORT_OR_LONG = SHORT_TM_CODE;\ |
shreeshas95 | 4:104dd82c99b8 | 1188 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1189 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1190 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 1191 | for( int i = 0 ; i < TM_LONG_SIZE ; ++i ){\ |
shreeshas95 | 4:104dd82c99b8 | 1192 | gLAST_TM[i] = put_tm_here->TM_string[i];\ |
shreeshas95 | 4:104dd82c99b8 | 1193 | gLAST_TM_SHORT_OR_LONG = LONG_TM_CODE;\ |
shreeshas95 | 4:104dd82c99b8 | 1194 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1195 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1196 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1197 | /*PENDING: APPEND ACK L1*/\ |
shreeshas95 | 4:104dd82c99b8 | 1198 | Base_tm *tm_ptr = tm_ptr_head;\ |
shreeshas95 | 4:104dd82c99b8 | 1199 | get_ack_l1(tm_ptr->next_TM);\ |
shreeshas95 | 4:104dd82c99b8 | 1200 | int overflowCountExecute = 0;\ |
shreeshas95 | 4:104dd82c99b8 | 1201 | while( tm_ptr->next_TM != NULL ){\ |
shreeshas95 | 4:104dd82c99b8 | 1202 | if( overflowCountExecute < TM_OVERFLOW_CONSTANT ){\ |
shreeshas95 | 4:104dd82c99b8 | 1203 | tm_ptr = tm_ptr->next_TM;\ |
shreeshas95 | 4:104dd82c99b8 | 1204 | ++overflowCountExecute;\ |
shreeshas95 | 4:104dd82c99b8 | 1205 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1206 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 1207 | /*PENDING: RESET CDMS*/\ |
shreeshas95 | 4:104dd82c99b8 | 1208 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 1209 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1210 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1211 | tm_ptr->next_TM = put_tm_here;\ |
shreeshas95 | 4:104dd82c99b8 | 1212 | /*CHECK FOR HOT PA*/\ |
shreeshas95 | 4:104dd82c99b8 | 1213 | isPAhot(tempPAhot);\ |
shreeshas95 | 4:104dd82c99b8 | 1214 | if( tempPAhot == 0x00 ){\ |
shreeshas95 | 4:104dd82c99b8 | 1215 | gFLAGS = gFLAGS | COM_PA_HOT_FLAG;\ |
shreeshas95 | 4:104dd82c99b8 | 1216 | }\ |
ee12b079 | 73:6c99294b7802 | 1217 | tm_ptr = tm_ptr_head;\ |
ee12b079 | 73:6c99294b7802 | 1218 | while( tm_ptr != NULL ){\ |
ee12b079 | 73:6c99294b7802 | 1219 | int length = TM_SHORT_SIZE;\ |
shreeshas95 | 102:80c911a6e736 | 1220 | if( GETshort_or_long_tm(tm_ptr) == SHORT_TM_CODE ){\ |
ee12b079 | 73:6c99294b7802 | 1221 | length = TM_SHORT_SIZE;\ |
ee12b079 | 73:6c99294b7802 | 1222 | }\ |
ee12b079 | 73:6c99294b7802 | 1223 | else{\ |
ee12b079 | 73:6c99294b7802 | 1224 | length = TM_LONG_SIZE;\ |
ee12b079 | 73:6c99294b7802 | 1225 | }\ |
ee12b079 | 73:6c99294b7802 | 1226 | /*gPC.puts("Printing Call Sign, ACK_L1, TM list");*/\ |
ee12b079 | 73:6c99294b7802 | 1227 | for(int i = 0 ; i < length ; ++i){\ |
ee12b079 | 73:6c99294b7802 | 1228 | /*gPC.putc(tm_ptr->TM_string[i]);*/\ |
ee12b079 | 73:6c99294b7802 | 1229 | }\ |
ee12b079 | 73:6c99294b7802 | 1230 | tm_ptr = tm_ptr->next_TM;\ |
ee12b079 | 73:6c99294b7802 | 1231 | }\ |
ee12b079 | 80:b2155ba726c3 | 1232 | /*SEND call sign, ACK_L1, NON OBSRS TM TO GS*/\ |
ee12b079 | 95:42d6747900cb | 1233 | snd_tm.head_pointer(tm_ptr_head);\ |
ee12b079 | 98:fd99ddc0e0a1 | 1234 | gPC.puts("enter_adf\r\n");\ |
ee12b079 | 186:eb19a02f83d6 | 1235 | transmit_adf;\ |
ee12b079 | 98:fd99ddc0e0a1 | 1236 | gPC.puts("exit_adf\r\n");\ |
ee12b079 | 73:6c99294b7802 | 1237 | /*DELETE THE TM AFTER USE*/\ |
ee12b079 | 73:6c99294b7802 | 1238 | tm_ptr = tm_ptr_head;\ |
ee12b079 | 73:6c99294b7802 | 1239 | overflowCountExecute = 0;\ |
ee12b079 | 73:6c99294b7802 | 1240 | while(tm_ptr != NULL){\ |
ee12b079 | 73:6c99294b7802 | 1241 | if( overflowCountExecute < TM_OVERFLOW_CONSTANT ){\ |
ee12b079 | 73:6c99294b7802 | 1242 | Base_tm *temp = tm_ptr->next_TM;\ |
ee12b079 | 73:6c99294b7802 | 1243 | delete tm_ptr;\ |
ee12b079 | 73:6c99294b7802 | 1244 | tm_ptr = temp;\ |
ee12b079 | 73:6c99294b7802 | 1245 | ++overflowCountExecute;\ |
ee12b079 | 73:6c99294b7802 | 1246 | }\ |
ee12b079 | 73:6c99294b7802 | 1247 | else{\ |
ee12b079 | 73:6c99294b7802 | 1248 | /*PENDING: RESET CDMS*/\ |
ee12b079 | 73:6c99294b7802 | 1249 | break;\ |
ee12b079 | 73:6c99294b7802 | 1250 | }\ |
ee12b079 | 73:6c99294b7802 | 1251 | }\ |
shreeshas95 | 0:f016e9e8d48b | 1252 | }\ |
shreeshas95 | 0:f016e9e8d48b | 1253 | else{\ |
aniruddhv | 12:ffdb29353058 | 1254 | /*gPC.printf("sd card at %u\r\n", execute_psc);*/\ |
shreeshas95 | 4:104dd82c99b8 | 1255 | /*EXECUTION OF SD-CARD DATA SENDING (OBSRS)*/\ |
aniruddhv | 37:c9a739750806 | 1256 | Base_tm *tm_ptr_head = NULL;\ |
aniruddhv | 37:c9a739750806 | 1257 | get_call_sign(tm_ptr_head);\ |
aniruddhv | 37:c9a739750806 | 1258 | Base_tm *put_tm_here = NULL;\ |
aniruddhv | 37:c9a739750806 | 1259 | /*execute_obsrs(current_TC, put_tm_here)*/\ |
shreeshas95 | 4:104dd82c99b8 | 1260 | /*read_TC(current_TC);*/\ |
ee12b079 | 87:6e154fd43531 | 1261 | execute_OBSRS_TC(current_TC);\ |
ee12b079 | 171:31bdf83591a1 | 1262 | gPC.puts("enter_adf\r\n");\ |
ee12b079 | 186:eb19a02f83d6 | 1263 | transmit_adf;\ |
ee12b079 | 171:31bdf83591a1 | 1264 | gPC.puts("exit_adf\r\n");\ |
shreeshas95 | 6:79d422d1ed42 | 1265 | uint8_t tempExec = TC_STATE_SUCCESSFULLY_EXECUTED;\ |
shreeshas95 | 6:79d422d1ed42 | 1266 | PUTexec_status(current_TC, tempExec);\ |
ee12b079 | 73:6c99294b7802 | 1267 | /*PENDING: ABORT ON NACK CHECK, gMASTER_STATE VERIFICATION WITH SD CARD, session timeout, last executed ack l234*/\ |
shreeshas95 | 4:104dd82c99b8 | 1268 | if( (GETexec_status(current_TC) == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\ |
shreeshas95 | 4:104dd82c99b8 | 1269 | gMASTER_STATE = TCL_STATE_ABORTED;\ |
shreeshas95 | 0:f016e9e8d48b | 1270 | }\ |
shreeshas95 | 15:1c1ca992b43b | 1271 | else if( execute_psc == (gTOTAL_VALID_TC-1) ){\ |
shreeshas95 | 6:79d422d1ed42 | 1272 | gMASTER_STATE = TCL_STATE_COMPLETED;\ |
shreeshas95 | 6:79d422d1ed42 | 1273 | }\ |
ee12b079 | 73:6c99294b7802 | 1274 | else{\ |
ee12b079 | 73:6c99294b7802 | 1275 | uint8_t check1 = 1;\ |
ee12b079 | 73:6c99294b7802 | 1276 | for( uint8_t test_psc = execute_psc+1 ; test_psc < gTOTAL_VALID_TC ; ++test_psc ){\ |
ee12b079 | 73:6c99294b7802 | 1277 | Base_tc* test_TC = gHEAD_NODE_TCL;\ |
ee12b079 | 73:6c99294b7802 | 1278 | while(test_TC != NULL){\ |
ee12b079 | 73:6c99294b7802 | 1279 | if( GETpacket_seq_count(test_TC) == test_psc ){\ |
ee12b079 | 73:6c99294b7802 | 1280 | uint8_t checkval;\ |
ee12b079 | 73:6c99294b7802 | 1281 | isit_obosc(test_TC, checkval);\ |
ee12b079 | 73:6c99294b7802 | 1282 | if( checkval == 0 ){\ |
ee12b079 | 73:6c99294b7802 | 1283 | check1 = 0;\ |
ee12b079 | 73:6c99294b7802 | 1284 | }\ |
ee12b079 | 73:6c99294b7802 | 1285 | }\ |
ee12b079 | 73:6c99294b7802 | 1286 | test_TC = test_TC->next_TC;\ |
ee12b079 | 73:6c99294b7802 | 1287 | }\ |
ee12b079 | 73:6c99294b7802 | 1288 | }\ |
ee12b079 | 73:6c99294b7802 | 1289 | if( check1 == 0x01 ){\ |
ee12b079 | 73:6c99294b7802 | 1290 | gMASTER_STATE = TCL_STATE_COMPLETED;\ |
ee12b079 | 73:6c99294b7802 | 1291 | }\ |
ee12b079 | 73:6c99294b7802 | 1292 | }\ |
ee12b079 | 73:6c99294b7802 | 1293 | /*update last executed L1_ack*/\ |
ee12b079 | 73:6c99294b7802 | 1294 | if( put_tm_here != NULL ){\ |
shreeshas95 | 102:80c911a6e736 | 1295 | if( GETshort_or_long_tm(put_tm_here) == SHORT_TM_CODE ){\ |
ee12b079 | 73:6c99294b7802 | 1296 | for(int i = 0 ; i < TM_SHORT_SIZE ; ++i){\ |
ee12b079 | 73:6c99294b7802 | 1297 | gLAST_TM[i] = put_tm_here->TM_string[i];\ |
ee12b079 | 73:6c99294b7802 | 1298 | gLAST_TM_SHORT_OR_LONG = SHORT_TM_CODE;\ |
ee12b079 | 73:6c99294b7802 | 1299 | }\ |
ee12b079 | 73:6c99294b7802 | 1300 | }\ |
ee12b079 | 73:6c99294b7802 | 1301 | else{\ |
ee12b079 | 73:6c99294b7802 | 1302 | for( int i = 0 ; i < TM_LONG_SIZE ; ++i ){\ |
ee12b079 | 73:6c99294b7802 | 1303 | gLAST_TM[i] = put_tm_here->TM_string[i];\ |
ee12b079 | 73:6c99294b7802 | 1304 | gLAST_TM_SHORT_OR_LONG = LONG_TM_CODE;\ |
ee12b079 | 73:6c99294b7802 | 1305 | }\ |
ee12b079 | 73:6c99294b7802 | 1306 | }\ |
ee12b079 | 73:6c99294b7802 | 1307 | }\ |
rohit3342 | 44:b9b067d0559f | 1308 | /*PENDING: APPEND ACK L1*/\ |
rohit3342 | 44:b9b067d0559f | 1309 | Base_tm *tm_ptr = tm_ptr_head;\ |
rohit3342 | 44:b9b067d0559f | 1310 | get_ack_l1(tm_ptr->next_TM);\ |
rohit3342 | 44:b9b067d0559f | 1311 | int overflowCountExecute = 0;\ |
rohit3342 | 44:b9b067d0559f | 1312 | while( tm_ptr->next_TM != NULL ){\ |
rohit3342 | 44:b9b067d0559f | 1313 | if( overflowCountExecute < TM_OVERFLOW_CONSTANT ){\ |
rohit3342 | 44:b9b067d0559f | 1314 | tm_ptr = tm_ptr->next_TM;\ |
rohit3342 | 44:b9b067d0559f | 1315 | ++overflowCountExecute;\ |
rohit3342 | 44:b9b067d0559f | 1316 | }\ |
rohit3342 | 44:b9b067d0559f | 1317 | else{\ |
rohit3342 | 44:b9b067d0559f | 1318 | /*PENDING: RESET CDMS*/\ |
rohit3342 | 44:b9b067d0559f | 1319 | break;\ |
rohit3342 | 44:b9b067d0559f | 1320 | }\ |
rohit3342 | 44:b9b067d0559f | 1321 | }\ |
rohit3342 | 44:b9b067d0559f | 1322 | tm_ptr->next_TM = put_tm_here;\ |
rohit3342 | 44:b9b067d0559f | 1323 | /*CHECK FOR HOT PA*/\ |
rohit3342 | 44:b9b067d0559f | 1324 | uint8_t tempPAhot = 0x00;\ |
rohit3342 | 44:b9b067d0559f | 1325 | isPAhot(tempPAhot);\ |
rohit3342 | 44:b9b067d0559f | 1326 | if( tempPAhot == 0x00 ){\ |
rohit3342 | 44:b9b067d0559f | 1327 | gFLAGS = gFLAGS | COM_PA_HOT_FLAG;\ |
rohit3342 | 44:b9b067d0559f | 1328 | }\ |
ee12b079 | 73:6c99294b7802 | 1329 | tm_ptr = tm_ptr_head;\ |
ee12b079 | 73:6c99294b7802 | 1330 | while( tm_ptr != NULL ){\ |
ee12b079 | 73:6c99294b7802 | 1331 | int length = TM_SHORT_SIZE;\ |
shreeshas95 | 102:80c911a6e736 | 1332 | if( GETshort_or_long_tm(tm_ptr) == SHORT_TM_CODE ){\ |
ee12b079 | 73:6c99294b7802 | 1333 | length = TM_SHORT_SIZE;\ |
ee12b079 | 73:6c99294b7802 | 1334 | }\ |
ee12b079 | 73:6c99294b7802 | 1335 | else{\ |
ee12b079 | 73:6c99294b7802 | 1336 | length = TM_LONG_SIZE;\ |
ee12b079 | 73:6c99294b7802 | 1337 | }\ |
ee12b079 | 73:6c99294b7802 | 1338 | /*gPC.puts("Printing Call Sign, ACK_L1, TM list");*/\ |
ee12b079 | 73:6c99294b7802 | 1339 | for(int i = 0 ; i < length ; ++i){\ |
ee12b079 | 73:6c99294b7802 | 1340 | /*gPC.putc(tm_ptr->TM_string[i]);*/\ |
ee12b079 | 73:6c99294b7802 | 1341 | }\ |
ee12b079 | 73:6c99294b7802 | 1342 | tm_ptr = tm_ptr->next_TM;\ |
ee12b079 | 73:6c99294b7802 | 1343 | }\ |
ee12b079 | 80:b2155ba726c3 | 1344 | /*SEND call sign, ACK_L1, OBSRS TO GS*/\ |
ee12b079 | 73:6c99294b7802 | 1345 | /*snd_tm.head_pointer(tm_ptr_head);*/\ |
ee12b079 | 73:6c99294b7802 | 1346 | /*adf_SDcard();*/\ |
ee12b079 | 73:6c99294b7802 | 1347 | /*DELETE THE TM AFTER USE*/\ |
ee12b079 | 73:6c99294b7802 | 1348 | tm_ptr = tm_ptr_head;\ |
ee12b079 | 73:6c99294b7802 | 1349 | overflowCountExecute = 0;\ |
ee12b079 | 73:6c99294b7802 | 1350 | while(tm_ptr != NULL){\ |
ee12b079 | 73:6c99294b7802 | 1351 | if( overflowCountExecute < TM_OVERFLOW_CONSTANT ){\ |
ee12b079 | 73:6c99294b7802 | 1352 | Base_tm *temp = tm_ptr->next_TM;\ |
ee12b079 | 73:6c99294b7802 | 1353 | delete tm_ptr;\ |
ee12b079 | 73:6c99294b7802 | 1354 | tm_ptr = temp;\ |
ee12b079 | 73:6c99294b7802 | 1355 | ++overflowCountExecute;\ |
ee12b079 | 73:6c99294b7802 | 1356 | }\ |
ee12b079 | 73:6c99294b7802 | 1357 | else{\ |
ee12b079 | 73:6c99294b7802 | 1358 | /*PENDING: RESET CDMS*/\ |
ee12b079 | 73:6c99294b7802 | 1359 | break;\ |
ee12b079 | 73:6c99294b7802 | 1360 | }\ |
ee12b079 | 73:6c99294b7802 | 1361 | }\ |
shreeshas95 | 0:f016e9e8d48b | 1362 | }\ |
shreeshas95 | 0:f016e9e8d48b | 1363 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1364 | break;\ |
shreeshas95 | 0:f016e9e8d48b | 1365 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1366 | current_TC = current_TC->next_TC;\ |
shreeshas95 | 4:104dd82c99b8 | 1367 | ++overflowCount;\ |
shreeshas95 | 0:f016e9e8d48b | 1368 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1369 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 1370 | /*PENDING: RESET CDMS*/\ |
shreeshas95 | 2:2caf2a9a13aa | 1371 | break;\ |
shreeshas95 | 2:2caf2a9a13aa | 1372 | }\ |
shreeshas95 | 2:2caf2a9a13aa | 1373 | }\ |
shreeshas95 | 6:79d422d1ed42 | 1374 | if( gFLAGS & COM_SESSION_TIMEOUT_FLAG ){\ |
shreeshas95 | 6:79d422d1ed42 | 1375 | break;\ |
shreeshas95 | 6:79d422d1ed42 | 1376 | }\ |
shreeshas95 | 6:79d422d1ed42 | 1377 | else if( gMASTER_STATE == TCL_STATE_ABORTED ){\ |
aniruddhv | 12:ffdb29353058 | 1378 | /*gPC.puts("ABORTING DUE TO ABORT ON NACK\r\n");*/\ |
shreeshas95 | 4:104dd82c99b8 | 1379 | /*EXITED DUE TO ABORT ON NACK:*/\ |
shreeshas95 | 2:2caf2a9a13aa | 1380 | /*PENDING : POWER OFF COM TX*/\ |
shreeshas95 | 2:2caf2a9a13aa | 1381 | RX1M.attach(&rx_read, Serial::RxIrq);\ |
shreeshas95 | 2:2caf2a9a13aa | 1382 | gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\ |
shreeshas95 | 0:f016e9e8d48b | 1383 | break;\ |
shreeshas95 | 2:2caf2a9a13aa | 1384 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1385 | else if( gFLAGS & COM_PA_HOT_FLAG ){\ |
shreeshas95 | 4:104dd82c99b8 | 1386 | /*PA HOT: WAIT FOR TIMEOUT*/\ |
shreeshas95 | 4:104dd82c99b8 | 1387 | gCOM_PA_COOLING_TIMEOUT.attach(&after_cooling_pa, COM_PA_COOLING_TIME_LIMIT);\ |
shreeshas95 | 4:104dd82c99b8 | 1388 | /*PENDING : POWER OFF COMM TX*/\ |
shreeshas95 | 4:104dd82c99b8 | 1389 | RX1M.attach(&rx_read, Serial::RxIrq);\ |
shreeshas95 | 4:104dd82c99b8 | 1390 | gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\ |
shreeshas95 | 2:2caf2a9a13aa | 1391 | break;\ |
shreeshas95 | 2:2caf2a9a13aa | 1392 | }\ |
aniruddhv | 12:ffdb29353058 | 1393 | /*gPC.printf("successflly executed %u tc\r\n", execute_psc);*/\ |
shreeshas95 | 0:f016e9e8d48b | 1394 | }\ |
shreeshas95 | 6:79d422d1ed42 | 1395 | if( (gMASTER_STATE == TCL_STATE_COMPLETED) || (gFLAGS & COM_SESSION_TIMEOUT_FLAG) ){\ |
aniruddhv | 12:ffdb29353058 | 1396 | /*gPC.printf("completed or session timed out: %x\r\n", gMASTER_STATE);*/\ |
shreeshas95 | 5:ab276a17ca07 | 1397 | /*COMPLETED EXECUTION OF TC*/\ |
shreeshas95 | 5:ab276a17ca07 | 1398 | gMASTER_STATE = TCL_STATE_COMPLETED;\ |
shreeshas95 | 5:ab276a17ca07 | 1399 | COM_POWER_OFF_TX;\ |
shreeshas95 | 5:ab276a17ca07 | 1400 | reset_all;\ |
shreeshas95 | 5:ab276a17ca07 | 1401 | /*PENDING : ENABLE THREADS*/\ |
shreeshas95 | 5:ab276a17ca07 | 1402 | gSESSION_TIMEOUT.detach();\ |
shreeshas95 | 5:ab276a17ca07 | 1403 | gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\ |
shreeshas95 | 5:ab276a17ca07 | 1404 | gFLAGS = gFLAGS & (~COM_SESSION_FLAG);\ |
ee12b079 | 182:8b73c010286b | 1405 | gPC.puts("end\r\n");\ |
shreeshas95 | 5:ab276a17ca07 | 1406 | }\ |
shreeshas95 | 0:f016e9e8d48b | 1407 | } |