working version
Dependencies: mbed mbed-rtos SimpleDMA FreescaleIAP eeprom
Fork of CDMS_CODE_FM_28JAN2017 by
Diff: COM_MNG_TMTC.h
- Revision:
- 161:a63672bf4423
- Parent:
- 154:9aec89c8cdc7
- Child:
- 162:48fda0b8d573
diff -r 9aec89c8cdc7 -r a63672bf4423 COM_MNG_TMTC.h --- a/COM_MNG_TMTC.h Mon Apr 11 16:04:55 2016 +0000 +++ b/COM_MNG_TMTC.h Thu Apr 14 04:14:21 2016 +0000 @@ -10,11 +10,6 @@ //added RLY_TMTC function //added included related files -//#include "Flash.h" -#include "cdms_rtc.h" - -DigitalIn tm_status_4m_slv(PIN39); //I2C interrupt to CDMS from BAE -//DigitalIn tm_status_4m_pl(PIN61); //I2C interrupt to CDMS from PL uint8_t received = 0; uint16_t mid1; @@ -196,7 +191,7 @@ // CDMS TEAM CODE START inline Base_tm* FCTN_CDMS_RLY_TMTC(Base_tc *tc_ptr){ - uint8_t ACKCODE = 0x00; + uint8_t ACKCODE = 0xB0; //printf("\rTC execution in progress\r\n"); Base_tm *tm_pointer = new Long_tm; Base_tm *tm_ptr = tm_pointer; @@ -205,9 +200,9 @@ { case 1: //apid=01 implies it corresponds to bae { - //printf("Telecommand is for BAE\r\n"); + gPC.printf("Telecommand is for BAE\r\n"); //printf("Sending TC to BAE...\r\n"); //interrupt to be sent to the bae - FCTN_I2C_WRITE((char*)tc_ptr->TC_string); + /*FCTN_I2C_WRITE((char*)tc_ptr->TC_string); while(1) { wait(1); //TimeOut instead of wait @@ -255,7 +250,7 @@ tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); tm_pointer->next_TM = NULL; return tm_ptr; } - break; + break;*/ } case 2: { @@ -293,7 +288,7 @@ } case 0x2: { - //printf("sub_service:Read from Flash_Memory\r\n"); + gPC.printf("sub_service:Read from Flash_Memory\r\n"); mid=(uint16_t)(tc_ptr->TC_string[3]<<4)+(uint16_t)(tc_ptr->TC_string[4]); //Data[0] = FCTN_CDMS_RD_FLASH(0); @@ -787,22 +782,39 @@ } case 3: { - //printf("Telecommand is for PL\r\n"); - // printf("Informing PL about TC using I2C\r\n"); //interrupt to be sent to the bae - // FCTN_I2C_WRITE((char*)tc_ptr->TC_string); - // printf("sent the Telecommand to BAE\r\n"); //packet along with crc will be sent when bae is ready - // wait(1); //wait time is to be optimised - // if(tm_status_4m_slv == 1) - // { - // FCTN_I2C_READ((char*)tm_ptr->TM_string); - // received = 1; - // } - // if(received == 1 ) - // { - // printf("Telemetry is received from BAE\r\n"); - // printf("%s", tm_ptr->TM_string); - // received = 0; - // } // similar to BAE functions + #if DEBUG + printf("Telecommand is for PL\r\n"); + #endif + + + if(GETservice_subtype(tc_ptr) == 0xD0 || GETservice_subtype(tc_ptr) == 0xD2 || GETservice_subtype(tc_ptr) == 0xD3) + { + PL_TM_SIZE = TM_LONG_SIZE; + } + else + { + PL_TM_SIZE = TM_LONG_SIZE; + } + + if(GETshort_or_long_tc(tc_ptr) == LONG_TC_CODE) + FCTN_I2C_WRITE_PL((char*)tc_ptr->TC_string,TC_LONG_SIZE); + else + { + FCTN_I2C_WRITE_PL((char*)tc_ptr->TC_string,TC_SHORT_SIZE); + } + + while(1) + { + if(rcv_isr == 1) + { + //gPC.printf("i2c_t = %d",t_pl.read_ms()); + for(int i = 0;i< PL_TM_SIZE;i++) + tm_pointer->TM_string[i] = PL_I2C_DATA[i]; + rcv_isr = 0; + break; + } + } + tm_pointer->next_TM = NULL; return tm_ptr; break; } default: //invalid TC @@ -1230,9 +1242,7 @@ /*execute_obsrs(current_TC, put_tm_here)*/\ /*read_TC(current_TC);*/\ execute_OBSRS_TC(current_TC);\ - gPC.puts("en_adf\n\r");\ transmit_adf;\ - gPC.puts("ex_adf\n\r");\ uint8_t tempExec = TC_STATE_SUCCESSFULLY_EXECUTED;\ PUTexec_status(current_TC, tempExec);\ /*PENDING: ABORT ON NACK CHECK, gMASTER_STATE VERIFICATION WITH SD CARD, session timeout, last executed ack l234*/\