![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
vr1.1
Dependencies: FreescaleIAP mbed-rtos mbed
Fork of CDMS_RTOS_v1_1 by
Diff: TC.cpp
- Revision:
- 1:f926f14a52d8
- Parent:
- 0:d6e3d1e21484
- Child:
- 2:4c79b3dfef31
diff -r d6e3d1e21484 -r f926f14a52d8 TC.cpp --- a/TC.cpp Mon Jun 15 12:16:59 2015 +0000 +++ b/TC.cpp Mon Jun 15 13:03:26 2015 +0000 @@ -2,12 +2,13 @@ #include "TC.h" #include "SDCard.h" #include "func_head.h" +#include "i2c.h" Serial sc(USBTX,USBRX); void FUNC_CDMS_RLY_TC() { - sc.printf("in FUNC_CDMS_RLY_TC\n"); + sc.printf("in FUNC_CDMS_RLY_TC\r\n"); uint8_t read; sc.scanf("%d",&read); //Packet sequence count pac_seq_cnt = read; @@ -19,7 +20,7 @@ { case 1: //apid=01 implies it corresponds to bae { - sc.printf("BAE\r\r\n"); + sc.printf("BAE\r\r\r\n"); uint8_t p_i2c_bae[long_or_short*124+11]; p_i2c_bae[0]=pac_seq_cnt; p_i2c_bae[1]=apid_size; @@ -29,13 +30,19 @@ sc.scanf("%d",&read); p_i2c_bae[i] = read; } - sc.printf("inform BAE about TC using I2C\r\n"); //interrupt to be sent to the bae - sc.printf("send the packet + CRC to the BAE after receving i2c signal from BAE\r\n"); //packet along with crc will be sent when bae is ready + sc.printf("informing BAE about TC using I2C\r\r\n"); //interrupt to be sent to the bae + if(long_or_short==0) + FCTN_MASTER_I2C('s', (char *)p_i2c_bae); + else if(long_or_short==1) + FCTN_MASTER_I2C('l', (char *)p_i2c_bae); + else + sc.printf("long_or_short invalid\r\r\n"); + sc.printf("send the packet + CRC to the BAE after receving i2c signal from BAE\r\r\n"); //packet along with crc will be sent when bae is ready break; } case 3: { - sc.printf("SPEED\r\n"); //speed corresponds to apid = 11 + sc.printf("SPEED\r\r\n"); //speed corresponds to apid = 11 uint8_t p_i2c_speed[long_or_short*124+11]; p_i2c_speed[0]=pac_seq_cnt; p_i2c_speed[1]=apid_size; @@ -45,13 +52,13 @@ sc.scanf("%d",&read); p_i2c_speed[i] = read; } - sc.printf("inform PL about TC using I2C\r\n"); - sc.printf("send the packet + CRC to the PL after receving i2c signal from PL\r\n"); + sc.printf("inform PL about TC using I2C\r\r\n"); + sc.printf("send the packet + CRC to the PL after receving i2c signal from PL\r\r\n"); break; } case 2: { - sc.printf("CDMS\r\n"); //apid = 10 corresponds to cdms + sc.printf("CDMS\r\r\n"); //apid = 10 corresponds to cdms uint8_t services,appdata[long_or_short*124+6],crc[2]; sc.scanf("%d",&read); services = read; //services contains service_type and sub_service_type @@ -68,13 +75,13 @@ switch(service_type){ case 6: { - sc.printf("memory management syservice_typeem\r\n"); + sc.printf("memory management syservice_typeem\r\r\n"); switch(sub_service_type){ case 1: { - sc.printf("READ FROM MEMORY\r\n"); + sc.printf("READ FROM MEMORY\r\r\n"); if(appdata[0]==2){ //appdata[0] is pid - sc.printf("RD_L_FLASH1\r\n"); //tm is lmb + sc.printf("RD_L_FLASH1\r\r\n"); //tm is lmb //P_CDMS_RD_FLASH for(int i=0;i<128;i++){ @@ -85,7 +92,7 @@ } } else if ((appdata[0]&0xF0)==0x10){ - sc.printf("RD_L_FLASH2\r\n"); //tm is lmb + sc.printf("RD_L_FLASH2\r\r\n"); //tm is lmb //P_CDMS_RD_FLASH for(int i=0;i<128;i++){ @@ -96,7 +103,7 @@ } } else if (appdata[0]==0x22){ - sc.printf("RD_S_FLASH1\r\n"); //tm is smb + sc.printf("RD_S_FLASH1\r\r\n"); //tm is smb //P_CDMS_RD_FLASH telemetry_type2[0]=tmid3_spr_tm; @@ -110,7 +117,7 @@ } } else if ((appdata[0]&0xF0)==0x30){ - sc.printf("RD_S_FLASH2\r\n"); //tm is smb + sc.printf("RD_S_FLASH2\r\r\n"); //tm is smb //P_CDMS_RD_FLASH telemetry_type2[0]=tmid3_spr_tm; @@ -124,7 +131,7 @@ } } else if (appdata[0]==0x42){ - sc.printf("RD_L_RAM1\r\n"); //tm is lmb + sc.printf("RD_L_RAM1\r\r\n"); //tm is lmb //P_CDMS_RD_RAM for(int i=0;i<128;i++){ @@ -135,7 +142,7 @@ } } else if ((appdata[0]&0xF0)==0x50){ - sc.printf("RD_L_RAM2\r\n"); //tm is lmb + sc.printf("RD_L_RAM2\r\r\n"); //tm is lmb //P_CDMS_RD_RAM for(int i=0;i<128;i++){ @@ -146,7 +153,7 @@ } } else if (appdata[0]==0x62){ - sc.printf("RD_S_RAM\r\n"); //tm is smb + sc.printf("RD_S_RAM\r\r\n"); //tm is smb //P_CDMS_RD_RAM telemetry_type2[0]=tmid3_spr_tm; @@ -160,7 +167,7 @@ } } else if ((appdata[0]&0xF0)==0x70){ - sc.printf("RD_S_RAM2\r\n"); //tm is smb + sc.printf("RD_S_RAM2\r\r\n"); //tm is smb //P_CDMS_RD_RAM telemetry_type2[0]=tmid3_spr_tm; @@ -181,9 +188,9 @@ } case 5: { - sc.printf("WRITE ON MEMORY\r\n"); + sc.printf("WRITE ON MEMORY\r\r\n"); switch(appdata[0]){ - case 0:sc.printf("WR_S_FLASH\r\n"); + case 0:sc.printf("WR_S_FLASH\r\r\n"); //P_CDMS_WR_FLASH telemetry_type2[0]=0XB0; telemetry_type2[1]=tc_pac_seq_cnt_tm; @@ -194,7 +201,7 @@ } break; - case 1:sc.printf("WR_S_RAM\r\n"); + case 1:sc.printf("WR_S_RAM\r\r\n"); //P_CDMS_WR_RAM telemetry_type2[0]=0XB0; telemetry_type2[1]=tc_pac_seq_cnt_tm; @@ -205,7 +212,7 @@ } break; - case 16:sc.printf("WR_L_FLASH\r\n"); + case 16:sc.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; @@ -216,7 +223,7 @@ //P_CDMS_WR_FLASH break; - case 17:sc.printf("WR_L_RAM\r\n"); + case 17:sc.printf("WR_L_RAM\r\r\n"); //P_CDMS_WR_RAM telemetry_type2[0]=0XB0; telemetry_type2[1]=tc_pac_seq_cnt_tm; @@ -235,9 +242,9 @@ } case 6: { - sc.printf("WRITE FROM ONE MEMORY TO ANOTHER\r\n"); + sc.printf("WRITE FROM ONE MEMORY TO ANOTHER\r\r\n"); switch(appdata[0]){ - case 0:sc.printf("WR_S_FLASH\r\n"); + case 0:sc.printf("WR_S_FLASH\r\r\n"); //P_CDMS_WR_FLASH telemetry_type2[0]=0XB0; telemetry_type2[1]=tc_pac_seq_cnt_tm; @@ -247,7 +254,7 @@ telemetry_type2[i]=0X00; } break; - case 1:sc.printf("WR_S_RAM\r\n"); + case 1:sc.printf("WR_S_RAM\r\r\n"); //P_CDMS_WR_RAM telemetry_type2[0]=0XB0; telemetry_type2[1]=tc_pac_seq_cnt_tm; @@ -257,7 +264,7 @@ telemetry_type2[i]=0X00; } break; - case 16:sc.printf("WR_L_FLASH\r\n"); + case 16:sc.printf("WR_L_FLASH\r\r\n"); //P_CDMS_WR_FLASH telemetry_type2[0]=0XB0; telemetry_type2[1]=tc_pac_seq_cnt_tm; @@ -267,7 +274,7 @@ telemetry_type2[i]=0X00; } break; - case 17:sc.printf("WR_L_RAM\r\n"); + case 17:sc.printf("WR_L_RAM\r\r\n"); //P_CDMS_WR_RAM telemetry_type2[0]=0XB0; telemetry_type2[1]=tc_pac_seq_cnt_tm; @@ -285,9 +292,9 @@ } case 9: { - sc.printf("SEND CRC OF FLASH MEMORY\r\n"); + sc.printf("SEND CRC OF FLASH MEMORY\r\r\n"); if(appdata[0]==2){ - sc.printf("GET_FLASH_CRC\r\n"); //tm is crc_flash + sc.printf("GET_FLASH_CRC\r\r\n"); //tm is crc_flash //P_CDMS_GET_FLASH_CRC for(int i=0;i<2;i++){ @@ -314,12 +321,12 @@ } case 8: { - sc.printf("FUNCTION MANAGEMENT SERVICE\r\n"); + sc.printf("FUNCTION MANAGEMENT SERVICE\r\r\n"); if(sub_service_type==1){ if((appdata[0]&0xF0)==0x00){ - sc.printf("RUN_PRCS\r\n"); + sc.printf("RUN_PRCS\r\r\n"); switch(appdata[0]){ - case 1:sc.printf("P_PL_INIT\r\n");//tm is ack_l234 + case 1:sc.printf("P_PL_INIT\r\r\n");//tm is ack_l234 //P_PL_INIT telemetry_type2[0]=tmid2_spr_tm; telemetry_type2[1]=tc_pac_seq_cnt_tm; @@ -332,7 +339,7 @@ telemetry_type2[i]=crc_tm[i-11]; } break; - case 2:sc.printf("P_PL_MNGR\r\n");//tm is ack_l234 + case 2:sc.printf("P_PL_MNGR\r\r\n");//tm is ack_l234 //P_PL_MNGR telemetry_type2[0]=tmid2_spr_tm; telemetry_type2[1]=tc_pac_seq_cnt_tm; @@ -345,7 +352,7 @@ telemetry_type2[i]=crc_tm[i-11]; } break; - case 3:sc.printf("P_COM_INIT\r\n");//tm is ack_l234 + case 3:sc.printf("P_COM_INIT\r\r\n");//tm is ack_l234 //P_COM_INIT telemetry_type2[0]=tmid2_spr_tm; telemetry_type2[1]=tc_pac_seq_cnt_tm; @@ -358,7 +365,7 @@ telemetry_type2[i]=crc_tm[i-11]; } break; - case 4:sc.printf("P_CDMS_HK_MNGR\r\n");//tm is ack_l234 + case 4:sc.printf("P_CDMS_HK_MNGR\r\r\n");//tm is ack_l234 //P_CDMS_HK_MNGR telemetry_type2[0]=tmid2_spr_tm; telemetry_type2[1]=tc_pac_seq_cnt_tm; @@ -377,17 +384,17 @@ } } else if((appdata[0]&0xF0)==0x10){ - sc.printf("PWR_SWCH\r\n"); + sc.printf("PWR_SWCH\r\r\n"); //P_CDMS_SWCH_PWR } else if((appdata[0]&0xF0)==0x20){ - sc.printf("PWR_Rservice_type\r\n"); + sc.printf("PWR_Rservice_type\r\r\n"); //P_CDMS_RST_PWR } else if((appdata[0]&0xF0)==0xE0){ - sc.printf("RD_RTC\n"); //tm is func_mngmt_service_tm + sc.printf("RD_RTC\r\n"); //tm is func_mngmt_service_tm uint8_t *data; data = FUNC_CDMS_RD_RTC(); telemetry_type2[0]=tmid4_spr_tm; @@ -397,26 +404,31 @@ { telemetry_type2[i]=data[i-3]; } - for(int i=0;i<11;i++) + for(int i=0;i<13;i++) { - sc.printf("%d\r\n",telemetry_type2[i]); + sc.printf("%d\r\r\n",telemetry_type2[i]); } for(int i=11;i<13;i++){ telemetry_type2[i]=crc_tm[i-11]; } for(int i=0;i<13;i++) { sd_data[i]=telemetry_type2[i];} + initialise_card(); + int result= initialise_card(); + printf("initialise card result=%d\r\n",result); + disk_initialize(); for(int i=13;i<512;i++) - { sd_data[i]=' ';} - disk_write(sd_data, TM_SD_BLOCK_NUMBER); - disk_read(sd_read_data,TM_SD_BLOCK_NUMBER); - sc.printf("data read from sd card\r\n"); - sc.printf("%s\r\n",sd_read_data); + { sd_data[i]='f';} + disk_write(sd_data, 1); + disk_read(sd_read_data,1); + sc.printf("data read from sd card\r\r\n"); + for(int i=0;i<512;i++) + sc.printf("%d",sd_read_data[i]); TM_SD_BLOCK_NUMBER++; } else if((appdata[0]&0xF0)==0xF0){ - sc.printf("SD_MNGR\r\n"); //tm is func_mngmt_service_tm + sc.printf("SD_MNGR\r\r\n"); //tm is func_mngmt_service_tm //P_CDMS_MNG_SD telemetry_type2[0]=tmid4_spr_tm; @@ -442,9 +454,9 @@ } case 7: { - sc.printf("PAYLOAD MANAGEMENT SERVICE\r\n"); //TM is ACKL234 + sc.printf("PAYLOAD MANAGEMENT SERVICE\r\r\n"); //TM is ACKL234 switch(sub_service_type){ - case 1:sc.printf("INSERT PL SCHEDULE\r\n"); + case 1:sc.printf("INSERT PL SCHEDULE\r\r\n"); telemetry_type2[0]=tmid2_spr_tm; telemetry_type2[1]=tc_pac_seq_cnt_tm; telemetry_type2[2]=tm_pac_seq_cnt_tm; @@ -456,7 +468,7 @@ telemetry_type2[i]=crc_tm[i-11]; } break; - case 2:sc.printf("DELETE PL SCHEDULE\r\n"); + case 2:sc.printf("DELETE PL SCHEDULE\r\r\n"); telemetry_type2[0]=tmid2_spr_tm; telemetry_type2[1]=tc_pac_seq_cnt_tm; telemetry_type2[2]=tm_pac_seq_cnt_tm; @@ -476,11 +488,11 @@ } case 11: { - sc.printf("ONBOARD OPERATIONS SCHEDULING SERVICE\r\n"); + sc.printf("ONBOARD OPERATIONS SCHEDULING SERVICE\r\r\n"); switch(sub_service_type){ case 1: { - sc.printf("DISABLE RELEASE OF TCs\r\n"); //tm is ack_l1 + sc.printf("DISABLE RELEASE OF TCs\r\r\n"); //tm is ack_l1 telemetry_type2[0]=tmid1_spr_tm; telemetry_type2[1]=tc_exec_tm; telemetry_type2[2]=tc_service_typeatus_tm; @@ -494,17 +506,17 @@ } case 2: { - sc.printf("ENABLE RELEASE OF TCs\r\n"); + sc.printf("ENABLE RELEASE OF TCs\r\r\n"); break; } case 5: { - sc.printf("DELETE TELECOMMANDS\r\n"); + sc.printf("DELETE TELECOMMANDS\r\r\n"); break; } case 6: { - sc.printf("REPORT TC LIST IN DETAILED FORM\r\n"); //tm is tc_liservice_type + sc.printf("REPORT TC LIST IN DETAILED FORM\r\r\n"); //tm is tc_liservice_type for(int i=0;i<9;i++){ telemetry_type1[i]=tc_liservice_type_packet1_tm[i]; } @@ -518,7 +530,7 @@ } case 8: { - sc.printf("REPORT STATUS OF TC LIST\r\n"); //tm is ack_l1 + sc.printf("REPORT STATUS OF TC LIST\r\r\n"); //tm is ack_l1 telemetry_type2[0]=tmid1_spr_tm; telemetry_type2[1]=tc_exec_tm; telemetry_type2[2]=tc_service_typeatus_tm; @@ -532,7 +544,7 @@ } case 15: { - sc.printf("REPORT STATUS OF LAST UNEXECUTED TC\r\n"); //tm is ack_l234 + sc.printf("REPORT STATUS OF LAST UNEXECUTED TC\r\r\n"); //tm is ack_l234 telemetry_type2[0]=tmid2_spr_tm; telemetry_type2[1]=tc_pac_seq_cnt_tm; telemetry_type2[2]=tm_pac_seq_cnt_tm; @@ -553,7 +565,7 @@ } case 13: { - sc.printf("LARGE DATA TRANSFER\r\n"); //tm is ack_l234 + sc.printf("LARGE DATA TRANSFER\r\r\n"); //tm is ack_l234 telemetry_type2[0]=tmid2_spr_tm; telemetry_type2[1]=tc_pac_seq_cnt_tm; telemetry_type2[2]=tm_pac_seq_cnt_tm; @@ -568,11 +580,11 @@ } case 15: { - sc.printf("ONBOARD STORAGE AND RETRIEVAL SERVICE\r\n"); + sc.printf("ONBOARD STORAGE AND RETRIEVAL SERVICE\r\r\n"); switch(sub_service_type){ case 0: { - sc.printf("SCF\r\n"); //tm is obsrs + sc.printf("SCF\r\r\n"); //tm is obsrs telemetry_type1[0]=frmseqcnt_fileheadpointer_tm; for(int i=1;i<128;i++){ telemetry_type1[i]=multi_obsrs_tm_packets[i-1]; @@ -584,7 +596,7 @@ } case 1: { - sc.printf("SFF-AT\r\n"); + sc.printf("SFF-AT\r\r\n"); telemetry_type1[0]=frmseqcnt_fileheadpointer_tm; //tm is obsrs for(int i=1;i<128;i++){ telemetry_type1[i]=multi_obsrs_tm_packets[i-1]; @@ -596,7 +608,7 @@ } case 2: { - sc.printf("SFF-BT\r\n"); //tm is obsrs + sc.printf("SFF-BT\r\r\n"); //tm is obsrs telemetry_type1[0]=frmseqcnt_fileheadpointer_tm; for(int i=1;i<128;i++){ telemetry_type1[i]=multi_obsrs_tm_packets[i-1]; @@ -608,7 +620,7 @@ } case 3: { - sc.printf("LOG\r\n"); //tm is obsrs + sc.printf("LOG\r\r\n"); //tm is obsrs telemetry_type1[0]=frmseqcnt_fileheadpointer_tm; for(int i=1;i<128;i++){ telemetry_type1[i]=multi_obsrs_tm_packets[i-1]; @@ -620,7 +632,7 @@ } case 4: { - sc.printf("HK_ARCHIVE\r\n"); //tm is obsrs + sc.printf("HK_ARCHIVE\r\r\n"); //tm is obsrs telemetry_type1[0]=frmseqcnt_fileheadpointer_tm; for(int i=1;i<128;i++){ telemetry_type1[i]=multi_obsrs_tm_packets[i-1];