
Repository for CDMS code
Dependencies: SimpleDMA mbed-rtos mbed eeprom
Fork of COM_MNG_TMTC_SIMPLE by
Revision 38:ce72cc56b85d, committed 2016-01-07
- Comitter:
- Shashank7906
- Date:
- Thu Jan 07 09:30:58 2016 +0000
- Parent:
- 22:5febef18443d
- Commit message:
- initial commit;
Changed in this revision
COM_MNG_TMTC.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/COM_MNG_TMTC.h Tue Jan 05 10:59:56 2016 +0000 +++ b/COM_MNG_TMTC.h Thu Jan 07 09:30:58 2016 +0000 @@ -400,8 +400,636 @@ // CDMS TEAM CODE START #define CDMS_RLY_TMTC(tc_ptr, tm_ptr){\ tm_ptr = NULL;\ + printf("\rTC execution in progress\r\n");\ + //Base_tm *tm = new Long_tm;\ + Base_tm *tm_pointer = tm_ptr;\ + received = 0;\ + switch(GETapid(tc_ptr))\ + {\ + case 1:\ //apid=01 implies it corresponds to bae\ + {\ + 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);\ + while(1)\ + {\ + wait(1);\ //TimeOut instead of wait\ + if(tm_status_4m_slv == 1)\ + {\ + printf("receiving...\r\n");\ + FCTN_I2C_READ((char*)tm_pointer->TM_string);\ + //printf("%s", tm_pointer->TM_string);\ + received+=1;\ + tm_pointer = tm_pointer->next_TM;\ + break;\ //only for testing purpose\ + }\ + else\ + {\ + break;\ + }\ + }\ + if(received >= 1 )\ + {\ + printf("Telemetry is received from BAE\r\n");\ + Base_tm *tm_print = tm_ptr;\ + for(uint8_t i=0;\i<received;\i++)\ + {\ + printf("%s", tm_print->TM_string);\ + tm_print = tm_print->next_TM;\ //for check\ + }\ + received = 0;\ + return tm_ptr;\ + }\ + else\ + {\ + printf("Telemetry is not received from BAE\r\n");\ + tm_pointer = new Short_tm;\ + tm_pointer->TM_string[0] = 0xB0;\ + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + tm_pointer->TM_string[2] = 0x01;\ + tm_pointer->TM_string[3] = ACKCODE;\ //ackcode to be decided\ + tm_pointer->TM_string[4] = 0x01;\ + for(uint8_t i=0;i<6;i++)\ + {\ + tm_pointer->TM_string[i+5] = 0;\ + }\ + crc16 = CRC::crc16_gen(tm_ptr->TM_string,11);\ + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);\ + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);\ + return tm_ptr;\ + }\ + break;\ + }\ + case 2:\ + {\ + printf("Telecommand is for CDMS\r\n");\ //apid = 10 corresponds to cdms\ + switch(GETservice_type(tc_ptr))\ + {\ + case 0x60:\ + {\ + printf("service:MMS\r\n");\ + switch(GETservice_subtype(tc_ptr))\ + {\ + case 0x1:\ + {\ + printf("sub_service:Read from RAM_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);\ + Data[1] = FCTN_CDMS_RD_FLASH(1);\ + tm_pointer = new Long_tm;\ + tm_pointer->TM_string[0] = 0x30;\ + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + tm_pointer->TM_string[2] = (uint8_t)(flash_counter);\ + for(uint8_t i=0;i<4;i++)\ + {\ + tm_pointer->TM_string[3+i] = (uint8_t)((Data[0]>>(8*i))&0x00FF);\ + }\ + for(uint8_t i=4;\i<8;\i++)\ + {\ + tm_pointer->TM_string[3+i] = (uint8_t)((Data[1]>>(8*i))&0x00FF);\ + }\ + crc16 = CRC::crc16_gen(tm_ptr->TM_string,9);\ + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);\ + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);\ + return tm_ptr;\ + }\ + case 0x2:\ + {\ + 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);\ + Data[1] = FCTN_CDMS_RD_FLASH(1);\ + tm_pointer = new Long_tm;\ + tm_pointer->TM_string[0] = 0x30;\ + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + tm_pointer->TM_string[2] = (uint8_t)(flash_counter);\ + for(uint8_t i=0;i<4;i++)\ + {\ + tm_pointer->TM_string[3+i] = (uint8_t)((Data[0]>>(8*i))&0x00FF);\ + }\ + for(uint8_t i=4;i<8;i++)\ + {\ + tm_pointer->TM_string[3+i] = (uint8_t)((Data[1]>>(8*i))&0x00FF);\ + }\ + crc16 = CRC::crc16_gen(tm_ptr->TM_string,9);\ + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);\ + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);\ + return tm_ptr;\ + }\ + case 0x5:\ + {\ + printf("WRITE ON FLASH_MEMORY\r\n");\ + mid=(uint16_t)(tc_ptr->TC_string[3]<<4)+(uint16_t)(tc_ptr->TC_string[4]);\ + block = (((uint32_t)(tc_ptr->TC_string[5])<<24)|((uint32_t)(tc_ptr->TC_string[5])<<16)|((uint32_t)(tc_ptr->TC_string[5])<<8)|((uint32_t)(tc_ptr->TC_string[5])));\ + FCTN_CDMS_WR_FLASH(mid,block);\ + tm_pointer = new Short_tm;\ + tm_pointer->TM_string[0] = 0xB0;\ + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + tm_pointer->TM_string[2] = 0x01;\ + tm_pointer->TM_string[3] = ACKCODE;\ //ackcode to be decided\ + tm_pointer->TM_string[4] = 0x01;\ + for(uint8_t i=0;i<6;i++)\ + {\ + tm_pointer->TM_string[i+5] = 0;\ + }\ + crc16 = CRC::crc16_gen(tm_ptr->TM_string,11);\ + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);\ + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);\ + return tm_ptr;\ + break;\ + }\ + default:\ + {\ + printf("INVALID TC\r\n");\ //Send Invalid TC Telemetry\ + tm_pointer = new Short_tm;\ + tm_pointer->TM_string[0] = 0xB0;\ + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + tm_pointer->TM_string[2] = 0x01;\ + tm_pointer->TM_string[3] = ACKCODE;\ //ackcode to be decided\ + tm_pointer->TM_string[4] = 0x01;\ + for(uint8_t i=0;i<6;i++)\ + {\ + tm_pointer->TM_string[i+5] = 0;\ + }\ + crc16 = CRC::crc16_gen(tm_ptr->TM_string,11);\ + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);\ + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);\ + return tm_ptr;\ + }\ + break;\ + }\ + }\ + case 0x8:\ + {\ + printf("service:FUNCTION MANAGEMENT SERVICE\r\n");\ + if(GETservice_subtype(tc_ptr)==0x1)\ + {\ + if(GETpid(tc_ptr)==0x01)\ + {\ + printf("TC_PL_INIT\r\n");\ // call PWR_SWCH_ON function\ + tm_pointer = new Short_tm;\ + tm_pointer->TM_string[0] = 0xB0;\ + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + tm_pointer->TM_string[2] = ACKCODE;\ + for(uint8_t i=3;i<11;i++)\ + {\ + tm_pointer->TM_string[i] = 0;\ + }\ + crc16 = CRC::crc16_gen(tm_ptr->TM_string,11);\ + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);\ + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);\ + return tm_ptr;\ + break;\ + }\ + else if(GETpid(tc_ptr)==0x02)\ + {\ + printf("TC_PL_MAIN\r\n");\ // call PWR_SWCH_ON function\ + tm_pointer = new Short_tm;\ + tm_pointer->TM_string[0] = 0xB0;\ + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + tm_pointer->TM_string[2] = ACKCODE;\ + for(uint8_t i=3;i<11;i++)\ + {\ + tm_pointer->TM_string[i] = 0;\ + }\ + crc16 = CRC::crc16_gen(tm_ptr->TM_string,11);\ + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);\ + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);\ + return tm_ptr;\ + break;\ + }\ + else if(GETpid(tc_ptr)==0x03)\ + {\ + printf("TC_COM_INIT\r\n");\ // call PWR_SWCH_ON function\ + tm_pointer = new Short_tm;\ + tm_pointer->TM_string[0] = 0xB0;\ + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + tm_pointer->TM_string[2] = ACKCODE;\ + for(uint8_t i=3;i<11;i++)\ + {\ + tm_pointer->TM_string[i] = 0;\ + }\ + crc16 = CRC::crc16_gen(tm_ptr->TM_string,11);\ + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);\ + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);\ + return tm_ptr;\ + break;\ + }\ + else if(GETpid(tc_ptr)==0x04)\ + {\ + printf("TC_CDMS_HK_MAIN\r\n");\ // call PWR_SWCH_ON function\ + tm_pointer = new Short_tm;\ + tm_pointer->TM_string[0] = 0xB0;\ + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + tm_pointer->TM_string[2] = ACKCODE;\ + for(uint8_t i=3;i<11;i++)\ + {\ + tm_pointer->TM_string[i] = 0;\ + }\ + crc16 = CRC::crc16_gen(tm_ptr->TM_string,11);\ + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);\ + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);\ + return tm_ptr;\ + break;\ + }\ + else if(GETpid(tc_ptr)==0x11)\ + {\ + printf("TC_SW_ON_SD\r\n");\ // call PWR_SWCH_ON function\ + tm_pointer = new Short_tm;\ + tm_pointer->TM_string[0] = 0xB0;\ + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + tm_pointer->TM_string[2] = ACKCODE;\ + for(uint8_t i=3;i<11;i++)\ + {\ + tm_pointer->TM_string[i] = 0;\ + }\ + crc16 = CRC::crc16_gen(tm_ptr->TM_string,11);\ + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);\ + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);\ + return tm_ptr;\ + break;\ + }\ + else if(GETpid(tc_ptr)==0x12)\ + {\ + printf("TC_SW_ON_RTC\r\n");\ // call PWR_SWCH_ON function\ + tm_pointer = new Short_tm;\ + tm_pointer->TM_string[0] = 0xB0;\ + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + tm_pointer->TM_string[2] = ACKCODE;\ + for(uint8_t i=3;i<11;i++)\ + {\ + tm_pointer->TM_string[i] = 0;\ + }\ + crc16 = CRC::crc16_gen(tm_ptr->TM_string,11);\ + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);\ + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);\ + return tm_ptr;\ + break;\ + }\ + else if(GETpid(tc_ptr)==0x13)\ + {\ + printf("TC_SW_ON_BAE\r\n");\ // call PWR_SWCH_ON function\ + tm_pointer = new Short_tm;\ + tm_pointer->TM_string[0] = 0xB0;\ + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + tm_pointer->TM_string[2] = ACKCODE;\ + for(uint8_t i=3;i<11;i++)\ + {\ + tm_pointer->TM_string[i] = 0;\ + }\ + crc16 = CRC::crc16_gen(tm_ptr->TM_string,11);\ + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);\ + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);\ + return tm_ptr;\ + break;\ + }\ + else if(GETpid(tc_ptr)==0x14)\ + {\ + printf("TC_SW_ON_PL_DL\r\n");\ // call PWR_SWCH_ON function\ + tm_pointer = new Short_tm;\ + tm_pointer->TM_string[0] = 0xB0;\ + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + tm_pointer->TM_string[2] = ACKCODE;\ + for(uint8_t i=3;i<11;i++)\ + {\ + tm_pointer->TM_string[i] = 0;\ + }\ + crc16 = CRC::crc16_gen(tm_ptr->TM_string,11);\ + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);\ + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);\ + return tm_ptr;\ + break;\ + }\ + else if(GETpid(tc_ptr)==0x15)\ + {\ + printf("TC_SW_ON_PL_AG_HV\r\n");\ // call PWR_SWCH_ON function\ + tm_pointer = new Short_tm;\ + tm_pointer->TM_string[0] = 0xB0;\ + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + tm_pointer->TM_string[2] = ACKCODE;\ + for(uint8_t i=3;i<11;i++)\ + {\ + tm_pointer->TM_string[i] = 0;\ + }\ + crc16 = CRC::crc16_gen(tm_ptr->TM_string,11);\ + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);\ + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);\ + return tm_ptr;\ + break;\ + }\ + else if(GETpid(tc_ptr)==0x16)\ + {\ + printf("TC_SW_ON_V_A_EN\r\n");\ // call PWR_SWCH_ON function\ + tm_pointer = new Short_tm;\ + tm_pointer->TM_string[0] = 0xB0;\ + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + tm_pointer->TM_string[2] = ACKCODE;\ + for(uint8_t i=3;i<11;i++)\ + {\ + tm_pointer->TM_string[i] = 0;\ + }\ + crc16 = CRC::crc16_gen(tm_ptr->TM_string,11);\ + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);\ + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);\ + return tm_ptr;\ + break;\ + }\ + else if(GETpid(tc_ptr)==0x21)\ + {\ + printf("TC_SW_OFF_SD\r\n");\ // call PWR_SWCH_ON function\ + tm_pointer = new Short_tm;\ + tm_pointer->TM_string[0] = 0xB0;\ + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + tm_pointer->TM_string[2] = ACKCODE;\ + for(uint8_t i=3;i<11;i++)\ + {\ + tm_pointer->TM_string[i] = 0;\ + }\ + crc16 = CRC::crc16_gen(tm_ptr->TM_string,11);\ + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);\ + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);\ + return tm_ptr;\ + break;\ + }\ + else if(GETpid(tc_ptr)==0x22)\ + {\ + printf("TC_SW_OFF_RTC\r\n");\ // call PWR_SWCH_ON function\ + tm_pointer = new Short_tm;\ + tm_pointer->TM_string[0] = 0xB0;\ + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + tm_pointer->TM_string[2] = ACKCODE;\ + for(uint8_t i=3;i<11;i++)\ + {\ + tm_pointer->TM_string[i] = 0;\ + }\ + crc16 = CRC::crc16_gen(tm_ptr->TM_string,11);\ + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);\ + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);\ + return tm_ptr;\ + break;\ + }\ + else if(GETpid(tc_ptr)==0x23)\ + {\ + printf("TC_SW_OFF_BAE\r\n");\ // call PWR_SWCH_ON function\ + tm_pointer = new Short_tm;\ + tm_pointer->TM_string[0] = 0xB0;\ + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + tm_pointer->TM_string[2] = ACKCODE;\ + for(uint8_t i=3;i<11;i++)\ + {\ + tm_pointer->TM_string[i] = 0;\ + }\ + crc16 = CRC::crc16_gen(tm_ptr->TM_string,11);\ + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);\ + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);\ + return tm_ptr;\ + break;\ + }\ + else if(GETpid(tc_ptr)==0x24)\ + {\ + printf("TC_SW_OFF_PL_DL\r\n");\ // call PWR_SWCH_ON function\ + tm_pointer = new Short_tm;\ + tm_pointer->TM_string[0] = 0xB0;\ + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + tm_pointer->TM_string[2] = ACKCODE;\ + for(uint8_t i=3;i<11;i++)\ + {\ + tm_pointer->TM_string[i] = 0;\ + }\ + crc16 = CRC::crc16_gen(tm_ptr->TM_string,11);\ + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);\ + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);\ + return tm_ptr;\ + break;\ + }\ + else\ if(GETpid(tc_ptr)==0x25)\ + {\ + printf("TC_SW_OFF_PL_AG_HV\r\n");\ // call PWR_SWCH_ON function\ + tm_pointer = new Short_tm;\ + tm_pointer->TM_string[0] = 0xB0;\ + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + tm_pointer->TM_string[2] = ACKCODE;\ + for(uint8_t i=3;i<11;i++)\ + {\ + tm_pointer->TM_string[i] = 0;\ + }\ + crc16 = CRC::crc16_gen(tm_ptr->TM_string,11);\ + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);\ + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);\ + return tm_ptr;\ + break;\ + }\ + else\ if(GETpid(tc_ptr)==0x26)\ + {\ + printf("TC_SW_OFF_V_A_EN\r\n");\ // call PWR_SWCH_ON function\ + tm_pointer = new Short_tm;\ + tm_pointer->TM_string[0] = 0xB0;\ + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + tm_pointer->TM_string[2] = ACKCODE;\ + for(uint8_t i=3;i<11;i++)\ + {\ + tm_pointer->TM_string[i] = 0;\ + }\ + crc16 = CRC::crc16_gen(tm_ptr->TM_string,11);\ + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);\ + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);\ + return tm_ptr;\ + break;\ + }\ + else\ if(GETpid(tc_ptr)==0x31)\ + {\ + printf("TC_RST_SD\r\n");\ // call PWR_SWCH_ON function\ + tm_pointer = new Short_tm;\ + tm_pointer->TM_string[0] = 0xB0;\ + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + tm_pointer->TM_string[2] = ACKCODE;\ + for(uint8_t i=3;i<11;i++)\ + {\ + tm_pointer->TM_string[i] = 0;\ + }\ + crc16 = CRC::crc16_gen(tm_ptr->TM_string,11);\ + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);\ + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);\ + return tm_ptr;\ + break;\ + }\ + else\ if(GETpid(tc_ptr)==0x32)\ + {\ + printf("TC_RST_RTC\r\n");\ // call PWR_SWCH_ON function\ + tm_pointer = new Short_tm;\ + tm_pointer->TM_string[0] = 0xB0;\ + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + tm_pointer->TM_string[2] = ACKCODE;\ + for(uint8_t i=3;i<11;i++)\ + {\ + tm_pointer->TM_string[i] = 0;\ + }\ + crc16 = CRC::crc16_gen(tm_ptr->TM_string,11);\ + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);\ + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);\ + return tm_ptr;\ + break;\ + }\ + else\ if(GETpid(tc_ptr)==0x33)\ + {\ + printf("TC_RST_BAE\r\n");\ // call PWR_SWCH_ON function\ + tm_pointer = new Short_tm;\ + tm_pointer->TM_string[0] = 0xB0;\ + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + tm_pointer->TM_string[2] = ACKCODE;\ + for(uint8_t i=3;i<11;i++)\ + {\ + tm_pointer->TM_string[i] = 0;\ + }\ + crc16 = CRC::crc16_gen(tm_ptr->TM_string,11);\ + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);\ + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);\ + return tm_ptr;\ + break;\ + }\ + else if(GETpid(tc_ptr)==0x34)\ + {\ + printf("TC_RST_PL_DL\r\n");\ // call PWR_SWCH_ON function\ + tm_pointer = new Short_tm;\ + tm_pointer->TM_string[0] = 0xB0;\ + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + tm_pointer->TM_string[2] = ACKCODE;\ + for(uint8_t i=3;\i<11;\i++)\ + {\ + tm_pointer->TM_string[i] = 0;\ + }\ + crc16 = CRC::crc16_gen(tm_ptr->TM_string,11);\ + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);\ + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);\ + return tm_ptr;\ + break;\ + break;\ + }\ + else if(GETpid(tc_ptr)==0xC1)\ + {\ + printf("RESET_HK_COUNTER\r\n");\ // call PWR_SWCH_ON function\ + tm_pointer = new Short_tm;\ + tm_pointer->TM_string[0] = 0xB0;\ + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + tm_pointer->TM_string[2] = ACKCODE;\ + for(uint8_t i=3;i<11;i++)\ + {\ + tm_pointer->TM_string[i] = 0;\ + }\ + crc16 = CRC::crc16_gen(tm_ptr->TM_string,11);\ + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);\ + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);\ + return tm_ptr;\ + break;\ + }\ + else\ if(GETpid(tc_ptr)==0xF1)\ + {\ + printf("RD_RTC\r\n");\ //call RD_RTC\ + tm_pointer = new Short_tm;\ + tm_pointer->TM_string[0] = 0xD0;\ + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + tm_pointer->TM_string[2] = 0x01;\ + uint64_t time = FCTN_CDMS_RD_RTC();\ + tm_pointer->TM_string[3] = (uint8_t)((time&0xFF00000000000000)>>56);\ + tm_pointer->TM_string[4] = (uint8_t)((time&0x00FF000000000000)>>48);\ + tm_pointer->TM_string[5] = (uint8_t)((time&0x0000FF0000000000)>>40);\ + tm_pointer->TM_string[6] = (uint8_t)((time&0x000000FF00000000)>>32);\ + tm_pointer->TM_string[7] = (uint8_t)((time&0x00000000FF000000)>>24);\ + tm_pointer->TM_string[8] = (uint8_t)((time&0x0000000000FF0000)>>16);\ + tm_pointer->TM_string[9] = (uint8_t)((time&0x000000000000FF00)>>8);\ + tm_pointer->TM_string[10] = (uint8_t)(time&0x00000000000000FF);\ + crc16 = CRC::crc16_gen(tm_ptr->TM_string,11);\ + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);\ + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);\ + return tm_ptr;\ + }\ + else\ + {\ + printf("INVALID TC\r\n");\ + tm_pointer = new Short_tm;\ + tm_pointer->TM_string[0] = 0xB0;\ + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + tm_pointer->TM_string[2] = 0x01;\ + tm_pointer->TM_string[3] = ACKCODE;\ //ackcode to be decided\ + tm_pointer->TM_string[4] = 0x01;\ + for(uint8_t i=0;i<6;i++)\ + {\ + tm_pointer->TM_string[i+5] = 0;\ + }\ + crc16 = CRC::crc16_gen(tm_ptr->TM_string,11);\ + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);\ + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);\ + return tm_ptr;\ + }\ + }\ + }\ + }\ + }\ + default:\ + {\ + printf("INVALID TC");\ //send invalid TC TM\ + tm_pointer = new Short_tm;\ + tm_pointer->TM_string[0] = 0xB0;\ + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + tm_pointer->TM_string[2] = 0x01;\ + tm_pointer->TM_string[3] = ACKCODE;\ //ackcode to be decided\ + tm_pointer->TM_string[4] = 0x01;\ + for(uint8_t i=0;i<6;i++)\ + {\ + tm_pointer->TM_string[i+5] = 0;\ + }\ + crc16 = CRC::crc16_gen(tm_ptr->TM_string,11);\ + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);\ + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);\ + return tm_ptr;\ + break;\ + }\ + }\ + }\ + 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\ + break;\ + }\ + default: //invalid TC\ + {\ + printf("INVALID TC\r\n");\ + tm_pointer = new Short_tm;\ + tm_pointer->TM_string[0] = 0xB0;\ + tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr);\ + tm_pointer->TM_string[2] = 0x01;\ + tm_pointer->TM_string[3] = ACKCODE;\ //ackcode to be decided\ + tm_pointer->TM_string[4] = 0x01;\ + for(uint8_t i=0;i<6;i++)\ + {\ + tm_pointer->TM_string[i+5] = 0;\ + }\ + crc16 = CRC::crc16_gen(tm_ptr->TM_string,11);\ + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8);\ + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF);\ + return tm_ptr;\ + break;\ + }\ + }\ }\ -// CDMS TEAM CODE END +// CDMS TEAM CODE END\ // EXECUTE OBOSC #define execute_obosc_core(tc_ptr, tm_ptr) {\