DMA issue to be tested
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE by
COM_MNG_TMTC.h@49:1103da5a87f5, 2016-01-13 (annotated)
- Committer:
- Shashank7906
- Date:
- Wed Jan 13 14:19:47 2016 +0000
- Revision:
- 49:1103da5a87f5
- Parent:
- 43:4bc440bbad2f
Added the null assignments before returning the tm_ptr
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" |
Shashank7906 | 42:b7a4aac53314 | 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 | |
shreeshas95 | 0:f016e9e8d48b | 424 | // CDMS TEAM CODE START |
ee12b079 | 35:3beac900a034 | 425 | inline Base_tm* FCTN_CDMS_RLY_TMTC(Base_tc *tc_ptr){ |
Shashank7906 | 49:1103da5a87f5 | 426 | // CDMS TEAM CODE START ( |
Shashank7906 | 49:1103da5a87f5 | 427 | |
Shashank7906 | 49:1103da5a87f5 | 428 | inline Base_tm* FCTN_CDMS_RLY_TMTC(Base_tc *tc_ptr){ |
ee12b079 | 35:3beac900a034 | 429 | uint8_t ACKCODE = 0x00; |
ee12b079 | 35:3beac900a034 | 430 | printf("\rTC execution in progress\r\n"); |
Shashank7906 | 41:7e06018f6a1c | 431 | Base_tm *tm_pointer = new Long_tm; |
Shashank7906 | 41:7e06018f6a1c | 432 | Base_tm *tm_ptr = tm_pointer; |
ee12b079 | 35:3beac900a034 | 433 | received = 0; |
ee12b079 | 35:3beac900a034 | 434 | switch(GETapid(tc_ptr)) |
ee12b079 | 35:3beac900a034 | 435 | { |
ee12b079 | 35:3beac900a034 | 436 | case 1: //apid=01 implies it corresponds to bae |
ee12b079 | 35:3beac900a034 | 437 | { |
ee12b079 | 35:3beac900a034 | 438 | printf("Telecommand is for BAE\r\n"); |
ee12b079 | 35:3beac900a034 | 439 | printf("Sending TC to BAE...\r\n"); //interrupt to be sent to the bae |
ee12b079 | 35:3beac900a034 | 440 | FCTN_I2C_WRITE((char*)tc_ptr->TC_string); |
ee12b079 | 35:3beac900a034 | 441 | while(1) |
ee12b079 | 35:3beac900a034 | 442 | { |
ee12b079 | 35:3beac900a034 | 443 | wait(1); //TimeOut instead of wait |
ee12b079 | 35:3beac900a034 | 444 | if(tm_status_4m_slv == 1) |
ee12b079 | 35:3beac900a034 | 445 | { |
ee12b079 | 35:3beac900a034 | 446 | printf("receiving...\r\n"); |
ee12b079 | 35:3beac900a034 | 447 | FCTN_I2C_READ((char*)tm_pointer->TM_string); |
ee12b079 | 35:3beac900a034 | 448 | //printf("%s", tm_pointer->TM_string); |
ee12b079 | 35:3beac900a034 | 449 | received+=1; |
ee12b079 | 35:3beac900a034 | 450 | tm_pointer = tm_pointer->next_TM; |
ee12b079 | 35:3beac900a034 | 451 | break; //only for testing purpose |
ee12b079 | 35:3beac900a034 | 452 | } |
ee12b079 | 35:3beac900a034 | 453 | else |
ee12b079 | 35:3beac900a034 | 454 | { |
ee12b079 | 35:3beac900a034 | 455 | break; |
ee12b079 | 35:3beac900a034 | 456 | } |
ee12b079 | 35:3beac900a034 | 457 | } |
ee12b079 | 35:3beac900a034 | 458 | if(received >= 1 ) |
ee12b079 | 35:3beac900a034 | 459 | { |
ee12b079 | 35:3beac900a034 | 460 | printf("Telemetry is received from BAE\r\n"); |
ee12b079 | 35:3beac900a034 | 461 | Base_tm *tm_print = tm_ptr; |
ee12b079 | 35:3beac900a034 | 462 | for(uint8_t i=0;i<received;i++) |
ee12b079 | 35:3beac900a034 | 463 | { |
ee12b079 | 35:3beac900a034 | 464 | printf("%s", tm_print->TM_string); |
ee12b079 | 35:3beac900a034 | 465 | tm_print = tm_print->next_TM; //for check |
ee12b079 | 35:3beac900a034 | 466 | } |
ee12b079 | 35:3beac900a034 | 467 | received = 0; |
Shashank7906 | 49:1103da5a87f5 | 468 | tm_pointer->next_TM = NULL; return tm_ptr; |
ee12b079 | 35:3beac900a034 | 469 | } |
ee12b079 | 35:3beac900a034 | 470 | else |
ee12b079 | 35:3beac900a034 | 471 | { |
ee12b079 | 35:3beac900a034 | 472 | printf("Telemetry is not received from BAE\r\n"); |
Shashank7906 | 49:1103da5a87f5 | 473 | tm_pointer = new Short_tm; |
ee12b079 | 35:3beac900a034 | 474 | tm_pointer->TM_string[0] = 0xB0; |
ee12b079 | 35:3beac900a034 | 475 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
ee12b079 | 35:3beac900a034 | 476 | tm_pointer->TM_string[2] = 0x01; |
ee12b079 | 35:3beac900a034 | 477 | tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided |
ee12b079 | 35:3beac900a034 | 478 | tm_pointer->TM_string[4] = 0x01; |
ee12b079 | 35:3beac900a034 | 479 | for(uint8_t i=0;i<6;i++) |
ee12b079 | 35:3beac900a034 | 480 | { |
ee12b079 | 35:3beac900a034 | 481 | tm_pointer->TM_string[i+5] = 0; |
ee12b079 | 35:3beac900a034 | 482 | } |
ee12b079 | 35:3beac900a034 | 483 | crc16 = crc16_gen(tm_ptr->TM_string,11); |
ee12b079 | 35:3beac900a034 | 484 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
ee12b079 | 35:3beac900a034 | 485 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 486 | tm_pointer->next_TM = NULL; |
ee12b079 | 35:3beac900a034 | 487 | return tm_ptr; |
ee12b079 | 35:3beac900a034 | 488 | } |
ee12b079 | 35:3beac900a034 | 489 | break; |
ee12b079 | 35:3beac900a034 | 490 | } |
ee12b079 | 35:3beac900a034 | 491 | case 2: |
ee12b079 | 35:3beac900a034 | 492 | { |
ee12b079 | 35:3beac900a034 | 493 | printf("Telecommand is for CDMS\r\n"); //apid = 10 corresponds to cdms |
ee12b079 | 35:3beac900a034 | 494 | switch(GETservice_type(tc_ptr)) |
ee12b079 | 35:3beac900a034 | 495 | { |
ee12b079 | 35:3beac900a034 | 496 | case 0x60: |
ee12b079 | 35:3beac900a034 | 497 | { |
Shashank7906 | 49:1103da5a87f5 | 498 | printf("service:MMS\r\n"); |
Shashank7906 | 49:1103da5a87f5 | 499 | switch(GETservice_subtype(tc_ptr)) |
Shashank7906 | 49:1103da5a87f5 | 500 | { |
Shashank7906 | 49:1103da5a87f5 | 501 | case 0x1: |
ee12b079 | 35:3beac900a034 | 502 | { |
ee12b079 | 35:3beac900a034 | 503 | printf("sub_service:Read from RAM_Memory\r\n"); |
ee12b079 | 35:3beac900a034 | 504 | mid=(uint16_t)(tc_ptr->TC_string[3]<<4)+(uint16_t)(tc_ptr->TC_string[4]); |
Shashank7906 | 49:1103da5a87f5 | 505 | |
Shashank7906 | 49:1103da5a87f5 | 506 | Data[0] = FCTN_CDMS_RD_FLASH(0); |
Shashank7906 | 49:1103da5a87f5 | 507 | Data[1] = FCTN_CDMS_RD_FLASH(1); |
Shashank7906 | 49:1103da5a87f5 | 508 | tm_pointer = new Long_tm; |
Shashank7906 | 49:1103da5a87f5 | 509 | tm_pointer->TM_string[0] = 0x30; |
Shashank7906 | 49:1103da5a87f5 | 510 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
Shashank7906 | 49:1103da5a87f5 | 511 | tm_pointer->TM_string[2] = (uint8_t)(flash_counter); |
Shashank7906 | 49:1103da5a87f5 | 512 | for(uint8_t i=0;i<4;i++) |
ee12b079 | 35:3beac900a034 | 513 | { |
Shashank7906 | 49:1103da5a87f5 | 514 | tm_pointer->TM_string[3+i] = (uint8_t)((Data[0]>>(8*i))&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 515 | } |
Shashank7906 | 49:1103da5a87f5 | 516 | for(uint8_t i=4;i<8;i++) |
Shashank7906 | 49:1103da5a87f5 | 517 | { |
Shashank7906 | 49:1103da5a87f5 | 518 | tm_pointer->TM_string[3+i] = (uint8_t)((Data[1]>>(8*i))&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 519 | } |
Shashank7906 | 49:1103da5a87f5 | 520 | crc16 = crc16_gen(tm_ptr->TM_string,9); |
Shashank7906 | 49:1103da5a87f5 | 521 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
Shashank7906 | 49:1103da5a87f5 | 522 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 523 | tm_pointer->next_TM = NULL; return tm_ptr; |
Shashank7906 | 49:1103da5a87f5 | 524 | } |
Shashank7906 | 49:1103da5a87f5 | 525 | case 0x2: |
Shashank7906 | 49:1103da5a87f5 | 526 | { |
ee12b079 | 35:3beac900a034 | 527 | printf("sub_service:Read from Flash_Memory\r\n"); |
ee12b079 | 35:3beac900a034 | 528 | mid=(uint16_t)(tc_ptr->TC_string[3]<<4)+(uint16_t)(tc_ptr->TC_string[4]); |
Shashank7906 | 49:1103da5a87f5 | 529 | |
Shashank7906 | 49:1103da5a87f5 | 530 | Data[0] = FCTN_CDMS_RD_FLASH(0); |
Shashank7906 | 49:1103da5a87f5 | 531 | Data[1] = FCTN_CDMS_RD_FLASH(1); |
Shashank7906 | 49:1103da5a87f5 | 532 | tm_pointer = new Long_tm; |
Shashank7906 | 49:1103da5a87f5 | 533 | //tm_pointer = new Long_tm; |
Shashank7906 | 49:1103da5a87f5 | 534 | tm_pointer->TM_string[0] = 0x30; |
Shashank7906 | 49:1103da5a87f5 | 535 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
Shashank7906 | 49:1103da5a87f5 | 536 | tm_pointer->TM_string[2] = (uint8_t)(flash_counter); |
Shashank7906 | 49:1103da5a87f5 | 537 | for(uint8_t i=0;i<4;i++) |
ee12b079 | 35:3beac900a034 | 538 | { |
Shashank7906 | 49:1103da5a87f5 | 539 | tm_pointer->TM_string[3+i] = (uint8_t)((Data[0]>>(8*i))&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 540 | } |
Shashank7906 | 49:1103da5a87f5 | 541 | for(uint8_t i=4;i<8;i++) |
Shashank7906 | 49:1103da5a87f5 | 542 | { |
Shashank7906 | 49:1103da5a87f5 | 543 | tm_pointer->TM_string[3+i] = (uint8_t)((Data[1]>>(8*i))&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 544 | } |
Shashank7906 | 49:1103da5a87f5 | 545 | crc16 = crc16_gen(tm_ptr->TM_string,9); |
Shashank7906 | 49:1103da5a87f5 | 546 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
Shashank7906 | 49:1103da5a87f5 | 547 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 548 | tm_pointer->next_TM = NULL; return tm_ptr; |
Shashank7906 | 49:1103da5a87f5 | 549 | } |
Shashank7906 | 49:1103da5a87f5 | 550 | case 0x5: |
Shashank7906 | 49:1103da5a87f5 | 551 | { |
ee12b079 | 35:3beac900a034 | 552 | printf("WRITE ON FLASH_MEMORY\r\n"); |
Shashank7906 | 49:1103da5a87f5 | 553 | mid=(uint16_t)(tc_ptr->TC_string[3]<<4)+(uint16_t)(tc_ptr->TC_string[4]); |
Shashank7906 | 49:1103da5a87f5 | 554 | 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]))); |
Shashank7906 | 49:1103da5a87f5 | 555 | FCTN_CDMS_WR_FLASH(mid,block); |
Shashank7906 | 49:1103da5a87f5 | 556 | tm_pointer = new Short_tm; |
Shashank7906 | 49:1103da5a87f5 | 557 | tm_pointer->TM_string[0] = 0xB0; |
Shashank7906 | 49:1103da5a87f5 | 558 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
Shashank7906 | 49:1103da5a87f5 | 559 | tm_pointer->TM_string[2] = 0x01; |
Shashank7906 | 49:1103da5a87f5 | 560 | tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided |
Shashank7906 | 49:1103da5a87f5 | 561 | tm_pointer->TM_string[4] = 0x01; |
Shashank7906 | 49:1103da5a87f5 | 562 | for(uint8_t i=0;i<6;i++) |
Shashank7906 | 49:1103da5a87f5 | 563 | { |
Shashank7906 | 49:1103da5a87f5 | 564 | tm_pointer->TM_string[i+5] = 0; |
Shashank7906 | 49:1103da5a87f5 | 565 | } |
Shashank7906 | 49:1103da5a87f5 | 566 | crc16 = crc16_gen(tm_ptr->TM_string,11); |
Shashank7906 | 49:1103da5a87f5 | 567 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
Shashank7906 | 49:1103da5a87f5 | 568 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 569 | tm_pointer->next_TM = NULL; return tm_ptr; |
Shashank7906 | 49:1103da5a87f5 | 570 | break; |
Shashank7906 | 49:1103da5a87f5 | 571 | } |
Shashank7906 | 49:1103da5a87f5 | 572 | default: |
Shashank7906 | 49:1103da5a87f5 | 573 | { |
Shashank7906 | 49:1103da5a87f5 | 574 | printf("INVALID TC\r\n"); //Send Invalid TC Telemetry |
Shashank7906 | 49:1103da5a87f5 | 575 | tm_pointer = new Short_tm; |
Shashank7906 | 49:1103da5a87f5 | 576 | tm_pointer->TM_string[0] = 0xB0; |
Shashank7906 | 49:1103da5a87f5 | 577 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
Shashank7906 | 49:1103da5a87f5 | 578 | tm_pointer->TM_string[2] = 0x01; |
Shashank7906 | 49:1103da5a87f5 | 579 | tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided |
Shashank7906 | 49:1103da5a87f5 | 580 | tm_pointer->TM_string[4] = 0x01; |
Shashank7906 | 49:1103da5a87f5 | 581 | for(uint8_t i=0;i<6;i++) |
Shashank7906 | 49:1103da5a87f5 | 582 | { |
Shashank7906 | 49:1103da5a87f5 | 583 | tm_pointer->TM_string[i+5] = 0; |
Shashank7906 | 49:1103da5a87f5 | 584 | } |
Shashank7906 | 49:1103da5a87f5 | 585 | crc16 = crc16_gen(tm_ptr->TM_string,11); |
Shashank7906 | 49:1103da5a87f5 | 586 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
Shashank7906 | 49:1103da5a87f5 | 587 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 588 | tm_pointer->next_TM = NULL; return tm_ptr; |
Shashank7906 | 49:1103da5a87f5 | 589 | } |
Shashank7906 | 49:1103da5a87f5 | 590 | break; |
Shashank7906 | 49:1103da5a87f5 | 591 | } |
Shashank7906 | 49:1103da5a87f5 | 592 | } |
Shashank7906 | 49:1103da5a87f5 | 593 | case 0x8: |
Shashank7906 | 49:1103da5a87f5 | 594 | { |
Shashank7906 | 49:1103da5a87f5 | 595 | printf("service:FUNCTION MANAGEMENT SERVICE\r\n"); |
Shashank7906 | 49:1103da5a87f5 | 596 | if(GETservice_subtype(tc_ptr)==0x1) |
Shashank7906 | 49:1103da5a87f5 | 597 | { |
Shashank7906 | 49:1103da5a87f5 | 598 | if(GETpid(tc_ptr)==0x01) |
Shashank7906 | 49:1103da5a87f5 | 599 | { |
Shashank7906 | 49:1103da5a87f5 | 600 | printf("TC_PL_INIT\r\n"); // call PWR_SWCH_ON function |
Shashank7906 | 49:1103da5a87f5 | 601 | tm_pointer = new Short_tm; |
Shashank7906 | 49:1103da5a87f5 | 602 | tm_pointer->TM_string[0] = 0xB0; |
Shashank7906 | 49:1103da5a87f5 | 603 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
Shashank7906 | 49:1103da5a87f5 | 604 | tm_pointer->TM_string[2] = ACKCODE; |
Shashank7906 | 49:1103da5a87f5 | 605 | for(uint8_t i=3;i<11;i++) |
Shashank7906 | 49:1103da5a87f5 | 606 | { |
Shashank7906 | 49:1103da5a87f5 | 607 | tm_pointer->TM_string[i] = 0; |
Shashank7906 | 49:1103da5a87f5 | 608 | } |
Shashank7906 | 49:1103da5a87f5 | 609 | crc16 = crc16_gen(tm_ptr->TM_string,11); |
Shashank7906 | 49:1103da5a87f5 | 610 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
Shashank7906 | 49:1103da5a87f5 | 611 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 612 | tm_pointer->next_TM = NULL; return tm_ptr; |
Shashank7906 | 49:1103da5a87f5 | 613 | break; |
Shashank7906 | 49:1103da5a87f5 | 614 | } |
Shashank7906 | 49:1103da5a87f5 | 615 | else if(GETpid(tc_ptr)==0x02) |
Shashank7906 | 49:1103da5a87f5 | 616 | { |
Shashank7906 | 49:1103da5a87f5 | 617 | printf("TC_PL_MAIN\r\n"); // call PWR_SWCH_ON function |
Shashank7906 | 49:1103da5a87f5 | 618 | tm_pointer = new Short_tm; |
Shashank7906 | 49:1103da5a87f5 | 619 | tm_pointer->TM_string[0] = 0xB0; |
Shashank7906 | 49:1103da5a87f5 | 620 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
Shashank7906 | 49:1103da5a87f5 | 621 | tm_pointer->TM_string[2] = ACKCODE; |
Shashank7906 | 49:1103da5a87f5 | 622 | for(uint8_t i=3;i<11;i++) |
Shashank7906 | 49:1103da5a87f5 | 623 | { |
Shashank7906 | 49:1103da5a87f5 | 624 | tm_pointer->TM_string[i] = 0; |
Shashank7906 | 49:1103da5a87f5 | 625 | } |
Shashank7906 | 49:1103da5a87f5 | 626 | crc16 = crc16_gen(tm_ptr->TM_string,11); |
Shashank7906 | 49:1103da5a87f5 | 627 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
Shashank7906 | 49:1103da5a87f5 | 628 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 629 | tm_pointer->next_TM = NULL; return tm_ptr; |
Shashank7906 | 49:1103da5a87f5 | 630 | break; |
Shashank7906 | 49:1103da5a87f5 | 631 | } |
Shashank7906 | 49:1103da5a87f5 | 632 | else if(GETpid(tc_ptr)==0x03) |
Shashank7906 | 49:1103da5a87f5 | 633 | { |
Shashank7906 | 49:1103da5a87f5 | 634 | printf("TC_COM_INIT\r\n"); // call PWR_SWCH_ON function |
Shashank7906 | 49:1103da5a87f5 | 635 | tm_pointer = new Short_tm; |
Shashank7906 | 49:1103da5a87f5 | 636 | tm_pointer->TM_string[0] = 0xB0; |
Shashank7906 | 49:1103da5a87f5 | 637 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
Shashank7906 | 49:1103da5a87f5 | 638 | tm_pointer->TM_string[2] = ACKCODE; |
Shashank7906 | 49:1103da5a87f5 | 639 | for(uint8_t i=3;i<11;i++) |
ee12b079 | 35:3beac900a034 | 640 | { |
Shashank7906 | 49:1103da5a87f5 | 641 | tm_pointer->TM_string[i] = 0; |
Shashank7906 | 49:1103da5a87f5 | 642 | } |
Shashank7906 | 49:1103da5a87f5 | 643 | crc16 = crc16_gen(tm_ptr->TM_string,11); |
Shashank7906 | 49:1103da5a87f5 | 644 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
Shashank7906 | 49:1103da5a87f5 | 645 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 646 | tm_pointer->next_TM = NULL; return tm_ptr; |
Shashank7906 | 49:1103da5a87f5 | 647 | break; |
Shashank7906 | 49:1103da5a87f5 | 648 | } |
Shashank7906 | 49:1103da5a87f5 | 649 | else if(GETpid(tc_ptr)==0x04) |
Shashank7906 | 49:1103da5a87f5 | 650 | { |
Shashank7906 | 49:1103da5a87f5 | 651 | printf("TC_CDMS_HK_MAIN\r\n"); // call PWR_SWCH_ON function |
Shashank7906 | 49:1103da5a87f5 | 652 | tm_pointer = new Short_tm; |
Shashank7906 | 49:1103da5a87f5 | 653 | tm_pointer->TM_string[0] = 0xB0; |
Shashank7906 | 49:1103da5a87f5 | 654 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
Shashank7906 | 49:1103da5a87f5 | 655 | tm_pointer->TM_string[2] = ACKCODE; |
Shashank7906 | 49:1103da5a87f5 | 656 | for(uint8_t i=3;i<11;i++) |
Shashank7906 | 49:1103da5a87f5 | 657 | { |
Shashank7906 | 49:1103da5a87f5 | 658 | tm_pointer->TM_string[i] = 0; |
Shashank7906 | 49:1103da5a87f5 | 659 | } |
Shashank7906 | 49:1103da5a87f5 | 660 | crc16 = crc16_gen(tm_ptr->TM_string,11); |
Shashank7906 | 49:1103da5a87f5 | 661 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
Shashank7906 | 49:1103da5a87f5 | 662 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 663 | tm_pointer->next_TM = NULL; return tm_ptr; |
Shashank7906 | 49:1103da5a87f5 | 664 | break; |
Shashank7906 | 49:1103da5a87f5 | 665 | } |
Shashank7906 | 49:1103da5a87f5 | 666 | else if(GETpid(tc_ptr)==0x11) |
Shashank7906 | 49:1103da5a87f5 | 667 | { |
Shashank7906 | 49:1103da5a87f5 | 668 | printf("TC_SW_ON_SD\r\n"); // call PWR_SWCH_ON function |
Shashank7906 | 49:1103da5a87f5 | 669 | tm_pointer = new Short_tm; |
Shashank7906 | 49:1103da5a87f5 | 670 | tm_pointer->TM_string[0] = 0xB0; |
Shashank7906 | 49:1103da5a87f5 | 671 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
Shashank7906 | 49:1103da5a87f5 | 672 | tm_pointer->TM_string[2] = ACKCODE; |
Shashank7906 | 49:1103da5a87f5 | 673 | for(uint8_t i=3;i<11;i++) |
Shashank7906 | 49:1103da5a87f5 | 674 | { |
Shashank7906 | 49:1103da5a87f5 | 675 | tm_pointer->TM_string[i] = 0; |
Shashank7906 | 49:1103da5a87f5 | 676 | } |
Shashank7906 | 49:1103da5a87f5 | 677 | crc16 = crc16_gen(tm_ptr->TM_string,11); |
Shashank7906 | 49:1103da5a87f5 | 678 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
Shashank7906 | 49:1103da5a87f5 | 679 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 680 | tm_pointer->next_TM = NULL; return tm_ptr; |
Shashank7906 | 49:1103da5a87f5 | 681 | break; |
Shashank7906 | 49:1103da5a87f5 | 682 | } |
Shashank7906 | 49:1103da5a87f5 | 683 | else if(GETpid(tc_ptr)==0x12) |
Shashank7906 | 49:1103da5a87f5 | 684 | { |
Shashank7906 | 49:1103da5a87f5 | 685 | printf("TC_SW_ON_RTC\r\n"); // call PWR_SWCH_ON function |
Shashank7906 | 49:1103da5a87f5 | 686 | tm_pointer = new Short_tm; |
Shashank7906 | 49:1103da5a87f5 | 687 | tm_pointer->TM_string[0] = 0xB0; |
Shashank7906 | 49:1103da5a87f5 | 688 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
Shashank7906 | 49:1103da5a87f5 | 689 | tm_pointer->TM_string[2] = ACKCODE; |
Shashank7906 | 49:1103da5a87f5 | 690 | for(uint8_t i=3;i<11;i++) |
Shashank7906 | 49:1103da5a87f5 | 691 | { |
Shashank7906 | 49:1103da5a87f5 | 692 | tm_pointer->TM_string[i] = 0; |
ee12b079 | 35:3beac900a034 | 693 | } |
Shashank7906 | 49:1103da5a87f5 | 694 | crc16 = crc16_gen(tm_ptr->TM_string,11); |
Shashank7906 | 49:1103da5a87f5 | 695 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
Shashank7906 | 49:1103da5a87f5 | 696 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 697 | tm_pointer->next_TM = NULL; return tm_ptr; |
Shashank7906 | 49:1103da5a87f5 | 698 | break; |
Shashank7906 | 49:1103da5a87f5 | 699 | } |
Shashank7906 | 49:1103da5a87f5 | 700 | else if(GETpid(tc_ptr)==0x13) |
Shashank7906 | 49:1103da5a87f5 | 701 | { |
Shashank7906 | 49:1103da5a87f5 | 702 | printf("TC_SW_ON_BAE\r\n"); // call PWR_SWCH_ON function |
Shashank7906 | 49:1103da5a87f5 | 703 | tm_pointer = new Short_tm; |
Shashank7906 | 49:1103da5a87f5 | 704 | tm_pointer->TM_string[0] = 0xB0; |
Shashank7906 | 49:1103da5a87f5 | 705 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
Shashank7906 | 49:1103da5a87f5 | 706 | tm_pointer->TM_string[2] = ACKCODE; |
Shashank7906 | 49:1103da5a87f5 | 707 | for(uint8_t i=3;i<11;i++) |
Shashank7906 | 49:1103da5a87f5 | 708 | { |
Shashank7906 | 49:1103da5a87f5 | 709 | tm_pointer->TM_string[i] = 0; |
Shashank7906 | 49:1103da5a87f5 | 710 | } |
Shashank7906 | 49:1103da5a87f5 | 711 | crc16 = crc16_gen(tm_ptr->TM_string,11); |
Shashank7906 | 49:1103da5a87f5 | 712 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
Shashank7906 | 49:1103da5a87f5 | 713 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 714 | tm_pointer->next_TM = NULL; return tm_ptr; |
Shashank7906 | 49:1103da5a87f5 | 715 | break; |
Shashank7906 | 49:1103da5a87f5 | 716 | } |
Shashank7906 | 49:1103da5a87f5 | 717 | else if(GETpid(tc_ptr)==0x14) |
Shashank7906 | 49:1103da5a87f5 | 718 | { |
Shashank7906 | 49:1103da5a87f5 | 719 | printf("TC_SW_ON_PL_DL\r\n"); // call PWR_SWCH_ON function |
Shashank7906 | 49:1103da5a87f5 | 720 | tm_pointer = new Short_tm; |
Shashank7906 | 49:1103da5a87f5 | 721 | tm_pointer->TM_string[0] = 0xB0; |
Shashank7906 | 49:1103da5a87f5 | 722 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
Shashank7906 | 49:1103da5a87f5 | 723 | tm_pointer->TM_string[2] = ACKCODE; |
Shashank7906 | 49:1103da5a87f5 | 724 | for(uint8_t i=3;i<11;i++) |
Shashank7906 | 49:1103da5a87f5 | 725 | { |
Shashank7906 | 49:1103da5a87f5 | 726 | tm_pointer->TM_string[i] = 0; |
Shashank7906 | 49:1103da5a87f5 | 727 | } |
Shashank7906 | 49:1103da5a87f5 | 728 | crc16 = crc16_gen(tm_ptr->TM_string,11); |
Shashank7906 | 49:1103da5a87f5 | 729 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
Shashank7906 | 49:1103da5a87f5 | 730 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 731 | tm_pointer->next_TM = NULL; return tm_ptr; |
Shashank7906 | 49:1103da5a87f5 | 732 | break; |
Shashank7906 | 49:1103da5a87f5 | 733 | } |
Shashank7906 | 49:1103da5a87f5 | 734 | else if(GETpid(tc_ptr)==0x15) |
Shashank7906 | 49:1103da5a87f5 | 735 | { |
Shashank7906 | 49:1103da5a87f5 | 736 | printf("TC_SW_ON_PL_AG_HV\r\n"); // call PWR_SWCH_ON function |
Shashank7906 | 49:1103da5a87f5 | 737 | tm_pointer = new Short_tm; |
Shashank7906 | 49:1103da5a87f5 | 738 | tm_pointer->TM_string[0] = 0xB0; |
Shashank7906 | 49:1103da5a87f5 | 739 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
Shashank7906 | 49:1103da5a87f5 | 740 | tm_pointer->TM_string[2] = ACKCODE; |
Shashank7906 | 49:1103da5a87f5 | 741 | for(uint8_t i=3;i<11;i++) |
Shashank7906 | 49:1103da5a87f5 | 742 | { |
Shashank7906 | 49:1103da5a87f5 | 743 | tm_pointer->TM_string[i] = 0; |
Shashank7906 | 49:1103da5a87f5 | 744 | } |
Shashank7906 | 49:1103da5a87f5 | 745 | crc16 = crc16_gen(tm_ptr->TM_string,11); |
Shashank7906 | 49:1103da5a87f5 | 746 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
Shashank7906 | 49:1103da5a87f5 | 747 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 748 | tm_pointer->next_TM = NULL; return tm_ptr; |
ee12b079 | 35:3beac900a034 | 749 | break; |
Shashank7906 | 49:1103da5a87f5 | 750 | } |
Shashank7906 | 49:1103da5a87f5 | 751 | else if(GETpid(tc_ptr)==0x16) |
Shashank7906 | 49:1103da5a87f5 | 752 | { |
Shashank7906 | 49:1103da5a87f5 | 753 | printf("TC_SW_ON_V_A_EN\r\n"); // call PWR_SWCH_ON function |
Shashank7906 | 49:1103da5a87f5 | 754 | tm_pointer = new Short_tm; |
Shashank7906 | 49:1103da5a87f5 | 755 | tm_pointer->TM_string[0] = 0xB0; |
Shashank7906 | 49:1103da5a87f5 | 756 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
Shashank7906 | 49:1103da5a87f5 | 757 | tm_pointer->TM_string[2] = ACKCODE; |
Shashank7906 | 49:1103da5a87f5 | 758 | for(uint8_t i=3;i<11;i++) |
Shashank7906 | 49:1103da5a87f5 | 759 | { |
Shashank7906 | 49:1103da5a87f5 | 760 | tm_pointer->TM_string[i] = 0; |
Shashank7906 | 49:1103da5a87f5 | 761 | } |
Shashank7906 | 49:1103da5a87f5 | 762 | crc16 = crc16_gen(tm_ptr->TM_string,11); |
Shashank7906 | 49:1103da5a87f5 | 763 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
Shashank7906 | 49:1103da5a87f5 | 764 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 765 | tm_pointer->next_TM = NULL; return tm_ptr; |
Shashank7906 | 49:1103da5a87f5 | 766 | break; |
Shashank7906 | 49:1103da5a87f5 | 767 | } |
Shashank7906 | 49:1103da5a87f5 | 768 | else if(GETpid(tc_ptr)==0x21) |
Shashank7906 | 49:1103da5a87f5 | 769 | { |
Shashank7906 | 49:1103da5a87f5 | 770 | printf("TC_SW_OFF_SD\r\n"); // call PWR_SWCH_ON function |
Shashank7906 | 49:1103da5a87f5 | 771 | tm_pointer = new Short_tm; |
Shashank7906 | 49:1103da5a87f5 | 772 | tm_pointer->TM_string[0] = 0xB0; |
Shashank7906 | 49:1103da5a87f5 | 773 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
Shashank7906 | 49:1103da5a87f5 | 774 | tm_pointer->TM_string[2] = ACKCODE; |
Shashank7906 | 49:1103da5a87f5 | 775 | for(uint8_t i=3;i<11;i++) |
Shashank7906 | 49:1103da5a87f5 | 776 | { |
Shashank7906 | 49:1103da5a87f5 | 777 | tm_pointer->TM_string[i] = 0; |
Shashank7906 | 49:1103da5a87f5 | 778 | } |
Shashank7906 | 49:1103da5a87f5 | 779 | crc16 = crc16_gen(tm_ptr->TM_string,11); |
Shashank7906 | 49:1103da5a87f5 | 780 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
Shashank7906 | 49:1103da5a87f5 | 781 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 782 | tm_pointer->next_TM = NULL; return tm_ptr; |
Shashank7906 | 49:1103da5a87f5 | 783 | break; |
Shashank7906 | 49:1103da5a87f5 | 784 | } |
Shashank7906 | 49:1103da5a87f5 | 785 | else if(GETpid(tc_ptr)==0x22) |
Shashank7906 | 49:1103da5a87f5 | 786 | { |
Shashank7906 | 49:1103da5a87f5 | 787 | printf("TC_SW_OFF_RTC\r\n"); // call PWR_SWCH_ON function |
Shashank7906 | 49:1103da5a87f5 | 788 | tm_pointer = new Short_tm; |
Shashank7906 | 49:1103da5a87f5 | 789 | tm_pointer->TM_string[0] = 0xB0; |
Shashank7906 | 49:1103da5a87f5 | 790 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
Shashank7906 | 49:1103da5a87f5 | 791 | tm_pointer->TM_string[2] = ACKCODE; |
Shashank7906 | 49:1103da5a87f5 | 792 | for(uint8_t i=3;i<11;i++) |
Shashank7906 | 49:1103da5a87f5 | 793 | { |
Shashank7906 | 49:1103da5a87f5 | 794 | tm_pointer->TM_string[i] = 0; |
Shashank7906 | 49:1103da5a87f5 | 795 | } |
Shashank7906 | 49:1103da5a87f5 | 796 | crc16 = crc16_gen(tm_ptr->TM_string,11); |
Shashank7906 | 49:1103da5a87f5 | 797 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
Shashank7906 | 49:1103da5a87f5 | 798 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 799 | tm_pointer->next_TM = NULL; return tm_ptr; |
Shashank7906 | 49:1103da5a87f5 | 800 | break; |
Shashank7906 | 49:1103da5a87f5 | 801 | } |
Shashank7906 | 49:1103da5a87f5 | 802 | else if(GETpid(tc_ptr)==0x23) |
Shashank7906 | 49:1103da5a87f5 | 803 | { |
Shashank7906 | 49:1103da5a87f5 | 804 | printf("TC_SW_OFF_BAE\r\n"); // call PWR_SWCH_ON function |
Shashank7906 | 49:1103da5a87f5 | 805 | tm_pointer = new Short_tm; |
Shashank7906 | 49:1103da5a87f5 | 806 | tm_pointer->TM_string[0] = 0xB0; |
Shashank7906 | 49:1103da5a87f5 | 807 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
Shashank7906 | 49:1103da5a87f5 | 808 | tm_pointer->TM_string[2] = ACKCODE; |
Shashank7906 | 49:1103da5a87f5 | 809 | for(uint8_t i=3;i<11;i++) |
Shashank7906 | 49:1103da5a87f5 | 810 | { |
Shashank7906 | 49:1103da5a87f5 | 811 | tm_pointer->TM_string[i] = 0; |
Shashank7906 | 49:1103da5a87f5 | 812 | } |
Shashank7906 | 49:1103da5a87f5 | 813 | crc16 = crc16_gen(tm_ptr->TM_string,11); |
Shashank7906 | 49:1103da5a87f5 | 814 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
Shashank7906 | 49:1103da5a87f5 | 815 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 816 | tm_pointer->next_TM = NULL; return tm_ptr; |
Shashank7906 | 49:1103da5a87f5 | 817 | break; |
Shashank7906 | 49:1103da5a87f5 | 818 | } |
Shashank7906 | 49:1103da5a87f5 | 819 | else if(GETpid(tc_ptr)==0x24) |
Shashank7906 | 49:1103da5a87f5 | 820 | { |
Shashank7906 | 49:1103da5a87f5 | 821 | printf("TC_SW_OFF_PL_DL\r\n"); // call PWR_SWCH_ON function |
Shashank7906 | 49:1103da5a87f5 | 822 | tm_pointer = new Short_tm; |
Shashank7906 | 49:1103da5a87f5 | 823 | tm_pointer->TM_string[0] = 0xB0; |
Shashank7906 | 49:1103da5a87f5 | 824 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
Shashank7906 | 49:1103da5a87f5 | 825 | tm_pointer->TM_string[2] = ACKCODE; |
Shashank7906 | 49:1103da5a87f5 | 826 | for(uint8_t i=3;i<11;i++) |
Shashank7906 | 49:1103da5a87f5 | 827 | { |
Shashank7906 | 49:1103da5a87f5 | 828 | tm_pointer->TM_string[i] = 0; |
Shashank7906 | 49:1103da5a87f5 | 829 | } |
Shashank7906 | 49:1103da5a87f5 | 830 | crc16 = crc16_gen(tm_ptr->TM_string,11); |
Shashank7906 | 49:1103da5a87f5 | 831 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
Shashank7906 | 49:1103da5a87f5 | 832 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 833 | tm_pointer->next_TM = NULL; return tm_ptr; |
Shashank7906 | 49:1103da5a87f5 | 834 | break; |
Shashank7906 | 49:1103da5a87f5 | 835 | } |
Shashank7906 | 49:1103da5a87f5 | 836 | else if(GETpid(tc_ptr)==0x25) |
Shashank7906 | 49:1103da5a87f5 | 837 | { |
Shashank7906 | 49:1103da5a87f5 | 838 | printf("TC_SW_OFF_PL_AG_HV\r\n"); // call PWR_SWCH_ON function |
Shashank7906 | 49:1103da5a87f5 | 839 | tm_pointer = new Short_tm; |
Shashank7906 | 49:1103da5a87f5 | 840 | tm_pointer->TM_string[0] = 0xB0; |
Shashank7906 | 49:1103da5a87f5 | 841 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
Shashank7906 | 49:1103da5a87f5 | 842 | tm_pointer->TM_string[2] = ACKCODE; |
Shashank7906 | 49:1103da5a87f5 | 843 | for(uint8_t i=3;i<11;i++) |
Shashank7906 | 49:1103da5a87f5 | 844 | { |
Shashank7906 | 49:1103da5a87f5 | 845 | tm_pointer->TM_string[i] = 0; |
Shashank7906 | 49:1103da5a87f5 | 846 | } |
Shashank7906 | 49:1103da5a87f5 | 847 | crc16 = crc16_gen(tm_ptr->TM_string,11); |
Shashank7906 | 49:1103da5a87f5 | 848 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
Shashank7906 | 49:1103da5a87f5 | 849 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 850 | tm_pointer->next_TM = NULL; return tm_ptr; |
Shashank7906 | 49:1103da5a87f5 | 851 | break; |
Shashank7906 | 49:1103da5a87f5 | 852 | } |
Shashank7906 | 49:1103da5a87f5 | 853 | else if(GETpid(tc_ptr)==0x26) |
Shashank7906 | 49:1103da5a87f5 | 854 | { |
Shashank7906 | 49:1103da5a87f5 | 855 | printf("TC_SW_OFF_V_A_EN\r\n"); // call PWR_SWCH_ON function |
Shashank7906 | 49:1103da5a87f5 | 856 | tm_pointer = new Short_tm; |
Shashank7906 | 49:1103da5a87f5 | 857 | tm_pointer->TM_string[0] = 0xB0; |
Shashank7906 | 49:1103da5a87f5 | 858 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
Shashank7906 | 49:1103da5a87f5 | 859 | tm_pointer->TM_string[2] = ACKCODE; |
Shashank7906 | 49:1103da5a87f5 | 860 | for(uint8_t i=3;i<11;i++) |
Shashank7906 | 49:1103da5a87f5 | 861 | { |
Shashank7906 | 49:1103da5a87f5 | 862 | tm_pointer->TM_string[i] = 0; |
Shashank7906 | 49:1103da5a87f5 | 863 | } |
Shashank7906 | 49:1103da5a87f5 | 864 | crc16 = crc16_gen(tm_ptr->TM_string,11); |
Shashank7906 | 49:1103da5a87f5 | 865 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
Shashank7906 | 49:1103da5a87f5 | 866 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 867 | tm_pointer->next_TM = NULL; return tm_ptr; |
Shashank7906 | 49:1103da5a87f5 | 868 | break; |
Shashank7906 | 49:1103da5a87f5 | 869 | } |
Shashank7906 | 49:1103da5a87f5 | 870 | else if(GETpid(tc_ptr)==0x31) |
Shashank7906 | 49:1103da5a87f5 | 871 | { |
Shashank7906 | 49:1103da5a87f5 | 872 | printf("TC_RST_SD\r\n"); // call PWR_SWCH_ON function |
Shashank7906 | 49:1103da5a87f5 | 873 | tm_pointer = new Short_tm; |
Shashank7906 | 49:1103da5a87f5 | 874 | tm_pointer->TM_string[0] = 0xB0; |
Shashank7906 | 49:1103da5a87f5 | 875 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
Shashank7906 | 49:1103da5a87f5 | 876 | tm_pointer->TM_string[2] = ACKCODE; |
Shashank7906 | 49:1103da5a87f5 | 877 | for(uint8_t i=3;i<11;i++) |
Shashank7906 | 49:1103da5a87f5 | 878 | { |
Shashank7906 | 49:1103da5a87f5 | 879 | tm_pointer->TM_string[i] = 0; |
Shashank7906 | 49:1103da5a87f5 | 880 | } |
Shashank7906 | 49:1103da5a87f5 | 881 | crc16 = crc16_gen(tm_ptr->TM_string,11); |
Shashank7906 | 49:1103da5a87f5 | 882 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
Shashank7906 | 49:1103da5a87f5 | 883 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 884 | tm_pointer->next_TM = NULL; return tm_ptr; |
Shashank7906 | 49:1103da5a87f5 | 885 | break; |
Shashank7906 | 49:1103da5a87f5 | 886 | } |
Shashank7906 | 49:1103da5a87f5 | 887 | else if(GETpid(tc_ptr)==0x32) |
Shashank7906 | 49:1103da5a87f5 | 888 | { |
Shashank7906 | 49:1103da5a87f5 | 889 | printf("TC_RST_RTC\r\n"); // call PWR_SWCH_ON function |
Shashank7906 | 49:1103da5a87f5 | 890 | tm_pointer = new Short_tm; |
Shashank7906 | 49:1103da5a87f5 | 891 | tm_pointer->TM_string[0] = 0xB0; |
Shashank7906 | 49:1103da5a87f5 | 892 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
Shashank7906 | 49:1103da5a87f5 | 893 | tm_pointer->TM_string[2] = ACKCODE; |
Shashank7906 | 49:1103da5a87f5 | 894 | for(uint8_t i=3;i<11;i++) |
Shashank7906 | 49:1103da5a87f5 | 895 | { |
Shashank7906 | 49:1103da5a87f5 | 896 | tm_pointer->TM_string[i] = 0; |
Shashank7906 | 49:1103da5a87f5 | 897 | } |
Shashank7906 | 49:1103da5a87f5 | 898 | crc16 = crc16_gen(tm_ptr->TM_string,11); |
Shashank7906 | 49:1103da5a87f5 | 899 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
Shashank7906 | 49:1103da5a87f5 | 900 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 901 | tm_pointer->next_TM = NULL; return tm_ptr; |
Shashank7906 | 49:1103da5a87f5 | 902 | break; |
Shashank7906 | 49:1103da5a87f5 | 903 | } |
Shashank7906 | 49:1103da5a87f5 | 904 | else if(GETpid(tc_ptr)==0x33) |
Shashank7906 | 49:1103da5a87f5 | 905 | { |
Shashank7906 | 49:1103da5a87f5 | 906 | printf("TC_RST_BAE\r\n"); // call PWR_SWCH_ON function |
Shashank7906 | 49:1103da5a87f5 | 907 | tm_pointer = new Short_tm; |
Shashank7906 | 49:1103da5a87f5 | 908 | tm_pointer->TM_string[0] = 0xB0; |
Shashank7906 | 49:1103da5a87f5 | 909 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
Shashank7906 | 49:1103da5a87f5 | 910 | tm_pointer->TM_string[2] = ACKCODE; |
Shashank7906 | 49:1103da5a87f5 | 911 | for(uint8_t i=3;i<11;i++) |
Shashank7906 | 49:1103da5a87f5 | 912 | { |
Shashank7906 | 49:1103da5a87f5 | 913 | tm_pointer->TM_string[i] = 0; |
Shashank7906 | 49:1103da5a87f5 | 914 | } |
Shashank7906 | 49:1103da5a87f5 | 915 | crc16 = crc16_gen(tm_ptr->TM_string,11); |
Shashank7906 | 49:1103da5a87f5 | 916 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
Shashank7906 | 49:1103da5a87f5 | 917 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 918 | tm_pointer->next_TM = NULL; return tm_ptr; |
Shashank7906 | 49:1103da5a87f5 | 919 | break; |
Shashank7906 | 49:1103da5a87f5 | 920 | } |
Shashank7906 | 49:1103da5a87f5 | 921 | else if(GETpid(tc_ptr)==0x34) |
Shashank7906 | 49:1103da5a87f5 | 922 | { |
Shashank7906 | 49:1103da5a87f5 | 923 | printf("TC_RST_PL_DL\r\n"); // call PWR_SWCH_ON function |
Shashank7906 | 49:1103da5a87f5 | 924 | tm_pointer = new Short_tm; |
Shashank7906 | 49:1103da5a87f5 | 925 | tm_pointer->TM_string[0] = 0xB0; |
Shashank7906 | 49:1103da5a87f5 | 926 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
Shashank7906 | 49:1103da5a87f5 | 927 | tm_pointer->TM_string[2] = ACKCODE; |
Shashank7906 | 49:1103da5a87f5 | 928 | for(uint8_t i=3;i<11;i++) |
Shashank7906 | 49:1103da5a87f5 | 929 | { |
Shashank7906 | 49:1103da5a87f5 | 930 | tm_pointer->TM_string[i] = 0; |
Shashank7906 | 49:1103da5a87f5 | 931 | } |
Shashank7906 | 49:1103da5a87f5 | 932 | crc16 = crc16_gen(tm_ptr->TM_string,11); |
Shashank7906 | 49:1103da5a87f5 | 933 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
Shashank7906 | 49:1103da5a87f5 | 934 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 935 | tm_pointer->next_TM = NULL; return tm_ptr; |
Shashank7906 | 49:1103da5a87f5 | 936 | break; |
Shashank7906 | 49:1103da5a87f5 | 937 | break; |
Shashank7906 | 49:1103da5a87f5 | 938 | } |
Shashank7906 | 49:1103da5a87f5 | 939 | else if(GETpid(tc_ptr)==0xC1) |
Shashank7906 | 49:1103da5a87f5 | 940 | { |
Shashank7906 | 49:1103da5a87f5 | 941 | printf("RESET_HK_COUNTER\r\n"); // call PWR_SWCH_ON function |
Shashank7906 | 49:1103da5a87f5 | 942 | tm_pointer = new Short_tm; |
Shashank7906 | 49:1103da5a87f5 | 943 | tm_pointer->TM_string[0] = 0xB0; |
Shashank7906 | 49:1103da5a87f5 | 944 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
Shashank7906 | 49:1103da5a87f5 | 945 | tm_pointer->TM_string[2] = ACKCODE; |
Shashank7906 | 49:1103da5a87f5 | 946 | for(uint8_t i=3;i<11;i++) |
Shashank7906 | 49:1103da5a87f5 | 947 | { |
Shashank7906 | 49:1103da5a87f5 | 948 | tm_pointer->TM_string[i] = 0; |
Shashank7906 | 49:1103da5a87f5 | 949 | } |
Shashank7906 | 49:1103da5a87f5 | 950 | crc16 = crc16_gen(tm_ptr->TM_string,11); |
Shashank7906 | 49:1103da5a87f5 | 951 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
Shashank7906 | 49:1103da5a87f5 | 952 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 953 | tm_pointer->next_TM = NULL; return tm_ptr; |
Shashank7906 | 49:1103da5a87f5 | 954 | break; |
Shashank7906 | 49:1103da5a87f5 | 955 | } |
Shashank7906 | 49:1103da5a87f5 | 956 | else if(GETpid(tc_ptr)==0xF1) |
Shashank7906 | 49:1103da5a87f5 | 957 | { |
Shashank7906 | 49:1103da5a87f5 | 958 | printf("RD_RTC\r\n"); //call RD_RTC |
Shashank7906 | 49:1103da5a87f5 | 959 | tm_pointer = new Short_tm; |
Shashank7906 | 49:1103da5a87f5 | 960 | tm_pointer->TM_string[0] = 0xD0; |
Shashank7906 | 49:1103da5a87f5 | 961 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
Shashank7906 | 49:1103da5a87f5 | 962 | tm_pointer->TM_string[2] = 0x01; |
Shashank7906 | 49:1103da5a87f5 | 963 | uint64_t time = FCTN_CDMS_RD_RTC(); |
Shashank7906 | 49:1103da5a87f5 | 964 | tm_pointer->TM_string[3] = (uint8_t)((time&0xFF00000000000000)>>56); |
Shashank7906 | 49:1103da5a87f5 | 965 | tm_pointer->TM_string[4] = (uint8_t)((time&0x00FF000000000000)>>48); |
Shashank7906 | 49:1103da5a87f5 | 966 | tm_pointer->TM_string[5] = (uint8_t)((time&0x0000FF0000000000)>>40); |
Shashank7906 | 49:1103da5a87f5 | 967 | tm_pointer->TM_string[6] = (uint8_t)((time&0x000000FF00000000)>>32); |
Shashank7906 | 49:1103da5a87f5 | 968 | tm_pointer->TM_string[7] = (uint8_t)((time&0x00000000FF000000)>>24); |
Shashank7906 | 49:1103da5a87f5 | 969 | tm_pointer->TM_string[8] = (uint8_t)((time&0x0000000000FF0000)>>16); |
Shashank7906 | 49:1103da5a87f5 | 970 | tm_pointer->TM_string[9] = (uint8_t)((time&0x000000000000FF00)>>8); |
Shashank7906 | 49:1103da5a87f5 | 971 | tm_pointer->TM_string[10] = (uint8_t)(time&0x00000000000000FF); |
Shashank7906 | 49:1103da5a87f5 | 972 | crc16 = crc16_gen(tm_ptr->TM_string,11); |
Shashank7906 | 49:1103da5a87f5 | 973 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
Shashank7906 | 49:1103da5a87f5 | 974 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 975 | tm_pointer->next_TM = NULL; return tm_ptr; |
Shashank7906 | 49:1103da5a87f5 | 976 | } |
Shashank7906 | 49:1103da5a87f5 | 977 | else |
Shashank7906 | 49:1103da5a87f5 | 978 | { |
Shashank7906 | 49:1103da5a87f5 | 979 | printf("INVALID TC\r\n"); |
Shashank7906 | 49:1103da5a87f5 | 980 | tm_pointer = new Short_tm; |
Shashank7906 | 49:1103da5a87f5 | 981 | tm_pointer->TM_string[0] = 0xB0; |
Shashank7906 | 49:1103da5a87f5 | 982 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
Shashank7906 | 49:1103da5a87f5 | 983 | tm_pointer->TM_string[2] = 0x01; |
Shashank7906 | 49:1103da5a87f5 | 984 | tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided |
Shashank7906 | 49:1103da5a87f5 | 985 | tm_pointer->TM_string[4] = 0x01; |
Shashank7906 | 49:1103da5a87f5 | 986 | for(uint8_t i=0;i<6;i++) |
Shashank7906 | 49:1103da5a87f5 | 987 | { |
Shashank7906 | 49:1103da5a87f5 | 988 | tm_pointer->TM_string[i+5] = 0; |
Shashank7906 | 49:1103da5a87f5 | 989 | } |
Shashank7906 | 49:1103da5a87f5 | 990 | crc16 = crc16_gen(tm_ptr->TM_string,11); |
Shashank7906 | 49:1103da5a87f5 | 991 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
Shashank7906 | 49:1103da5a87f5 | 992 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 993 | tm_pointer->next_TM = NULL; return tm_ptr; |
Shashank7906 | 49:1103da5a87f5 | 994 | } |
Shashank7906 | 49:1103da5a87f5 | 995 | } |
ee12b079 | 35:3beac900a034 | 996 | } |
ee12b079 | 35:3beac900a034 | 997 | default: |
ee12b079 | 35:3beac900a034 | 998 | { |
ee12b079 | 35:3beac900a034 | 999 | printf("INVALID TC"); //send invalid TC TM |
Shashank7906 | 49:1103da5a87f5 | 1000 | tm_pointer = new Short_tm; |
ee12b079 | 35:3beac900a034 | 1001 | tm_pointer->TM_string[0] = 0xB0; |
ee12b079 | 35:3beac900a034 | 1002 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
ee12b079 | 35:3beac900a034 | 1003 | tm_pointer->TM_string[2] = 0x01; |
ee12b079 | 35:3beac900a034 | 1004 | tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided |
ee12b079 | 35:3beac900a034 | 1005 | tm_pointer->TM_string[4] = 0x01; |
ee12b079 | 35:3beac900a034 | 1006 | for(uint8_t i=0;i<6;i++) |
ee12b079 | 35:3beac900a034 | 1007 | { |
ee12b079 | 35:3beac900a034 | 1008 | tm_pointer->TM_string[i+5] = 0; |
ee12b079 | 35:3beac900a034 | 1009 | } |
ee12b079 | 35:3beac900a034 | 1010 | crc16 = crc16_gen(tm_ptr->TM_string,11); |
ee12b079 | 35:3beac900a034 | 1011 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
ee12b079 | 35:3beac900a034 | 1012 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 1013 | tm_pointer->next_TM = NULL; return tm_ptr; |
ee12b079 | 35:3beac900a034 | 1014 | break; |
ee12b079 | 35:3beac900a034 | 1015 | } |
ee12b079 | 35:3beac900a034 | 1016 | } |
ee12b079 | 35:3beac900a034 | 1017 | } |
ee12b079 | 35:3beac900a034 | 1018 | case 3: |
ee12b079 | 35:3beac900a034 | 1019 | { |
ee12b079 | 35:3beac900a034 | 1020 | printf("Telecommand is for PL\r\n"); |
ee12b079 | 35:3beac900a034 | 1021 | // printf("Informing PL about TC using I2C\r\n"); //interrupt to be sent to the bae |
ee12b079 | 35:3beac900a034 | 1022 | // FCTN_I2C_WRITE((char*)tc_ptr->TC_string); |
ee12b079 | 35:3beac900a034 | 1023 | // printf("sent the Telecommand to BAE\r\n"); //packet along with crc will be sent when bae is ready |
ee12b079 | 35:3beac900a034 | 1024 | // wait(1); //wait time is to be optimised |
ee12b079 | 35:3beac900a034 | 1025 | // if(tm_status_4m_slv == 1) |
ee12b079 | 35:3beac900a034 | 1026 | // { |
ee12b079 | 35:3beac900a034 | 1027 | // FCTN_I2C_READ((char*)tm_ptr->TM_string); |
ee12b079 | 35:3beac900a034 | 1028 | // received = 1; |
ee12b079 | 35:3beac900a034 | 1029 | // } |
ee12b079 | 35:3beac900a034 | 1030 | // if(received == 1 ) |
ee12b079 | 35:3beac900a034 | 1031 | // { |
ee12b079 | 35:3beac900a034 | 1032 | // printf("Telemetry is received from BAE\r\n"); |
ee12b079 | 35:3beac900a034 | 1033 | // printf("%s", tm_ptr->TM_string); |
ee12b079 | 35:3beac900a034 | 1034 | // received = 0; |
ee12b079 | 35:3beac900a034 | 1035 | // } // similar to BAE functions |
ee12b079 | 35:3beac900a034 | 1036 | break; |
ee12b079 | 35:3beac900a034 | 1037 | } |
ee12b079 | 35:3beac900a034 | 1038 | default: //invalid TC |
ee12b079 | 35:3beac900a034 | 1039 | { |
ee12b079 | 35:3beac900a034 | 1040 | printf("INVALID TC\r\n"); |
Shashank7906 | 49:1103da5a87f5 | 1041 | tm_pointer = new Short_tm; |
ee12b079 | 35:3beac900a034 | 1042 | tm_pointer->TM_string[0] = 0xB0; |
ee12b079 | 35:3beac900a034 | 1043 | tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); |
ee12b079 | 35:3beac900a034 | 1044 | tm_pointer->TM_string[2] = 0x01; |
ee12b079 | 35:3beac900a034 | 1045 | tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided |
ee12b079 | 35:3beac900a034 | 1046 | tm_pointer->TM_string[4] = 0x01; |
ee12b079 | 35:3beac900a034 | 1047 | for(uint8_t i=0;i<6;i++) |
ee12b079 | 35:3beac900a034 | 1048 | { |
ee12b079 | 35:3beac900a034 | 1049 | tm_pointer->TM_string[i+5] = 0; |
ee12b079 | 35:3beac900a034 | 1050 | } |
ee12b079 | 35:3beac900a034 | 1051 | crc16 = crc16_gen(tm_ptr->TM_string,11); |
ee12b079 | 35:3beac900a034 | 1052 | tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); |
ee12b079 | 35:3beac900a034 | 1053 | tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); |
Shashank7906 | 49:1103da5a87f5 | 1054 | tm_pointer->next_TM = NULL; return tm_ptr; |
ee12b079 | 35:3beac900a034 | 1055 | break; |
ee12b079 | 35:3beac900a034 | 1056 | } |
Shashank7906 | 49:1103da5a87f5 | 1057 | } |
ee12b079 | 35:3beac900a034 | 1058 | } |
shreeshas95 | 0:f016e9e8d48b | 1059 | // CDMS TEAM CODE END |
Shashank7906 | 49:1103da5a87f5 | 1060 | // CDMS TEAM CODE END |
shreeshas95 | 0:f016e9e8d48b | 1061 | |
shreeshas95 | 0:f016e9e8d48b | 1062 | // EXECUTE OBOSC |
shreeshas95 | 0:f016e9e8d48b | 1063 | #define execute_obosc_core(tc_ptr, tm_ptr) {\ |
shreeshas95 | 0:f016e9e8d48b | 1064 | uint8_t service_subtype = (tc_ptr->TC_string[2]) & 0x0F;\ |
shreeshas95 | 4:104dd82c99b8 | 1065 | uint8_t temp8 = 0x00;\ |
shreeshas95 | 4:104dd82c99b8 | 1066 | Base_tc *modify_this = gHEAD_NODE_TCL;\ |
shreeshas95 | 4:104dd82c99b8 | 1067 | int modify_overflow = 0x00;\ |
shreeshas95 | 4:104dd82c99b8 | 1068 | switch( service_subtype ){\ |
shreeshas95 | 4:104dd82c99b8 | 1069 | case OBOSC_SUB_DISABLE:\ |
aniruddhv | 12:ffdb29353058 | 1070 | /*gPC.puts("target psc are ");*/\ |
shreeshas95 | 5:ab276a17ca07 | 1071 | for(int i = 3 ; i < 9 ; ++i){\ |
aniruddhv | 12:ffdb29353058 | 1072 | /*gPC.printf("%u ", tc_ptr->TC_string[i]);*/\ |
shreeshas95 | 5:ab276a17ca07 | 1073 | }\ |
aniruddhv | 12:ffdb29353058 | 1074 | /*gPC.puts("\r\n");*/\ |
shreeshas95 | 5:ab276a17ca07 | 1075 | /*gPC.puts("disable type obosc\r\n");*/\ |
shreeshas95 | 4:104dd82c99b8 | 1076 | while( modify_this != NULL ){\ |
shreeshas95 | 4:104dd82c99b8 | 1077 | if( modify_overflow < TCL_OVERFLOW_CONSTANT ){\ |
shreeshas95 | 5:ab276a17ca07 | 1078 | uint8_t modify_psc = GETpacket_seq_count(modify_this);\ |
shreeshas95 | 5:ab276a17ca07 | 1079 | /*gPC.printf("mosify_psc = %u\r\n", modify_psc);*/\ |
shreeshas95 | 4:104dd82c99b8 | 1080 | for( int i = 3 ; i < 9 ; ++i ){\ |
shreeshas95 | 5:ab276a17ca07 | 1081 | uint8_t target_psc = tc_ptr->TC_string[i];\ |
shreeshas95 | 5:ab276a17ca07 | 1082 | if( (target_psc == modify_psc) && (target_psc != 0) ){\ |
shreeshas95 | 4:104dd82c99b8 | 1083 | uint16_t tempExec = TC_STATE_DISABLED;\ |
shreeshas95 | 4:104dd82c99b8 | 1084 | PUTexec_status( modify_this, tempExec );\ |
shreeshas95 | 4:104dd82c99b8 | 1085 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 1086 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1087 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1088 | modify_this = modify_this->next_TC;\ |
shreeshas95 | 4:104dd82c99b8 | 1089 | ++modify_overflow;\ |
shreeshas95 | 4:104dd82c99b8 | 1090 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1091 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 1092 | /*PENDING: RESET CDMS*/\ |
shreeshas95 | 4:104dd82c99b8 | 1093 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 1094 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1095 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1096 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 1097 | case OBOSC_SUB_RETRY:\ |
aniruddhv | 12:ffdb29353058 | 1098 | /*gPC.puts("retry type obosc\r\n");*/\ |
shreeshas95 | 4:104dd82c99b8 | 1099 | while( modify_this != NULL ){\ |
shreeshas95 | 4:104dd82c99b8 | 1100 | if( modify_overflow < TCL_OVERFLOW_CONSTANT ){\ |
shreeshas95 | 5:ab276a17ca07 | 1101 | uint8_t modify_psc = GETpacket_seq_count(modify_this);\ |
shreeshas95 | 4:104dd82c99b8 | 1102 | for( int i = 3 ; i < 9 ; ++i ){\ |
shreeshas95 | 5:ab276a17ca07 | 1103 | uint8_t target_psc = tc_ptr->TC_string[i];\ |
shreeshas95 | 5:ab276a17ca07 | 1104 | if( (target_psc == modify_psc) && (target_psc != 0) ){\ |
shreeshas95 | 4:104dd82c99b8 | 1105 | uint16_t tempExec = TC_STATE_MARKED_RETRY;\ |
shreeshas95 | 4:104dd82c99b8 | 1106 | PUTexec_status( modify_this, tempExec );\ |
aniruddhv | 12:ffdb29353058 | 1107 | /*gPC.puts("reqquired tc found: disable\r\n");*/\ |
shreeshas95 | 4:104dd82c99b8 | 1108 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 1109 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1110 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1111 | modify_this = modify_this->next_TC;\ |
shreeshas95 | 4:104dd82c99b8 | 1112 | ++modify_overflow;\ |
shreeshas95 | 4:104dd82c99b8 | 1113 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1114 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 1115 | /*PENDING: RESET CDMS*/\ |
shreeshas95 | 4:104dd82c99b8 | 1116 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 1117 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1118 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1119 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 1120 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1121 | Base_tm *ackl234new = new Short_tm;\ |
shreeshas95 | 4:104dd82c99b8 | 1122 | ackl234new->next_TM = NULL;\ |
shreeshas95 | 4:104dd82c99b8 | 1123 | /*return telemetry pointer here*/\ |
shreeshas95 | 4:104dd82c99b8 | 1124 | tm_ptr = ackl234new;\ |
shreeshas95 | 4:104dd82c99b8 | 1125 | temp8 = SHORT_TM_CODE;\ |
shreeshas95 | 4:104dd82c99b8 | 1126 | PUTshort_or_long_tm(ackl234new->fields, temp8);\ |
shreeshas95 | 4:104dd82c99b8 | 1127 | temp8 = TMID_ACK_L234;\ |
shreeshas95 | 4:104dd82c99b8 | 1128 | PUTtmid((ackl234new->fields), temp8);\ |
shreeshas95 | 4:104dd82c99b8 | 1129 | ackl234new->TM_string[0] = TMID_ACK_L234 << 4;\ |
shreeshas95 | 4:104dd82c99b8 | 1130 | ackl234new->TM_string[1] = GETpacket_seq_count(tc_ptr);\ |
shreeshas95 | 4:104dd82c99b8 | 1131 | ackl234new->TM_string[2] = 0xA0;\ |
shreeshas95 | 4:104dd82c99b8 | 1132 | for(int i = 3; i < 11; ++i){\ |
shreeshas95 | 4:104dd82c99b8 | 1133 | ackl234new->TM_string[i] = 0x00;\ |
shreeshas95 | 4:104dd82c99b8 | 1134 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1135 | uint16_t crc = crc16_gen(ackl234new->TM_string, TM_SHORT_SIZE-2);\ |
shreeshas95 | 4:104dd82c99b8 | 1136 | ackl234new->TM_string[11] = (crc & 0xFF00) >> 8;\ |
shreeshas95 | 4:104dd82c99b8 | 1137 | ackl234new->TM_string[12] = crc & 0x00FF;\ |
shreeshas95 | 4:104dd82c99b8 | 1138 | /*ack l234 old*/\ |
shreeshas95 | 4:104dd82c99b8 | 1139 | if( service_subtype == OBOSC_SUB_REP_LE ){\ |
shreeshas95 | 4:104dd82c99b8 | 1140 | if( gLAST_TM_SHORT_OR_LONG == SHORT_TM_CODE ){\ |
shreeshas95 | 4:104dd82c99b8 | 1141 | Base_tm *ackl234old = new Short_tm;\ |
shreeshas95 | 4:104dd82c99b8 | 1142 | ackl234old->next_TM = NULL;\ |
shreeshas95 | 4:104dd82c99b8 | 1143 | /*APPEND TO ACK L234 NEW HERE*/\ |
shreeshas95 | 4:104dd82c99b8 | 1144 | ackl234new->next_TM = ackl234old;\ |
shreeshas95 | 4:104dd82c99b8 | 1145 | uint8_t temp82 = TM_SHORT_SIZE;\ |
shreeshas95 | 4:104dd82c99b8 | 1146 | PUTshort_or_long_tm(ackl234old->fields, temp82);\ |
shreeshas95 | 4:104dd82c99b8 | 1147 | /*TMID FOR SHORT TM*/\ |
shreeshas95 | 4:104dd82c99b8 | 1148 | uint8_t y = (gLAST_TM[0] & 0xF0) >> 4;\ |
shreeshas95 | 4:104dd82c99b8 | 1149 | PUTtmid((ackl234old->fields), y);\ |
shreeshas95 | 4:104dd82c99b8 | 1150 | for( int i = 0 ; i < TM_SHORT_SIZE ; ++i ){\ |
shreeshas95 | 4:104dd82c99b8 | 1151 | ackl234old->TM_string[i] = gLAST_TM[i];\ |
shreeshas95 | 4:104dd82c99b8 | 1152 | }\ |
shreeshas95 | 0:f016e9e8d48b | 1153 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1154 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 1155 | Base_tm *tempLongTM = new Long_tm;\ |
shreeshas95 | 4:104dd82c99b8 | 1156 | tempLongTM->next_TM = NULL;\ |
shreeshas95 | 4:104dd82c99b8 | 1157 | /*APPEND TO ACK L234 NEW HERE*/\ |
shreeshas95 | 4:104dd82c99b8 | 1158 | ackl234new->next_TM = tempLongTM;\ |
shreeshas95 | 4:104dd82c99b8 | 1159 | uint8_t temp82 = TM_LONG_SIZE;\ |
shreeshas95 | 4:104dd82c99b8 | 1160 | PUTshort_or_long_tm(tempLongTM->fields, temp82);\ |
shreeshas95 | 4:104dd82c99b8 | 1161 | /*TMID FOR LONG TM*/\ |
shreeshas95 | 4:104dd82c99b8 | 1162 | uint8_t y = (gLAST_TM[0] & 0x78) >> 3;\ |
shreeshas95 | 4:104dd82c99b8 | 1163 | PUTtmid((tempLongTM->fields), y);\ |
shreeshas95 | 4:104dd82c99b8 | 1164 | for( int i = 0 ; i < TM_LONG_SIZE ; ++i ){\ |
shreeshas95 | 4:104dd82c99b8 | 1165 | tempLongTM->TM_string[i] = gLAST_TM[i];\ |
shreeshas95 | 4:104dd82c99b8 | 1166 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1167 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1168 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1169 | else if( service_subtype == OBOSC_SUB_REP_TCLD ){\ |
shreeshas95 | 4:104dd82c99b8 | 1170 | get_tc_list(ackl234new->next_TM, GETpacket_seq_count(tc_ptr));\ |
shreeshas95 | 4:104dd82c99b8 | 1171 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1172 | else if( service_subtype == OBOSC_SUB_RESET ){\ |
shreeshas95 | 4:104dd82c99b8 | 1173 | reset_all;\ |
shreeshas95 | 4:104dd82c99b8 | 1174 | /*PENDING: VERIFY reset_all, RESET CDMS*/\ |
shreeshas95 | 0:f016e9e8d48b | 1175 | }\ |
shreeshas95 | 5:ab276a17ca07 | 1176 | else if( (service_subtype != OBOSC_SUB_DISABLE) && (service_subtype != OBOSC_SUB_RETRY) ){\ |
shreeshas95 | 4:104dd82c99b8 | 1177 | /*CHANGE THE ACK CODE TO INVALID TC*/\ |
shreeshas95 | 4:104dd82c99b8 | 1178 | ackl234new->TM_string[2] = 0xA2;\ |
shreeshas95 | 0:f016e9e8d48b | 1179 | }\ |
aniruddhv | 12:ffdb29353058 | 1180 | /*gPC.puts("completed obosc\r\n");*/\ |
shreeshas95 | 4:104dd82c99b8 | 1181 | } |
shreeshas95 | 4:104dd82c99b8 | 1182 | |
shreeshas95 | 4:104dd82c99b8 | 1183 | /*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 | 1184 | #define get_call_sign(tm_ptr) {\ |
shreeshas95 | 4:104dd82c99b8 | 1185 | Base_tm* call_sign_tm = new Short_tm;\ |
shreeshas95 | 4:104dd82c99b8 | 1186 | call_sign_tm->next_TM = NULL;\ |
shreeshas95 | 4:104dd82c99b8 | 1187 | tm_ptr = call_sign_tm;\ |
shreeshas95 | 4:104dd82c99b8 | 1188 | uint8_t temp8 = TMID_CALL_SIGN;\ |
shreeshas95 | 4:104dd82c99b8 | 1189 | PUTtmid(call_sign_tm->fields, temp8);\ |
shreeshas95 | 4:104dd82c99b8 | 1190 | temp8 = SHORT_TM_CODE;\ |
shreeshas95 | 4:104dd82c99b8 | 1191 | PUTshort_or_long_tm(call_sign_tm->fields, temp8);\ |
shreeshas95 | 4:104dd82c99b8 | 1192 | for( int i = 0 ; i < TM_SHORT_SIZE ; ++i ){\ |
shreeshas95 | 4:104dd82c99b8 | 1193 | call_sign_tm->TM_string[i] = gCALL_SIGN_STRING[i];\ |
shreeshas95 | 4:104dd82c99b8 | 1194 | }\ |
shreeshas95 | 0:f016e9e8d48b | 1195 | } |
shreeshas95 | 0:f016e9e8d48b | 1196 | |
shreeshas95 | 0:f016e9e8d48b | 1197 | #define EXECUTE_OBOSC_ONLY {\ |
shreeshas95 | 4:104dd82c99b8 | 1198 | Base_tm *obosc_tm_head = NULL;\ |
shreeshas95 | 4:104dd82c99b8 | 1199 | get_call_sign(obosc_tm_head);\ |
shreeshas95 | 4:104dd82c99b8 | 1200 | Base_tm *obosc_tm_current = obosc_tm_head;\ |
shreeshas95 | 4:104dd82c99b8 | 1201 | get_ack_l1(obosc_tm_current->next_TM);\ |
shreeshas95 | 4:104dd82c99b8 | 1202 | int overflowCountOBONLY = 0;\ |
shreeshas95 | 4:104dd82c99b8 | 1203 | while( obosc_tm_current->next_TM != NULL ){\ |
shreeshas95 | 4:104dd82c99b8 | 1204 | if( overflowCountOBONLY < TM_OVERFLOW_CONSTANT ){\ |
shreeshas95 | 4:104dd82c99b8 | 1205 | obosc_tm_current = obosc_tm_current->next_TM;\ |
shreeshas95 | 4:104dd82c99b8 | 1206 | ++overflowCountOBONLY;\ |
shreeshas95 | 4:104dd82c99b8 | 1207 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1208 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 1209 | /*PENDING: RESET CDMS*/\ |
shreeshas95 | 4:104dd82c99b8 | 1210 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 1211 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1212 | }\ |
shreeshas95 | 15:1c1ca992b43b | 1213 | for(uint8_t execute_psc = PSC_START_VALUE ; execute_psc < gTOTAL_VALID_TC ; ++execute_psc){\ |
shreeshas95 | 4:104dd82c99b8 | 1214 | Base_tc* current_TC = gHEAD_NODE_TCL;\ |
shreeshas95 | 4:104dd82c99b8 | 1215 | int overCount = 0;\ |
shreeshas95 | 0:f016e9e8d48b | 1216 | while( current_TC != NULL ){\ |
shreeshas95 | 4:104dd82c99b8 | 1217 | if( overCount < TCL_OVERFLOW_CONSTANT ){\ |
shreeshas95 | 4:104dd82c99b8 | 1218 | if( (GETcrc_pass(current_TC) == 1) && (GETpacket_seq_count(current_TC) == execute_psc) ){\ |
shreeshas95 | 4:104dd82c99b8 | 1219 | /*CHECK FOR OBOSC*/\ |
shreeshas95 | 0:f016e9e8d48b | 1220 | uint8_t temp82 = 0x00;\ |
shreeshas95 | 0:f016e9e8d48b | 1221 | isit_obosc(current_TC, temp82);\ |
shreeshas95 | 0:f016e9e8d48b | 1222 | if(temp82 == 0x01){\ |
shreeshas95 | 4:104dd82c99b8 | 1223 | uint16_t current_exec_status = GETexec_status(current_TC);\ |
shreeshas95 | 4:104dd82c99b8 | 1224 | if( (current_exec_status == TC_STATE_SUCCESSFULLY_EXECUTED) || (current_exec_status == TC_STATE_DISABLED) )\ |
shreeshas95 | 4:104dd82c99b8 | 1225 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 1226 | else if( (current_exec_status == TC_STATE_UNEXECUTED) || (current_exec_status == TC_STATE_MARKED_RETRY) ){\ |
aniruddhv | 12:ffdb29353058 | 1227 | /*gPC.printf("It is obosc: %u\r\n", execute_psc);*/\ |
shreeshas95 | 4:104dd82c99b8 | 1228 | /*EXECUTION OF OBOSC TC*/\ |
shreeshas95 | 4:104dd82c99b8 | 1229 | /*WARNING: LARGE MEMORY UTILIZATION FOR TC-LIST-REPORT */\ |
shreeshas95 | 4:104dd82c99b8 | 1230 | execute_obosc_core(current_TC, obosc_tm_current->next_TM);\ |
shreeshas95 | 4:104dd82c99b8 | 1231 | /*INCREMENT POINTER TO THE LAST NODE*/\ |
shreeshas95 | 4:104dd82c99b8 | 1232 | int overflowCountOBinside = 0;\ |
shreeshas95 | 4:104dd82c99b8 | 1233 | while( obosc_tm_current->next_TM != NULL ){\ |
shreeshas95 | 4:104dd82c99b8 | 1234 | if( overflowCountOBinside < TM_OVERFLOW_CONSTANT ){\ |
shreeshas95 | 4:104dd82c99b8 | 1235 | obosc_tm_current = obosc_tm_current->next_TM;\ |
shreeshas95 | 4:104dd82c99b8 | 1236 | ++overflowCountOBinside;\ |
shreeshas95 | 4:104dd82c99b8 | 1237 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1238 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 1239 | /*PENDING: RESET CDMS*/\ |
shreeshas95 | 4:104dd82c99b8 | 1240 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 1241 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1242 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1243 | uint16_t temp16 = TC_STATE_SUCCESSFULLY_EXECUTED;\ |
shreeshas95 | 4:104dd82c99b8 | 1244 | PUTexec_status(current_TC, temp16);\ |
shreeshas95 | 0:f016e9e8d48b | 1245 | }\ |
shreeshas95 | 0:f016e9e8d48b | 1246 | }\ |
shreeshas95 | 0:f016e9e8d48b | 1247 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1248 | current_TC = current_TC->next_TC;\ |
shreeshas95 | 4:104dd82c99b8 | 1249 | ++overCount;\ |
shreeshas95 | 0:f016e9e8d48b | 1250 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1251 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 1252 | /*PENDING: REST CDMS: MEMORY LEAK FOUND*/\ |
shreeshas95 | 4:104dd82c99b8 | 1253 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 1254 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1255 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1256 | }\ |
shreeshas95 | 15:1c1ca992b43b | 1257 | obosc_tm_current = obosc_tm_head;\ |
shreeshas95 | 15:1c1ca992b43b | 1258 | while( obosc_tm_current != NULL ){\ |
shreeshas95 | 15:1c1ca992b43b | 1259 | int length = TM_SHORT_SIZE;\ |
shreeshas95 | 15:1c1ca992b43b | 1260 | if( GETshort_or_long_tm(obosc_tm_current->fields) == SHORT_TM_CODE ){\ |
shreeshas95 | 15:1c1ca992b43b | 1261 | length = TM_SHORT_SIZE;\ |
shreeshas95 | 15:1c1ca992b43b | 1262 | }\ |
shreeshas95 | 15:1c1ca992b43b | 1263 | else{\ |
shreeshas95 | 15:1c1ca992b43b | 1264 | length = TM_LONG_SIZE;\ |
shreeshas95 | 15:1c1ca992b43b | 1265 | }\ |
shreeshas95 | 15:1c1ca992b43b | 1266 | for(int i = 0 ; i < length ; ++i){\ |
shreeshas95 | 15:1c1ca992b43b | 1267 | gPC.putc(obosc_tm_current->TM_string[i]);\ |
shreeshas95 | 15:1c1ca992b43b | 1268 | }\ |
shreeshas95 | 15:1c1ca992b43b | 1269 | obosc_tm_current = obosc_tm_current->next_TM;\ |
shreeshas95 | 15:1c1ca992b43b | 1270 | }\ |
ee12b079 | 25:60964ad4f13b | 1271 | /*snd_tm.head_pointer(obosc_tm_head);*/\ |
ee12b079 | 34:f0b518523381 | 1272 | /*adf_not_SDcard();*/\ |
shreeshas95 | 4:104dd82c99b8 | 1273 | /*DELETE THE TM AFTER USE*/\ |
shreeshas95 | 4:104dd82c99b8 | 1274 | obosc_tm_current = obosc_tm_head;\ |
shreeshas95 | 4:104dd82c99b8 | 1275 | int overCount = 0;\ |
shreeshas95 | 4:104dd82c99b8 | 1276 | while( obosc_tm_current != NULL ){\ |
shreeshas95 | 4:104dd82c99b8 | 1277 | if( (overCount < TM_OVERFLOW_CONSTANT) ){\ |
shreeshas95 | 4:104dd82c99b8 | 1278 | Base_tm *temp = obosc_tm_current->next_TM;\ |
shreeshas95 | 4:104dd82c99b8 | 1279 | delete obosc_tm_current;\ |
shreeshas95 | 4:104dd82c99b8 | 1280 | obosc_tm_current = temp;\ |
shreeshas95 | 5:ab276a17ca07 | 1281 | ++overCount;\ |
shreeshas95 | 4:104dd82c99b8 | 1282 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1283 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 1284 | /*PENDING: RESET CDMS: MEMORY LEAK FOUND*/\ |
shreeshas95 | 4:104dd82c99b8 | 1285 | break;\ |
shreeshas95 | 0:f016e9e8d48b | 1286 | }\ |
shreeshas95 | 0:f016e9e8d48b | 1287 | }\ |
shreeshas95 | 0:f016e9e8d48b | 1288 | } |
shreeshas95 | 0:f016e9e8d48b | 1289 | |
shreeshas95 | 0:f016e9e8d48b | 1290 | #define EXECUTE_TC {\ |
shreeshas95 | 5:ab276a17ca07 | 1291 | gMASTER_STATE = TCL_STATE_EXECUTING;\ |
ee12b079 | 34:f0b518523381 | 1292 | /*gPC.printf("%u\r\n", gTOTAL_VALID_TC);*/\ |
rohit3342 | 16:538de1b20b3a | 1293 | for(uint8_t execute_psc = PSC_START_VALUE ; execute_psc < gTOTAL_VALID_TC ; ++execute_psc ){\ |
ee12b079 | 34:f0b518523381 | 1294 | /*gPC.printf("executing normal %u\r\n", execute_psc);*/\ |
shreeshas95 | 2:2caf2a9a13aa | 1295 | /*gLEDG = !gLEDG;*/\ |
shreeshas95 | 2:2caf2a9a13aa | 1296 | /*gLEDR = !gLEDR;*/\ |
shreeshas95 | 0:f016e9e8d48b | 1297 | Base_tc* current_TC = gHEAD_NODE_TCL;\ |
shreeshas95 | 4:104dd82c99b8 | 1298 | int overflowCount = 0;\ |
shreeshas95 | 0:f016e9e8d48b | 1299 | while(current_TC != NULL){\ |
shreeshas95 | 4:104dd82c99b8 | 1300 | if( overflowCount < TCL_OVERFLOW_CONSTANT ){\ |
shreeshas95 | 4:104dd82c99b8 | 1301 | if( (GETcrc_pass(current_TC) == 1) && (GETpacket_seq_count(current_TC) == execute_psc) ){\ |
shreeshas95 | 4:104dd82c99b8 | 1302 | uint8_t current_exec_status = GETexec_status(current_TC);\ |
shreeshas95 | 5:ab276a17ca07 | 1303 | if( (current_exec_status == TC_STATE_SUCCESSFULLY_EXECUTED) || (current_exec_status == TC_STATE_DISABLED) ){\ |
aniruddhv | 12:ffdb29353058 | 1304 | /*gPC.printf("disabled or completed at %u\n", execute_psc);*/\ |
shreeshas95 | 4:104dd82c99b8 | 1305 | break;\ |
shreeshas95 | 5:ab276a17ca07 | 1306 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1307 | else if( (current_exec_status == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\ |
aniruddhv | 12:ffdb29353058 | 1308 | /*gPC.printf("abort on nack at %u psc\r\n", execute_psc);*/\ |
shreeshas95 | 4:104dd82c99b8 | 1309 | gMASTER_STATE = TCL_STATE_ABORTED;\ |
shreeshas95 | 4:104dd82c99b8 | 1310 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 1311 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1312 | else if( (current_exec_status == TC_STATE_UNEXECUTED) || (current_exec_status == TC_STATE_MARKED_RETRY) ){\ |
shreeshas95 | 4:104dd82c99b8 | 1313 | /*EXECUTION OF TC START*/\ |
shreeshas95 | 4:104dd82c99b8 | 1314 | uint8_t temp81 = 0x00;\ |
shreeshas95 | 4:104dd82c99b8 | 1315 | isit_sdcard(current_TC, temp81);\ |
shreeshas95 | 4:104dd82c99b8 | 1316 | if( temp81 == 0x00 ){\ |
aniruddhv | 12:ffdb29353058 | 1317 | /*gPC.printf("non sd card at %u\r\n", execute_psc);*/\ |
shreeshas95 | 4:104dd82c99b8 | 1318 | /*EXECUTION OF NON SD-CARD (BOTH OBOSC and CDMS functions)*/\ |
shreeshas95 | 4:104dd82c99b8 | 1319 | Base_tm *tm_ptr_head = NULL;\ |
shreeshas95 | 4:104dd82c99b8 | 1320 | get_call_sign(tm_ptr_head);\ |
shreeshas95 | 4:104dd82c99b8 | 1321 | Base_tm *put_tm_here = NULL;\ |
shreeshas95 | 4:104dd82c99b8 | 1322 | uint8_t temp82 = 0x00;\ |
shreeshas95 | 4:104dd82c99b8 | 1323 | uint8_t tempPAhot = 0x00;\ |
shreeshas95 | 4:104dd82c99b8 | 1324 | isit_obosc(current_TC, temp82);\ |
shreeshas95 | 4:104dd82c99b8 | 1325 | if(temp82 == 0x01){\ |
aniruddhv | 12:ffdb29353058 | 1326 | /*gPC.printf("obosc tc inside normal tc at %u\r\n", execute_psc);*/\ |
shreeshas95 | 4:104dd82c99b8 | 1327 | /*EXECUTION OF OBOSC TC*/\ |
shreeshas95 | 4:104dd82c99b8 | 1328 | /*SKIP EXECUTION OF OBOSC HERE*/\ |
shreeshas95 | 4:104dd82c99b8 | 1329 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1330 | else{\ |
ee12b079 | 35:3beac900a034 | 1331 | gPC.printf("cdms relay tmtc at %u\r\n", execute_psc);\ |
ee12b079 | 35:3beac900a034 | 1332 | put_tm_here = FCTN_CDMS_RLY_TMTC(current_TC);\ |
Shashank7906 | 49:1103da5a87f5 | 1333 | gPC.printf("first : %02X\n",put_tm_here->TM_string[0]);\ |
shreeshas95 | 4:104dd82c99b8 | 1334 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1335 | /*DETECT ACK OR NACK*/\ |
shreeshas95 | 4:104dd82c99b8 | 1336 | uint8_t temp83 = 0x00;\ |
shreeshas95 | 4:104dd82c99b8 | 1337 | uint8_t temp84 = GETpacket_seq_count(current_TC);\ |
shreeshas95 | 4:104dd82c99b8 | 1338 | detect_ack(put_tm_here, temp83, temp84);\ |
shreeshas95 | 4:104dd82c99b8 | 1339 | if( temp83 == 0x01){\ |
shreeshas95 | 4:104dd82c99b8 | 1340 | uint16_t temp16 = TC_STATE_SUCCESSFULLY_EXECUTED;\ |
shreeshas95 | 4:104dd82c99b8 | 1341 | PUTexec_status(current_TC, temp16);\ |
shreeshas95 | 4:104dd82c99b8 | 1342 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1343 | else{\ |
ee12b079 | 34:f0b518523381 | 1344 | /*gPC.puts("TC_STATE_EXECUTION_FAILED");*/\ |
shreeshas95 | 4:104dd82c99b8 | 1345 | uint16_t temp16 = TC_STATE_EXECUTION_FAILED;\ |
shreeshas95 | 4:104dd82c99b8 | 1346 | PUTexec_status(current_TC, temp16);\ |
shreeshas95 | 4:104dd82c99b8 | 1347 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1348 | /*ABORT ON NACK AND TC LIST COMPLETED: UPDATE IN gMASTERSTATE*/\ |
shreeshas95 | 4:104dd82c99b8 | 1349 | if( (GETexec_status(current_TC) == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\ |
shreeshas95 | 4:104dd82c99b8 | 1350 | gMASTER_STATE = TCL_STATE_ABORTED;\ |
shreeshas95 | 4:104dd82c99b8 | 1351 | }\ |
shreeshas95 | 15:1c1ca992b43b | 1352 | else if( execute_psc == (gTOTAL_VALID_TC-1) ){\ |
shreeshas95 | 4:104dd82c99b8 | 1353 | /*LAST TC IS EXECUTED*/\ |
shreeshas95 | 4:104dd82c99b8 | 1354 | gMASTER_STATE = TCL_STATE_COMPLETED;\ |
shreeshas95 | 4:104dd82c99b8 | 1355 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1356 | /*update last executed L1_ack*/\ |
shreeshas95 | 4:104dd82c99b8 | 1357 | if( put_tm_here != NULL ){\ |
shreeshas95 | 4:104dd82c99b8 | 1358 | if( GETshort_or_long_tm(put_tm_here->fields) == SHORT_TM_CODE ){\ |
shreeshas95 | 4:104dd82c99b8 | 1359 | for(int i = 0 ; i < TM_SHORT_SIZE ; ++i){\ |
shreeshas95 | 4:104dd82c99b8 | 1360 | gLAST_TM[i] = put_tm_here->TM_string[i];\ |
shreeshas95 | 4:104dd82c99b8 | 1361 | gLAST_TM_SHORT_OR_LONG = SHORT_TM_CODE;\ |
shreeshas95 | 4:104dd82c99b8 | 1362 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1363 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1364 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 1365 | for( int i = 0 ; i < TM_LONG_SIZE ; ++i ){\ |
shreeshas95 | 4:104dd82c99b8 | 1366 | gLAST_TM[i] = put_tm_here->TM_string[i];\ |
shreeshas95 | 4:104dd82c99b8 | 1367 | gLAST_TM_SHORT_OR_LONG = LONG_TM_CODE;\ |
shreeshas95 | 4:104dd82c99b8 | 1368 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1369 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1370 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1371 | /*PENDING: APPEND ACK L1*/\ |
shreeshas95 | 4:104dd82c99b8 | 1372 | Base_tm *tm_ptr = tm_ptr_head;\ |
shreeshas95 | 4:104dd82c99b8 | 1373 | get_ack_l1(tm_ptr->next_TM);\ |
shreeshas95 | 4:104dd82c99b8 | 1374 | int overflowCountExecute = 0;\ |
shreeshas95 | 4:104dd82c99b8 | 1375 | while( tm_ptr->next_TM != NULL ){\ |
shreeshas95 | 4:104dd82c99b8 | 1376 | if( overflowCountExecute < TM_OVERFLOW_CONSTANT ){\ |
shreeshas95 | 4:104dd82c99b8 | 1377 | tm_ptr = tm_ptr->next_TM;\ |
shreeshas95 | 4:104dd82c99b8 | 1378 | ++overflowCountExecute;\ |
shreeshas95 | 4:104dd82c99b8 | 1379 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1380 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 1381 | /*PENDING: RESET CDMS*/\ |
shreeshas95 | 4:104dd82c99b8 | 1382 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 1383 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1384 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1385 | tm_ptr->next_TM = put_tm_here;\ |
shreeshas95 | 4:104dd82c99b8 | 1386 | /*CHECK FOR HOT PA*/\ |
shreeshas95 | 4:104dd82c99b8 | 1387 | isPAhot(tempPAhot);\ |
shreeshas95 | 4:104dd82c99b8 | 1388 | if( tempPAhot == 0x00 ){\ |
shreeshas95 | 4:104dd82c99b8 | 1389 | gFLAGS = gFLAGS | COM_PA_HOT_FLAG;\ |
shreeshas95 | 4:104dd82c99b8 | 1390 | }\ |
shreeshas95 | 15:1c1ca992b43b | 1391 | tm_ptr = tm_ptr_head;\ |
shreeshas95 | 15:1c1ca992b43b | 1392 | while( tm_ptr != NULL ){\ |
shreeshas95 | 15:1c1ca992b43b | 1393 | int length = TM_SHORT_SIZE;\ |
shreeshas95 | 15:1c1ca992b43b | 1394 | if( GETshort_or_long_tm(tm_ptr->fields) == SHORT_TM_CODE ){\ |
shreeshas95 | 15:1c1ca992b43b | 1395 | length = TM_SHORT_SIZE;\ |
shreeshas95 | 15:1c1ca992b43b | 1396 | }\ |
shreeshas95 | 15:1c1ca992b43b | 1397 | else{\ |
shreeshas95 | 15:1c1ca992b43b | 1398 | length = TM_LONG_SIZE;\ |
shreeshas95 | 15:1c1ca992b43b | 1399 | }\ |
Shashank7906 | 49:1103da5a87f5 | 1400 | gPC.printf("\ndata: \n");\ |
ee12b079 | 34:f0b518523381 | 1401 | /*gPC.puts("Printing Call Sign, ACK_L1, TM list");*/\ |
shreeshas95 | 15:1c1ca992b43b | 1402 | for(int i = 0 ; i < length ; ++i){\ |
Shashank7906 | 49:1103da5a87f5 | 1403 | gPC.putc(tm_ptr->TM_string[i]);\ |
Shashank7906 | 49:1103da5a87f5 | 1404 | /*gPC.putc(tm_ptr->TM_string[i]);*/\ |
Shashank7906 | 41:7e06018f6a1c | 1405 | gPC.printf("%02X",tm_ptr->TM_string[i]);\ |
shreeshas95 | 15:1c1ca992b43b | 1406 | }\ |
shreeshas95 | 15:1c1ca992b43b | 1407 | tm_ptr = tm_ptr->next_TM;\ |
shreeshas95 | 15:1c1ca992b43b | 1408 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1409 | /*SEND DATA TO GS*/\ |
Shashank7906 | 49:1103da5a87f5 | 1410 | /*snd_tm.head_pointer(tm_ptr_head);*/\ |
Shashank7906 | 49:1103da5a87f5 | 1411 | /*adf_not_SDcard();*/\ |
Shashank7906 | 41:7e06018f6a1c | 1412 | snd_tm.head_pointer(tm_ptr_head);\ |
Shashank7906 | 41:7e06018f6a1c | 1413 | adf_not_SDcard;\ |
shreeshas95 | 4:104dd82c99b8 | 1414 | /*DELETE THE TM AFTER USE*/\ |
shreeshas95 | 4:104dd82c99b8 | 1415 | tm_ptr = tm_ptr_head;\ |
shreeshas95 | 4:104dd82c99b8 | 1416 | overflowCountExecute = 0;\ |
shreeshas95 | 4:104dd82c99b8 | 1417 | while(tm_ptr != NULL){\ |
shreeshas95 | 4:104dd82c99b8 | 1418 | if( overflowCountExecute < TM_OVERFLOW_CONSTANT ){\ |
shreeshas95 | 4:104dd82c99b8 | 1419 | Base_tm *temp = tm_ptr->next_TM;\ |
shreeshas95 | 4:104dd82c99b8 | 1420 | delete tm_ptr;\ |
shreeshas95 | 4:104dd82c99b8 | 1421 | tm_ptr = temp;\ |
shreeshas95 | 4:104dd82c99b8 | 1422 | ++overflowCountExecute;\ |
shreeshas95 | 4:104dd82c99b8 | 1423 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1424 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 1425 | /*PENDING: RESET CDMS*/\ |
shreeshas95 | 4:104dd82c99b8 | 1426 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 1427 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1428 | }\ |
shreeshas95 | 0:f016e9e8d48b | 1429 | }\ |
shreeshas95 | 0:f016e9e8d48b | 1430 | else{\ |
aniruddhv | 12:ffdb29353058 | 1431 | /*gPC.printf("sd card at %u\r\n", execute_psc);*/\ |
shreeshas95 | 4:104dd82c99b8 | 1432 | /*EXECUTION OF SD-CARD DATA SENDING (OBSRS)*/\ |
shreeshas95 | 4:104dd82c99b8 | 1433 | /*CHECK FOR HOT PA*/\ |
shreeshas95 | 4:104dd82c99b8 | 1434 | uint8_t tempPAhot = 0x00;\ |
shreeshas95 | 4:104dd82c99b8 | 1435 | isPAhot(tempPAhot);\ |
shreeshas95 | 4:104dd82c99b8 | 1436 | if( tempPAhot == 0x00 ){\ |
shreeshas95 | 4:104dd82c99b8 | 1437 | gFLAGS = gFLAGS | COM_PA_HOT_FLAG;\ |
shreeshas95 | 4:104dd82c99b8 | 1438 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1439 | /*read_TC(current_TC);*/\ |
shreeshas95 | 6:79d422d1ed42 | 1440 | uint8_t tempExec = TC_STATE_SUCCESSFULLY_EXECUTED;\ |
shreeshas95 | 6:79d422d1ed42 | 1441 | PUTexec_status(current_TC, tempExec);\ |
shreeshas95 | 6:79d422d1ed42 | 1442 | /*PENDING: ABORT ON NACK CHECK, gMASTER_STATE VERIFICATION WITH SD CARD, session timeout, last executed ack l234*/\ |
shreeshas95 | 4:104dd82c99b8 | 1443 | if( (GETexec_status(current_TC) == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\ |
shreeshas95 | 4:104dd82c99b8 | 1444 | gMASTER_STATE = TCL_STATE_ABORTED;\ |
shreeshas95 | 0:f016e9e8d48b | 1445 | }\ |
shreeshas95 | 15:1c1ca992b43b | 1446 | else if( execute_psc == (gTOTAL_VALID_TC-1) ){\ |
shreeshas95 | 6:79d422d1ed42 | 1447 | gMASTER_STATE = TCL_STATE_COMPLETED;\ |
shreeshas95 | 6:79d422d1ed42 | 1448 | }\ |
shreeshas95 | 0:f016e9e8d48b | 1449 | }\ |
shreeshas95 | 0:f016e9e8d48b | 1450 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1451 | break;\ |
shreeshas95 | 0:f016e9e8d48b | 1452 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1453 | current_TC = current_TC->next_TC;\ |
shreeshas95 | 4:104dd82c99b8 | 1454 | ++overflowCount;\ |
shreeshas95 | 0:f016e9e8d48b | 1455 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1456 | else{\ |
shreeshas95 | 4:104dd82c99b8 | 1457 | /*PENDING: RESET CDMS*/\ |
shreeshas95 | 2:2caf2a9a13aa | 1458 | break;\ |
shreeshas95 | 2:2caf2a9a13aa | 1459 | }\ |
shreeshas95 | 2:2caf2a9a13aa | 1460 | }\ |
shreeshas95 | 6:79d422d1ed42 | 1461 | if( gFLAGS & COM_SESSION_TIMEOUT_FLAG ){\ |
shreeshas95 | 6:79d422d1ed42 | 1462 | break;\ |
shreeshas95 | 6:79d422d1ed42 | 1463 | }\ |
shreeshas95 | 6:79d422d1ed42 | 1464 | else if( gMASTER_STATE == TCL_STATE_ABORTED ){\ |
aniruddhv | 12:ffdb29353058 | 1465 | /*gPC.puts("ABORTING DUE TO ABORT ON NACK\r\n");*/\ |
shreeshas95 | 4:104dd82c99b8 | 1466 | /*EXITED DUE TO ABORT ON NACK:*/\ |
shreeshas95 | 2:2caf2a9a13aa | 1467 | /*PENDING : POWER OFF COM TX*/\ |
shreeshas95 | 2:2caf2a9a13aa | 1468 | RX1M.attach(&rx_read, Serial::RxIrq);\ |
shreeshas95 | 2:2caf2a9a13aa | 1469 | gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\ |
shreeshas95 | 0:f016e9e8d48b | 1470 | break;\ |
shreeshas95 | 2:2caf2a9a13aa | 1471 | }\ |
shreeshas95 | 4:104dd82c99b8 | 1472 | else if( gFLAGS & COM_PA_HOT_FLAG ){\ |
shreeshas95 | 4:104dd82c99b8 | 1473 | /*PA HOT: WAIT FOR TIMEOUT*/\ |
shreeshas95 | 4:104dd82c99b8 | 1474 | gCOM_PA_COOLING_TIMEOUT.attach(&after_cooling_pa, COM_PA_COOLING_TIME_LIMIT);\ |
shreeshas95 | 4:104dd82c99b8 | 1475 | /*PENDING : POWER OFF COMM TX*/\ |
shreeshas95 | 4:104dd82c99b8 | 1476 | RX1M.attach(&rx_read, Serial::RxIrq);\ |
shreeshas95 | 4:104dd82c99b8 | 1477 | gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\ |
shreeshas95 | 2:2caf2a9a13aa | 1478 | break;\ |
shreeshas95 | 2:2caf2a9a13aa | 1479 | }\ |
aniruddhv | 12:ffdb29353058 | 1480 | /*gPC.printf("successflly executed %u tc\r\n", execute_psc);*/\ |
shreeshas95 | 0:f016e9e8d48b | 1481 | }\ |
shreeshas95 | 6:79d422d1ed42 | 1482 | if( (gMASTER_STATE == TCL_STATE_COMPLETED) || (gFLAGS & COM_SESSION_TIMEOUT_FLAG) ){\ |
aniruddhv | 12:ffdb29353058 | 1483 | /*gPC.printf("completed or session timed out: %x\r\n", gMASTER_STATE);*/\ |
shreeshas95 | 5:ab276a17ca07 | 1484 | /*COMPLETED EXECUTION OF TC*/\ |
shreeshas95 | 5:ab276a17ca07 | 1485 | gMASTER_STATE = TCL_STATE_COMPLETED;\ |
shreeshas95 | 5:ab276a17ca07 | 1486 | COM_POWER_OFF_TX;\ |
shreeshas95 | 5:ab276a17ca07 | 1487 | reset_all;\ |
shreeshas95 | 5:ab276a17ca07 | 1488 | /*PENDING : ENABLE THREADS*/\ |
shreeshas95 | 5:ab276a17ca07 | 1489 | gSESSION_TIMEOUT.detach();\ |
shreeshas95 | 5:ab276a17ca07 | 1490 | gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG);\ |
shreeshas95 | 5:ab276a17ca07 | 1491 | gFLAGS = gFLAGS & (~COM_SESSION_FLAG);\ |
shreeshas95 | 5:ab276a17ca07 | 1492 | }\ |
Shashank7906 | 49:1103da5a87f5 | 1493 | } |