
Compression code changed and RLY_TMTC pointers managed
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE by
Diff: ThreadsAndFunctions.h
- Revision:
- 215:570251b23c7b
- Parent:
- 213:867de6d350fa
- Child:
- 216:93505a6f8db7
--- a/ThreadsAndFunctions.h Sun Jul 03 09:26:42 2016 +0000 +++ b/ThreadsAndFunctions.h Sun Jul 03 09:47:05 2016 +0000 @@ -36,12 +36,6 @@ gCOM_MNG_TMTC_THREAD->signal_set(COM_MNG_TMTC_SIGNAL_UART_INT); } -// COM_RX_DISABLE ISR -void after_com_disable(){ - gCOM_RX_DISABLE.detach(); - RX1M.attach(&rx_read, Serial::RxIrq); -} - // RX_TIMEOUT ISR void after_receive(){ gRX_TIMEOUT.detach(); @@ -69,15 +63,15 @@ }\ gHEAD_NODE_TCL = NULL;\ gLAST_NODE_TCL = NULL;\ - gMASTER_STATE = TCL_STATE_COMPLETED;\ + gMASTER_STATE = TCL_STATE_INCOMPLETE;\ gTOTAL_INCORRECT_SIZE_TC = 0;\ gTOTAL_CRC_FAIL_TC = 0;\ gTOTAL_REPEATED_TC = 0;\ gTOTAL_VALID_TC = 0;\ for(int i = 0 ; i < TM_LONG_SIZE ; ++i){\ - /*gLAST_TM[i] = 0x00;*/\ + gLAST_TM[i] = 0x00;\ }\ - /*gLAST_TM_SHORT_OR_LONG = SHORT_TM_CODE;*/\ + gLAST_TM_SHORT_OR_LONG = SHORT_TM_CODE;\ COM_RX_DATA_NODE *dataptr = gRX_HEAD_DATA_NODE;\ while( dataptr != NULL ){\ COM_RX_DATA_NODE *temp = dataptr->next_node;\ @@ -88,7 +82,6 @@ gRX_HEAD_DATA_NODE->next_node = NULL;\ gRX_CURRENT_DATA_NODE = gRX_HEAD_DATA_NODE;\ gRX_COUNT = 0;\ - gTOTAL_RAW_BYTES = 0;\ /*PENDING : ALL GLOBAL VAARIABLES AND FLAGS*/\ /*gPC.puts("finished reset all\r\n");*/\ } @@ -103,7 +96,6 @@ gRX_CURRENT_DATA_NODE = gRX_CURRENT_DATA_NODE->next_node;\ gRX_CURRENT_DATA_NODE->next_node = NULL;\ }\ - ++gTOTAL_RAW_BYTES;\ gRX_TIMEOUT.attach(&after_receive, RX_TIMEOUT_LIMIT);\ } @@ -118,12 +110,10 @@ gFLAGS = gFLAGS & (~UART_INT_FLAG); if( !(gFLAGS & COM_SESSION_FLAG) ){ // PENDING : DISABLE THREADS - // gCDMS_HK_TIMER.stop(); PL_wo_dma->stop(); gFLAGS = gFLAGS | COM_SESSION_FLAG; gSESSION_TIMEOUT.attach(&after_session, SESSION_TIME_LIMIT); gFLAGS = gFLAGS | COM_RX_FLAG; - gTOTAL_RAW_BYTES = 0; PUT_RAW_BYTE; // PENDING : MEASURE RSSI if( gFLAGS & COM_SESSION_FLAG ){ @@ -142,15 +132,10 @@ gFLAGS = gFLAGS | COM_RX_FLAG; PUT_RAW_BYTE; } - if(gTOTAL_RAW_BYTES > BYTE_OVERFLOW_CONSTANT){ - RX1M.attach(NULL); - gCOM_RX_DISABLE.attach(&after_com_disable, COM_RX_DISABLE_TIMEOUT); - after_receive(); - } } else if( gFLAGS & NEW_TC_RECEIVED ){ gPC.puts("NEW TC RECEIVED\r\n"); - Thread::wait(1000);/*For testing with transmitter. To be removed later*/ + Thread::wait(1000); gFLAGS = gFLAGS & (~NEW_TC_RECEIVED); gFLAGS = gFLAGS | COM_MNG_TMTC_RUNNING_FLAG; @@ -178,24 +163,30 @@ // CHECK WEATHER GS VERIFICATION CODE MATCHES uint8_t tempGSver = 0x00; GScodeVerification(tempGSver); + /*PENDING: INCLUDE GS VERIFICATION CODE*/ if( tempGSver == 0xFF ){ /*gPC.puts("GS code match !!\r\n");*/ gFLAGS = gFLAGS | COM_SESSION_VALIDITY; COM_POWER_ON_TX; - P_COM_HK; - if( (gFLAGS & COM_PA_HOT_FLAG) || ( gFLAGS & COM_PA_OC_FLAG ) ){ - COM_TX_CNTRL = 0; + // PENDING: PA HOT HANDLED IN EXECUTE_XXX FUNCTIONS + uint8_t tempPAHot = 0x00; + isPAhot(tempPAHot); + if( tempPAHot == 0xFF ){ + gFLAGS = gFLAGS & ~(COM_PA_HOT_FLAG); + gCOM_PA_COOLING_TIMEOUT.detach(); + gPC.puts("EXECUTING TELECOMMANDS\r\n"); +// DEBUF_PRINT("EXECUTING TELECOMMANDS\r\n"); + EXECUTE_OBOSC_ONLY; + EXECUTE_TC; + gPC.puts("COMPLETED EXECUTION\r\n"); + } + else{ + gFLAGS = gFLAGS | COM_PA_HOT_FLAG; + // PENDING: power off transmitter only gCOM_PA_COOLING_TIMEOUT.attach(&after_cooling_pa, COM_PA_COOLING_TIME_LIMIT); gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG); RX1M.attach(&rx_read, Serial::RxIrq); } - else{ - gCOM_PA_COOLING_TIMEOUT.detach(); - gPC.puts("EXECUTING TELECOMMANDS\r\n"); - EXECUTE_OBOSC_ONLY; - EXECUTE_TC; - gPC.puts("COMPLETED EXECUTION\r\n"); - } } else{ /*gPC.puts("GS code mismatch !!\r\n");*/ @@ -203,11 +194,10 @@ reset_all; gFLAGS = gFLAGS & (~COM_SESSION_VALIDITY); // PENDING : ENABLE THREADS - // gCDMS_HK_TIMER.start(5000); PL_wo_dma->start(6000); gSESSION_TIMEOUT.detach(); gFLAGS = gFLAGS & (~COM_SESSION_FLAG); - gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG); + // WARNING: clear COM_MNG_TMTC ? } } else{ @@ -238,16 +228,15 @@ } //gPC.puts("\r\n"); COM_POWER_ON_TX; - COM_TX_CNTRL = 0; + // PENDING : POWER OFF TX RX1M.attach(&rx_read, Serial::RxIrq); gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG); } } else{ COM_POWER_ON_TX; - COM_TX_CNTRL = 0; - reset_all; - gFLAGS = gFLAGS & (~COM_SESSION_FLAG); + // POWER OFF TX transmitter only + // WARNING: reset_all ? clear com_session ? RX1M.attach(&rx_read, Serial::RxIrq); gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG); } @@ -258,7 +247,6 @@ gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG); reset_all; // PENDING : ENABLE THREADS - // gCDMS_HK_TIMER.start(5000); PL_wo_dma->start(6000); gSESSION_TIMEOUT.detach(); gFLAGS = gFLAGS & (~COM_SESSION_FLAG); @@ -266,17 +254,29 @@ } else if( gFLAGS & COM_PA_HOT_FLAG ){ /*gPC.puts("checking for PA hot in main\r\n");*/ - P_COM_HK; - if((gFLAGS & COM_PA_HOT_FLAG) || (gFLAGS & COM_PA_OC_FLAG)){ - COM_TX_CNTRL = 0; - gCOM_PA_COOLING_TIMEOUT.attach(&after_cooling_pa, COM_PA_COOLING_TIME_LIMIT); + if( gFLAGS & COM_RX_FLAG ){ + uint8_t tempPA = 0xFF; + isPAhot(tempPA); + if( tempPA == 0x00 ){ + gCOM_PA_COOLING_TIMEOUT.attach(&after_cooling_pa, COM_PA_COOLING_TIME_LIMIT); + } + else{ + gFLAGS = gFLAGS & ~(COM_PA_HOT_FLAG); + gCOM_PA_COOLING_TIMEOUT.detach(); + } } else{ - gCOM_PA_COOLING_TIMEOUT.detach(); - if( !(gFLAGS & COM_RX_FLAG) ){ + uint8_t tempPA = 0xFF; + isPAhot(tempPA); + if( tempPA == 0x00 ){ + gCOM_PA_COOLING_TIMEOUT.attach(&after_cooling_pa, COM_PA_COOLING_TIME_LIMIT); + } + else{ /*gPC.puts("PA IS COOLED DOWN\r\n");*/ + gFLAGS = gFLAGS & (~COM_PA_HOT_FLAG); gFLAGS = gFLAGS | COM_MNG_TMTC_RUNNING_FLAG; RX1M.attach(NULL); + gCOM_PA_COOLING_TIMEOUT.detach(); COM_POWER_ON_TX; EXECUTE_OBOSC_ONLY; EXECUTE_TC; @@ -287,7 +287,7 @@ /*gPC.puts("session timeout: resetting in main\r\n");*/ COM_POWER_OFF_TX; /*PENDING : ENABLE THREADS*/ - // gCDMS_HK_TIMER.start(5000); + gSESSION_TIMEOUT.detach(); gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG); gFLAGS = gFLAGS & (~COM_SESSION_FLAG);