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