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