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