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