
Compression code changed and RLY_TMTC pointers managed
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE by
Diff: ThreadsAndFunctions.h
- Revision:
- 6:79d422d1ed42
- Parent:
- 5:ab276a17ca07
- Child:
- 12:ffdb29353058
--- a/ThreadsAndFunctions.h Wed Dec 30 06:36:38 2015 +0000 +++ b/ThreadsAndFunctions.h Thu Dec 31 06:43:13 2015 +0000 @@ -15,8 +15,10 @@ // SESSION_TIMOUT ISR void after_session(){ gSESSION_TIMEOUT.detach(); - gFLAGS = gFLAGS & (~COM_SESSION_FLAG); - gCOM_MNG_TMTC_THREAD->signal_set(COM_MNG_TMTC_SIGNAL_UART_INT); + gFLAGS = gFLAGS | COM_SESSION_TIMEOUT_FLAG; + if( gMASTER_STATE != TCL_STATE_EXECUTING ){ + gCOM_MNG_TMTC_THREAD->signal_set(COM_MNG_TMTC_SIGNAL_UART_INT); + } } #define reset_all {\ @@ -102,7 +104,6 @@ else if( gFLAGS & NEW_TC_RECEIVED ){ gPC.puts("NEW TC RECEIVED\r\n"); gFLAGS = gFLAGS & (~NEW_TC_RECEIVED); - gFLAGS = gFLAGS & (~COM_RX_FLAG); gFLAGS = gFLAGS | COM_MNG_TMTC_RUNNING_FLAG; // DISABLE THE RX1M INTERRUPT @@ -115,6 +116,7 @@ } gRX_COUNT = 0; raw_data_to_tc(); + gFLAGS = gFLAGS & (~COM_RX_FLAG); if( gTOTAL_VALID_TC > 0 ){ gPC.printf("valid TC rx: %u\r\n", gTOTAL_VALID_TC); @@ -137,6 +139,8 @@ 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"); EXECUTE_OBOSC_ONLY; EXECUTE_TC; @@ -144,13 +148,15 @@ } else{ gFLAGS = gFLAGS | COM_PA_HOT_FLAG; - COM_POWER_OFF_TX; + // 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); - gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG); } } else{ gPC.puts("GS code mismatch !!\r\n"); + RX1M.attach(&rx_read, Serial::RxIrq); reset_all; gFLAGS = gFLAGS & (~COM_SESSION_VALIDITY); // PENDING : ENABLE THREADS @@ -194,41 +200,64 @@ } else{ COM_POWER_ON_TX; - // POWER OFF TX + // POWER OFF TX transmitter only // WARNING: reset_all ? clear com_session ? RX1M.attach(&rx_read, Serial::RxIrq); gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG); } } else{ - gPC.puts("No valid TC recweived\r\n"); + gPC.puts("No valid TC received\r\n"); RX1M.attach(&rx_read, Serial::RxIrq); gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG); - - if( !(gFLAGS & COM_TX_FLAG) ){ - reset_all; - // PENDING : ENABLE THREADS - gSESSION_TIMEOUT.detach(); - gFLAGS = gFLAGS & (~COM_SESSION_FLAG); - } - // else wait + reset_all; + // PENDING : ENABLE THREADS + gSESSION_TIMEOUT.detach(); + gFLAGS = gFLAGS & (~COM_SESSION_FLAG); } } else if( gFLAGS & COM_PA_HOT_FLAG ){ - uint8_t tempPA = 0xFF; - isPAhot(tempPA); - if( tempPA == 0x00 ){ - gCOM_PA_COOLING_TIMEOUT.attach(&after_cooling_pa, COM_PA_COOLING_TIME_LIMIT); + gPC.puts("checking for PA hot in main\r\n"); + 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{ - gFLAGS = gFLAGS & (~COM_PA_HOT_FLAG); - gCOM_PA_COOLING_TIMEOUT.detach(); - COM_POWER_ON_TX; - EXECUTE_OBOSC_ONLY; - EXECUTE_TC; + 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; + } } } + else if( gFLAGS & COM_SESSION_TIMEOUT_FLAG ){ + gPC.puts("session timeout: resetting in main\r\n"); + COM_POWER_OFF_TX; + /*PENDING : ENABLE THREADS*/ + gSESSION_TIMEOUT.detach(); + gFLAGS = gFLAGS & (~COM_MNG_TMTC_RUNNING_FLAG); + gFLAGS = gFLAGS & (~COM_SESSION_FLAG); + reset_all; + } else{ + gPC.puts("INVALID SIGNAL RECEIVED IN MAIN\r\n"); // SOME INVALID SIGNAL RECEIVED COM_POWER_OFF_TX; reset_all;