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