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