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