
Compression code changed and RLY_TMTC pointers managed
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE by
ThreadsAndFunctions.h@251:c766afa330a3, 2016-07-11 (annotated)
- Committer:
- chaithanyarss
- Date:
- Mon Jul 11 12:30:41 2016 +0000
- Revision:
- 251:c766afa330a3
- Parent:
- 246:565458eefd94
- Child:
- 252:9c631b2f5da8
Threads integrated to be tested
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ee12b079 | 173:f81ded27423d | 1 | //Science Thread |
ee12b079 | 173:f81ded27423d | 2 | //SPI ISR |
ee12b079 | 173:f81ded27423d | 3 | void payload_isr_fun(){ |
ee12b079 | 173:f81ded27423d | 4 | gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL); |
ee12b079 | 173:f81ded27423d | 5 | } |
ee12b079 | 173:f81ded27423d | 6 | |
ee12b079 | 191:0636c8391407 | 7 | void payload_isr_fun_dma(void const *args ){ |
ee12b079 | 191:0636c8391407 | 8 | gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL); |
ee12b079 | 191:0636c8391407 | 9 | } |
ee12b079 | 192:f0d5fde60221 | 10 | |
ee12b079 | 173:f81ded27423d | 11 | void SCIENCE_FUN(void const *args){ |
ee12b079 | 245:da9d1bd999da | 12 | gPAY_SPI = new dmaSPISlave(PAY_SPI_MOSI, PAY_SPI_MISO, PAY_SPI_CLK, PAY_SPI_CS); |
ee12b079 | 245:da9d1bd999da | 13 | gPAY_SPI->frequency(1000000); |
ee12b079 | 245:da9d1bd999da | 14 | gPAY_SPI->format(8,0); |
ee12b079 | 245:da9d1bd999da | 15 | gPAY_SPI->bulkRead_init(gPAYLOAD_BUFFER, PAYLOAD_BUFFER_LENGTH, &payload_isr_fun); |
ee12b079 | 245:da9d1bd999da | 16 | gPAY_SPI->bulkRead_start(); |
ee12b079 | 173:f81ded27423d | 17 | while(true){ |
ee12b079 | 173:f81ded27423d | 18 | gPC.puts("entering sci\r\n"); |
ee12b079 | 173:f81ded27423d | 19 | gSCIENCE_THREAD->signal_wait(SCIENCE_SIGNAL); |
chaithanyarss | 251:c766afa330a3 | 20 | gMutex.lock(); |
ee12b079 | 173:f81ded27423d | 21 | gPC.puts("sig_set\r\n"); |
chaithanyarss | 251:c766afa330a3 | 22 | srp(gPAYLOAD_BUFFER);//skip one apcket when cdms resets |
ee12b079 | 173:f81ded27423d | 23 | gPC.puts("exit_srp\r\n"); |
ee12b079 | 245:da9d1bd999da | 24 | wait(2);/*timeout to be decided*/ |
ee12b079 | 245:da9d1bd999da | 25 | gPAY_SPI->bulkRead_start(); |
chaithanyarss | 251:c766afa330a3 | 26 | gMutex.unlock(); |
ee12b079 | 173:f81ded27423d | 27 | } |
ee12b079 | 173:f81ded27423d | 28 | } |
ee12b079 | 173:f81ded27423d | 29 | |
ee12b079 | 245:da9d1bd999da | 30 | //HK Thread(Contains HK_main() and PL_main()) |
ee12b079 | 245:da9d1bd999da | 31 | //RTOS timer calllback func |
ee12b079 | 245:da9d1bd999da | 32 | void hk_isr(void const *args){ |
ee12b079 | 246:565458eefd94 | 33 | gHK_THREAD->signal_set(HK_SIGNAL); |
ee12b079 | 245:da9d1bd999da | 34 | } |
ee12b079 | 245:da9d1bd999da | 35 | |
ee12b079 | 245:da9d1bd999da | 36 | |
ee12b079 | 173:f81ded27423d | 37 | //COM THREAD |
shreeshas95 | 0:f016e9e8d48b | 38 | // UART ISR |
shreeshas95 | 0:f016e9e8d48b | 39 | void rx_read(){ |
shreeshas95 | 2:2caf2a9a13aa | 40 | gRX_CURRENT_DATA_NODE->values[gRX_COUNT] = RX1M.getc(); |
shreeshas95 | 2:2caf2a9a13aa | 41 | gFLAGS = gFLAGS | UART_INT_FLAG; |
shreeshas95 | 0:f016e9e8d48b | 42 | gCOM_MNG_TMTC_THREAD->signal_set(COM_MNG_TMTC_SIGNAL_UART_INT); |
shreeshas95 | 0:f016e9e8d48b | 43 | } |
shreeshas95 | 0:f016e9e8d48b | 44 | |
shreeshas95 | 0:f016e9e8d48b | 45 | // RX_TIMEOUT ISR |
shreeshas95 | 0:f016e9e8d48b | 46 | void after_receive(){ |
shreeshas95 | 0:f016e9e8d48b | 47 | gRX_TIMEOUT.detach(); |
shreeshas95 | 2:2caf2a9a13aa | 48 | gFLAGS = gFLAGS | NEW_TC_RECEIVED; |
shreeshas95 | 0:f016e9e8d48b | 49 | gCOM_MNG_TMTC_THREAD->signal_set(COM_MNG_TMTC_SIGNAL_UART_INT); |
shreeshas95 | 0:f016e9e8d48b | 50 | } |
shreeshas95 | 0:f016e9e8d48b | 51 | |
shreeshas95 | 0:f016e9e8d48b | 52 | // SESSION_TIMOUT ISR |
shreeshas95 | 0:f016e9e8d48b | 53 | void after_session(){ |
shreeshas95 | 0:f016e9e8d48b | 54 | gSESSION_TIMEOUT.detach(); |
shreeshas95 | 6:79d422d1ed42 | 55 | gFLAGS = gFLAGS | COM_SESSION_TIMEOUT_FLAG; |
shreeshas95 | 6:79d422d1ed42 | 56 | if( gMASTER_STATE != TCL_STATE_EXECUTING ){ |
shreeshas95 | 6:79d422d1ed42 | 57 | gCOM_MNG_TMTC_THREAD->signal_set(COM_MNG_TMTC_SIGNAL_UART_INT); |
shreeshas95 | 6:79d422d1ed42 | 58 | } |
shreeshas95 | 0:f016e9e8d48b | 59 | } |
shreeshas95 | 0:f016e9e8d48b | 60 | |
shreeshas95 | 0:f016e9e8d48b | 61 | #define reset_all {\ |
shreeshas95 | 0:f016e9e8d48b | 62 | Base_tc *tcp = gHEAD_NODE_TCL;\ |
aniruddhv | 12:ffdb29353058 | 63 | /*gPC.puts("inside reset\r\n");*/\ |
shreeshas95 | 5:ab276a17ca07 | 64 | gFLAGS = 0x0000;\ |
shreeshas95 | 0:f016e9e8d48b | 65 | while(tcp != NULL){\ |
shreeshas95 | 0:f016e9e8d48b | 66 | Base_tc *temp = tcp->next_TC;\ |
shreeshas95 | 0:f016e9e8d48b | 67 | delete tcp;\ |
shreeshas95 | 0:f016e9e8d48b | 68 | tcp = temp;\ |
shreeshas95 | 0:f016e9e8d48b | 69 | }\ |
shreeshas95 | 5:ab276a17ca07 | 70 | gHEAD_NODE_TCL = NULL;\ |
shreeshas95 | 5:ab276a17ca07 | 71 | gLAST_NODE_TCL = NULL;\ |
shreeshas95 | 5:ab276a17ca07 | 72 | gMASTER_STATE = TCL_STATE_INCOMPLETE;\ |
shreeshas95 | 0:f016e9e8d48b | 73 | gTOTAL_INCORRECT_SIZE_TC = 0;\ |
shreeshas95 | 0:f016e9e8d48b | 74 | gTOTAL_CRC_FAIL_TC = 0;\ |
shreeshas95 | 2:2caf2a9a13aa | 75 | gTOTAL_REPEATED_TC = 0;\ |
shreeshas95 | 5:ab276a17ca07 | 76 | gTOTAL_VALID_TC = 0;\ |
shreeshas95 | 5:ab276a17ca07 | 77 | for(int i = 0 ; i < TM_LONG_SIZE ; ++i){\ |
shreeshas95 | 5:ab276a17ca07 | 78 | gLAST_TM[i] = 0x00;\ |
shreeshas95 | 5:ab276a17ca07 | 79 | }\ |
shreeshas95 | 5:ab276a17ca07 | 80 | gLAST_TM_SHORT_OR_LONG = SHORT_TM_CODE;\ |
shreeshas95 | 0:f016e9e8d48b | 81 | COM_RX_DATA_NODE *dataptr = gRX_HEAD_DATA_NODE;\ |
shreeshas95 | 0:f016e9e8d48b | 82 | while( dataptr != NULL ){\ |
shreeshas95 | 0:f016e9e8d48b | 83 | COM_RX_DATA_NODE *temp = dataptr->next_node;\ |
shreeshas95 | 0:f016e9e8d48b | 84 | delete dataptr;\ |
shreeshas95 | 0:f016e9e8d48b | 85 | dataptr = temp;\ |
shreeshas95 | 0:f016e9e8d48b | 86 | }\ |
shreeshas95 | 0:f016e9e8d48b | 87 | gRX_HEAD_DATA_NODE = new COM_RX_DATA_NODE;\ |
shreeshas95 | 0:f016e9e8d48b | 88 | gRX_HEAD_DATA_NODE->next_node = NULL;\ |
shreeshas95 | 0:f016e9e8d48b | 89 | gRX_CURRENT_DATA_NODE = gRX_HEAD_DATA_NODE;\ |
shreeshas95 | 0:f016e9e8d48b | 90 | gRX_COUNT = 0;\ |
shreeshas95 | 2:2caf2a9a13aa | 91 | /*PENDING : ALL GLOBAL VAARIABLES AND FLAGS*/\ |
aniruddhv | 12:ffdb29353058 | 92 | /*gPC.puts("finished reset all\r\n");*/\ |
shreeshas95 | 2:2caf2a9a13aa | 93 | } |
shreeshas95 | 2:2caf2a9a13aa | 94 | |
shreeshas95 | 2:2caf2a9a13aa | 95 | #define PUT_RAW_BYTE {\ |
shreeshas95 | 2:2caf2a9a13aa | 96 | if( gRX_COUNT < (RX_BUFFER_LENGTH-1) ){\ |
shreeshas95 | 2:2caf2a9a13aa | 97 | ++gRX_COUNT;\ |
shreeshas95 | 2:2caf2a9a13aa | 98 | }\ |
shreeshas95 | 2:2caf2a9a13aa | 99 | else{\ |
shreeshas95 | 2:2caf2a9a13aa | 100 | gRX_COUNT = 0;\ |
shreeshas95 | 2:2caf2a9a13aa | 101 | gRX_CURRENT_DATA_NODE->next_node = new COM_RX_DATA_NODE;\ |
shreeshas95 | 2:2caf2a9a13aa | 102 | gRX_CURRENT_DATA_NODE = gRX_CURRENT_DATA_NODE->next_node;\ |
shreeshas95 | 2:2caf2a9a13aa | 103 | gRX_CURRENT_DATA_NODE->next_node = NULL;\ |
shreeshas95 | 2:2caf2a9a13aa | 104 | }\ |
shreeshas95 | 2:2caf2a9a13aa | 105 | gRX_TIMEOUT.attach(&after_receive, RX_TIMEOUT_LIMIT);\ |
shreeshas95 | 0:f016e9e8d48b | 106 | } |
shreeshas95 | 0:f016e9e8d48b | 107 | |
shreeshas95 | 0:f016e9e8d48b | 108 | void COM_MNG_TMTC_FUN(void const *args){ |
shreeshas95 | 4:104dd82c99b8 | 109 | if( !(gFLAGS & COM_SESSION_FLAG) ){ |
ee12b079 | 96:4ca92f9775e0 | 110 | //gLEDR = 1; |
ee12b079 | 96:4ca92f9775e0 | 111 | //gLEDG = 1; |
shreeshas95 | 4:104dd82c99b8 | 112 | } |
shreeshas95 | 0:f016e9e8d48b | 113 | while(true){ |
shreeshas95 | 0:f016e9e8d48b | 114 | Thread::signal_wait( COM_MNG_TMTC_SIGNAL_UART_INT ); |
shreeshas95 | 0:f016e9e8d48b | 115 | if( gFLAGS & UART_INT_FLAG ){ |
shreeshas95 | 0:f016e9e8d48b | 116 | gFLAGS = gFLAGS & (~UART_INT_FLAG); |
shreeshas95 | 2:2caf2a9a13aa | 117 | if( !(gFLAGS & COM_SESSION_FLAG) ){ |
shreeshas95 | 2:2caf2a9a13aa | 118 | // PENDING : DISABLE THREADS |
ee12b079 | 246:565458eefd94 | 119 | HK_counter->stop();\ |
ee12b079 | 245:da9d1bd999da | 120 | gPAY_SPI->bulkRead_pause(); |
shreeshas95 | 2:2caf2a9a13aa | 121 | gFLAGS = gFLAGS | COM_SESSION_FLAG; |
shreeshas95 | 2:2caf2a9a13aa | 122 | gSESSION_TIMEOUT.attach(&after_session, SESSION_TIME_LIMIT); |
shreeshas95 | 2:2caf2a9a13aa | 123 | gFLAGS = gFLAGS | COM_RX_FLAG; |
shreeshas95 | 2:2caf2a9a13aa | 124 | PUT_RAW_BYTE; |
shreeshas95 | 2:2caf2a9a13aa | 125 | // PENDING : MEASURE RSSI |
shreeshas95 | 4:104dd82c99b8 | 126 | if( gFLAGS & COM_SESSION_FLAG ){ |
ee12b079 | 96:4ca92f9775e0 | 127 | //gLEDR = 0; |
ee12b079 | 96:4ca92f9775e0 | 128 | //gLEDG = 0; |
shreeshas95 | 4:104dd82c99b8 | 129 | } |
shreeshas95 | 2:2caf2a9a13aa | 130 | } |
shreeshas95 | 2:2caf2a9a13aa | 131 | else if( gFLAGS & COM_RX_FLAG ){ |
ee12b079 | 96:4ca92f9775e0 | 132 | //gLEDR = 0; |
ee12b079 | 96:4ca92f9775e0 | 133 | //gLEDG = 1; |
shreeshas95 | 2:2caf2a9a13aa | 134 | PUT_RAW_BYTE; |
shreeshas95 | 0:f016e9e8d48b | 135 | } |
shreeshas95 | 0:f016e9e8d48b | 136 | else{ |
ee12b079 | 96:4ca92f9775e0 | 137 | //gLEDR = 1; |
ee12b079 | 96:4ca92f9775e0 | 138 | //gLEDG = 0; |
shreeshas95 | 2:2caf2a9a13aa | 139 | gFLAGS = gFLAGS | COM_RX_FLAG; |
shreeshas95 | 2:2caf2a9a13aa | 140 | PUT_RAW_BYTE; |
shreeshas95 | 0:f016e9e8d48b | 141 | } |
shreeshas95 | 0:f016e9e8d48b | 142 | } |
shreeshas95 | 4:104dd82c99b8 | 143 | else if( gFLAGS & NEW_TC_RECEIVED ){ |
ee12b079 | 98:fd99ddc0e0a1 | 144 | gPC.puts("NEW TC RECEIVED\r\n"); |
ee12b079 | 197:1369ef45b49e | 145 | Thread::wait(1000); |
shreeshas95 | 0:f016e9e8d48b | 146 | gFLAGS = gFLAGS & (~NEW_TC_RECEIVED); |
shreeshas95 | 4:104dd82c99b8 | 147 | gFLAGS = gFLAGS | COM_MNG_TMTC_RUNNING_FLAG; |
shreeshas95 | 2:2caf2a9a13aa | 148 | |
shreeshas95 | 0:f016e9e8d48b | 149 | // DISABLE THE RX1M INTERRUPT |
shreeshas95 | 0:f016e9e8d48b | 150 | RX1M.attach(NULL); |
shreeshas95 | 0:f016e9e8d48b | 151 | |
shreeshas95 | 4:104dd82c99b8 | 152 | // VERIFY CRC, REPEATED PSC AND UPDATE TOTAL_VALID_TC, INCORRECT SIZE TC, CRC FAIL TC |
shreeshas95 | 2:2caf2a9a13aa | 153 | while(gRX_COUNT < (RX_BUFFER_LENGTH)){ |
shreeshas95 | 2:2caf2a9a13aa | 154 | gRX_CURRENT_DATA_NODE->values[gRX_COUNT] = 0x00; |
shreeshas95 | 0:f016e9e8d48b | 155 | ++gRX_COUNT; |
shreeshas95 | 0:f016e9e8d48b | 156 | } |
shreeshas95 | 0:f016e9e8d48b | 157 | gRX_COUNT = 0; |
shreeshas95 | 4:104dd82c99b8 | 158 | raw_data_to_tc(); |
shreeshas95 | 6:79d422d1ed42 | 159 | gFLAGS = gFLAGS & (~COM_RX_FLAG); |
aniruddhv | 51:da85d84768e2 | 160 | |
chaithanyarss | 251:c766afa330a3 | 161 | //Mutex |
chaithanyarss | 251:c766afa330a3 | 162 | gMutex.lock(); |
chaithanyarss | 251:c766afa330a3 | 163 | |
shreeshas95 | 2:2caf2a9a13aa | 164 | if( gTOTAL_VALID_TC > 0 ){ |
aniruddhv | 12:ffdb29353058 | 165 | /*gPC.printf("valid TC rx: %u\r\n", gTOTAL_VALID_TC);*/ |
shreeshas95 | 4:104dd82c99b8 | 166 | if( gTOTAL_VALID_TC < COM_MAX_TC_LIMIT ){ |
shreeshas95 | 4:104dd82c99b8 | 167 | // CHECK WEATHER TC LIST HAS MISSING TC OR WEATHER LAST FRAME BIT IS HIGH IN THE LAST PSC-TC |
aniruddhv | 12:ffdb29353058 | 168 | /*gPC.puts("checking for tc list complete\r\n");*/ |
shreeshas95 | 4:104dd82c99b8 | 169 | uint8_t tempContinue = 0xFF; |
shreeshas95 | 4:104dd82c99b8 | 170 | continueToExecute(tempContinue); |
shreeshas95 | 4:104dd82c99b8 | 171 | if(tempContinue == 0x00){ |
aniruddhv | 12:ffdb29353058 | 172 | /*gPC.puts("tc list is complete\r\n");*/ |
shreeshas95 | 4:104dd82c99b8 | 173 | // CHECK WEATHER GS VERIFICATION CODE MATCHES |
shreeshas95 | 4:104dd82c99b8 | 174 | uint8_t tempGSver = 0x00; |
shreeshas95 | 4:104dd82c99b8 | 175 | GScodeVerification(tempGSver); |
shreeshas95 | 5:ab276a17ca07 | 176 | /*PENDING: INCLUDE GS VERIFICATION CODE*/ |
aniruddhv | 37:c9a739750806 | 177 | if( tempGSver == 0xFF ){ |
aniruddhv | 37:c9a739750806 | 178 | /*gPC.puts("GS code match !!\r\n");*/ |
shreeshas95 | 4:104dd82c99b8 | 179 | gFLAGS = gFLAGS | COM_SESSION_VALIDITY; |
shreeshas95 | 4:104dd82c99b8 | 180 | COM_POWER_ON_TX; |
shreeshas95 | 4:104dd82c99b8 | 181 | // PENDING: PA HOT HANDLED IN EXECUTE_XXX FUNCTIONS |
shreeshas95 | 4:104dd82c99b8 | 182 | uint8_t tempPAHot = 0x00; |
shreeshas95 | 4:104dd82c99b8 | 183 | isPAhot(tempPAHot); |
shreeshas95 | 4:104dd82c99b8 | 184 | if( tempPAHot == 0xFF ){ |
shreeshas95 | 6:79d422d1ed42 | 185 | gFLAGS = gFLAGS & ~(COM_PA_HOT_FLAG); |
shreeshas95 | 6:79d422d1ed42 | 186 | gCOM_PA_COOLING_TIMEOUT.detach(); |
ee12b079 | 98:fd99ddc0e0a1 | 187 | gPC.puts("EXECUTING TELECOMMANDS\r\n"); |
ee12b079 | 98:fd99ddc0e0a1 | 188 | // DEBUF_PRINT("EXECUTING TELECOMMANDS\r\n"); |
shreeshas95 | 4:104dd82c99b8 | 189 | EXECUTE_OBOSC_ONLY; |
shreeshas95 | 4:104dd82c99b8 | 190 | EXECUTE_TC; |
ee12b079 | 164:be3b4b760d0c | 191 | gPC.puts("COMPLETED EXECUTION\r\n"); |
shreeshas95 | 4:104dd82c99b8 | 192 | } |
shreeshas95 | 4:104dd82c99b8 | 193 | else{ |
shreeshas95 | 4:104dd82c99b8 | 194 | gFLAGS = gFLAGS | COM_PA_HOT_FLAG; |
shreeshas95 | 6:79d422d1ed42 | 195 | // PENDING: power off transmitter only |
shreeshas95 | 6:79d422d1ed42 | 196 | gCOM_PA_COOLING_TIMEOUT.attach(&after_cooling_pa, COM_PA_COOLING_TIME_LIMIT); |
shreeshas95 | 6:79d422d1ed42 | 197 | gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG); |
shreeshas95 | 4:104dd82c99b8 | 198 | RX1M.attach(&rx_read, Serial::RxIrq); |
shreeshas95 | 4:104dd82c99b8 | 199 | } |
shreeshas95 | 4:104dd82c99b8 | 200 | } |
shreeshas95 | 4:104dd82c99b8 | 201 | else{ |
aniruddhv | 12:ffdb29353058 | 202 | /*gPC.puts("GS code mismatch !!\r\n");*/ |
shreeshas95 | 6:79d422d1ed42 | 203 | RX1M.attach(&rx_read, Serial::RxIrq); |
shreeshas95 | 4:104dd82c99b8 | 204 | reset_all; |
shreeshas95 | 4:104dd82c99b8 | 205 | gFLAGS = gFLAGS & (~COM_SESSION_VALIDITY); |
shreeshas95 | 4:104dd82c99b8 | 206 | // PENDING : ENABLE THREADS |
ee12b079 | 246:565458eefd94 | 207 | HK_counter->start(10000);\ |
ee12b079 | 245:da9d1bd999da | 208 | gPAY_SPI->bulkRead_resume(&payload_isr_fun); |
shreeshas95 | 4:104dd82c99b8 | 209 | gSESSION_TIMEOUT.detach(); |
shreeshas95 | 4:104dd82c99b8 | 210 | gFLAGS = gFLAGS & (~COM_SESSION_FLAG); |
shreeshas95 | 4:104dd82c99b8 | 211 | // WARNING: clear COM_MNG_TMTC ? |
shreeshas95 | 4:104dd82c99b8 | 212 | } |
shreeshas95 | 0:f016e9e8d48b | 213 | } |
shreeshas95 | 2:2caf2a9a13aa | 214 | else{ |
ee12b079 | 164:be3b4b760d0c | 215 | gPC.puts("tc list is not complete\r\n"); |
shreeshas95 | 5:ab276a17ca07 | 216 | if(tempContinue & 0x01){ |
aniruddhv | 69:20f09a0c3fd2 | 217 | //gPC.puts("last packet bit not found\r\n"); |
shreeshas95 | 5:ab276a17ca07 | 218 | } |
shreeshas95 | 5:ab276a17ca07 | 219 | if( tempContinue & 0x02 ){ |
aniruddhv | 69:20f09a0c3fd2 | 220 | //gPC.puts("missing psc found\r\n"); |
shreeshas95 | 5:ab276a17ca07 | 221 | } |
aniruddhv | 69:20f09a0c3fd2 | 222 | //gPC.printf("crc fail tc = %u\r\n", gTOTAL_CRC_FAIL_TC); |
aniruddhv | 69:20f09a0c3fd2 | 223 | //gPC.printf("incorrect size tc = %u\r\n", gTOTAL_INCORRECT_SIZE_TC); |
aniruddhv | 69:20f09a0c3fd2 | 224 | //gPC.printf("repeated psc = %u\r\n", gTOTAL_REPEATED_TC); |
shreeshas95 | 5:ab276a17ca07 | 225 | Base_tc *test_tc = gHEAD_NODE_TCL; |
shreeshas95 | 5:ab276a17ca07 | 226 | while( test_tc != NULL ){ |
shreeshas95 | 5:ab276a17ca07 | 227 | int length = 0; |
shreeshas95 | 5:ab276a17ca07 | 228 | if( GETshort_or_long_tc(test_tc) == SHORT_TC_CODE ){ |
shreeshas95 | 5:ab276a17ca07 | 229 | length = TC_SHORT_SIZE; |
shreeshas95 | 5:ab276a17ca07 | 230 | } |
shreeshas95 | 5:ab276a17ca07 | 231 | else{ |
shreeshas95 | 5:ab276a17ca07 | 232 | length = TC_LONG_SIZE; |
shreeshas95 | 5:ab276a17ca07 | 233 | } |
rohit3342 | 16:538de1b20b3a | 234 | for(int i = 0 ; i < length ; ++i ){ |
aniruddhv | 69:20f09a0c3fd2 | 235 | //gPC.printf("%x ", test_tc->TC_string[i]); |
shreeshas95 | 5:ab276a17ca07 | 236 | } |
aniruddhv | 69:20f09a0c3fd2 | 237 | //gPC.puts("\r\n"); |
shreeshas95 | 5:ab276a17ca07 | 238 | test_tc = test_tc->next_TC; |
shreeshas95 | 5:ab276a17ca07 | 239 | } |
aniruddhv | 69:20f09a0c3fd2 | 240 | //gPC.puts("\r\n"); |
shreeshas95 | 4:104dd82c99b8 | 241 | COM_POWER_ON_TX; |
shreeshas95 | 4:104dd82c99b8 | 242 | // PENDING : POWER OFF TX |
shreeshas95 | 4:104dd82c99b8 | 243 | RX1M.attach(&rx_read, Serial::RxIrq); |
shreeshas95 | 4:104dd82c99b8 | 244 | gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG); |
shreeshas95 | 2:2caf2a9a13aa | 245 | } |
shreeshas95 | 0:f016e9e8d48b | 246 | } |
shreeshas95 | 0:f016e9e8d48b | 247 | else{ |
shreeshas95 | 4:104dd82c99b8 | 248 | COM_POWER_ON_TX; |
shreeshas95 | 6:79d422d1ed42 | 249 | // POWER OFF TX transmitter only |
shreeshas95 | 4:104dd82c99b8 | 250 | // WARNING: reset_all ? clear com_session ? |
shreeshas95 | 2:2caf2a9a13aa | 251 | RX1M.attach(&rx_read, Serial::RxIrq); |
shreeshas95 | 4:104dd82c99b8 | 252 | gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG); |
shreeshas95 | 0:f016e9e8d48b | 253 | } |
shreeshas95 | 2:2caf2a9a13aa | 254 | } |
shreeshas95 | 4:104dd82c99b8 | 255 | else{ |
ee12b079 | 164:be3b4b760d0c | 256 | gPC.puts("No valid TC received\r\n"); |
shreeshas95 | 2:2caf2a9a13aa | 257 | RX1M.attach(&rx_read, Serial::RxIrq); |
shreeshas95 | 4:104dd82c99b8 | 258 | gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG); |
shreeshas95 | 6:79d422d1ed42 | 259 | reset_all; |
shreeshas95 | 6:79d422d1ed42 | 260 | // PENDING : ENABLE THREADS |
ee12b079 | 246:565458eefd94 | 261 | HK_counter->start(10000); |
ee12b079 | 245:da9d1bd999da | 262 | gPAY_SPI->bulkRead_resume(&payload_isr_fun); |
shreeshas95 | 6:79d422d1ed42 | 263 | gSESSION_TIMEOUT.detach(); |
shreeshas95 | 6:79d422d1ed42 | 264 | gFLAGS = gFLAGS & (~COM_SESSION_FLAG); |
shreeshas95 | 2:2caf2a9a13aa | 265 | } |
shreeshas95 | 2:2caf2a9a13aa | 266 | } |
shreeshas95 | 2:2caf2a9a13aa | 267 | else if( gFLAGS & COM_PA_HOT_FLAG ){ |
aniruddhv | 12:ffdb29353058 | 268 | /*gPC.puts("checking for PA hot in main\r\n");*/ |
shreeshas95 | 6:79d422d1ed42 | 269 | if( gFLAGS & COM_RX_FLAG ){ |
shreeshas95 | 6:79d422d1ed42 | 270 | uint8_t tempPA = 0xFF; |
shreeshas95 | 6:79d422d1ed42 | 271 | isPAhot(tempPA); |
shreeshas95 | 6:79d422d1ed42 | 272 | if( tempPA == 0x00 ){ |
shreeshas95 | 6:79d422d1ed42 | 273 | gCOM_PA_COOLING_TIMEOUT.attach(&after_cooling_pa, COM_PA_COOLING_TIME_LIMIT); |
shreeshas95 | 6:79d422d1ed42 | 274 | } |
shreeshas95 | 6:79d422d1ed42 | 275 | else{ |
shreeshas95 | 6:79d422d1ed42 | 276 | gFLAGS = gFLAGS & ~(COM_PA_HOT_FLAG); |
shreeshas95 | 6:79d422d1ed42 | 277 | gCOM_PA_COOLING_TIMEOUT.detach(); |
shreeshas95 | 6:79d422d1ed42 | 278 | } |
shreeshas95 | 0:f016e9e8d48b | 279 | } |
shreeshas95 | 0:f016e9e8d48b | 280 | else{ |
shreeshas95 | 6:79d422d1ed42 | 281 | uint8_t tempPA = 0xFF; |
shreeshas95 | 6:79d422d1ed42 | 282 | isPAhot(tempPA); |
shreeshas95 | 6:79d422d1ed42 | 283 | if( tempPA == 0x00 ){ |
shreeshas95 | 6:79d422d1ed42 | 284 | gCOM_PA_COOLING_TIMEOUT.attach(&after_cooling_pa, COM_PA_COOLING_TIME_LIMIT); |
shreeshas95 | 6:79d422d1ed42 | 285 | } |
shreeshas95 | 6:79d422d1ed42 | 286 | else{ |
aniruddhv | 12:ffdb29353058 | 287 | /*gPC.puts("PA IS COOLED DOWN\r\n");*/ |
shreeshas95 | 6:79d422d1ed42 | 288 | gFLAGS = gFLAGS & (~COM_PA_HOT_FLAG); |
shreeshas95 | 6:79d422d1ed42 | 289 | gFLAGS = gFLAGS | COM_MNG_TMTC_RUNNING_FLAG; |
shreeshas95 | 6:79d422d1ed42 | 290 | RX1M.attach(NULL); |
shreeshas95 | 6:79d422d1ed42 | 291 | gCOM_PA_COOLING_TIMEOUT.detach(); |
shreeshas95 | 6:79d422d1ed42 | 292 | COM_POWER_ON_TX; |
shreeshas95 | 6:79d422d1ed42 | 293 | EXECUTE_OBOSC_ONLY; |
shreeshas95 | 6:79d422d1ed42 | 294 | EXECUTE_TC; |
shreeshas95 | 6:79d422d1ed42 | 295 | } |
shreeshas95 | 0:f016e9e8d48b | 296 | } |
shreeshas95 | 2:2caf2a9a13aa | 297 | } |
shreeshas95 | 6:79d422d1ed42 | 298 | else if( gFLAGS & COM_SESSION_TIMEOUT_FLAG ){ |
aniruddhv | 12:ffdb29353058 | 299 | /*gPC.puts("session timeout: resetting in main\r\n");*/ |
shreeshas95 | 6:79d422d1ed42 | 300 | COM_POWER_OFF_TX; |
shreeshas95 | 6:79d422d1ed42 | 301 | /*PENDING : ENABLE THREADS*/ |
ee12b079 | 246:565458eefd94 | 302 | HK_counter->start(10000); |
ee12b079 | 245:da9d1bd999da | 303 | gPAY_SPI->bulkRead_resume(&payload_isr_fun); |
shreeshas95 | 6:79d422d1ed42 | 304 | gSESSION_TIMEOUT.detach(); |
shreeshas95 | 6:79d422d1ed42 | 305 | gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG); |
shreeshas95 | 6:79d422d1ed42 | 306 | gFLAGS = gFLAGS & (~COM_SESSION_FLAG); |
shreeshas95 | 6:79d422d1ed42 | 307 | reset_all; |
shreeshas95 | 6:79d422d1ed42 | 308 | } |
shreeshas95 | 2:2caf2a9a13aa | 309 | else{ |
aniruddhv | 12:ffdb29353058 | 310 | /*gPC.puts("INVALID SIGNAL RECEIVED IN MAIN\r\n");*/ |
shreeshas95 | 2:2caf2a9a13aa | 311 | // SOME INVALID SIGNAL RECEIVED |
shreeshas95 | 4:104dd82c99b8 | 312 | COM_POWER_OFF_TX; |
shreeshas95 | 2:2caf2a9a13aa | 313 | reset_all; |
shreeshas95 | 2:2caf2a9a13aa | 314 | // PENDING : ENABLE THREADS |
ee12b079 | 246:565458eefd94 | 315 | HK_counter->start(10000); |
ee12b079 | 245:da9d1bd999da | 316 | gPAY_SPI->bulkRead_resume(&payload_isr_fun); |
shreeshas95 | 2:2caf2a9a13aa | 317 | gSESSION_TIMEOUT.detach(); |
shreeshas95 | 2:2caf2a9a13aa | 318 | gFLAGS = gFLAGS & (~COM_SESSION_FLAG); |
shreeshas95 | 0:f016e9e8d48b | 319 | } |
chaithanyarss | 251:c766afa330a3 | 320 | gMutex.unlock(); |
shreeshas95 | 0:f016e9e8d48b | 321 | } |
shreeshas95 | 101:bece931236a2 | 322 | } |