To fix the hang problem
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE by
COM_POWER_ON_TX.h@319:c11a52b91d25, 2016-12-08 (annotated)
- Committer:
- ee12b079
- Date:
- Thu Dec 08 15:17:24 2016 +0000
- Revision:
- 319:c11a52b91d25
- Parent:
- 295:699801854b71
- Child:
- 333:cddef120cae3
changed few flags
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
aniruddhv | 262:752c8689944a | 1 | #define STANDBY_PRCS(tm_ptr){\ |
aniruddhv | 262:752c8689944a | 2 | Base_tc *stdby_tc = new Long_tc;\ |
aniruddhv | 262:752c8689944a | 3 | stdby_tc->next_TC = NULL;\ |
aniruddhv | 262:752c8689944a | 4 | PUTshort_or_long(stdby_tc,LONG_TC_CODE);\ |
aniruddhv | 262:752c8689944a | 5 | PUTcrc_pass(stdby_tc,0x1);\ |
aniruddhv | 262:752c8689944a | 6 | PUTexec_status(stdby_tc,0);\ |
aniruddhv | 262:752c8689944a | 7 | stdby_tc->TC_string[0] = 0x01;\ |
aniruddhv | 262:752c8689944a | 8 | stdby_tc->TC_string[1] = 0x41;\ |
aniruddhv | 262:752c8689944a | 9 | stdby_tc->TC_string[2] = 0x81;\ |
aniruddhv | 262:752c8689944a | 10 | stdby_tc->TC_string[3] = 0x40;\ |
aniruddhv | 262:752c8689944a | 11 | stdby_tc->TC_string[4] = 0;\ |
aniruddhv | 262:752c8689944a | 12 | stdby_tc->TC_string[5] = 0;\ |
aniruddhv | 262:752c8689944a | 13 | stdby_tc->TC_string[6] = 0;\ |
aniruddhv | 262:752c8689944a | 14 | stdby_tc->TC_string[7] = 0;\ |
aniruddhv | 262:752c8689944a | 15 | stdby_tc->TC_string[8] = 0;\ |
aniruddhv | 262:752c8689944a | 16 | uint16_t crc16 = crc16_gen(stdby_tc->TC_string, 9);\ |
aniruddhv | 262:752c8689944a | 17 | stdby_tc->TC_string[9] = (crc16 & 0xFF00)>>8;\ |
aniruddhv | 262:752c8689944a | 18 | stdby_tc->TC_string[10] = (crc16 & 0x00FF);\ |
aniruddhv | 262:752c8689944a | 19 | for(int i = 11; i < 135; i++){\ |
aniruddhv | 262:752c8689944a | 20 | stdby_tc->TC_string[i] = 0;\ |
aniruddhv | 262:752c8689944a | 21 | }\ |
aniruddhv | 262:752c8689944a | 22 | tm_ptr = FCTN_CDMS_RLY_TMTC(stdby_tc);\ |
aniruddhv | 262:752c8689944a | 23 | delete stdby_tc;\ |
aniruddhv | 262:752c8689944a | 24 | } |
aniruddhv | 262:752c8689944a | 25 | |
aniruddhv | 262:752c8689944a | 26 | #define SET_BCN_STANDBY(tm_ptr){\ |
aniruddhv | 262:752c8689944a | 27 | Base_tc *beacon_tc = new Long_tc;\ |
aniruddhv | 262:752c8689944a | 28 | beacon_tc->next_TC = NULL;\ |
aniruddhv | 262:752c8689944a | 29 | PUTshort_or_long(beacon_tc,LONG_TC_CODE);\ |
aniruddhv | 262:752c8689944a | 30 | PUTcrc_pass(beacon_tc,0x1);\ |
aniruddhv | 262:752c8689944a | 31 | PUTexec_status(beacon_tc,0);\ |
aniruddhv | 262:752c8689944a | 32 | beacon_tc->TC_string[0] = 0x01;\ |
aniruddhv | 262:752c8689944a | 33 | beacon_tc->TC_string[1] = BCN_APID_SOURCE;\ |
aniruddhv | 262:752c8689944a | 34 | beacon_tc->TC_string[2] = BCN_SERVICE;\ |
aniruddhv | 262:752c8689944a | 35 | beacon_tc->TC_string[3] = 0xE2;\ |
aniruddhv | 262:752c8689944a | 36 | beacon_tc->TC_string[4] = 0x01;\ |
aniruddhv | 262:752c8689944a | 37 | beacon_tc->TC_string[5] = 0;\ |
aniruddhv | 262:752c8689944a | 38 | beacon_tc->TC_string[6] = 0;\ |
aniruddhv | 262:752c8689944a | 39 | beacon_tc->TC_string[7] = 0;\ |
aniruddhv | 262:752c8689944a | 40 | beacon_tc->TC_string[8] = 0;\ |
aniruddhv | 262:752c8689944a | 41 | uint16_t crc16 = crc16_gen(beacon_tc->TC_string, 9);\ |
aniruddhv | 262:752c8689944a | 42 | beacon_tc->TC_string[9] = (crc16 & 0xFF00)>>8;\ |
aniruddhv | 262:752c8689944a | 43 | beacon_tc->TC_string[10] = (crc16 & 0x00FF);\ |
aniruddhv | 262:752c8689944a | 44 | for(int i = 11; i < 135; i++){\ |
aniruddhv | 262:752c8689944a | 45 | beacon_tc->TC_string[i] = 0;\ |
aniruddhv | 262:752c8689944a | 46 | }\ |
aniruddhv | 262:752c8689944a | 47 | tm_ptr = FCTN_CDMS_RLY_TMTC(beacon_tc);\ |
aniruddhv | 262:752c8689944a | 48 | delete beacon_tc;\ |
aniruddhv | 262:752c8689944a | 49 | } |
aniruddhv | 262:752c8689944a | 50 | |
aniruddhv | 262:752c8689944a | 51 | #define P_CDMS_HK_MAIN {\ |
aniruddhv | 262:752c8689944a | 52 | Base_tc *hk_main_ptr = new Short_tc;\ |
aniruddhv | 262:752c8689944a | 53 | hk_main_ptr->next_TC = NULL;\ |
aniruddhv | 262:752c8689944a | 54 | PUTshort_or_long(hk_main_ptr,SHORT_TC_CODE);\ |
aniruddhv | 262:752c8689944a | 55 | PUTcrc_pass(hk_main_ptr,0x1);\ |
aniruddhv | 262:752c8689944a | 56 | PUTexec_status(hk_main_ptr,0);\ |
aniruddhv | 262:752c8689944a | 57 | hk_main_ptr->TC_string[0] = 0x01;\ |
aniruddhv | 262:752c8689944a | 58 | hk_main_ptr->TC_string[1] = 0x81;\ |
aniruddhv | 262:752c8689944a | 59 | hk_main_ptr->TC_string[2] = 0x81;\ |
aniruddhv | 262:752c8689944a | 60 | hk_main_ptr->TC_string[3] = 0x04;\ |
aniruddhv | 262:752c8689944a | 61 | hk_main_ptr->TC_string[4] = 0;\ |
aniruddhv | 262:752c8689944a | 62 | hk_main_ptr->TC_string[5] = 0;\ |
aniruddhv | 262:752c8689944a | 63 | hk_main_ptr->TC_string[6] = 0;\ |
aniruddhv | 262:752c8689944a | 64 | hk_main_ptr->TC_string[7] = 0;\ |
aniruddhv | 262:752c8689944a | 65 | hk_main_ptr->TC_string[8] = 0;\ |
aniruddhv | 262:752c8689944a | 66 | uint16_t crc16 = crc16_gen(hk_main_ptr->TC_string, 9);\ |
aniruddhv | 262:752c8689944a | 67 | hk_main_ptr->TC_string[9] = (crc16 & 0xFF00)>>8;\ |
aniruddhv | 262:752c8689944a | 68 | hk_main_ptr->TC_string[10] = (crc16 & 0x00FF);\ |
aniruddhv | 262:752c8689944a | 69 | Base_tm *tm_ptr = NULL;\ |
aniruddhv | 262:752c8689944a | 70 | tm_ptr = FCTN_CDMS_RLY_TMTC(hk_main_ptr);\ |
aniruddhv | 262:752c8689944a | 71 | delete hk_main_ptr;\ |
aniruddhv | 262:752c8689944a | 72 | /*DELETE THE TM AFTER USE*/\ |
aniruddhv | 262:752c8689944a | 73 | Base_tm *del_tm = tm_ptr;\ |
aniruddhv | 262:752c8689944a | 74 | int overCount = 0;\ |
aniruddhv | 262:752c8689944a | 75 | while( del_tm != NULL ){\ |
aniruddhv | 262:752c8689944a | 76 | if( (overCount < TM_OVERFLOW_CONSTANT) ){\ |
aniruddhv | 262:752c8689944a | 77 | Base_tm *temp = del_tm->next_TM;\ |
aniruddhv | 262:752c8689944a | 78 | delete del_tm;\ |
aniruddhv | 262:752c8689944a | 79 | del_tm = temp;\ |
aniruddhv | 262:752c8689944a | 80 | ++overCount;\ |
shreeshas95 | 4:104dd82c99b8 | 81 | }\ |
aniruddhv | 262:752c8689944a | 82 | else{\ |
aniruddhv | 262:752c8689944a | 83 | RESET_CDMS;\ |
shreeshas95 | 4:104dd82c99b8 | 84 | break;\ |
shreeshas95 | 4:104dd82c99b8 | 85 | }\ |
shreeshas95 | 4:104dd82c99b8 | 86 | }\ |
aniruddhv | 262:752c8689944a | 87 | } |
aniruddhv | 262:752c8689944a | 88 | |
aniruddhv | 262:752c8689944a | 89 | #define P_BCN_TX_MAIN(tm_ptr) {\ |
aniruddhv | 262:752c8689944a | 90 | Base_tc *bcn_tx_main_ptr = new Long_tc;\ |
aniruddhv | 262:752c8689944a | 91 | bcn_tx_main_ptr->next_TC = NULL;\ |
aniruddhv | 262:752c8689944a | 92 | PUTshort_or_long(bcn_tx_main_ptr,LONG_TC_CODE);\ |
aniruddhv | 262:752c8689944a | 93 | PUTcrc_pass(bcn_tx_main_ptr,0x1);\ |
aniruddhv | 262:752c8689944a | 94 | PUTexec_status(bcn_tx_main_ptr,0);\ |
aniruddhv | 262:752c8689944a | 95 | bcn_tx_main_ptr->TC_string[0] = 0x01;\ |
aniruddhv | 262:752c8689944a | 96 | bcn_tx_main_ptr->TC_string[1] = 0x41;\ |
aniruddhv | 262:752c8689944a | 97 | bcn_tx_main_ptr->TC_string[2] = 0x81;\ |
aniruddhv | 262:752c8689944a | 98 | bcn_tx_main_ptr->TC_string[3] = 0x07;\ |
aniruddhv | 262:752c8689944a | 99 | bcn_tx_main_ptr->TC_string[4] = 0;\ |
aniruddhv | 262:752c8689944a | 100 | bcn_tx_main_ptr->TC_string[5] = 0;\ |
aniruddhv | 262:752c8689944a | 101 | bcn_tx_main_ptr->TC_string[6] = 0;\ |
aniruddhv | 262:752c8689944a | 102 | bcn_tx_main_ptr->TC_string[7] = 0;\ |
aniruddhv | 262:752c8689944a | 103 | bcn_tx_main_ptr->TC_string[8] = 0;\ |
aniruddhv | 262:752c8689944a | 104 | uint16_t crc16 = crc16_gen(bcn_tx_main_ptr->TC_string, 9);\ |
aniruddhv | 262:752c8689944a | 105 | bcn_tx_main_ptr->TC_string[9] = (crc16 & 0xFF00)>>8;\ |
aniruddhv | 262:752c8689944a | 106 | bcn_tx_main_ptr->TC_string[10] = (crc16 & 0x00FF);\ |
aniruddhv | 262:752c8689944a | 107 | for(int i = 11; i < 135; i++){\ |
aniruddhv | 262:752c8689944a | 108 | bcn_tx_main_ptr->TC_string[i] = 0;\ |
shreeshas95 | 4:104dd82c99b8 | 109 | }\ |
aniruddhv | 262:752c8689944a | 110 | tm_ptr = FCTN_CDMS_RLY_TMTC(bcn_tx_main_ptr);\ |
aniruddhv | 262:752c8689944a | 111 | delete bcn_tx_main_ptr;\ |
aniruddhv | 262:752c8689944a | 112 | } |
aniruddhv | 262:752c8689944a | 113 | |
aniruddhv | 262:752c8689944a | 114 | void COM_POWER_ON_TX() { |
ee12b079 | 295:699801854b71 | 115 | //gPC.puts("Inside COM_POWER_ON_TX\r\n"); |
aniruddhv | 262:752c8689944a | 116 | if( !(gFLAGS & COM_TX_FLAG) ){ |
aniruddhv | 262:752c8689944a | 117 | gFLAGS = gFLAGS | COM_TX_FLAG; |
ee12b079 | 295:699801854b71 | 118 | //gPC.puts("Inside COM_TX_FLAG\r\n"); |
aniruddhv | 264:f7d8f9f361e3 | 119 | gFLAGS = gFLAGS | BAE_SW_EN_FLAG ; |
aniruddhv | 262:752c8689944a | 120 | if( gFLAGS & BAE_SW_EN_FLAG ){ |
aniruddhv | 262:752c8689944a | 121 | /*WARNING: INFINITE WHILE LOOP POSSIBLE: if standby ack received and bcn tx main status = 0*/ |
aniruddhv | 262:752c8689944a | 122 | bool retryFlag = true; |
aniruddhv | 262:752c8689944a | 123 | while( retryFlag == true ){ |
aniruddhv | 262:752c8689944a | 124 | Base_tm *tm_ptr = NULL; |
aniruddhv | 264:f7d8f9f361e3 | 125 | gPC.puts("setting Bcn off\r\n"); |
aniruddhv | 264:f7d8f9f361e3 | 126 | wait(1); |
aniruddhv | 262:752c8689944a | 127 | SET_BCN_STANDBY(tm_ptr); |
ee12b079 | 295:699801854b71 | 128 | //gPC.puts("set Bcn off\r\n"); |
aniruddhv | 262:752c8689944a | 129 | uint8_t bcn_main_status = (tm_ptr->TM_string[2] & 0xEF); |
ee12b079 | 271:72529b247333 | 130 | gPC.printf("bcn_main_status = 0x%02X\r\n",bcn_main_status); |
aniruddhv | 262:752c8689944a | 131 | if(( bcn_main_status == 0xC0 )||( bcn_main_status ==0xA0 )){ |
aniruddhv | 262:752c8689944a | 132 | /*ACK RECCEIVED*/ |
aniruddhv | 262:752c8689944a | 133 | if( bcn_main_status == 0xA0 ){ |
aniruddhv | 264:f7d8f9f361e3 | 134 | gPC.puts("A0\r\n"); |
aniruddhv | 262:752c8689944a | 135 | retryFlag = false; |
aniruddhv | 262:752c8689944a | 136 | RF_SW_CNTRL_TX = 1; |
aniruddhv | 262:752c8689944a | 137 | Thread::wait(25); |
aniruddhv | 262:752c8689944a | 138 | RF_SW_CNTRL_TX = 0; |
ee12b079 | 319:c11a52b91d25 | 139 | gFLAGS = gFLAGS | RF_SW_STATUS_FLAG;/*RF_SW_STATUS_FLAG set to RF_COM_TX*/ |
aniruddhv | 262:752c8689944a | 140 | } |
aniruddhv | 262:752c8689944a | 141 | else{ |
ee12b079 | 295:699801854b71 | 142 | gPC.puts("waiting for bcn off\r\n"); |
aniruddhv | 262:752c8689944a | 143 | Thread::wait(5000); |
aniruddhv | 262:752c8689944a | 144 | } |
aniruddhv | 262:752c8689944a | 145 | } |
aniruddhv | 262:752c8689944a | 146 | else{ |
aniruddhv | 264:f7d8f9f361e3 | 147 | gPC.puts("not A0\r\n"); |
aniruddhv | 262:752c8689944a | 148 | SW_RST_BAE(); |
aniruddhv | 262:752c8689944a | 149 | Base_tm *tm_ptr2 = NULL; |
ee12b079 | 295:699801854b71 | 150 | gPC.puts("settin bcn off\r\n"); |
aniruddhv | 262:752c8689944a | 151 | SET_BCN_STANDBY(tm_ptr2); |
ee12b079 | 295:699801854b71 | 152 | //gPC.puts("bcn off\r\n"); |
aniruddhv | 262:752c8689944a | 153 | uint8_t standbyAck2 = 0; |
aniruddhv | 262:752c8689944a | 154 | uint8_t bcn_main_status2 = (tm_ptr2->TM_string[2] & 0xEF); |
aniruddhv | 262:752c8689944a | 155 | if( ( bcn_main_status2 == 0xC0 )||( bcn_main_status2 == 0xA0 ) ){ |
aniruddhv | 262:752c8689944a | 156 | if( bcn_main_status2 == 0xA0 ){ |
aniruddhv | 264:f7d8f9f361e3 | 157 | gPC.puts("ack = A0\r\n"); |
aniruddhv | 262:752c8689944a | 158 | retryFlag = false; |
aniruddhv | 262:752c8689944a | 159 | RF_SW_CNTRL_TX = 1; |
aniruddhv | 262:752c8689944a | 160 | Thread::wait(25); |
aniruddhv | 262:752c8689944a | 161 | RF_SW_CNTRL_TX = 0; |
ee12b079 | 319:c11a52b91d25 | 162 | gFLAGS = gFLAGS | RF_SW_STATUS_FLAG;/*RF_SW_STATUS_FLAG set to RF_COM_TX*/ |
aniruddhv | 262:752c8689944a | 163 | } |
aniruddhv | 262:752c8689944a | 164 | else{ |
aniruddhv | 264:f7d8f9f361e3 | 165 | gPC.puts("ack = C0\r\n"); |
aniruddhv | 262:752c8689944a | 166 | Thread::wait(5000); |
aniruddhv | 262:752c8689944a | 167 | } |
aniruddhv | 262:752c8689944a | 168 | } |
aniruddhv | 262:752c8689944a | 169 | else{ |
aniruddhv | 264:f7d8f9f361e3 | 170 | gPC.puts("sw off BAE\r\n"); |
aniruddhv | 262:752c8689944a | 171 | retryFlag = false; |
aniruddhv | 262:752c8689944a | 172 | SW_OFF_BAE(); |
aniruddhv | 264:f7d8f9f361e3 | 173 | gPC.puts("swd off BAE\r\n"); |
aniruddhv | 262:752c8689944a | 174 | gFLAGS = gFLAGS | COM_AUTO_POWER_OFF_BAE_FLAG; |
aniruddhv | 262:752c8689944a | 175 | RF_SW_CNTRL_TX = 1; |
aniruddhv | 262:752c8689944a | 176 | Thread::wait(25); |
aniruddhv | 262:752c8689944a | 177 | RF_SW_CNTRL_TX = 0; |
ee12b079 | 319:c11a52b91d25 | 178 | gFLAGS = gFLAGS | RF_SW_STATUS_FLAG;/*RF_SW_STATUS_FLAG set to RF_COM_TX*/ |
aniruddhv | 262:752c8689944a | 179 | } |
aniruddhv | 262:752c8689944a | 180 | /*DELETE THE TM AFTER USE*/ |
aniruddhv | 262:752c8689944a | 181 | Base_tm *del_tm = tm_ptr2; |
aniruddhv | 262:752c8689944a | 182 | int overCount = 0; |
aniruddhv | 262:752c8689944a | 183 | while( del_tm != NULL ){ |
aniruddhv | 262:752c8689944a | 184 | if( (overCount < TM_OVERFLOW_CONSTANT) ){ |
aniruddhv | 262:752c8689944a | 185 | Base_tm *temp = del_tm->next_TM; |
aniruddhv | 262:752c8689944a | 186 | delete del_tm; |
aniruddhv | 262:752c8689944a | 187 | del_tm = temp; |
aniruddhv | 262:752c8689944a | 188 | ++overCount; |
aniruddhv | 262:752c8689944a | 189 | } |
aniruddhv | 262:752c8689944a | 190 | else{ |
aniruddhv | 262:752c8689944a | 191 | RESET_CDMS; |
aniruddhv | 262:752c8689944a | 192 | break; |
aniruddhv | 262:752c8689944a | 193 | } |
aniruddhv | 262:752c8689944a | 194 | } |
aniruddhv | 262:752c8689944a | 195 | } |
aniruddhv | 262:752c8689944a | 196 | /*DELETE THE TM AFTER USE*/ |
aniruddhv | 262:752c8689944a | 197 | Base_tm *del_tm = tm_ptr; |
aniruddhv | 262:752c8689944a | 198 | int overCount = 0; |
aniruddhv | 262:752c8689944a | 199 | while( del_tm != NULL ){ |
aniruddhv | 262:752c8689944a | 200 | if( (overCount < TM_OVERFLOW_CONSTANT) ){ |
aniruddhv | 262:752c8689944a | 201 | Base_tm *temp = del_tm->next_TM; |
aniruddhv | 262:752c8689944a | 202 | delete del_tm; |
aniruddhv | 262:752c8689944a | 203 | del_tm = temp; |
aniruddhv | 262:752c8689944a | 204 | ++overCount; |
aniruddhv | 262:752c8689944a | 205 | } |
aniruddhv | 262:752c8689944a | 206 | else{ |
aniruddhv | 262:752c8689944a | 207 | RESET_CDMS; |
aniruddhv | 262:752c8689944a | 208 | break; |
aniruddhv | 262:752c8689944a | 209 | } |
aniruddhv | 262:752c8689944a | 210 | } |
aniruddhv | 262:752c8689944a | 211 | } |
aniruddhv | 262:752c8689944a | 212 | } |
aniruddhv | 262:752c8689944a | 213 | else{ |
aniruddhv | 264:f7d8f9f361e3 | 214 | gPC.puts("RF_SW_CNTRL_TX\r\n"); |
aniruddhv | 262:752c8689944a | 215 | RF_SW_CNTRL_TX = 1; |
aniruddhv | 262:752c8689944a | 216 | Thread::wait(25); |
aniruddhv | 262:752c8689944a | 217 | RF_SW_CNTRL_TX = 0; |
ee12b079 | 319:c11a52b91d25 | 218 | gFLAGS = gFLAGS | RF_SW_STATUS_FLAG;/*RF_SW_STATUS_FLAG set to RF_COM_TX*/ |
aniruddhv | 262:752c8689944a | 219 | } |
aniruddhv | 262:752c8689944a | 220 | } |
aniruddhv | 264:f7d8f9f361e3 | 221 | gPC.puts("swd off BAE\r\n"); |
aniruddhv | 262:752c8689944a | 222 | COM_TX_CNTRL = 1; |
aniruddhv | 262:752c8689944a | 223 | uint8_t adfConfigPass = 0xFF; |
aniruddhv | 262:752c8689944a | 224 | for( int i = 0 ; i < COM_TX_CONFIG_LIMIT ; ++i ){ |
aniruddhv | 262:752c8689944a | 225 | /*PENDING: CONFIGURE ADF and set adfConfigPass*/ |
aniruddhv | 262:752c8689944a | 226 | if( adfConfigPass == 0xFF ){ |
aniruddhv | 262:752c8689944a | 227 | break; |
aniruddhv | 262:752c8689944a | 228 | } |
aniruddhv | 262:752c8689944a | 229 | } |
aniruddhv | 262:752c8689944a | 230 | if( adfConfigPass == 0xFF ){ |
aniruddhv | 262:752c8689944a | 231 | /*adf successfully configured*/ |
aniruddhv | 262:752c8689944a | 232 | gFLAGS = gFLAGS | COM_TX_STATUS_FLAG; |
aniruddhv | 262:752c8689944a | 233 | /*CALL SIGN*/ |
aniruddhv | 262:752c8689944a | 234 | Base_tm *power_on_tm = NULL; |
aniruddhv | 262:752c8689944a | 235 | Base_tm *power_on_tm_head = NULL; |
aniruddhv | 262:752c8689944a | 236 | get_call_sign( power_on_tm_head ); |
aniruddhv | 262:752c8689944a | 237 | power_on_tm = power_on_tm_head; |
aniruddhv | 262:752c8689944a | 238 | /*ACK L1*/ |
aniruddhv | 262:752c8689944a | 239 | get_ack_l1(power_on_tm->next_TM); |
aniruddhv | 262:752c8689944a | 240 | int overFlowCountADF = 0; |
aniruddhv | 262:752c8689944a | 241 | while( power_on_tm->next_TM != NULL ){ |
aniruddhv | 262:752c8689944a | 242 | if( overFlowCountADF < TM_OVERFLOW_CONSTANT ){ |
aniruddhv | 262:752c8689944a | 243 | power_on_tm = power_on_tm->next_TM; |
aniruddhv | 262:752c8689944a | 244 | ++overFlowCountADF; |
aniruddhv | 262:752c8689944a | 245 | } |
aniruddhv | 262:752c8689944a | 246 | else{ |
aniruddhv | 262:752c8689944a | 247 | RESET_CDMS; |
aniruddhv | 262:752c8689944a | 248 | break; |
aniruddhv | 262:752c8689944a | 249 | } |
aniruddhv | 262:752c8689944a | 250 | } |
aniruddhv | 262:752c8689944a | 251 | get_tc_list(power_on_tm->next_TM, 0x00); |
aniruddhv | 262:752c8689944a | 252 | /*Call Sign, ACK_L1, TC_LIST*/ |
aniruddhv | 262:752c8689944a | 253 | /*snd_tm.head_pointer(power_on_tm_head);*/ |
aniruddhv | 262:752c8689944a | 254 | /*transmit_adf;*/ |
aniruddhv | 262:752c8689944a | 255 | uint8_t transmissionPass = 0xFF; |
aniruddhv | 262:752c8689944a | 256 | /*PENDING: get acknowledgement of transmission*/ |
aniruddhv | 262:752c8689944a | 257 | /*deleting the telemetry*/ |
aniruddhv | 262:752c8689944a | 258 | power_on_tm = power_on_tm_head; |
aniruddhv | 262:752c8689944a | 259 | overFlowCountADF = 0; |
aniruddhv | 262:752c8689944a | 260 | while( power_on_tm != NULL ){ |
aniruddhv | 262:752c8689944a | 261 | if( overFlowCountADF < TM_OVERFLOW_CONSTANT ){ |
aniruddhv | 262:752c8689944a | 262 | Base_tm *temp = power_on_tm->next_TM; |
aniruddhv | 262:752c8689944a | 263 | delete power_on_tm; |
aniruddhv | 262:752c8689944a | 264 | power_on_tm = temp; |
aniruddhv | 262:752c8689944a | 265 | ++overFlowCountADF; |
aniruddhv | 262:752c8689944a | 266 | } |
aniruddhv | 262:752c8689944a | 267 | else{ |
aniruddhv | 262:752c8689944a | 268 | RESET_CDMS; |
aniruddhv | 262:752c8689944a | 269 | break; |
aniruddhv | 262:752c8689944a | 270 | } |
aniruddhv | 262:752c8689944a | 271 | } |
aniruddhv | 262:752c8689944a | 272 | if( transmissionPass == 0 ){ |
aniruddhv | 262:752c8689944a | 273 | /*NOT Transmitted succesfully*/ |
aniruddhv | 262:752c8689944a | 274 | COM_POWER_OFF_TX; |
aniruddhv | 262:752c8689944a | 275 | P_CDMS_HK_MAIN; |
aniruddhv | 262:752c8689944a | 276 | Base_tm *ptr_tm = NULL; |
aniruddhv | 262:752c8689944a | 277 | STANDBY_PRCS(ptr_tm); |
aniruddhv | 262:752c8689944a | 278 | uint8_t standbyACK = 0x00; |
aniruddhv | 262:752c8689944a | 279 | uint8_t bcn_main_status = (ptr_tm->TM_string[2] & 0xEF); |
aniruddhv | 262:752c8689944a | 280 | if(( bcn_main_status == 0xC0 )||( bcn_main_status ==0xA0 )){ |
aniruddhv | 262:752c8689944a | 281 | standbyACK = 1; |
aniruddhv | 262:752c8689944a | 282 | } |
aniruddhv | 262:752c8689944a | 283 | if(standbyACK == 1){ |
aniruddhv | 262:752c8689944a | 284 | uint8_t ackReceived = 0x00; |
aniruddhv | 262:752c8689944a | 285 | Base_tm *tm_ptr = NULL; |
aniruddhv | 262:752c8689944a | 286 | P_BCN_TX_MAIN(tm_ptr); |
aniruddhv | 262:752c8689944a | 287 | uint8_t ackcode = tm_ptr->TM_string[2] & 0xEF; |
aniruddhv | 262:752c8689944a | 288 | if( (ackcode == 0xA0) || (ackcode == 0xC0)) |
aniruddhv | 262:752c8689944a | 289 | ackReceived = 0xFF; |
aniruddhv | 262:752c8689944a | 290 | /*DELETE THE TM AFTER USE*/ |
aniruddhv | 262:752c8689944a | 291 | Base_tm *del_tm = tm_ptr; |
aniruddhv | 262:752c8689944a | 292 | int overCount = 0; |
aniruddhv | 262:752c8689944a | 293 | while( del_tm != NULL ){ |
aniruddhv | 262:752c8689944a | 294 | if( (overCount < TM_OVERFLOW_CONSTANT) ){ |
aniruddhv | 262:752c8689944a | 295 | Base_tm *temp = del_tm->next_TM; |
aniruddhv | 262:752c8689944a | 296 | delete del_tm; |
aniruddhv | 262:752c8689944a | 297 | del_tm = temp; |
aniruddhv | 262:752c8689944a | 298 | ++overCount; |
aniruddhv | 262:752c8689944a | 299 | } |
aniruddhv | 262:752c8689944a | 300 | else{ |
aniruddhv | 262:752c8689944a | 301 | RESET_CDMS; |
aniruddhv | 262:752c8689944a | 302 | break; |
aniruddhv | 262:752c8689944a | 303 | } |
aniruddhv | 262:752c8689944a | 304 | } |
aniruddhv | 262:752c8689944a | 305 | if( ackReceived == 0xFF ){ |
aniruddhv | 262:752c8689944a | 306 | Thread::wait(5000); |
aniruddhv | 262:752c8689944a | 307 | } |
aniruddhv | 262:752c8689944a | 308 | } |
aniruddhv | 262:752c8689944a | 309 | /*DELETE THE TM AFTER USE*/ |
aniruddhv | 262:752c8689944a | 310 | Base_tm *del_tm = ptr_tm; |
aniruddhv | 262:752c8689944a | 311 | int overCount = 0; |
aniruddhv | 262:752c8689944a | 312 | while( del_tm != NULL ){ |
aniruddhv | 262:752c8689944a | 313 | if( (overCount < TM_OVERFLOW_CONSTANT) ){ |
aniruddhv | 262:752c8689944a | 314 | Base_tm *temp = del_tm->next_TM; |
aniruddhv | 262:752c8689944a | 315 | delete del_tm; |
aniruddhv | 262:752c8689944a | 316 | del_tm = temp; |
aniruddhv | 262:752c8689944a | 317 | ++overCount; |
aniruddhv | 262:752c8689944a | 318 | } |
aniruddhv | 262:752c8689944a | 319 | else{ |
aniruddhv | 262:752c8689944a | 320 | RESET_CDMS; |
aniruddhv | 262:752c8689944a | 321 | break; |
aniruddhv | 262:752c8689944a | 322 | } |
aniruddhv | 262:752c8689944a | 323 | } |
aniruddhv | 262:752c8689944a | 324 | RESET_CDMS_TC; |
aniruddhv | 262:752c8689944a | 325 | } |
aniruddhv | 262:752c8689944a | 326 | } |
aniruddhv | 262:752c8689944a | 327 | else{ |
aniruddhv | 262:752c8689944a | 328 | /*ADF not configured*/ |
aniruddhv | 262:752c8689944a | 329 | gFLAGS = gFLAGS & (~COM_TX_STATUS_FLAG); |
aniruddhv | 262:752c8689944a | 330 | COM_POWER_OFF_TX; |
aniruddhv | 262:752c8689944a | 331 | P_CDMS_HK_MAIN; |
aniruddhv | 262:752c8689944a | 332 | Base_tm *ptr_tm = NULL; |
aniruddhv | 262:752c8689944a | 333 | STANDBY_PRCS(ptr_tm); |
aniruddhv | 262:752c8689944a | 334 | uint8_t standbyACK = 0x00; |
aniruddhv | 262:752c8689944a | 335 | uint8_t bcn_main_status = (ptr_tm->TM_string[2] & 0xEF); |
aniruddhv | 262:752c8689944a | 336 | if(( bcn_main_status == 0xC0 )||( bcn_main_status ==0xA0 )){ |
aniruddhv | 262:752c8689944a | 337 | standbyACK = 1; |
aniruddhv | 262:752c8689944a | 338 | } |
aniruddhv | 262:752c8689944a | 339 | if(standbyACK == 1){ |
aniruddhv | 262:752c8689944a | 340 | uint8_t ackReceived = 0x00; |
aniruddhv | 262:752c8689944a | 341 | Base_tm *tm_ptr = NULL; |
aniruddhv | 262:752c8689944a | 342 | P_BCN_TX_MAIN(tm_ptr); |
aniruddhv | 262:752c8689944a | 343 | uint8_t ackcode = tm_ptr->TM_string[2] & 0xEF; |
aniruddhv | 262:752c8689944a | 344 | if( (ackcode == 0xA0) || (ackcode == 0xC0)) |
aniruddhv | 262:752c8689944a | 345 | ackReceived = 0xFF; |
aniruddhv | 262:752c8689944a | 346 | /*DELETE THE TM AFTER USE*/ |
aniruddhv | 262:752c8689944a | 347 | Base_tm *del_tm = tm_ptr; |
aniruddhv | 262:752c8689944a | 348 | int overCount = 0; |
aniruddhv | 262:752c8689944a | 349 | while( del_tm != NULL ){ |
aniruddhv | 262:752c8689944a | 350 | if( (overCount < TM_OVERFLOW_CONSTANT) ){ |
aniruddhv | 262:752c8689944a | 351 | Base_tm *temp = del_tm->next_TM; |
aniruddhv | 262:752c8689944a | 352 | delete del_tm; |
aniruddhv | 262:752c8689944a | 353 | del_tm = temp; |
aniruddhv | 262:752c8689944a | 354 | ++overCount; |
aniruddhv | 262:752c8689944a | 355 | } |
aniruddhv | 262:752c8689944a | 356 | else{ |
aniruddhv | 262:752c8689944a | 357 | RESET_CDMS; |
aniruddhv | 262:752c8689944a | 358 | break; |
aniruddhv | 262:752c8689944a | 359 | } |
aniruddhv | 262:752c8689944a | 360 | } |
aniruddhv | 262:752c8689944a | 361 | if( ackReceived == 0xFF ){ |
aniruddhv | 262:752c8689944a | 362 | Thread::wait(5000); |
aniruddhv | 262:752c8689944a | 363 | } |
aniruddhv | 262:752c8689944a | 364 | } |
aniruddhv | 262:752c8689944a | 365 | /*DELETE THE TM AFTER USE*/ |
aniruddhv | 262:752c8689944a | 366 | Base_tm *del_tm = ptr_tm; |
aniruddhv | 262:752c8689944a | 367 | int overCount = 0; |
aniruddhv | 262:752c8689944a | 368 | while( del_tm != NULL ){ |
aniruddhv | 262:752c8689944a | 369 | if( (overCount < TM_OVERFLOW_CONSTANT) ){ |
aniruddhv | 262:752c8689944a | 370 | Base_tm *temp = del_tm->next_TM; |
aniruddhv | 262:752c8689944a | 371 | delete del_tm; |
aniruddhv | 262:752c8689944a | 372 | del_tm = temp; |
aniruddhv | 262:752c8689944a | 373 | ++overCount; |
aniruddhv | 262:752c8689944a | 374 | } |
aniruddhv | 262:752c8689944a | 375 | else{ |
aniruddhv | 262:752c8689944a | 376 | RESET_CDMS; |
aniruddhv | 262:752c8689944a | 377 | break; |
aniruddhv | 262:752c8689944a | 378 | } |
aniruddhv | 262:752c8689944a | 379 | } |
aniruddhv | 262:752c8689944a | 380 | RESET_CDMS_TC; |
aniruddhv | 262:752c8689944a | 381 | } |
aniruddhv | 264:f7d8f9f361e3 | 382 | gPC.puts("COMPLETED COM_POWER_ON_TX\r\n"); |
shreeshas95 | 4:104dd82c99b8 | 383 | } |