![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
things are working
Dependencies: FreescaleIAP mbed-rtos mbed
Fork of CDMS_DEC_2016_jan by
Diff: TMTC.cpp
- Revision:
- 1:ad3b8a8032e2
- Parent:
- 0:bcbd76c86cde
- Child:
- 4:560716ec8414
diff -r bcbd76c86cde -r ad3b8a8032e2 TMTC.cpp --- a/TMTC.cpp Wed Dec 16 09:06:59 2015 +0000 +++ b/TMTC.cpp Thu Jan 21 14:46:28 2016 +0000 @@ -7,6 +7,7 @@ #include "cdms_sd.h" #include "Flash.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 @@ -14,7 +15,7 @@ uint16_t mid1; uint16_t mid2; uint16_t Nbytes; -uint32_t Data; +uint32_t Data[2]; uint16_t nbytes; uint8_t flash_counter = 0; uint16_t crc16; @@ -40,8 +41,8 @@ if(tm_status_4m_slv == 1) { printf("receiving...\r\n"); - FCTN_I2C_READ((char*)tm_pointer->TM_string); - printf("%s", tm_pointer->TM_string); + FCTN_I2C_READ((char*)tm_pointer->TM_string,135); + //printf("%s", tm_pointer->TM_string); received+=1; tm_pointer = tm_pointer->next_TM; break; //only for testing purpose @@ -88,158 +89,97 @@ printf("Telecommand is for CDMS\r\n"); //apid = 10 corresponds to cdms switch(GETservice_type(tc)) { - case 6: + case 0x60: { - printf("service:MMS\r\n"); - switch(GETservice_subtype(tc)) - { - case 1: + printf("service:MMS\r\n"); + switch(GETservice_subtype(tc)) { - printf("sub_service:Read from Memory\r\n"); - if(GETpid(tc) == 2) - { - printf("pid:RD_L_FLASH\r\n"); - mid1 = ((((uint16_t)tc->TC_string[5])<<8)|(uint16_t)(tc->TC_string[6])); - mid2 = ((((uint16_t)tc->TC_string[7])<<8)|(uint16_t)(tc->TC_string[8])); - Nbytes = (((mid2-mid1)*32)/8)+4; - uint8_t data[4*Nbytes]; - for(uint8_t i=0;i<mid2-mid1+1;i++) - { - Data = FCTN_CDMS_RD_FLASH(mid1+i); - data[4*i] = (uint8_t)((Data&0xFF000000)>>24); - data[4*i+1] = (uint8_t)((Data&0xFF000000)>>16); - data[4*i+2] = (uint8_t)((Data&0xFF000000)>>8); - data[4*i+3] = (uint8_t)(Data&0xFF000000); - } - nbytes = Nbytes; - flash_counter = 0; - while(nbytes>=8) - { + case 0x1: + { + printf("sub_service:Read from RAM_Memory\r\n"); + mid=(uint16_t)(tc->TC_string[3]<<4)+(uint16_t)(tc->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); tm_pointer->TM_string[2] = (uint8_t)(flash_counter); - for(uint8_t i=0;i<8;i++) + for(uint8_t i=0;i<4;i++) { - tm_pointer->TM_string[3+i] = data[i+128*flash_counter]; + 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->TM_string,9); - tm_pointer->TM_string[9] = (uint8_t)((crc16&0xFF00)>>8); - tm_pointer->TM_string[10] = (uint8_t)(crc16&0x00FF); - tm_pointer = tm_pointer->next_TM; - nbytes-=128; - flash_counter++; - } - if(nbytes>0) - { + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); + return tm; + } + + case 0x2: + { + printf("sub_service:Read from Flash_Memory\r\n"); + mid=(uint16_t)(tc->TC_string[3]<<4)+(uint16_t)(tc->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); - tm_pointer->TM_string[2] = (uint8_t)((flash_counter&0xFF00)>>8); - tm_pointer->TM_string[3] = (uint8_t)(flash_counter&0x00FF); - for(uint8_t i=0;i<nbytes;i++) + tm_pointer->TM_string[2] = (uint8_t)(flash_counter); + for(uint8_t i=0;i<4;i++) { - tm_pointer->TM_string[4+i] = data[i+128*flash_counter]; + tm_pointer->TM_string[3+i] = (uint8_t)((Data[0]>>(8*i))&0x00FF); } - for(uint8_t i=nbytes;i<128;i++) + for(uint8_t i=4;i<8;i++) { - tm_pointer->TM_string[4+i] = 0; + tm_pointer->TM_string[3+i] = (uint8_t)((Data[1]>>(8*i))&0x00FF); } - crc16 = CRC::crc16_gen(tm->TM_string,132); - tm_pointer->TM_string[132] = (uint8_t)((crc16&0xFF00)>>8); - tm_pointer->TM_string[133] = (uint8_t)(crc16&0x00FF); - } + crc16 = CRC::crc16_gen(tm->TM_string,9); + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); return tm; - } - else if (GETpid(tc)==0x22) + + } + + case 0x5: { - printf("RD_S_FLASH\r\n"); - mid1 = ((((uint16_t)tc->TC_string[5])<<8)|(uint16_t)(tc->TC_string[6])); - mid2 = ((((uint16_t)tc->TC_string[7])<<8)|(uint16_t)(tc->TC_string[8])); - Nbytes = (((mid2-mid1)*32)/8)+4; - uint8_t data[4*Nbytes]; - for(uint8_t i=0;i<mid2-mid1+1;i++) - { - Data = FCTN_CDMS_RD_FLASH(mid1+i); - data[4*i] = (uint8_t)((Data&0xFF000000)>>24); - data[4*i+1] = (uint8_t)((Data&0xFF000000)>>16); - data[4*i+2] = (uint8_t)((Data&0xFF000000)>>8); - data[4*i+3] = (uint8_t)(Data&0xFF000000); - } - nbytes = Nbytes; - flash_counter = 0; - while(nbytes>=8) - { + printf("WRITE ON FLASH_MEMORY\r\n"); + + mid=(uint16_t)(tc->TC_string[3]<<4)+(uint16_t)(tc->TC_string[4]); + + block = (((uint32_t)(tc->TC_string[5])<<24)|((uint32_t)(tc->TC_string[5])<<16)|((uint32_t)(tc->TC_string[5])<<8)|((uint32_t)(tc->TC_string[5]))); + FCTN_CDMS_WR_FLASH(mid,block); tm_pointer = new Short_tm; - tm_pointer->TM_string[0] = 0xC0; + tm_pointer->TM_string[0] = 0xB0; tm_pointer->TM_string[1] = GETpacket_seq_count(tc); - tm_pointer->TM_string[2] = (uint8_t)(flash_counter); - for(uint8_t i=0;i<8;i++) + 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[3+i] = data[i+8*flash_counter]; + tm_pointer->TM_string[i+5] = 0; } crc16 = CRC::crc16_gen(tm->TM_string,11); tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); - tm_pointer = tm_pointer->next_TM; - nbytes-=8; - flash_counter++; - } - if(nbytes>0) - { - tm_pointer->TM_string[0] = 0xC0; - tm_pointer->TM_string[1] = GETpacket_seq_count(tc); - tm_pointer->TM_string[2] = (uint8_t)(flash_counter); - for(uint8_t i=0;i<nbytes;i++) - { - tm_pointer->TM_string[3+i] = data[i+8*flash_counter]; - } - for(uint8_t i=nbytes;i<128;i++) - { - tm_pointer->TM_string[3+i] = 0; - } - crc16 = CRC::crc16_gen(tm->TM_string,11); - tm_pointer->TM_string[132] = (uint8_t)((crc16&0xFF00)>>2); - tm_pointer->TM_string[133] = (uint8_t)(crc16&0x00FF); - } - return tm; + return tm; + break; } - else if (GETpid(tc)==0x42) - { - printf("RD_L_RAM\r\r\n"); //to be discussed which RAM variables are to read; - tm_pointer = new Short_tm; //for now sending ACKL234 - tm_pointer->TM_string[0] = 0xB0; - tm_pointer->TM_string[1] = GETpacket_seq_count(tc); - tm_pointer->TM_string[2] = 0x01; - tm_pointer->TM_string[3] = ACKCODE; - 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->TM_string,11); - tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); - tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); - return tm; - } - else if (GETpid(tc)==0x62) - { - printf("RD_S_RAM\r\r\n"); //to be discussed which RAM variables are to read; - tm_pointer = new Short_tm; //for now sending ACKL234 - tm_pointer->TM_string[0] = 0xB0; - tm_pointer->TM_string[1] = GETpacket_seq_count(tc); - tm_pointer->TM_string[2] = 0x01; - tm_pointer->TM_string[3] = ACKCODE; - 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->TM_string,11); - tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); - tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); - return tm; - } - else + + + default: { printf("INVALID TC\r\n"); //Send Invalid TC Telemetry tm_pointer = new Short_tm; @@ -258,27 +198,28 @@ return tm; } break; - } - case 5: - { - printf("WRITE ON MEMORY\r\n"); - switch(GETpid(tc)) + + } + + + + case 0x8: + { + printf("service:FUNCTION MANAGEMENT SERVICE\r\n"); + if(GETservice_subtype(tc)==0x1) { - case 0: + + if(GETpid(tc)==0x01) { - printf("WR_S_FLASH\r\r\n"); - mid = ((uint16_t)tc->TC_string[4]); - block = (((uint32_t)(tc->TC_string[5])<<24)|((uint32_t)(tc->TC_string[5])<<16)|((uint32_t)(tc->TC_string[5])<<8)|((uint32_t)(tc->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); - 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++) + 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); + tm_pointer->TM_string[2] = ACKCODE; + + for(uint8_t i=3;i<11;i++) { - tm_pointer->TM_string[i+5] = 0; + tm_pointer->TM_string[i] = 0; } crc16 = CRC::crc16_gen(tm->TM_string,11); tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); @@ -286,18 +227,36 @@ return tm; break; } - case 1: + + else if(GETpid(tc)==0x02) { - printf("WR_S_RAM\r\r\n"); //RAM variables to be written is to be decided + 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); - 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[1] = GETpacket_seq_count(tc); + tm_pointer->TM_string[2] = ACKCODE; + + for(uint8_t i=3;i<11;i++) { - tm_pointer->TM_string[i+5] = 0; + tm_pointer->TM_string[i] = 0; + } + crc16 = CRC::crc16_gen(tm->TM_string,11); + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); + return tm; + break; + } + else if(GETpid(tc)==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); + 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->TM_string,11); tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); @@ -305,44 +264,36 @@ return tm; break; } - case 16: + else if(GETpid(tc)==0x04) { - printf("WR_L_FLASH\r\n"); - mid = ((uint16_t)tc->TC_string[4]); - for(uint8_t i=0;i<32;i++) + 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); + tm_pointer->TM_string[2] = ACKCODE; + + for(uint8_t i=3;i<11;i++) { - block = (((uint32_t)(tc->TC_string[5])<<24)|((uint32_t)(tc->TC_string[5])<<16)|((uint32_t)(tc->TC_string[5])<<8)|((uint32_t)(tc->TC_string[5]))); - FCTN_CDMS_WR_FLASH(mid+i,block); - } - tm_pointer = new Short_tm; - tm_pointer->TM_string[0] = 0xB0; - tm_pointer->TM_string[1] = GETpacket_seq_count(tc); - 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; + tm_pointer->TM_string[i] = 0; } crc16 = CRC::crc16_gen(tm->TM_string,11); tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); return tm; break; - break; + } - case 17: + else if(GETpid(tc)==0x11) { - printf("WR_L_RAM\r\r\n"); //RAM variables to be written is to be decided + 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); - 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[1] = GETpacket_seq_count(tc); + tm_pointer->TM_string[2] = ACKCODE; + + for(uint8_t i=3;i<11;i++) { - tm_pointer->TM_string[i+5] = 0; + tm_pointer->TM_string[i] = 0; } crc16 = CRC::crc16_gen(tm->TM_string,11); tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); @@ -350,18 +301,71 @@ return tm; break; } - default: + else if(GETpid(tc)==0x12) { - printf("INVALID TC"); //send invalid TC TM + 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); + 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->TM_string,11); + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); + return tm; + break; + } + else if(GETpid(tc)==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); - 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[1] = GETpacket_seq_count(tc); + tm_pointer->TM_string[2] = ACKCODE; + + for(uint8_t i=3;i<11;i++) { - tm_pointer->TM_string[i+5] = 0; + tm_pointer->TM_string[i] = 0; + } + crc16 = CRC::crc16_gen(tm->TM_string,11); + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); + return tm; + break; + } + else if(GETpid(tc)==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); + 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->TM_string,11); + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); + return tm; + break; + } + else if(GETpid(tc)==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); + 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->TM_string,11); tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); @@ -369,254 +373,108 @@ return tm; break; } - } - break; - } - // case 6: - // { - // printf("WRITE FROM ONE MEMORY TO ANOTHER\r\r\n"); - // switch(appdata[0]) - // { - // case 0: - // { - // printf("WR_S_FLASH\r\r\n"); - // telemetry_type2[0]=0XB0; - // telemetry_type2[1]=tc_pac_seq_cnt_tm; - // telemetry_type2[2]=tm_pac_seq_cnt_tm; - // telemetry_type2[3]=ackcode_tm; - // for(int i=4;i<11;i++) - // { - // telemetry_type2[i]=0X00; - // } - // break; - // } - // case 1: - // { - // printf("WR_S_RAM\r\r\n"); - // telemetry_type2[0]=0XB0; - // telemetry_type2[1]=tc_pac_seq_cnt_tm; - // telemetry_type2[2]=tm_pac_seq_cnt_tm; - // telemetry_type2[3]=ackcode_tm; - // for(int i=4;i<11;i++) - // { - // telemetry_type2[i]=0X00; - // } - // break; - // } - // case 16: - // { - // printf("WR_L_FLASH\r\r\n"); - // telemetry_type2[0]=0XB0; - // telemetry_type2[1]=tc_pac_seq_cnt_tm; - // telemetry_type2[2]=tm_pac_seq_cnt_tm; - // telemetry_type2[3]=ackcode_tm; - // for(int i=4;i<11;i++) - // { - // telemetry_type2[i]=0X00; - // } - // break; - // } - // case 17: - // { - // printf("WR_L_RAM\r\r\n"); - // telemetry_type2[0]=0XB0; - // telemetry_type2[1]=tc_pac_seq_cnt_tm; - // telemetry_type2[2]=tm_pac_seq_cnt_tm; - // telemetry_type2[3]=ackcode_tm; - // for(int i=4;i<11;i++) - // { - // telemetry_type2[i]=0X00; - // } - // break; - // } - // default: - // { - // printf("INVALID TC"); //send invalid TC TM - // break; - // } - // } - // break; - // } - case 9: - { - printf("SEND CRC OF FLASH MEMORY\r\n"); - if(GETpid(tc)==2) - { - printf("GET_FLASH_CRC\r\n"); - mid1 = ((((uint16_t)tc->TC_string[5])<<8)|(uint16_t)(tc->TC_string[6])); - mid2 = ((((uint16_t)tc->TC_string[7])<<8)|(uint16_t)(tc->TC_string[8])); - Nbytes = (((mid2-mid1)*32)/8)+4; - uint8_t data[4*Nbytes]; - uint8_t flash_counter = 0; - tm_pointer = new Long_tm; - tm_pointer->TM_string[0] = 0x80; - tm_pointer->TM_string[1] = 0x00; //spare - tm_pointer->TM_string[2] = GETpacket_seq_count(tc); - tm_pointer->TM_string[3] = (uint8_t)(flash_counter); - for(uint8_t i=0;i<mid2-mid1+1;i++) - { - Data = FCTN_CDMS_RD_FLASH(mid1+i); - data[4*i] = (uint8_t)((Data&0xFF000000)>>24); - data[4*i+1] = (uint8_t)((Data&0xFF000000)>>16); - data[4*i+2] = (uint8_t)((Data&0xFF000000)>>8); - data[4*i+3] = (uint8_t)(Data&0xFF000000); - } - nbytes = Nbytes; - while(nbytes>=32) - { - crc16 = CRC::crc16_gen((data+32*flash_counter),32); - tm_pointer->TM_string[11+2*flash_counter] = (uint8_t)((crc16&0xFF00)>>8); - tm_pointer->TM_string[12+2*flash_counter] = (uint8_t)(crc16&0x00FF); - nbytes-=32; - flash_counter++; - } - if(nbytes>0) - { - crc16 = CRC::crc16_gen((data+32*flash_counter),nbytes); - tm_pointer->TM_string[11+2*flash_counter] = (uint8_t)((crc16&0xFF00)>>8); - tm_pointer->TM_string[12+2*flash_counter] = (uint8_t)(crc16&0x00FF); - } - return tm; - } - else - { - printf("INVALID TC"); //Send Invalid TC Telemetry - tm_pointer = new Short_tm; - tm_pointer->TM_string[0] = 0xB0; - tm_pointer->TM_string[1] = GETpacket_seq_count(tc); - 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++) + else if(GETpid(tc)==0x16) { - tm_pointer->TM_string[i+5] = 0; - } - crc16 = CRC::crc16_gen(tm->TM_string,11); - tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); - tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); - return tm; - } - break; - } - case 8: - { - printf("service:FUNCTION MANAGEMENT SERVICE\r\n"); - if(GETservice_subtype(tc)==1) - { - if((GETpid(tc)&0xF0)==0x00) - { - printf("RUN_PRCS\r\n"); - switch(GETpid(tc)) + 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); + tm_pointer->TM_string[2] = ACKCODE; + + for(uint8_t i=3;i<11;i++) { - case 1: - { - printf("P_PL_INIT\r\n"); //call P_PL_INIT using CDMS_RUN_PRCS - tm_pointer = new Short_tm; - tm_pointer->TM_string[0] = 0xB0; - tm_pointer->TM_string[1] = GETpacket_seq_count(tc); - 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->TM_string,11); - tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); - tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); - return tm; - break; - } - case 2: - { - printf("P_PL_MNGR\r\n"); //call P_PL_MNGR using CDMS_RUN_PRCS - tm_pointer = new Short_tm; - tm_pointer->TM_string[0] = 0xB0; - tm_pointer->TM_string[1] = GETpacket_seq_count(tc); - 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->TM_string,11); - tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); - tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); - return tm; - break; - } - case 3: - { - printf("P_COM_INIT\r\n"); //call P_COM_INIT using CDMS_RUN_PRCS - tm_pointer = new Short_tm; - tm_pointer->TM_string[0] = 0xB0; - tm_pointer->TM_string[1] = GETpacket_seq_count(tc); - 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->TM_string,11); - tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); - tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); - return tm; - break; - } - case 4: - { - printf("P_CDMS_HK_MNGR\r\n"); //call P_CDMS_HK_MNGR using CDMS_RUN_PRCS - tm_pointer = new Short_tm; - tm_pointer->TM_string[0] = 0xB0; - tm_pointer->TM_string[1] = GETpacket_seq_count(tc); - 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->TM_string,11); - tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); - tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); - return tm; - break; - } - default: - { - 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); - 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->TM_string,11); - tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); - tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); - return tm; - break; - } + tm_pointer->TM_string[i] = 0; } + crc16 = CRC::crc16_gen(tm->TM_string,11); + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); + return tm; + break; + } - else if((GETpid(tc)&0xF0)==0x10) + else if(GETpid(tc)==0x21) { - printf("PWR_SWCH_ON\r\n"); // call PWR_SWCH_ON function + 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); + 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->TM_string,11); + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); + return tm; + break; + } + else if(GETpid(tc)==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); - 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[2] = ACKCODE; + + for(uint8_t i=3;i<11;i++) + { + tm_pointer->TM_string[i] = 0; + } + crc16 = CRC::crc16_gen(tm->TM_string,11); + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); + return tm; + break; + } + else if(GETpid(tc)==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); + tm_pointer->TM_string[2] = ACKCODE; + + for(uint8_t i=3;i<11;i++) { - tm_pointer->TM_string[i+5] = 0; + tm_pointer->TM_string[i] = 0; + } + crc16 = CRC::crc16_gen(tm->TM_string,11); + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); + return tm; + break; + } + else if(GETpid(tc)==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); + 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->TM_string,11); + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); + return tm; + break; + } + else if(GETpid(tc)==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); + 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->TM_string,11); tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); @@ -624,18 +482,53 @@ return tm; break; } - else if((GETpid(tc)&0xF0)==0x20) + else if(GETpid(tc)==0x26) { - printf("PWR_SWCH_OFF\r\n"); // call PWR_SWCH_OFF function + 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); + 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->TM_string,11); + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); + return tm; + break; + } + else if(GETpid(tc)==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); - 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[2] = ACKCODE; + + for(uint8_t i=3;i<11;i++) { - tm_pointer->TM_string[i+5] = 0; + tm_pointer->TM_string[i] = 0; + } + crc16 = CRC::crc16_gen(tm->TM_string,11); + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); + return tm; + break; + } + else if(GETpid(tc)==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); + 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->TM_string,11); tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); @@ -643,18 +536,17 @@ return tm; break; } - else if((GETpid(tc)&0xF0)==0x20) + else if(GETpid(tc)==0x33) { - printf("PWR_RST\r\n"); // call PWR_RST function + 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); - 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[2] = ACKCODE; + + for(uint8_t i=3;i<11;i++) { - tm_pointer->TM_string[i+5] = 0; + tm_pointer->TM_string[i] = 0; } crc16 = CRC::crc16_gen(tm->TM_string,11); tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); @@ -662,7 +554,44 @@ return tm; break; } - else if((GETpid(tc)&0xF0)==0xE0) + else if(GETpid(tc)==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); + 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->TM_string,11); + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); + return tm; + break; + + } + else if(GETpid(tc)==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); + 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->TM_string,11); + tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); + tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); + return tm; + break; + } + else if(GETpid(tc)==0xF1) { printf("RD_RTC\r\n"); //call RD_RTC tm_pointer = new Short_tm; @@ -683,22 +612,7 @@ tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); return tm; } - else if((GETpid(tc)&0xF0)==0xF0) - { - printf("SD_MNGR\r\n"); //call SD_MNGR function and send required information in FMS TM - tm_pointer = new Short_tm; // for now sending ACK L_234 - tm_pointer->TM_string[0] = 0xD0; - tm_pointer->TM_string[1] = GETpacket_seq_count(tc); - tm_pointer->TM_string[2] = 0x01; - for(uint8_t i=3;i<11;i++) - { - tm_pointer->TM_string[i] = 0; // for now filling with zeroes instead of SD_MNGR Data - } - crc16 = CRC::crc16_gen(tm->TM_string,11); - tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); - tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); - return tm; - } + else { printf("INVALID TC\r\n"); @@ -718,113 +632,12 @@ return tm; } } - default: - { - 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); - 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->TM_string,11); - tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); - tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); - return tm; - break; - } - break; + } - case 7: - { - printf("service:PAYLOAD MANAGEMENT SERVICE\r\r\n"); //TM is ACKL234 - switch(GETservice_subtype(tc)) - { - case 1: - { - printf("INSERT PL SCHEDULE\r\n"); //should be called PL_MAIN - tm_pointer = new Short_tm; // for now sending dummy ACK L_234 - tm_pointer->TM_string[0] = 0xB0; - tm_pointer->TM_string[1] = GETpacket_seq_count(tc); - 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->TM_string,11); - tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); - tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); - return tm; - break; - } - case 2: - { - printf("DELETE PL SCHEDULE\r\n"); //Should be called PL_MAIN - tm_pointer = new Short_tm; // for now sending dummy ACK L_234 - tm_pointer->TM_string[0] = 0xB0; - tm_pointer->TM_string[1] = GETpacket_seq_count(tc); - 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->TM_string,11); - tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); - tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); - return tm; - break; - } - case 3: - { - printf("REPORT PL SCHEDULE\r\n"); //Data is taken by calling PL_MAIN - tm_pointer = new Long_tm; //for now sending dummy PMS - tm_pointer->TM_string[0] = 0x48; - tm_pointer->TM_string[1] = 0x00; //spare 8 bits - tm_pointer->TM_string[2] = GETpacket_seq_count(tc); - tm_pointer->TM_string[3] = 0x01; - for(uint8_t i=4;i<132;i++) - { - tm_pointer->TM_string[i] = 0; // for now filling with zeros instead of PL_SCHEDULE - } - crc16 = CRC::crc16_gen(tm->TM_string,11); - tm_pointer->TM_string[132] = (uint8_t)((crc16&0xFF00)>>8); - tm_pointer->TM_string[133] = (uint8_t)(crc16&0x00FF); - return tm; - break; - } - 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); - 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->TM_string,11); - tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); - tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); - return tm; - break; - } - } - break; - } - } - break; - } + + + + default: { printf("INVALID TC"); //send invalid TC TM @@ -866,6 +679,7 @@ // } // similar to BAE functions break; } + default: //invalid TC { printf("INVALID TC\r\n"); @@ -884,6 +698,9 @@ tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); return tm; break; - } - } + } + + +} +} } \ No newline at end of file