ACS data acq changed completely. Tested and working. Deals all faults.
Dependencies: FreescaleIAP mbed-rtos mbed
Fork of QM_BAE_review_1 by
Diff: TCTM.cpp
- Revision:
- 3:07e15677a75c
- Parent:
- 0:7b4c00e3912f
- Child:
- 4:39a4ae8c7ecd
diff -r c823d84b4cb0 -r 07e15677a75c TCTM.cpp --- a/TCTM.cpp Fri Dec 25 15:25:44 2015 +0000 +++ b/TCTM.cpp Tue Dec 29 05:14:39 2015 +0000 @@ -1,432 +1,591 @@ #include "mbed.h" #include "TCTM.h" - -uint8_t telemetry_type2[13]; -uint8_t telemetry_type1[130]; //two types of telemetry possible -uint8_t long_memory_block_tm[128],crc_tm[2]; // tmlmb -uint8_t frmseqcnt_fileheadpointer_tm,multi_obsrs_tm_packets[127]; // tm obsrs -uint8_t tc_liservice_type_packet1_tm[9],tc_liservice_type_packet2_tm[9]; // tm tc_liservice_type -uint8_t crc1_tm[2],crc2_tm[2]; // tm flash_crc -uint8_t tmid1_spr_tm=0xA0,tc_exec_tm,tc_service_typeatus_tm,pac_seq_cnt_of_tc_tm[8]; // tm ack_l1 -uint8_t tmid2_spr_tm=0xB0,tc_pac_seq_cnt_tm,tm_pac_seq_cnt_tm,ackcode_tm; // tm ack_l234 -uint8_t tmid3_spr_tm=0xC0,small_memory_block_tm[7]; // tm smb -uint8_t tmid4_spr_tm=0xD0,func_mngmt_service_tm[8]; // tm func_mngmt_service_tm -uint8_t apid_size,pac_seq_cnt,apid,long_or_short=1,service_type,sub_service_type; //All variable used TC -uint8_t sd_data[512],sd_read_data[512]; -int TM_SD_BLOCK_NUMBER = 1;uint8_t rtc_tc_data[8]; +#include "crc.h" -void FCTN_TC_DECODE(uint8_t* TC_Packet) - -{ - // uint8_t long_or_short; - // uint8_t TC_Packet[long_or_short*124+11]; - uint8_t service_type,sub_service_type,ackcode_tm,func_mngmt_service_tm[8],crc_tm[2];; - service_type=(TC_Packet[2]&0xF0)>>4; - sub_service_type=(TC_Packet[2]&0x0F); - switch(service_type){ - case 6:printf("memory management service\n"); - switch(sub_service_type){ - case 1:printf("READ FROM MEMORY\n"); - if(TC_Packet[3]==2){ //TC_Packet[3] is pid - printf("RD_L_FyoyouyLASH1\n"); - //P_BAE_RD_FLASH - - uint8_t long_memory_block_tm[128]; - uint8_t TM_packet[130]; - for(int i=0;i<128;i++){ - TM_packet[i]=long_memory_block_tm[i-1]; - } - for(int i=128;i<130;i++){ - //FCTN_CRC(long_memory_block_tm) - TM_packet[i]=crc_tm[i-128]; - } - } - else if ((TC_Packet[3]&0xF0)==0x10){ - printf("RD_L_FLASH2\n"); - //P_BAE_RD_FLASH - - uint8_t long_memory_block_tm[128]; - uint8_t TM_packet[130]; - for(int i=0;i<128;i++){ - TM_packet[i]=long_memory_block_tm[i-1]; - } - for(int i=128;i<130;i++){ - TM_packet[i]=crc_tm[i-128]; - } - } - else if (TC_Packet[3]==0x22){ - printf("RD_S_FLASH1\n"); - //P_BAE_RD_FLASH - - uint8_t tmid_spr_tm=0xC0,tc_psc_tm,tm_psc_tm,small_memory_block_tm[8]; - uint8_t TM_packet[13]; - TM_packet[0]=tmid_spr_tm; - TM_packet[1]=tc_psc_tm; - TM_packet[2]=tm_psc_tm; - TM_packet[3]=ackcode_tm; - for(int i=3;i<11;i++){ - TM_packet[i]=small_memory_block_tm[i-3]; - } - for(int i=11;i<13;i++){ - TM_packet[i]=crc_tm[i-11]; - } - } - else if ((TC_Packet[3]&0xF0)==0x30){ - printf("RD_S_FLASH2\n"); - //P_BAE_RD_FLASH - - uint8_t tmid_spr_tm=0xC0,tc_psc_tm,tm_psc_tm,small_memory_block_tm[8]; - uint8_t TM_packet[13]; - TM_packet[0]=tmid_spr_tm; - TM_packet[1]=tc_psc_tm; - TM_packet[2]=tm_psc_tm; - TM_packet[3]=ackcode_tm; - for(int i=3;i<11;i++){ - TM_packet[i]=small_memory_block_tm[i-3]; - } - for(int i=11;i<13;i++){ - TM_packet[i]=crc_tm[i-11]; - } - } - else if (TC_Packet[3]==0x42){ - printf("RD_L_RAM1\n"); - //P_BAE_RD_RAM - - uint8_t long_memory_block_tm[128]; - uint8_t TM_packet[130]; - for(int i=0;i<128;i++){ - TM_packet[i]=long_memory_block_tm[i-1]; - } - for(int i=128;i<130;i++){ - TM_packet[i]=crc_tm[i-128]; - } - } - else if ((TC_Packet[3]&0xF0)==0x50){ - printf("RD_L_RAM2\n"); - ////P_BAE_RD_RAM - uint8_t long_memory_block_tm[128]; - uint8_t TM_packet[130]; - for(int i=0;i<128;i++){ - TM_packet[i]=long_memory_block_tm[i-1]; - } - for(int i=128;i<130;i++){ - TM_packet[i]=crc_tm[i-128]; - } - } - else if (TC_Packet[3]==0x62){ - printf("RD_S_RAM\n"); - //P_BAE_RD_RAM - - uint8_t tmid_spr_tm=0xC0,tc_psc_tm,tm_psc_tm,small_memory_block_tm[8]; - uint8_t TM_packet[13]; - TM_packet[0]=tmid_spr_tm; - TM_packet[1]=tc_psc_tm; - TM_packet[2]=tm_psc_tm; - TM_packet[3]=ackcode_tm; - for(int i=3;i<11;i++){ - TM_packet[i]=small_memory_block_tm[i-3]; - } - for(int i=11;i<13;i++){ - TM_packet[i]=crc_tm[i-11]; - } - } - else if ((TC_Packet[3]&0xF0)==0x70){ - printf("RD_S_RAM2\n"); - //P_BAE_RD_RAM - - uint8_t tmid_spr_tm=0xC0,tc_psc_tm,tm_psc_tm,small_memory_block_tm[8]; - uint8_t TM_packet[13]; - TM_packet[0]=tmid_spr_tm; - TM_packet[1]=tc_psc_tm; - TM_packet[2]=tm_psc_tm; - TM_packet[3]=ackcode_tm; - for(int i=3;i<11;i++){ - TM_packet[i]=small_memory_block_tm[i-3]; - } - for(int i=11;i<13;i++){ - TM_packet[i]=crc_tm[i-11]; - } - } - else { - printf("INVALID TC"); - //Send Invalid TC Telemetry - } - break; - case 5:printf("WRITE ON MEMORY\n"); - switch(TC_Packet[3]){ - case 0:printf("WR_S_FLASH\n"); - //P_BAE_WR_FLASH - 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\n"); - //P_BAE_WR_RAM - 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\n"); - //P_BAE_WR_FLASH - 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\n"); - //P_BAE_WR_RAM - 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; - } - break; - case 6:printf("WRITE FROM ONE MEMORY TO ANOTHER\n"); - switch(TC_Packet[3]){ - case 0:printf("WR_S_FLASH\n"); - //P_BAE_WR_FLASH - 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; - } +uint8_t* FCTN_BAE_TM_TC (uint8_t* tc) - break; - case 1:printf("WR_S_RAM\n"); - //P_BAE_WR_RAM - 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\n"); - //P_BAE_WR_FLASH - 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\n"); - //P_BAE_WR_RAM - 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; - } - break; - case 9:printf("SEND CRC OF FLASH MEMORY\n"); - if(TC_Packet[3]==2){ - printf("GET_FLASH_CRC\n"); - //P_BAE_GET_FLASH_CRC - - uint8_t crc1_tm[2],crc2_tm[2]; - uint8_t TM_packet[130]; - for(int i=0;i<2;i++){ - TM_packet[i]=crc1_tm[i]; - } - for(int i=2;i<4;i++){ - TM_packet[i]=crc2_tm[i-2]; - } - for(int i=128;i<130;i++){ - TM_packet[i]=crc_tm[i-128]; - } - } - else { - printf("INVALID TC"); - //Send Invalid TC Telemetry +{ + uint8_t service_type=(tc[2]&0xF0); + uint8_t* tm; + uint16_t crc16; + + + switch(service_type) + { + case 0x60: + { + printf("Memory Management Service\r\n"); + uint8_t service_subtype=(tc[2]&0x0F); + + switch(service_subtype) + { + case 0x01: + { + printf("Read from Flash\r\n"); + } + case 0x02: + { + printf("Read from RAM\r\n"); + } + case 0x05: + { + printf("Write on Flash\r\n"); + } + default: + { + printf("Invalid TC"); + //ACK_L234_TM + tm[0]=0xB0; + tm[1]=tc[0]; + tm[2]=ACK_CODE; + for(uint8_t i=3;i<11;i++) + { + tm[i]=0x00; } - break; - default:{printf("INVALID TC"); - //send invalid TC TM - break;} - } - break; - case 8:printf("FUNCTION MANAGEMENT SERVICE\n"); - if(sub_service_type==1){ - if((TC_Packet[3]&0xF0)==0x00){ - printf("RUN_PRCS\n"); - switch(TC_Packet[3]){ - case 1:printf("P_EPS_INIT\n"); - //FCTN_EPS_INIT - 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 2:printf("P_EPS_MAIN\n"); - //FCTN_EPS_MAIN - 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 3:printf("P_ACS_INIT\n"); - //FCTN_ACS_INIT - 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 4:printf("P_ACS_ACQ_DATA\n"); - //P_ACS_ACQ_DATA - 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 5:printf("P_ACS_MAIN\n"); - //P_ACS_MAIN - 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 6:printf("P_BCN_INIT\n"); - //FCTN_BCN_INIT - 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 7:printf("P_BCN_MAIN\n"); - //FCTN_BCN_MAIN - 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;} - } - } - else if((TC_Packet[3]&0xF0)==0x10){ - printf("PWR_SWCH\n"); - //P_BAE_SWCH_PWR - - } - else if((TC_Packet[3]&0xF0)==0x20){ - printf("PWR_Rservice_type\n"); - //P_BAE_RST_PWR - - } - else if((TC_Packet[3]&0xF0)==0xE0){ - printf("COMSN_ACS_ALGO\n"); - //P_BAE_COMSN_ACS_ALGO - - uint8_t tmid_spr_tm=0xD0,tc_psc_tm,tm_psc_tm,ackcode_tm; - uint8_t TM_packet[13]; - TM_packet[0]=tmid_spr_tm; - TM_packet[1]=tc_psc_tm; - TM_packet[2]=tm_psc_tm; - TM_packet[3]=ackcode_tm; - for(int i=3;i<11;i++){ - TM_packet[i]=func_mngmt_service_tm[i-3]; - } - for(int i=11;i<13;i++){ - TM_packet[i]=crc_tm[i-11]; - } - } - else if((TC_Packet[3]&0xF0)==0xF0){ - printf("COMSN_ACS_HW\n"); - //P_BAE_COMSN_ACS_HW - - uint8_t tmid_spr_tm=0xD0,tc_psc_tm,tm_psc_tm,ackcode_tm; - uint8_t TM_packet[13]; - TM_packet[0]=tmid_spr_tm; - TM_packet[1]=tc_psc_tm; - TM_packet[2]=tm_psc_tm; - TM_packet[3]=ackcode_tm; - for(int i=3;i<11;i++){ - TM_packet[i]=func_mngmt_service_tm[i-3]; - } - for(int i=11;i<13;i++){ - TM_packet[i]=crc_tm[i-11]; - } - } - else { - printf("INVALID TC"); - //Send Invalid TC Telemetry + crc16 = CRC::crc16_gen(tm,11); + tm[11] = (uint8_t)((crc16&0xFF00)>>8); + tm[12] = (uint8_t)(crc16&0x00FF); + for(uint8_t i=13;i<134;i++) + { + tm[i]=0x00; } - } - else { - printf("INVALID TC"); - //Send Invalid TC Telemetry - } - break; - default:{printf("INVALID TC"); - //send invalid TC TM - break;} - } - + return tm; + } + } } -/************************************************************************************************************************************/ -//FUNCTIONS EXECUTED BY TELECOMMAND -//MEMORY MANAGEMENT SERVICE -//PID 0X02 - - + case 0x80: + { + printf("Function Management Service\r\n"); + uint8_t service_subtype=(tc[2]&0x0F); + + switch(service_subtype) + { + case 0x01: + { + printf("FMS Activated\r\n"); + + uint8_t pid=tc[3]; + switch(pid) + { + case 0x01: + { + printf("Run P_EPS_INIT\r\n"); + //ACK_L234_TM + tm[0]=0xB0; + tm[1]=tc[0]; + tm[2]=ACK_CODE; + for(uint8_t i=3;i<11;i++) + { + tm[i]=0x00; + } + crc16 = CRC::crc16_gen(tm,11); + tm[11] = (uint8_t)((crc16&0xFF00)>>8); + tm[12] = (uint8_t)(crc16&0x00FF); + for(uint8_t i=13;i<134;i++) + { + tm[i]=0x00; + } + return tm; + + } + case 0x02: + { + printf("Run P_EPS_MAIN\r\n"); + //ACK_L234_TM + tm[0]=0xB0; + tm[1]=tc[0]; + tm[2]=ACK_CODE; + for(uint8_t i=3;i<11;i++) + { + tm[i]=0x00; + } + crc16 = CRC::crc16_gen(tm,11); + tm[11] = (uint8_t)((crc16&0xFF00)>>8); + tm[12] = (uint8_t)(crc16&0x00FF); + for(uint8_t i=13;i<134;i++) + { + tm[i]=0x00; + } + return tm; + } + case 0x03: + { + printf("Run P_ACS_INIT\r\n"); + //ACK_L234_TM + tm[0]=0xB0; + tm[1]=tc[0]; + tm[2]=ACK_CODE; + for(uint8_t i=3;i<11;i++) + { + tm[i]=0x00; + } + crc16 = CRC::crc16_gen(tm,11); + tm[11] = (uint8_t)((crc16&0xFF00)>>8); + tm[12] = (uint8_t)(crc16&0x00FF); + for(uint8_t i=13;i<134;i++) + { + tm[i]=0x00; + } + return tm; + } + case 0x04: + { + printf("Run P_ACS_ACQ_DATA\r\n"); + //ACK_L234_TM + tm[0]=0xB0; + tm[1]=tc[0]; + tm[2]=ACK_CODE; + for(uint8_t i=3;i<11;i++) + { + tm[i]=0x00; + } + crc16 = CRC::crc16_gen(tm,11); + tm[11] = (uint8_t)((crc16&0xFF00)>>8); + tm[12] = (uint8_t)(crc16&0x00FF); + for(uint8_t i=13;i<134;i++) + { + tm[i]=0x00; + } + return tm; + } + case 0x05: + { + printf("Run P_ACS_MAIN\r\n"); + //ACK_L234_TM + tm[0]=0xB0; + tm[1]=tc[0]; + tm[2]=ACK_CODE; + for(uint8_t i=3;i<11;i++) + { + tm[i]=0x00; + } + crc16 = CRC::crc16_gen(tm,11); + tm[11] = (uint8_t)((crc16&0xFF00)>>8); + tm[12] = (uint8_t)(crc16&0x00FF); + for(uint8_t i=13;i<134;i++) + { + tm[i]=0x00; + } + return tm; + } + case 0x06: + { + printf("Run P_BCN_INIT\r\n"); + //ACK_L234_TM + tm[0]=0xB0; + tm[1]=tc[0]; + tm[2]=ACK_CODE; + for(uint8_t i=3;i<11;i++) + { + tm[i]=0x00; + } + crc16 = CRC::crc16_gen(tm,11); + tm[11] = (uint8_t)((crc16&0xFF00)>>8); + tm[12] = (uint8_t)(crc16&0x00FF); + for(uint8_t i=13;i<134;i++) + { + tm[i]=0x00; + } + return tm; + } + case 0x07: + { + printf("Run P_BCN_TX_MAIN\r\n"); + //ACK_L234_TM + tm[0]=0xB0; + tm[1]=tc[0]; + tm[2]=ACK_CODE; + for(uint8_t i=3;i<11;i++) + { + tm[i]=0x00; + } + crc16 = CRC::crc16_gen(tm,11); + tm[11] = (uint8_t)((crc16&0xFF00)>>8); + tm[12] = (uint8_t)(crc16&0x00FF); + for(uint8_t i=13;i<134;i++) + { + tm[i]=0x00; + } + return tm; + } + case 0x11: + { + printf("SW_ON_ACS_ATS1_SW_ENABLE\r\n"); + //ACK_L234_TM + tm[0]=0xB0; + tm[1]=tc[0]; + tm[2]=ACK_CODE; + for(uint8_t i=3;i<11;i++) + { + tm[i]=0x00; + } + crc16 = CRC::crc16_gen(tm,11); + tm[11] = (uint8_t)((crc16&0xFF00)>>8); + tm[12] = (uint8_t)(crc16&0x00FF); + for(uint8_t i=13;i<134;i++) + { + tm[i]=0x00; + } + return tm; + } + case 0x12: + { + printf("SW_ON_ACS_ATS2_SW_ENABLE\r\n"); + //ACK_L234_TM + tm[0]=0xB0; + tm[1]=tc[0]; + tm[2]=ACK_CODE; + for(uint8_t i=3;i<11;i++) + { + tm[i]=0x00; + } + crc16 = CRC::crc16_gen(tm,11); + tm[11] = (uint8_t)((crc16&0xFF00)>>8); + tm[12] = (uint8_t)(crc16&0x00FF); + for(uint8_t i=13;i<134;i++) + { + tm[i]=0x00; + } + return tm; + } + case 0x13: + { + printf("SW_ON_ACS_TR_XY_ENABLE\r\n"); + //ACK_L234_TM + tm[0]=0xB0; + tm[1]=tc[0]; + tm[2]=ACK_CODE; + for(uint8_t i=3;i<11;i++) + { + tm[i]=0x00; + } + crc16 = CRC::crc16_gen(tm,11); + tm[11] = (uint8_t)((crc16&0xFF00)>>8); + tm[12] = (uint8_t)(crc16&0x00FF); + for(uint8_t i=13;i<134;i++) + { + tm[i]=0x00; + } + return tm; + } + case 0x14: + { + printf("SW_ON_ACS_TR_Z_ENABLE\r\n"); + //ACK_L234_TM + tm[0]=0xB0; + tm[1]=tc[0]; + tm[2]=ACK_CODE; + for(uint8_t i=3;i<11;i++) + { + tm[i]=0x00; + } + crc16 = CRC::crc16_gen(tm,11); + tm[11] = (uint8_t)((crc16&0xFF00)>>8); + tm[12] = (uint8_t)(crc16&0x00FF); + for(uint8_t i=13;i<134;i++) + { + tm[i]=0x00; + } + return tm; + } + case 0x15: + { + printf("SW_ON_BCN_TX_SW_ENABLE\r\n"); + //ACK_L234_TM + tm[0]=0xB0; + tm[1]=tc[0]; + tm[2]=ACK_CODE; + for(uint8_t i=3;i<11;i++) + { + tm[i]=0x00; + } + crc16 = CRC::crc16_gen(tm,11); + tm[11] = (uint8_t)((crc16&0xFF00)>>8); + tm[12] = (uint8_t)(crc16&0x00FF); + for(uint8_t i=13;i<134;i++) + { + tm[i]=0x00; + } + return tm; + } + case 0x21: + { + printf("SW_OFF_ACS_ATS1_SW_ENABLE\r\n"); + //ACK_L234_TM + tm[0]=0xB0; + tm[1]=tc[0]; + tm[2]=ACK_CODE; + for(uint8_t i=3;i<11;i++) + { + tm[i]=0x00; + } + crc16 = CRC::crc16_gen(tm,11); + tm[11] = (uint8_t)((crc16&0xFF00)>>8); + tm[12] = (uint8_t)(crc16&0x00FF); + for(uint8_t i=13;i<134;i++) + { + tm[i]=0x00; + } + return tm; + } + case 0x22: + { + printf("SW_OFF_ACS_ATS2_SW_ENABLE\r\n"); + //ACK_L234_TM + tm[0]=0xB0; + tm[1]=tc[0]; + tm[2]=ACK_CODE; + for(uint8_t i=3;i<11;i++) + { + tm[i]=0x00; + } + crc16 = CRC::crc16_gen(tm,11); + tm[11] = (uint8_t)((crc16&0xFF00)>>8); + tm[12] = (uint8_t)(crc16&0x00FF); + for(uint8_t i=13;i<134;i++) + { + tm[i]=0x00; + } + return tm; + } + case 0x23: + { + printf("SW_OFF_ACS_TR_XY_ENABLE\r\n"); + //ACK_L234_TM + tm[0]=0xB0; + tm[1]=tc[0]; + tm[2]=ACK_CODE; + for(uint8_t i=3;i<11;i++) + { + tm[i]=0x00; + } + crc16 = CRC::crc16_gen(tm,11); + tm[11] = (uint8_t)((crc16&0xFF00)>>8); + tm[12] = (uint8_t)(crc16&0x00FF); + for(uint8_t i=13;i<134;i++) + { + tm[i]=0x00; + } + return tm; + } + case 0x24: + { + printf("SW_OFF_ACS_TR_Z_ENABLE\r\n"); + //ACK_L234_TM + tm[0]=0xB0; + tm[1]=tc[0]; + tm[2]=ACK_CODE; + for(uint8_t i=3;i<11;i++) + { + tm[i]=0x00; + } + crc16 = CRC::crc16_gen(tm,11); + tm[11] = (uint8_t)((crc16&0xFF00)>>8); + tm[12] = (uint8_t)(crc16&0x00FF); + for(uint8_t i=13;i<134;i++) + { + tm[i]=0x00; + } + return tm; + } + case 0x25: + { + printf("SW_OFF_BCN_TX_SW_ENABLE\r\n"); + //ACK_L234_TM + tm[0]=0xB0; + tm[1]=tc[0]; + tm[2]=ACK_CODE; + for(uint8_t i=3;i<11;i++) + { + tm[i]=0x00; + } + crc16 = CRC::crc16_gen(tm,11); + tm[11] = (uint8_t)((crc16&0xFF00)>>8); + tm[12] = (uint8_t)(crc16&0x00FF); + for(uint8_t i=13;i<134;i++) + { + tm[i]=0x00; + } + return tm; + } + case 0x31: + { + printf("ACS_ATS_SW_RESET\r\n"); + //ACK_L234_TM + tm[0]=0xB0; + tm[1]=tc[0]; + tm[2]=ACK_CODE; + for(uint8_t i=3;i<11;i++) + { + tm[i]=0x00; + } + crc16 = CRC::crc16_gen(tm,11); + tm[11] = (uint8_t)((crc16&0xFF00)>>8); + tm[12] = (uint8_t)(crc16&0x00FF); + for(uint8_t i=13;i<134;i++) + { + tm[i]=0x00; + } + return tm; + } + case 0x32: + { + printf("BCN_SW_RESET\r\n"); + //ACK_L234_TM + tm[0]=0xB0; + tm[1]=tc[0]; + tm[2]=ACK_CODE; + for(uint8_t i=3;i<11;i++) + { + tm[i]=0x00; + } + crc16 = CRC::crc16_gen(tm,11); + tm[11] = (uint8_t)((crc16&0xFF00)>>8); + tm[12] = (uint8_t)(crc16&0x00FF); + for(uint8_t i=13;i<134;i++) + { + tm[i]=0x00; + } + return tm; + } + case 0x33: + { + printf("BAE_RESET\r\n"); + //ACK_L234_TM + tm[0]=0xB0; + tm[1]=tc[0]; + tm[2]=ACK_CODE; + for(uint8_t i=3;i<11;i++) + { + tm[i]=0x00; + } + crc16 = CRC::crc16_gen(tm,11); + tm[11] = (uint8_t)((crc16&0xFF00)>>8); + tm[12] = (uint8_t)(crc16&0x00FF); + for(uint8_t i=13;i<134;i++) + { + tm[i]=0x00; + } + return tm; + } + case 0x34: + { + printf("CDMS_SW_RESET\r\n"); + //ACK_L234_TM + tm[0]=0xB0; + tm[1]=tc[0]; + tm[2]=ACK_CODE; + for(uint8_t i=3;i<11;i++) + { + tm[i]=0x00; + } + crc16 = CRC::crc16_gen(tm,11); + tm[11] = (uint8_t)((crc16&0xFF00)>>8); + tm[12] = (uint8_t)(crc16&0x00FF); + for(uint8_t i=13;i<134;i++) + { + tm[i]=0x00; + } + return tm; + } + case 0xE0: + { + printf("CMSN_ACS_ALGO\r\n"); + //FMS_TM + tm[0]=0xF0; + tm[1]=tc[0]; + tm[2]=ACK_CODE; + for(uint8_t i=3;i<132;i++) + { + tm[i]=0x00; + } + crc16 = CRC::crc16_gen(tm,132); + tm[132] = (uint8_t)((crc16&0xFF00)>>8); + tm[133] = (uint8_t)(crc16&0x00FF); + return tm; + } + case 0xE1: + { + printf("CMSN_ACS_HW\r\n"); + //FMS_TM + tm[0]=0xF0; + tm[1]=tc[0]; + tm[2]=ACK_CODE; + for(uint8_t i=3;i<132;i++) + { + tm[i]=0x00; + } + crc16 = CRC::crc16_gen(tm,132); + tm[132] = (uint8_t)((crc16&0xFF00)>>8); + tm[133] = (uint8_t)(crc16&0x00FF); + return tm; + } + case 0xC1: + { + printf("Reset HK_Counter\r\n"); + //ACK_L234_TM + tm[0]=0xB0; + tm[1]=tc[0]; + tm[2]=ACK_CODE; + for(uint8_t i=3;i<11;i++) + { + tm[i]=0x00; + } + crc16 = CRC::crc16_gen(tm,11); + tm[11] = (uint8_t)((crc16&0xFF00)>>8); + tm[12] = (uint8_t)(crc16&0x00FF); + for(uint8_t i=13;i<134;i++) + { + tm[i]=0x00; + } + return tm; + } + default: + { + printf("Invalid TC\r\n"); + //ACK_L234_TM + tm[0]=0xB0; + tm[1]=tc[0]; + tm[2]=ACK_CODE; + for(uint8_t i=3;i<11;i++) + { + tm[i]=0x00; + } + crc16 = CRC::crc16_gen(tm,11); + tm[11] = (uint8_t)((crc16&0xFF00)>>8); + tm[12] = (uint8_t)(crc16&0x00FF); + for(uint8_t i=13;i<134;i++) + { + tm[i]=0x00; + } + return tm; + } + } + + default: + { + printf("Invalid TC\r\n"); + //ACK_L234_TM + tm[0]=0xB0; + tm[1]=tc[0]; + tm[2]=ACK_CODE; + for(uint8_t i=3;i<11;i++) + { + tm[i]=0x00; + } + crc16 = CRC::crc16_gen(tm,11); + tm[11] = (uint8_t)((crc16&0xFF00)>>8); + tm[12] = (uint8_t)(crc16&0x00FF); + for(uint8_t i=13;i<134;i++) + { + tm[i]=0x00; + } + return tm; + } + } + } + } + } +} \ No newline at end of file