/**
 * @file mfcc_tc_tm_sample.c
 *
 * @brief This file contains functions that provides demonstration of
 *        usage of TC TM Library APIs
 *
 * The functions provided in the file provides demonstration on
 * usage of TC TM library APIs
 */
/*********************************************************************/
#include "mfcc_tc_tm_sample.h"
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <sch_parser.h>
#include "tc_tm_lib_common.h"
#include "linux_timer.h"
#include "file_integrity_check.h"
#include "file_integrity_check.h"
#include <stdbool.h>
#include "ft_sample_app_upload.h"
#include "otsu_tctm_man.h"
#include "adcs_common.h"
#include "adcs_bsk.h"
#include "mfcc_thruster.h"
#include "ft_sample_app_dwnld.h"
#define SNS_GET_INF_PRINT
//#define ENBL_DBG_PRNT
//#define BUFF_READ_MAX_SIZE (TM_MAX_SIZE)
//#define  TM_STORAGE

#define MAX_PAYLOAD_SIZE 4096
#define MAX_TC_TEST_CASE 2
#define SAT_DEV_MAX_CNT 14
#define OBC_SUB_MOD_MAX 17
#define READ_LOG_CONFIG                 0
#define CONFIG_MODULE_ALL               1
#define CONFIG_MODULE_SPECIFIC          2
#define CONFIG_MODULE_ALL_LOG           3
#define CONFIG_MODULE_ALL_ERROR         4
#define CONFIG_MODULE_DEFAULT           5
#define READ_LOG_HANDLE_INFO            2
#define READ_LOG_LEVEL_FILTER           1
#define BACKUP_DATA_READ_FAIL           7
#define MAX_LUT_CNT                     2
#define LUT_CTRL                        1
#define LUT_STATUS_CHECK                2
#define INST_SIZE5                      5

uint8_t radio_mod_id = 0;
uint8_t sdr_radio_mod_id = 0;

/*
 * added for FT
 */
#include "file_transfer.h"
#include "ft_sample_app_upload.h"

#include "mfcc_tc_tm_sample.h"
#include "sch_parser.h"

#include "otsu_tctm_man.h"

#define SENSOR_MAX_BUFF_SIZE 5
#define MAX_SSD_SIZE 2
#define HM_EPS_RD_BFR_MAX_SIZE 18
#define MAX_RESET_NAME_LENGTH  25
int32_t sockfd;
extern s_sock_info tctm_soc_inf;
/**
 * @brief Global variable to keep track of target pointing response status
 */

/******** Automation Framework Start *********/

extern s_autom_user_input autom_user_input;
int autom_i = 3;

uint8_t gpio_pin_type;
uint8_t gpio_pin_id;
uint8_t gpio_pin_op;
uint8_t comms_set = 1;
uint8_t uhf_set = 1;
/******** Automation Framework End *********/

//eps_dev_tmr_t pwr_tmr[MAX_SAT_DEV_CNT];
uint32 obc_sw_rst_typ;
uint32 tm_obc_sw_rst_sts = 0;
uint64_t cpu_uptime;
float cpu_ld;
sys_mem_status mem_sts;
sys_time_date_s cur_rct = {0};
uint32 trgt_pt_rsp_sts = 0;
#if 0
uint32 ps_pwr_on_rsp_sts = 0;
uint32 ps_pwr_off_rsp_sts = 0;
#endif
uint32 tty_start_rsp_sts = 0;
uint32 tty_end_rsp_sts = 0;
#if 0
uint32 pld_hw_pwr_on_rsp_sts = 0;
uint8 pwr_ctrl_rsp_sts = 0;
#endif
uint32 pld_vm_pwr_on_rsp_sts = 0;

//uint32 pld_hw_pwr_off_rsp_sts = 0;
uint32 pld_vm_pwr_off_rsp_sts = 0;

uint8_t log_buff[1024*1024];
uint32 mem_data_resp = 0;
uint32 get_conv_brd_par = 0;
uint32 spi_intf_param_rsp_sts = 0;
uint32 eth_intf_param_rsp_sts = 0;
uint32 can_intf_param_rsp_sts = 0;
uint32 i2c_intf_param_rsp_sts = 0;
uint32 usb_intf_param_rsp_sts = 0;
uint32 uart_intf_param_rsp_sts = 0;
uint32 set_temp_sen_parm_sts =0;
uint32 set_imu_parm_sts = 0;
uint32 set_thrust_ctrl_parm_sts =0;
uint32 set_gpio_exp_parm_sts = 0;
uint32 set_dig_therm_parm_sts = 0;
uint32 set_pwr_mon_parm_sts = 0;
uint32 set_volt_ctrl_mon_parm_sts = 0;
uint32 set_pwr_seq_mon_parm_sts = 0;
uint32 set_data_log_parm_sts = 0;
uint32_t mem_debug_data = 0;
uint32 ssd_slec_resp = 0;
uint32 ssd_heat_slec_resp = 0;
uint32_t set_min_rbt_tm_rsp=0;

gps_location_data1 gps_loc_data1;
gps_location_data2 gps_loc_data2;
gps_time_data gps_date_time;
gps_best_xyz gps_pos_vel;
gps_loc_info gps_loc;
orbit_tle_t gps_tle;
uint32_t ahw_id;


uint8_t nvm_data_1[100];
nvm_param nvm_data;

uint8_t ssd_brd_slec;
uint8_t ssd_slot_slec;
uint8_t ssd_heat_slec[MAX_SSD_SIZE];
uint8_t ssd_sts=0;

dt_data_s dt_data_buffer[SENSOR_MAX_BUFF_SIZE];
hsc_data_s hsc_data_buffer[SENSOR_MAX_BUFF_SIZE];
psm_data_s psm_data_buffer[SENSOR_MAX_BUFF_SIZE];
temp_data_s temp_data_buffer[SENSOR_MAX_BUFF_SIZE];
vsm_data_s vsm_data_buffer[SENSOR_MAX_BUFF_SIZE];

temp_sens_cfg temp_sns_cfg;
reset_info receive_data;
digital_thermostat_cfg dgtl_thrmst_cfg;
hotswap_cntlr_cfg htswp_cntlr_cfg;
power_mntr_sns_cfg pwr_sns_mtr_cfg;
voltage_seq_mntr_cfg vltg_seq_mntr_cfg;
gpio_exp_cfg gpio_expdr_cfg;
thruster_info thrstr_inf;
thruster_param thrstr_para;
data_acq_dvc_info  data_acq_inf;
data_acq_dvc_param data_acq_para;
imu_info imu_inf;
imu_param imu_para;
char* tty_dcdu = "pwd";
char tty_dcdu_buff[2000];
sch_sband_ctrl_s *sch_sband_ctrl;
s_ps_brd_ssd_id ps_brd_id;

uint8 tty_drdu[2000];
/**
 * @brief Global variable to keep track of location information
 */
tctm_gnss_loc_info_s gli;
tctm_spi_init_s spii;
tctm_ethernet_init_s eth;
tctm_can_init_s cis;
tctm_i2c_init_s i2ci;
tctm_usb_otg_cfg_s usbo;
tctm_uart_init_s uarti;
adc_board_read adc_brd_read;

typedef struct 
{
    uint8_t integrity_fail;
    uint8_t integrity_pass_cnt[HM_TEST_CASE_MAX];
    uint16_t test_case_id;
}tc_tm_cb;

tc_tm_cb hm_fw_cb;


typedef struct ft_tctm_pld_tx
{
    uint8_t *payload_ptr;
    uint16_t payload_len;
    uint16_t tc_tm_id;
    uint8_t send_request;
    uint16_t dest_node;
}ft_tctm_payload_tx;

ft_tctm_payload_tx ft_pld_tx;
uint16_t set_ftds_debug;

ext_mem_test_tc_tm_s mem_type;
uint8_t obc_bringup_mdle;
s_otsu_tctm_info otsu_tc_tm;

uint16_t wr_offset = 0;
uint8_t sch_tc_store_en = 0;
uint8_t apd_owrt = 0;
FILE *file_w = NULL;
uint8_t ft_payload_transmitter(uint16 tc_tm_id, uint16 src_dst_id, uint8_t *payload_ptr, uint16_t payload_len);
void ft_destination_set(uint16_t set);
uint8_t board_id=0;
uint8_t heat_en_sts=0;
void send_tc_otsu(uint8_t tc_id);
uint16 tc_test_id_list[MAX_TC_TEST_CASE] = {546, 547};
uint8 tc_test_state = 0;
uint8 tc_tm_mngr_key[] = { 0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
    0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
    0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
    0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
    0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
    0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
    0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
    0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
    0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
    0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
    0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
    0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
    0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
    0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
    0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
    0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};
uint8_t ft_sample_dest_node;


uint32_t prod_key_table[39][6] = {
    {0x57712726,0xfea9f476,0x4354fe02,0x308a8b3e,0x2048, 0x64},
    {0x55713326,0x5aa9b47e,0x4354fe02,0x38828b3e,0x128, 0x128},
    {0x95712324,0x7ea9b476,0x4354fe00,0x3202833e,0x256, 0x256},
    {0x15712326,0x7ea9b476,0x4354fe01,0x389a8b36,0x512, 0x512},
    {0x17712324,0x7ea9f476,0x4254fe03,0x3b028bb2, 0x2048, 0x512},
    {0x53713724,0x5ea9f476,0x4254fe03,0x3a0a8b3e, 0x2048, 0x128},
    {0x31712324,0x7aa9f476,0x4254fe03,0x388a8b36, 0x1024, 0x512},
    {0x75713324,0x7ea9f476,0x4354fe03,0x380a8bbe, 0x1024, 0x128},
    {0xf1712326,0x5aa9f476,0x4354fe02,0x32828bba, 0x1024, 0x256},
    {0x55712324,0xdaa9b476,0x4354fe00,0x329a8bbe, 0x512, 0x64},
    {0x51713326,0x7aa9b476,0x4254fe01,0x381a8bbe, 0x512, 0x128},
    {0x51712324,0xfaa9b47e,0x4254fe03,0x32028b3e, 0x128, 0x64},
    {0x15712324,0xfaa9b476,0x4254fe00,0x320a833a, 0x256, 0x64},
    {0x11713326,0x5aa9b476,0x4354fe01,0x388a833a, 0x256, 0x128},
    {0x51713326,0x7aa9b476,0x4254fe01,0x381a8bbe, 0x512, 0x128},
    {0x71712326,0xdea9f476,0x4254fe02,0x328a8bbe, 0x1024, 0x64},
    {0x51712324,0xdea93476,0x4254fe01,0x380a8b3e, 0x64, 0x64},
    {0x1551a324,0x5ea9b476,0x4354fe01,0x3a8a8b3a, 0x32, 0x32},
    {0x6c0d1190,0xc62bb308,0x0840a0b7,0x1b083180, 0, 0},
    {0x2c0d1192,0xc22bf308,0x0840a0b5,0x3a1a3182, 0, 0},
    {0x2c0d1192,0x622bb308,0x0840a0b6,0x11083108, 0, 0},
    {0x680d0192,0x662bb308,0x0940a0b6,0x11883180, 0, 0},
    {0x0a0d1592,0x422bb308,0x0940a0b6,0x13083188, 0, 0},
    {0x4e0d0592,0x462bb308,0x0840a0b6,0x13883100, 0, 0},
    {0x6e0d0590,0x622bf300,0x0840a0b7,0x13003180, 0, 0},
    {0xae0d1592,0x462bf308,0x0840a0b5,0x19803980, 0, 0},
    {0x2e0d1590,0x462bf308,0x0840a0b4,0x13183188, 0, 0},
    {0x956389a3,0xf244b67b,0xdc3a63ab,0x96fc805e, 0, 0},
    {0x11638da1,0x5644b67b,0xdc3a63a8,0x9cf680de, 0, 0},
    {0x13639da1,0xd644f673,0xdd3a63a8,0x957680da, 0, 0},
    {0xd3638da3,0xf244f67b,0xdd3a63aa,0x9ff688da, 0, 0},
    {0x53638da1,0xf244f67b,0xdd3a63ab,0x956e80d2, 0, 0},
    {0x51638da3,0xf244b67b,0xdc3a63a9,0x96f68056, 0, 0},
    {0x15639da3,0xf644b67b,0xdd3a63a9,0x967680de, 0, 0},
    {0x77638da3,0xf644b67b,0xdc3a63a9,0x957e80d2, 0, 0},
    {0x33639da3,0xf244b67b,0xdd3a63a9,0x95fe805a, 0, 0},
    {0xb7638da1,0xd644b67b,0xdd3a63a8,0x9f76805e, 0, 0},
    {0x13638da3,0x5644f67b,0xdd3a63aa,0x9f6e805a, 0, 0},
    {0x17639da1,0xf644f67b,0xdc3a63ab,0x95ee805a, 0, 0}
};

/*
 * Configuration debug level macros
 */
#define ERROR_LOGS_EN                           0x01
#define WARNING_LOGS_EN                         0x02
#define INFO_L1_LOGS_EN                         0x04
#define INFO_L2_LOGS_EN                         0x08
#define INFO_L3_LOGS_EN                         0x10
#define ALL_LOGS_DIS                            0x00
#define ALL_LOGS_EN                             (ERROR_LOGS_EN | WARNING_LOGS_EN | INFO_L1_LOGS_EN | INFO_L2_LOGS_EN |INFO_L3_LOGS_EN)
/*
 * Initial debug level configuration
 * user can configure log level for each module
 *
 bit 0 -> LOG_ERROR,
 bit 1 -> LOG_WARNING,
 bit 2 -> LOG_INFO_L1,
 bit 3 -> LOG_INFO_L2,
 bit 4 -> LOG_INFO_L3,

 All bit zero - disabled all debug levels
 All bit ones - enabled all debug levels
 */
uint8_t log_level_cfg[LOG_MODULE_MAX+1]=
{
    (ALL_LOGS_EN),                                                                                  /// LOG_ADCS
    (ALL_LOGS_EN),                                                                                  /// LOG_OTSU
    (ALL_LOGS_EN),                                                                                  /// LOG_COMMS
    (ALL_LOGS_EN),                                                                                  /// LOG_FTM
    (ALL_LOGS_EN),                                                                                  /// LOG_OBC
    (ALL_LOGS_EN),                                                                                  /// LOG_EPS
    (ALL_LOGS_EN),                                                                                  /// LOG_TCTM
    (ALL_LOGS_EN),                                                                                  ///LOG_SHEDULER
    (ALL_LOGS_EN),                                                                                  ///LOG_AHW
    (ALL_LOGS_EN),                                                                                  ///LOG_LOGGER
    (ALL_LOGS_EN),                                                                                  ///LOG_ERROR_HANDLER
    (ALL_LOGS_EN),                                                                                  ///LOG_HM_
    (ALL_LOGS_EN),                                                                                  ///LOG_IPCC
};
typedef enum err_group_def
{
    ERR_GROUP_IO,
    ERR_GROUP_AHW_SET_1,
    ERR_GROUP_AHW_SET_2,
    ERR_GROUP_SYSTEM,
    ERR_GROUP_SERVICES,
    ERR_GROUP_COREMODULES,
    ERR_GROUP_ADCS,
    ERR_GROUP_EPS,
    ERR_GROUP_MAX
}err_group;


/*
 * Global variable to handle semented packet
 */
#define  MAX_RX_DEC_WAIT_TIME_MS (10*1000)
uint32 residue_size = 0;
volatile uint8* residue_pac=NULL;
size_t rx_timer_id;

uint8_t*  log_lev_cfg_encode(uint16_t *tc_len);
uint8_t module_level_selection();
uint32_t file_Crc32(uint32_t Crc, uint32_t Data);
//long int file_findSize(char file_name[]);
//uint32_t file_checksum(char file_name[], uint32_t length);
void module_level_display(uint8_t level);




char fread_line[50];
const char software_version[] = "{software_version:";
const char boot_mode[] = "{boot_mode:";
const char smooth_shutdown_time[] = "{smooth_shutdown_time:";
const char scheduled_boot_utc_time[] = "{scheduled_boot_utc_time:";
const char scheduled_boot_date[] = "{scheduled_boot_date:";
const char gs_sync_wait_utc_time[] = "{gs_sync_wait_utc_time:";
const char gs_sync_wait_date[] = "{gs_sync_wait_date:";
const char gs_contact_waittime_in_min[] = "{gs_contact_waittime_in_min:";


unsigned char otsu_cfg_sft_major;
unsigned char otsu_cfg_sft_minor;
unsigned char otsu_cfg_bt_mod;
unsigned int otsu_cfg_shuttime;
struct tm otsu_cfg_sch_time;
struct tm otsu_cfg_gssync_time;
unsigned int otsu_cfg_gscont_waittime;

/**
 * @brief Sensor information queue id
 */
typedef enum
{
    PSM_PS_DATA_QUEUE_ID,
    PSM_OBC_DATA_QUEUE_ID,
    TEMP_OBC_DATA_QUEUE_ID,
    TEMP_PS_DATA_QUEUE_ID,
    TEMP_ES_DATA_QUEUE_ID,
    TEMP_GPS_DATA_QUEUE_ID,
    DT_SPE01_DATA_QUEUE_ID,
    DT_SPE02_DATA_QUEUE_ID,
    DT_SPB01_DATA_QUEUE_ID,
    DT_SPW01_DATA_QUEUE_ID,
    DT_SPW02_DATA_QUEUE_ID,
    HSC_EDGE_DATA_QUEUE_ID,
    HSC_PS1_DATA_QUEUE_ID,
    HSC_PS2_DATA_QUEUE_ID,
    DT_PS_DATA_QUEUE_ID,
    DT_EDGE_DATA_QUEUE_ID,
    SNS_QUEUE_ID_MAX
}sns_queue_id;



/**
 * @brief Function that prepares Telecommand payload
 * based on user input
 */
void *mfcc_usr_input_thread(void *params)
{
    uint32 tst_id;
    uint32 tc_id;
    uint16 cur_test_tc_id = 0;
    uint16 cur_test_idx = 0;
    uint8 dst_node = 0;
    uint8_t err_id;

    sleep(1);

    ft_pld_tx.send_request = 0;
    ft_register_pld_trasnmitter_cblk(ft_payload_transmitter);
    ft_register_receiver_app(TC_DST_FTM_DBGLOG, log_notificataion_api_dwld);
    ft_register_receiver_app(TM_SRC_PS, app1234_notificataion_api_dwld);
    printf("\nEnter Radio ID: \n1 - SRS4 SBAND \n2 - UHF \n3 - IQS SBAND\n4 - GS2 Back door socket\n");
    scanf("%d",(int*)&radio_mod_id);


    while(1)
    {
        usleep(100);
        printf("Enter Test Type ID\n");
        printf("Test Type ID 1 - Send TC to OBC\n");
        printf("Test Type ID 2 - Send TC to OBC-COMMS\n");
        printf("Test Type ID 3 - Send TC to PS / PLD HW\n");
        printf("Test Type ID 4 - Select File Transfer\n");
        printf("Test Type ID 5 - Send TC to OBC-ADCS\n");
        printf("Test Type ID 6 - Send ADCS sequence\n");
        printf("Test Type ID 7 - Send ADCS TC/TM sequence\n");
        printf("Test Type ID 8 - Send TC to OBC- OTSU \n");
        printf("Test Type ID 9 - Start long run test sequence \n");
        printf("Test Type ID 10 - OBC-Memory Debug\n");
        printf("Test Type ID 11 - Continuous EPS Test\n");
        printf("Test Type ID 12 - Download Log from OBC\n");
        printf("Test Type ID 13 - External flash memory test\n");
        printf("Test Type ID 14 - Send TC to X-BAND\n");	
        printf("Test Type ID 15 - Send TC to UHF\n");	
        printf("Test Type ID 16 - SET SBAND USER CONFIGURATION\n");
        printf("Test Type ID 17 - Exit from Ground Station EXE\n");
        printf("Test Type ID 18 - SET UHF USER CONFIGURATION\n");
        printf("Test Type ID 19 - OBC board bring up test\n");
        printf("Test type ID 20 - Select radio Id \n");
        printf("Test Type ID 21 - Error Handler\n");
        printf("Test Type ID 22 - Send TC to SDR \n");
        printf("Test Type ID 23 - Send TC to TEST_LAYER \n");
        if(sch_tc_store_en == 0)
        {
            printf("Test Type ID 24 - Start TC commands Storage \n");
        }
        else
        {
            printf("Test Type ID 24 - Stop TC commands Storage\n");
        }



        if(autom_i < autom_user_input.autom_arg_cnt && autom_user_input.autom_argv_valid[2])
        {
            tst_id = atoi((char*)autom_user_input.autom_argv[2]);
        }
        else
        {
            scanf(" %d", &tst_id);
            getchar();
        }
        printf("Entered Test Type is: %d\n",tst_id);

        if(1 == tst_id)
        {
            /* Get Telecommand ID to be sent from Ground station to Satellite */
            printf("Enter Telecommand ID \n");
            if(autom_i < autom_user_input.autom_arg_cnt && autom_user_input.autom_argv_valid[autom_i])
            {
                tc_id = atoi((char*)autom_user_input.autom_argv[autom_i]);
            }
            else
            {
                scanf(" %d", &tc_id);
            }
            printf("Entered Telecommand ID: %d \n",tc_id);
            mfcc_tc_send(tc_id, TC_DST_OBC);
            if(autom_i < autom_user_input.autom_arg_cnt)
            {
                autom_i++;
                sleep(atoi((char*)autom_user_input.autom_argv[1]));
            }
        }
        else if(2 == tst_id)
        {
            /* Get Telecommand ID to be sent from Ground station to COMMS Module */
            printf("Enter Telecommand ID \n");
            if(autom_i < autom_user_input.autom_arg_cnt && autom_user_input.autom_argv_valid[autom_i])
            {
                tc_id = atoi((char*)autom_user_input.autom_argv[autom_i]);
            }
            else
            {
                scanf(" %d", &tc_id);
            }
            printf("Entered Telecommand ID: %d\n",tc_id);
            mfcc_tc_send(tc_id, TC_DST_SBND_COMMS);
            if(autom_user_input.autom_argv_valid[autom_i-1])
            {
                autom_i++;
                sleep(atoi((char*)autom_user_input.autom_argv[1]));
            }
        }
        else if(3 == tst_id)
        {
            printf("Enter the destination node to send the TC\n");
            scanf(" %hhd", &dst_node);
            if((TC_DST_PLD_TC == dst_node) || \
                    (TC_DST_PLD_AI == dst_node) || \
                    (TC_DST_PLD_NET == dst_node) || \
                    (TC_DST_PLD_ZES == dst_node) || \
                    (TC_DST_PLD_SL == dst_node) || \
                    (TC_DST_PS == dst_node))
            {
                /* Get Telecommand ID to be sent from Ground station to Satellite */
                printf("Enter Telecommand ID \n");
                scanf(" %d", &tc_id);
                printf("Entered Telecommand ID: %d\n",tc_id);
                mfcc_tc_send(tc_id, dst_node);
            }
            else
            {
                printf("Invalid Destination ID received. Please try again\n");
            }
        }
        else if(4 == tst_id)
        {
            printf("File Transfer Initiated...\n");
            ft_pld_tx.send_request = 0;


            printf("Enter FTDS interval time in ms between \"1 to 2000\"\n");

            if(autom_i < autom_user_input.autom_arg_cnt && autom_user_input.autom_argv_valid[3])
            {
                autom_i++;
                set_ftds_debug = atoi((char*)autom_user_input.autom_argv[3]);
                ft_set_ftds_delay(set_ftds_debug);
            }
            else
            {
                scanf("%hu",&set_ftds_debug);
                ft_set_ftds_delay(set_ftds_debug);
            }

            printf("Enter Destination node\n");
            printf("Destination Type ID 1 -  OBC/OTSU Firmware upload(Maximum size 1 mb(1024kb))\n");
            printf("Destination Type ID 2 -  Upload to PS\n");
            printf("Destination Type ID 3 -  OBC/COMMS Firmware upload\n");
            printf("Destination Type ID 4 -  OBC/EPS Firmware upload (Maximum size 200kb)\n");
            printf("Destination Type ID 5 -  OBC-ADCS Firmware upload\n");
            printf("Destination Type ID 6 -  OBC-LOGGER Firmware upload\n");
            printf("Destination Type ID 7 -  PS/COMMS Firmware upload\n");
            printf("Destination Type ID 8 -  None of the above\n");

            if(autom_i < autom_user_input.autom_arg_cnt && autom_user_input.autom_argv_valid[4])
            {
                autom_i++;
                tst_id = atoi((char*)autom_user_input.autom_argv[4]);
            }
            else
            {
                scanf(" %d", &tst_id);
                getchar();
            }

            if(1 == tst_id)
            {
                //ft_destination_set(TC_DST_FTM_OTSU);
                ft_sample_dest_node = TC_DST_FTM_OTSU;
                printf("OBC/OTSU selected\n");
            }
            else  if(2 == tst_id)
            {
                //ft_destination_set(TC_DST_PS);
                ft_sample_dest_node = TC_DST_PS;
                printf("PS selected\n");
            }
            else  if(3 == tst_id)
            {
                //ft_destination_set(TC_DST_PS);
                ft_sample_dest_node = TC_DST_FTM_OBC_COMMS;
                printf("OBC/COMMS selected\n");
            }
            else  if(4 == tst_id)
            {
                //ft_destination_set(TC_DST_PS);
                ft_sample_dest_node = TC_DST_FTM_OBC_EPS;
                printf("OBC/EPS selected\n");
            }          
            else  if(5 == tst_id)
            {
                ft_sample_dest_node = TC_DST_FTM_OBC_ADCS;
                printf("OBC-ADCS selected\n");
            } 
            else  if(6 == tst_id)
            {
                ft_sample_dest_node = TC_DST_FTM_DBGLOG;
                printf("OBC-LOGGER selected\n");
            }
            else  if(7 == tst_id)
            {
                ft_sample_dest_node = TC_DST_FTM_PS_COMMS;
                printf("PS/COMMS selected\n");
            }

            else
            {
                //ft_destination_set(TC_DST_PS);
                ft_sample_dest_node = TC_DST_PS;
                printf("Invalid selection ; ");
                printf("Default option PS selected\n");
            }

            app1234_thread();
        }
        else if(5 == tst_id)
        {
            /* Get Telecommand ID to be sent from Ground station to Satellite */
            printf("Enter Telecommand ID \n");
            scanf(" %d", &tc_id);
            printf("Entered Telecommand ID: %d\n",tc_id);
            mfcc_tc_send(tc_id, TC_DST_ADCS);
        }
        else if(6 == tst_id)
        {
            parse_adcs_seq_cmd();
        }
        else if(7 == tst_id)
        {
            parse_adcs_tc_tm_seq_cmd();
        }
        else if(8 == tst_id)
        {
            /* Get Telecommand ID to be sent from Ground station to Satellite */
            printf("Enter OTSU msg ID \n");

            printf("Test Type ID 1 - Request software version\n");
            printf("Test Type ID 2 - Get otsu status\n");
            printf("Test Type ID 3 - Send Firmware Update Configuration Params\n");
            printf("Test Type ID 4 - Integ test commands\n");
            printf("Test Type ID 5 - Get Partial Firmware Download Information\n");
            printf("Test Type ID 6 - Read Boot Configuration Params\n");
            printf("Test Type ID 7 - Read GS comntact Timer Value\n");
            printf("Test Type ID 8 - Set GS comntact Timer Value\n");
            printf("Test Type ID 9 - Read bootable 1\n");
            printf("Test Type ID 10 - Read bootable 2\n");
            printf("Test Type ID 11 - Request NVM software version\n");
            scanf(" %d", &tc_id);
            send_tc_otsu(tc_id);
        }
        else if(9 == tst_id)
        {
            tc_test_state = 0;
            while(1)
            {
                if(!tc_test_state)
                {
                    tc_test_state = 1;
                    cur_test_tc_id = tc_test_id_list[cur_test_idx];
                    mfcc_tc_send(cur_test_tc_id,TC_DST_OBC);
                    cur_test_idx ++;
                    cur_test_idx = cur_test_idx % MAX_TC_TEST_CASE;
                }
                else
                {
                    usleep(100);
                }
            }
        }
        else if(10 == tst_id)
        {
            printf("Enter the Memory Type Debug :\n");
            printf("1.SDRAM :\n");
            printf("2.FMC NOR-FLASH :\n");
            printf("3.QSPI NOR-FLASH :\n");
            printf("4.Internal RAM :\n");
            scanf("%d",&tst_id);
            getchar();

            obc_mem_debug_tc_encode(tst_id);

            mfcc_tc_send(TC_MEMD,TC_DST_OBC);
        }
        else if(11 == tst_id)
        {
            /* Get Telecommand ID to be sent from Ground station to COMMS Module */
            printf("Enter Telecommand ID \n");
            scanf(" %d", &tc_id);
            mfcc_tc_send(tc_id, TC_DST_EPS);
        }
        else if(12 == tst_id)
        {
            printf("log_notificataion_api_dwld registered with FTM\n");
            uint8_t cfg_dwn_selc = 0;
            printf("Enter your selection\n");
            printf("1.Download log data \n");
            printf("2.Configuration of module logs\n");
            printf("3.Read logger info\n");
            printf("4.Download back log data\n");
            printf("5.Decode logs\n");
            scanf("%hhu", &cfg_dwn_selc);
            if(1 == cfg_dwn_selc)
            {
                mfcc_tc_send(TC_LOG_DOWNLOAD_BLOCKS, TC_DST_OBC);
            }
            else if(2 == cfg_dwn_selc)
            {
                mfcc_tc_send(TC_LOG_LEVEL_FILTER_CONFIG, TC_DST_OBC);
            }
            else if(3 == cfg_dwn_selc)
            {
                mfcc_tc_send(TC_READ_LOG_INFO,TC_DST_OBC);
            }
            else if(4 == cfg_dwn_selc)
            {
                mfcc_tc_send(TC_LOG_DOWNLOAD_BACKUP_BLOCKS,TC_DST_OBC);
            }
            else if(5 == cfg_dwn_selc)
            {
                printf("Enter log file to decode\n");
                char log_file_name[50] = "x.bin";
                char decoder_cmd[150];
                scanf("%s",log_file_name);
                printf("Entered log file: %s\n", log_file_name);
                strcpy(decoder_cmd, "../../../exo_log_dcdr/exo_log_decoder/logdec_lin file ");
                strcat(decoder_cmd, log_file_name);
                printf("cmd: %s\n", decoder_cmd);
                //system("../../../exo_log_dcdr/exo_log_decoder/logdec_lin file obc_log.bin");  
                system(decoder_cmd); 
            }


        }
        else if(13 == tst_id)
        {
            printf("Enter ID 0 - SDRAM :\n");
            printf("Enter id 1 - QSPI NOR-FLASH :\n");
            printf("Enter ID 2 - FMC NOR-FLASH :\n");
            printf("Enter ID 3 - EEPROM_1 :\n");
            printf("Enter ID 4 - EEPROM_2 :\n");
            printf("Enter the memory type:\n");
            scanf("%hhd",&mem_type.mem_intf_type);
            if(mem_type.mem_intf_type==1 || mem_type.mem_intf_type == 2) 
            {
                printf("FULLCHIP TEST  - 1 :\n");
                printf("BLOCK LVL TEST -0\n");
                scanf("%hhd",&mem_type.block_or_fullchip);
            }
            printf("EXT_MEM_WRITE_55          - 0\n");
            printf("EXT_MEM_WRITE_AA          - 1\n");
            printf("EXT_MEM_WRITE_00          - 2\n");
            printf("EXT_MEM_WRITE_FF          - 3\n");
            printf("EXT_MEM_READ_55           - 4\n");
            printf("EXT_MEM_READ_AA           - 5\n");
            printf("EXT_MEM_READ_00           - 6\n");
            printf("EXT_MEM_READ_FF           - 7\n");
            printf("EXT_MEM_ERASE_WRITE_READ  - 8\n");
            printf("Enter the memory test type:\n");
            scanf("%hhd",&mem_type.test_type);
            mfcc_tc_send(TC_EXTRNL_MEM_TEST,TC_DST_OBC);

        }
        else if(14 == tst_id)
        {
            /* Get Telecommand ID to be sent from Ground station to COMMS Module */
            printf("Enter Telecommand ID \n");
            scanf(" %d", &tc_id);
            printf("Entered Telecommand ID: %d\n",tc_id);
            mfcc_tc_send(tc_id, TC_DST_XBND_COMMS);
        }
        else if(15 == tst_id)
        {
            /* Get Telecommand ID to be sent from Ground station to COMMS Module */
            printf("Enter Telecommand ID \n");
            if(autom_i < autom_user_input.autom_arg_cnt && autom_user_input.autom_argv_valid[autom_i])
            {
                tc_id = atoi((char*)autom_user_input.autom_argv[autom_i]);
            }
            else
            {
                scanf(" %d", &tc_id);
            }
            printf("Entered Telecommand ID: %d\n",tc_id);
            mfcc_tc_send(tc_id, TC_DST_UHF_COMMS);
            if(autom_user_input.autom_argv_valid[autom_i-1])
            {
                autom_i++;
                sleep(atoi((char*)autom_user_input.autom_argv[1]));
            }
        }
        else if(16 == tst_id)
        { 
            printf("set sband input configuration (1->Default, 2->User cfg):");
            scanf("%hhd",&comms_set);
            if(comms_set == 1)
            {
                printf("Sband Default input set\r\n");
            }
            else
            {
                printf("Sband user input cfg set\r\n");
            }
        }
        else if(17 == tst_id)
        {
            /* Test ID 15 will be used to exit from Ground Station EXE */
            printf("Manual Exit from User\n");
            exit(0);
        }
        else if(18 == tst_id)
        {
            printf("set UHF input configuration (1->Default, 2->User cfg):");
            scanf("%hhd",&uhf_set);
            if(uhf_set == 1)
            {
                printf("UHF Default input set\r\n");
            }
            else
            {
                printf("UHF user input cfg set\r\n");
            }
        }
        else if(19 == tst_id)
        {
            printf("OBC board bring up test\n");
            printf("GPIO pins test -     1\n");
            printf("sensors test   -     2\n");
            printf("GPIO expanders test -3\n");
            printf("Enter the test module:\n");
            scanf("%hhd",&obc_bringup_mdle);

            switch(obc_bringup_mdle)
            {
                case 1:
                    mfcc_tc_send(TC_TEST_GPIO,TC_DST_OBC);
                    break;
                case 2:
                    mfcc_tc_send(TC_TEST_SENSOR,TC_DST_OBC);
                    break;
                case 3:
                    mfcc_tc_send(TC_TEST_GPIO_EXP,TC_DST_OBC);
                    break;    

                default:
                    printf("Enter valid test module\n");
                    break;
            }

        }
        else if (20 == tst_id)
        {
            printf("\nEnter Radio ID: \n1 - SRS4 SBAND \n2 - UHF \n3 - IQS SBAND\n4 - GS2 Back door socket\n");
            scanf("%d",(int*)&radio_mod_id);
        }

        else if(21 == tst_id)
        {
            printf("\nEnter Error ID\n");
            printf("To Get all Faults      - 0\n");
            printf("To Read Group Status   - 1\n");
            printf("To Get Error History   - 2\n");
            printf("To Get Run Bist Option - 3\n");
            scanf("%hhd",&err_id);
            switch(err_id)
            {
                case 0:
                    mfcc_tc_send(TC_ERR_HANDLER_READ_FAULTS,TC_DST_OBC);
                    break;

                case 1:
                    mfcc_tc_send(TC_ERR_HANDER_READ_GROUP_ERROR_STATUS,TC_DST_OBC);
                    break;

                case 2:
                    mfcc_tc_send(TC_ERR_HANDLER_GET_ERROR_HISTORY,TC_DST_OBC);
                    break;

                case 3:
                    mfcc_tc_send(TC_ERR_HANDLER_RUN_BIST,TC_DST_OBC);
                    break;


                default:
                    printf("Invalid Error ID");
                    break;
            }        
        }

        else if(22 == tst_id)
        {
            /* Get Telecommand ID to be sent from Ground station to COMMS Module */
            printf("Enter Telecommand ID \n");
            scanf(" %d", &tc_id);
            printf("Entered Telecommand ID: %d\n",tc_id);
            mfcc_tc_send(tc_id, TC_DST_SDR_APP);
        }
        else if(23 == tst_id)
        {
            /* Get Telecommand ID to be sent from Ground station to COMMS Module */
            printf("Enter Telecommand ID \n");
            scanf(" %d", &tc_id);
            printf("Entered Telecommand ID: %d\n",tc_id);
            getchar();
            mfcc_tc_send(TC_HM_TEST_CASE_REQ, TC_DST_TEST_LAYER);
        }
        else if(24 == tst_id)
        {
            if(sch_tc_store_en == 0)
            {
                sch_tc_store_en =1;

                printf("\nNew File(0) or Merge with old File(1):");
                scanf("%hhu",&apd_owrt);
                if(apd_owrt == 1)
                {
                    file_w = fopen(SCH_TC_FILE, "r");
                    if (file_w == NULL) {

                        file_w = fopen(SCH_TC_FILE, "w");
                    }
                    else
                    {
                        fclose(file_w);
                        sch_tc_update_offset();
                        file_w = fopen(SCH_TC_FILE, "ab+");
                    }

                }
                else if(apd_owrt == 0)
                {
                    file_w = fopen(SCH_TC_FILE, "w");
                }

                if (file_w == NULL) {
                    printf("\nSCH File Open Error!-%s",SCH_TC_FILE);
                    exit(1);
                }
            }
            else
            {
                sch_tc_store_en =0;
                printf("\nSCH TC Write to File Stop Success\n");
                fclose(file_w);
            }

        }

        else
        {
            printf("Invalid Test ID Received - %d. Please try again. \n",tst_id);
        }

    }
}


char check_cfg_key_present(char *file_line, char const*cfg_key, char cfg_key_len)
{
    char ret;
    char read_key[50];

    //	printf("%s", file_line);
    memcpy(read_key, file_line, cfg_key_len);
    read_key[cfg_key_len-1]='\0';
    ret = strcmp(read_key, cfg_key);
    if(ret == 0)
    {
        //		printf("%s present\n",cfg_key);
    }
    else
    {
        printf("Error in %s %d\n",read_key, ret);
    }
    return ret;
}




int otsu_read_config_info(char *fileName)
{
    char ret_sts = 0;
    FILE* file = fopen(fileName, "r");
    char temp_str[6];

    if(!file)
    {
        printf("Unable to open : %s\n", fileName);
	fclose(file);
        return -1;
    }
    else
    {
        printf("Read otsu cfg file %s\n", fileName);
    }


    fgets(fread_line, sizeof(fread_line), file);
    // {software_version:10.13}
    ret_sts = check_cfg_key_present(fread_line, software_version, sizeof(software_version));
    if(ret_sts != 1)
    {

        memset(temp_str,'\0',sizeof(temp_str));
        memcpy(temp_str, fread_line+sizeof(software_version)-1, 2);
        otsu_cfg_sft_major = atoi(temp_str);
        memcpy(temp_str, fread_line+sizeof(software_version)-1+3, 2);
        otsu_cfg_sft_minor = atoi(temp_str);
        printf("1. Sft_ver    - %d.%d \n",otsu_cfg_sft_major, otsu_cfg_sft_minor);
    }
    else
    {
	fclose(file);
        return -2;
    }

    fgets(fread_line, sizeof(fread_line), file);
    //{boot_mode:2}
    ret_sts = check_cfg_key_present(fread_line, boot_mode, sizeof(boot_mode));
    if(ret_sts != 1)
    {
        memset(temp_str,'\0',sizeof(temp_str));
        memcpy(temp_str, fread_line+sizeof(boot_mode)-1, 1);
        otsu_cfg_bt_mod = atoi(temp_str);
        printf("2. bootmode  - %d \n",otsu_cfg_bt_mod);

    }
    else
    {
	fclose(file);
        return -3;
    }

    // {smooth_shutdown_time:0678}
    fgets(fread_line, sizeof(fread_line), file);
    ret_sts = check_cfg_key_present(fread_line, smooth_shutdown_time, sizeof(smooth_shutdown_time));
    if(ret_sts != 1)
    {
        memset(temp_str,'\0',sizeof(temp_str));
        if(fread_line[sizeof(smooth_shutdown_time)+3] != '}')
        {
            printf("shutdown time expects 4 digit input\n");
	    fclose(file);
            return -4;
        }
        memcpy(temp_str, fread_line+sizeof(smooth_shutdown_time)-1, 4);
        otsu_cfg_shuttime = atoi(temp_str);
        printf("3. shut time - %d seconds\n",otsu_cfg_shuttime);

    }
    else
    {
	fclose(file);
        return -4;
    }

    fgets(fread_line, sizeof(fread_line), file);
    ret_sts = check_cfg_key_present(fread_line, scheduled_boot_utc_time, sizeof(scheduled_boot_utc_time));
    if(ret_sts != 1)
    {
        memset(temp_str,'\0',sizeof(temp_str));
        memcpy(temp_str, fread_line+sizeof(scheduled_boot_utc_time)-1, 2);
        otsu_cfg_sch_time.tm_hour = atoi(temp_str);

        memcpy(temp_str, fread_line+sizeof(scheduled_boot_utc_time)-1+3, 2);
        otsu_cfg_sch_time.tm_min = atoi(temp_str);

        memcpy(temp_str, fread_line+sizeof(scheduled_boot_utc_time)-1+6, 2);
        otsu_cfg_sch_time.tm_sec = atoi(temp_str);

        printf("4. sch boot time - %d:%d:%d\n", otsu_cfg_sch_time.tm_hour, otsu_cfg_sch_time.tm_min, otsu_cfg_sch_time.tm_sec);

    }
    else
    {
	fclose(file);
        return -5;
    }

    fgets(fread_line, sizeof(fread_line), file);
    ret_sts = check_cfg_key_present(fread_line, scheduled_boot_date, sizeof(scheduled_boot_date));
    if(ret_sts != 1)
    {
        memset(temp_str,'\0',sizeof(temp_str));
        memcpy(temp_str, fread_line+sizeof(scheduled_boot_date)-1, 2);
        otsu_cfg_sch_time.tm_mday = atoi(temp_str);

        memcpy(temp_str, fread_line+sizeof(scheduled_boot_date)-1+3, 2);
        otsu_cfg_sch_time.tm_mon = atoi(temp_str);

        memcpy(temp_str, fread_line+sizeof(scheduled_boot_date)-1+6, 4);
        otsu_cfg_sch_time.tm_year = atoi(temp_str);
        otsu_cfg_sch_time.tm_isdst = 0;
        printf("5. sch boot date - %d/%d/%d\n", otsu_cfg_sch_time.tm_mday, otsu_cfg_sch_time.tm_mon, otsu_cfg_sch_time.tm_year);
    }
    else
    {
	fclose(file);
        return -6;
    }


    // {gs_contact_waittime_in_min:4321}
    fgets(fread_line, sizeof(fread_line), file);
    ret_sts = check_cfg_key_present(fread_line, gs_contact_waittime_in_min, sizeof(gs_contact_waittime_in_min));
    if(ret_sts != 1)
    {
        memset(temp_str,'\0',sizeof(temp_str));
        if(fread_line[sizeof(gs_contact_waittime_in_min)+3] != '}')
        {
            printf("gs contact wait time expects 4 digit input\n");
	    fclose(file);
            return -7;
        }
        memcpy(temp_str, fread_line+sizeof(gs_contact_waittime_in_min)-1, 4);
        otsu_cfg_gscont_waittime = atoi(temp_str);
        printf("6. gscontact wait time - %d minutes\n",otsu_cfg_gscont_waittime);

    }
    else
    {
	fclose(file);
        return -8;
    }


#if 0
    //{gs_sync_wait_utc_time:09:12:07}
    fgets(fread_line, sizeof(fread_line), file);
    ret_sts = check_cfg_key_present(fread_line, gs_sync_wait_utc_time, sizeof(gs_sync_wait_utc_time));
    if(ret_sts != 1)
    {
        memset(temp_str,'\0',sizeof(temp_str));
        memcpy(temp_str, fread_line+sizeof(gs_sync_wait_utc_time)-1, 2);
        otsu_cfg_gssync_time.tm_hour = atoi(temp_str);

        memcpy(temp_str, fread_line+sizeof(gs_sync_wait_utc_time)-1+3, 2);
        otsu_cfg_gssync_time.tm_min = atoi(temp_str);

        memcpy(temp_str, fread_line+sizeof(gs_sync_wait_utc_time)-1+6, 2);
        otsu_cfg_gssync_time.tm_sec = atoi(temp_str);

        printf("7. gssync time - %d:%d:%d\n", otsu_cfg_gssync_time.tm_hour, otsu_cfg_gssync_time.tm_min, otsu_cfg_gssync_time.tm_sec);

    }
    else
    {
	fclose(file);
        return -9;
    }

    fgets(fread_line, sizeof(fread_line), file);
    ret_sts = check_cfg_key_present(fread_line, gs_sync_wait_date, sizeof(gs_sync_wait_date));
    if(ret_sts != 1)
    {
        memset(temp_str,'\0',sizeof(temp_str));
        memcpy(temp_str, fread_line+sizeof(gs_sync_wait_date)-1, 2);
        otsu_cfg_gssync_time.tm_mday = atoi(temp_str);

        memcpy(temp_str, fread_line+sizeof(gs_sync_wait_date)-1+3, 2);
        otsu_cfg_gssync_time.tm_mon = atoi(temp_str);

        memcpy(temp_str, fread_line+sizeof(gs_sync_wait_date)-1+6, 4);
        otsu_cfg_gssync_time.tm_year = atoi(temp_str);
        otsu_cfg_gssync_time.tm_isdst = 0;
        printf("8. gssync date - %d/%d/%d\n", otsu_cfg_gssync_time.tm_mday, otsu_cfg_gssync_time.tm_mon, otsu_cfg_gssync_time.tm_year);
    }
    else
    {
	fclose(file);
        return -10;
    }

#endif
    fclose(file);

    return ret_sts;
}


void send_tc_otsu(uint8_t tc_id)
{
    s_otsu_tc_encode_def otsu_tc;
    uint16_t integ_test_cmd;
    //uint8_t get_time_sts;
    //sch_utc_s get_sch_time;
    uint8_t ret_sts;
    switch(tc_id)
    {
        case 1:   /* Get software version */
            memset(&otsu_tc, 0, sizeof(s_otsu_tc_encode_def));

            /* configure TC */
            // otsu_tc.otsu_msg_id = otsu_tc_software_vers;
            otsu_tc_encode(TC_OTSU_GET_VERSION, &otsu_tc,&otsu_tc_tm);
            mfcc_tc_send(TC_OTSU_GET_VERSION,TC_DST_OBC);
            break;

        case 2:   /* Get otsu status */
            memset(&otsu_tc, 0, sizeof(s_otsu_tc_encode_def));

            /* configure TC */
            // otsu_tc.otsu_msg_id = otsu_tc_firmware_status;
            otsu_tc_encode(TC_OTSU_CURRENT_STATUS, &otsu_tc,&otsu_tc_tm);
            mfcc_tc_send(TC_OTSU_CURRENT_STATUS,TC_DST_OBC);
            break;
        case 3:   /* Send Firmware Update Configure Params */
            memset(&otsu_tc, 0, sizeof(s_otsu_tc_encode_def));

            ret_sts = otsu_read_config_info("otsu_boot_config_param.txt");

            if(ret_sts != 0)
            {
                printf("Invalid cfg %d\n",ret_sts);
            }
            else
            {
                /* configure TC */
                //  otsu_tc.otsu_msg_id = otsu_tc_firmware_update_config;
                otsu_tc.fw_boot_cfg.boot_operation_ctrl = otsu_cfg_bt_mod;
                otsu_tc.fw_boot_cfg.shutdwn_process_timeout = otsu_cfg_shuttime; // seconds
                otsu_tc.fw_boot_cfg.sft_version = (otsu_cfg_sft_major << 8) | otsu_cfg_sft_minor;

                otsu_tc.fw_boot_cfg.schboot_utc_time.hours = otsu_cfg_sch_time.tm_hour;
                otsu_tc.fw_boot_cfg.schboot_utc_time.min = otsu_cfg_sch_time.tm_min;
                otsu_tc.fw_boot_cfg.schboot_utc_time.sec = otsu_cfg_sch_time.tm_sec;
                otsu_tc.fw_boot_cfg.schboot_utc_date.day = otsu_cfg_sch_time.tm_mday;
                otsu_tc.fw_boot_cfg.schboot_utc_date.month = otsu_cfg_sch_time.tm_mon;
                otsu_tc.fw_boot_cfg.schboot_utc_date.year = otsu_cfg_sch_time.tm_year;
                otsu_tc.fw_boot_cfg.gs_cont_failure_timeout = otsu_cfg_gscont_waittime;
                otsu_tc_encode(TC_OTSU_SEND_FW_UPDATE_BOOT_CFG, &otsu_tc,&otsu_tc_tm);
                mfcc_tc_send(TC_OTSU_SEND_FW_UPDATE_BOOT_CFG,TC_DST_OBC);
            }

            break;

        case 4:   /* Integeration test command */
            printf("Enter Integ test cmd 1 - FW validity pass\n");
            printf("Enter Integ test cmd 2 - FW validity fail\n");
            printf("Enter Integ test cmd 3 - Fallback 1 fail\n");
            printf("Enter Integ test cmd 4 - Fallback 2 fail\n");
            printf("Enter Integ test cmd 5 - Fallback 3 fail\n");
            printf("Enter Integ test cmd 6 - Fallback 4 fail\n");
            printf("Enter Integ test cmd 7 - sband failure on\n");
            printf("Enter Integ test cmd 8 - sband failure off\n");
            printf("Enter Integ test cmd 9 - FTDS ack enable\n");
            printf("Enter Integ test cmd 10 - FTDS ack disable\n");

            scanf(" %hd", &integ_test_cmd);
            if(integ_test_cmd != e_integ_tst_none && integ_test_cmd < e_integ_tst_max)
            {
                memset(&otsu_tc, 0, sizeof(s_otsu_tc_encode_def));

                /* Integertaion test cmd */
                //  otsu_tc.otsu_msg_id = otsu_tc_sft_integ_test;
                otsu_tc.integ_test_code = integ_test_cmd;
                otsu_tc_encode(TC_OTSU_INTEGERATION_TEST_CMD, &otsu_tc,&otsu_tc_tm);
                mfcc_tc_send(TC_OTSU_INTEGERATION_TEST_CMD,TC_DST_OBC);
            }
            else
            {
                printf("Invalid INteg Test ID Received - %d. Please try again. \n",integ_test_cmd);
            }

            break;

        case 5:   /*save context info */
            memset(&otsu_tc, 0, sizeof(s_otsu_tc_encode_def));

            /* configure TC */
            //  otsu_tc.otsu_msg_id = otsu_tc_get_fw_status;
            otsu_tc_encode(TC_OTSU_GET_FW_UPDATE_STS, &otsu_tc,&otsu_tc_tm);
            mfcc_tc_send(TC_OTSU_GET_FW_UPDATE_STS,TC_DST_OBC);
            break;

        case 6:   /* Get boot config */
            memset(&otsu_tc, 0, sizeof(s_otsu_tc_encode_def));

            /* configure TC */
            // otsu_tc.otsu_msg_id = otsu_tc_get_boot_config;
            otsu_tc_encode(TC_OTSU_GET_BOOT_CFG_INFO, &otsu_tc,&otsu_tc_tm);
            mfcc_tc_send(TC_OTSU_GET_BOOT_CFG_INFO,TC_DST_OBC);
            break;

        case 7:   /* Get gscontact waititme */

            memset(&otsu_tc, 0, sizeof(s_otsu_tc_encode_def));

            /*configure TC */
            // otsu_tc.otsu_msg_id = otsu_tc_get_gscont_waitime;
            otsu_tc_encode(TC_OTSU_READ_GSCONATCT_WAIT_TIME, &otsu_tc,&otsu_tc_tm);
            mfcc_tc_send(TC_OTSU_READ_GSCONATCT_WAIT_TIME,TC_DST_OBC);
            break;

        case 8:   /* Setgscontact waititme  */
            memset(&otsu_tc, 0, sizeof(s_otsu_tc_encode_def));

            // otsu_tc.otsu_msg_id = otsu_tc_set_gscont_waitime;
            otsu_tc_encode(TC_OTSU_SET_GSCONATCT_WAIT_TIME, &otsu_tc,&otsu_tc_tm);
            mfcc_tc_send(TC_OTSU_SET_GSCONATCT_WAIT_TIME,TC_DST_OBC);
            break;

        case 9:   /* get bootable 1  */
            memset(&otsu_tc, 0, sizeof(s_otsu_tc_encode_def));

            // otsu_tc.otsu_msg_id = otsu_tc_get_blt1;
            otsu_tc_encode(TC_OTSU_READ_BOOTABLE_BLT1, &otsu_tc,&otsu_tc_tm);
            mfcc_tc_send(TC_OTSU_READ_BOOTABLE_BLT1, TC_DST_OBC);
            break;

        case 10:   /* get bootable 2  */
            memset(&otsu_tc, 0, sizeof(s_otsu_tc_encode_def));

            // otsu_tc.otsu_msg_id = otsu_tc_get_blt2;
            otsu_tc_encode(TC_OTSU_READ_BOOTABLE_BLT2, &otsu_tc,&otsu_tc_tm);
            mfcc_tc_send(TC_OTSU_READ_BOOTABLE_BLT2,TC_DST_OBC);
            break;

        case 11:  /* get NVM soft version */
            memset(&otsu_tc, 0, sizeof(s_otsu_tc_encode_def));

            /* configure TC */
            // otsu_tc.otsu_msg_id = otsu_tc_nvm_sft_version;
            otsu_tc_encode(TC_OTSU_GET_NVM_FW_VERSION, &otsu_tc,&otsu_tc_tm);
            mfcc_tc_send(TC_OTSU_GET_NVM_FW_VERSION,TC_DST_OBC);


        default:
            printf("Invalid Test ID Received - %d. Please try again. \n",tc_id);
            break;

    }
}


void mfcc_tc_send(uint32 tc_id, uint16 da_id)
{
    int32 port = atoi(tctm_soc_inf.port_num);
    int32 addr = inet_addr(tctm_soc_inf.ip_addr);
    s_tc_frame *tc_orig_app;
    uint8 *dst;
    int8 status = 0;
    uint16 tc_len;
    //   uint16 num_events;
    uint32 ps_staged_tc_id;
    int32 size = 0;
    uint8 *tc_data = NULL;
    //    tctm_trgt_pt_req_s tpr;
    //uint8 tmp_cntr = 0;
    nvm_param nvm_data_hdr;
    uint8 *nvm_data_pld;
    evnt_time tc_time;
#if 0
    uint32 pld_hw_id;
#endif
    uint16 pld_vm_id;
    obc_vm_pwr_off_info_s vm_off;
    uint16 ipcc_test;
#if 0 
    uint8 pwr_ctrl;
#endif
    uint16 group;
    uint8 fallback;
    //    uint8 boot_opt;
    s_uhf_rf_cfg set_rf_cfg;
    s_uhf_rf_rx_cfg set_rf_rx_cfg;
    s_uhf_rf_tx_pkt_cfg set_rx_tc_pkt_cfg;
    s_uhf_rf_rx_pkt_cfg set_rf_rx_pkt_cfg;
    s_uhf_set_pwr_stng set_pwr_stng;
    s_sdr_cfg set_sdr_cfg;
    s_sdr_set_sts sdr_set_sts;
    s_sdr_tmr_cfg sdr_tmr_cfg;
    s_sdr_rx_rssi_cfg sdr_rx_rssi_cfg;
    s_sdr_tm_cfg sdr_tm_cfg;
    s_tctm_rm_overrule tctm_overrule ={0};

    s_gpass_beacon_cfg gpass_beacon_cfg={0};

    s_sdr_sens_cfg sdr_sns_cfg;
    s_comms_tx_cfg set_tx_cfg;
    s_comms_rx_cfg set_rx_cfg;
    s_comms_sys_cfg set_sys_cfg;
    s_comms_uart_cfg set_uart_cfg;
    s_comms_csp_cfg set_csp_cfg;
    s_comms_can_cfg set_can_cfg;
    s_comms_gwdt_cfg set_gwdt_cfg;
    s_comms_boot_cfg set_boot_cfg;
    s_comms_net_cfg set_net_cfg;
    s_comms_tx_crypto_cfg set_tx_crypto_cfg;
    s_comms_rx_crypto_cfg set_rx_crypto_cfg;
    s_comms_rx_afc_cfg set_rx_afc_cfg;
    //s_uhf_rf_cfg uhf_rf_cfg;
    SERVICE_START_RF_RCV_STRUCT xrf_r;
    SERVICE_VERSION_STRUCT xver;    
    SERVICE_VERSION_STRUCT_SET xver1; 
    SERVICE_RF_XMT_DATA_STRUCT xrf_xmt;
    SERVICE_DVBS2_CONF_STRUCT xdvbs2;
    SERVICE_IP_ADR_STRUCT xip_adr;
    SERVICE_DEVICE_CONF_STRUCT xdev;

    uint32 loop = 0;
    tctm_time_par_s *time;
    s_test_spi_uart_conv spi_uart_conv;
    /* Encryption related params */
    s_crypt_params param;
    uint8 key[] = {0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};

    uint8 iv[16] = {0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};

    /* Send buffer and frame memory allocations */
    tc_orig_app = (s_tc_frame *) malloc(sizeof(s_tc_frame));
    dst = (unsigned char *) malloc(MAX_TC_BUFF_SIZE);

    /* The above part need to be built in the Go Language */

    /* From here onwards TC TM library is used */
    /* Initialize telecommand structure instance */
    tc_orig_init(tc_orig_app);
    /* Configure Start of Frame */
    tc_orig_cfg_sof(tc_orig_app, TC_TM_LIB_SOF1, TC_TM_LIB_SOF2);
    /* Configure Satellite ID */
    tc_orig_cfg_sat_id(tc_orig_app, RECV_SAT_ID);
    /* Configure Ground station ID */
    tc_orig_cfg_gs_id(tc_orig_app, SOURCE_GROUND_STN_ID);
    /* Enable encryption */
    tc_orig_cfg_tc_ctrl(tc_orig_app, CRYPTO_ENCRYP_ENBL);
    /* Configure Quality of Service */
    tc_orig_cfg_qos(tc_orig_app, TC_QOS_CFG);
    /* Configure source address */
    tc_orig_cfg_sa_id(tc_orig_app, TC_SRC_GS);
    /* Configure Radio Module ID */
    //tc_orig_cfg_rm_id(tc_orig_app,RADIO_MOD_ID);
    tc_orig_cfg_rm_id(tc_orig_app,radio_mod_id);

    //printf("\n TC Radio ID: %d, %d",RADIO_MOD_ID,tc_orig_app->rm_id);
    printf("\n TC Radio ID: %d, %d",radio_mod_id,tc_orig_app->rm_id);
    /* Configure destination address */
    tc_orig_cfg_da_id(tc_orig_app, da_id);
    tc_orig_cfg_eof(tc_orig_app, TC_TM_LIB_EOF);
    if(da_id == TC_DST_EPS)
    {

        status =  eps_tc(tc_id, &tc_data, &tc_len);
        printf("status %d\n",status);
    }
    else
    {
        switch(tc_id)
        {

            case TC_THRUSTER_SET_MODE:
            case TC_THRUSTER_GET_MODE:
            case TC_THRUSTER_SET_FIRING_DURATION:
            case TC_THRUSTER_GET_FIRING_DURATION:
            case TC_THRUSTER_GET_INPUT_POWER_CONSMP: 
            case TC_THRUSTER_SET_RADIATOR_TEMP_LIMIT:
            case TC_THRUSTER_GET_RADIATOR_TEMP_LIMIT:
            case TC_THRUSTER_SET_TANK_PRESSURE_LIMIT:
            case TC_THRUSTER_GET_TANK_PRESSURE_LIMIT:
            case TC_THRUSTER_GET_REMAINING_PROPELLANT: 
            //case TC_THRUSTER_GET_ACTIVE_STATUS:
            case TC_THRUSTER_GET_ONBOARD_TEMPERATURE:
                     mfcc_thruster_tc_hdlr(tc_id,&tc_data,&tc_len);
                break; 

            case TC_GPS_GET_NMEA_GPGGA:
                tc_len = 0;
                tc_data = (uint8_t *)malloc(tc_len);
                break;

            case TC_GPS_GET_NMEA_GPRMC:
                tc_len = 0;
                tc_data = (uint8_t *)malloc(tc_len);
                break;

            case TC_GPS_GET_DATE_TIME:
                tc_len = 0;
                tc_data = (uint8_t *)malloc(tc_len);
                break;

            case TC_GPS_GET_3D_POSITION_VELOCITY:
                tc_len = 0;
                tc_data = (uint8_t *)malloc(tc_len);
                break;

            case TC_GPS_COMPUTE_TLE:
                tc_len = 0;
                tc_data = (uint8_t *)malloc(tc_len);
                break;

            case TC_GPS_GET_LOCATION_INFO:
                tc_len = 0;
                tc_data = (uint8_t *)malloc(tc_len);
                break;
            case TC_SET_GPS_TIME_SYNC_PRDCTY:
                {
                    uint32_t sts;
                    tc_len = 4;
                    tc_data = (uint8_t *)malloc(tc_len);
                    printf("Enter the gps sync periodicity in minutes\n");
                    scanf("%d",&sts);
                    if(sts == 0)
                    {
                        printf("Invalid value\n");
                        status = -1;
                    }
                    memcpy(tc_data,&sts,tc_len);
                }
                break;

            case TC_GET_GPS_TIME_SYNC_PRDCTY:
                tc_len = 0;
                tc_data = (uint8_t *)malloc(tc_len);
                break;

            case TC_SYNC_GPS_TIME:
                tc_len = 0;
                tc_data = (uint8_t *)malloc(tc_len);
                break;

            case TC_GPS_GET_GPS_TIME:
                tc_len = 0;
                tc_data = (uint8_t *)malloc(tc_len);
                break;

                /* Telecommand prepartion for Target Pointing Request */
                /*        case TC_TRGT_PT:
                          {
                          tc_len = sizeof(tpr);
                          tc_data = (uint8_t *) malloc(tc_len+1);
                          tpr.lat = 44;
                          tpr.longit = 72;;
                          tpr.alt = 101;
                          tpr.pld_hw_id = 3;
                          tpr.act_tmr_min = 10;
                          tpr.act_tmr_sec = 0;
                          tpr.act_tmr_ms = 0;
                          tc_data[0] = TC_TRGT_PT;
                          tc_trgt_point_req_enc(&tc_data[1], &tpr);
                          }
                          break;

                          case TC_LOC_INFO:
                          {
                          tc_len = 1;
                          tc_data = (uint8_t *) malloc(tc_len);
                          tc_data[0] = TC_LOC_INFO;
                          }
                          break;*/
#if 0
            case TC_PWR_CTRL_SBAND:
            case TC_PWR_CTRL_XBAND:
            case TC_PWR_CTRL_ADCS:
            case TC_PWR_CTRL_THRUSTER:

            case TC_PWR_CTRL_EDGE_BOARD:
                {
                    /* pack TC payload */
                    tc_len = sizeof(pwr_ctrl);
                    printf("Enter Power Control Mode: [1 - PowerON / 0 - PowerOFF]\n");
                    scanf("%d",(int*)&pwr_ctrl);
                    printf("Received power control is %d",pwr_ctrl);
                    tc_data = (uint8_t *) malloc(tc_len);
                    memcpy(tc_data,&pwr_ctrl,tc_len);
                }
                break;

            case TC_PS_PWR_ON:
                {
                    /* pack TC payload */
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);
                }
                break;
#endif
            case TC_OBC_SOFT_RESET:
                {
                    /* pack TC payload */
                    tc_len = sizeof(int);
                    tc_data = (uint8_t *) malloc(tc_len);
                    printf("Reset type 1-OTSU rst 2-Normal sw rst\nEnter OBC SW reset type\n");
                    scanf("%d",(int*)tc_data);
                    if(*(int*)tc_data == 1 || *(int*)tc_data == 2)
                    {
                        printf("Received reset type  %d",*tc_data);
                    }

                    else
                    { printf("Invalid Test ID\n");
                        status = -1;

                    }

                }
                break;

#if 0
            case TC_PLD_HW_PWR_ON:
                {
                    /* pack TC payload */
                    tc_len = sizeof(pld_hw_id);
                    printf("Enter Payload HW ID: \n");
                    scanf("%d",&pld_hw_id);
                    tc_data = (uint8_t *) malloc(tc_len);
                    memcpy(tc_data,&pld_hw_id,tc_len);
                }
                break;
#endif
            case TC_PLD_VM_PWR_ON:
                {
                    /* pack TC payload */
                    tc_len = sizeof(pld_vm_id);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(0 == tc_test_state)
                    {
                        printf("Enter VM ID to be Powered ON\n");
                        scanf("%hd",&pld_vm_id);
                    }
                    else
                    {
                        pld_vm_id = 0x89;
                    }
                    memcpy(tc_data,&pld_vm_id,tc_len);
                }
                break;
#if 0  
            case TC_PLD_HW_PWR_OFF:
                {
                    /* pack TC payload */
                    tc_len = sizeof(pld_hw_id);
                    printf("Enter Payload HW ID: \n");
                    scanf("%d",&pld_hw_id);
                    tc_data = (uint8_t *) malloc(tc_len);
                    memcpy(tc_data,&pld_hw_id,tc_len);
                }
                break;
#endif
            case TC_PLD_VM_PWR_OFF:
                {
                    /* pack TC payload */
                    tc_len = sizeof(vm_off);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(0 == tc_test_state)
                    {
                        printf("Enter VM ID to be Powered OFF\n");
                        scanf("%hd",&vm_off.vm_id);
                        vm_off.shut_tmr_min = 0;
                        vm_off.shut_tmr_sec = 60;
                        vm_off.shut_tmr_ms = 0;
                        vm_off.shut_purpose = ICM_SP_LOW_BTRY;
                    }
                    memcpy(tc_data,&vm_off,tc_len);
                }
                break;
#if 0
            case TC_PS_PWR_OFF:
                {
                    /* pack TC payload */
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);
                }
                break;
#endif
            case TC_TTY_START:
                {
                    /* pack TC payload */
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);
                }
                break;

            case TC_TTY_END:
                {
                    /* pack TC payload */
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);
                }
                break;

            case TC_TTY_DEBUG:
                {
                    /* pack TC data */
                    memset(tty_dcdu_buff,0,sizeof(tty_dcdu_buff));
                    printf("Enter command to be sent to PS\n");
                    scanf(" %[^\n]", tty_dcdu_buff);
                    printf("Received content from user is %s\n",tty_dcdu_buff);
                    tc_len = strlen(tty_dcdu_buff);
                    tty_dcdu_buff[tc_len++] = '\0';//Additional char is for null to terminate
                    printf("Length decoding is %d\n",tc_len);
                    tc_data = (uint8_t *) malloc(tc_len);
                    memcpy(tc_data,tty_dcdu_buff,tc_len);
                    //tc_tty_data_enc(tc_data,(uint8*)tty_dcdu,tc_len);
                }
                break;

            case TC_SET_MIN_REBOOT_TIME:
                {
                    uint32_t rbt_time;
                    /* pack TC data */
                    printf("Enter the minimum reboot time in minutes\n");
                    scanf(" %d",&rbt_time);
                    printf("Received time in minutes from user is %d\n",rbt_time);
                    tc_len = 4;
                    tc_data = (uint8_t *) malloc(tc_len);
                    memcpy(tc_data,&rbt_time,tc_len);
                }
                break;

            case TC_GET_SENSOR_DATA:
                {
                    printf("DT_DS620_EDGE - 5\n");
                    printf("DT_DS620_PS - 6\n");
                    printf("HSC_ADM1176_EDGE - 7\n");
                    printf("HSC_ADM1176_PS_2 - 8\n");
                    printf("HSC_ADM1176_PS_1 - 9\n");
                    printf("TEMP_SENSOR_MCP9843_OBC - 10\n");
                    printf("TEMP_SENSOR_MCP9843_PS - 11\n");
                    printf("TEMP_SENSOR_MCP9843_EDGE - 12\n");
                    printf("TEMP_SENSOR_MCP9843_GPS - 13\n");
                    printf("DT_DS620_SOLAR_PANNEL_E01 - 14\n");
                    printf("DT_DS620_SOLAR_PANNEL_E02 - 15\n");
                    printf("DT_DS620_SOLAR_PANNEL_W01 - 16\n");
                    printf("DT_DS620_SOLAR_PANNEL_W02 - 17\n");
                    printf("DT_DS620_SOLAR_PANNEL_B01 - 18\n");
                    printf("POWER_SENSE_MONITOR_OBC - 19\n");
                    printf("POWER_SENSE_MONITOR_PS - 20\n");

                    printf("Enter the sensor AHW ID\n");
                    scanf("%d",&ahw_id);
                    if(ahw_id < 5 || ahw_id > 20)
                    {
                        printf("Invalid Test ID\n");
                        status = -1;
                    }

                    printf("AHW ID==%d\n",ahw_id);
                    /* pack TC data */
                    tc_len = sizeof(uint32_t);
                    tc_data = (uint8_t *) malloc(tc_len);

                    /* encode */
                    memcpy(tc_data,&ahw_id,tc_len);
                }
		break;

	    case TC_PS_BRD_SELECT:
		{
			/* TC for payload board select*/
			tc_len = sizeof(ps_brd_id);
			tc_data = (uint8_t *) malloc(tc_len);
			printf("Select Payload Board\n 1 - PS_BRD_1\n 2 - PS_BRD_2\n 3 - BOTH_PS_BOARD_OFF\n Enter PS board type\n");
			scanf("%hhd",&ps_brd_id.ps_id);
			//printf("Select payload ssd \n 1-SSD_BRD_1\n 2-SSD_BRD_2\n 3-SSD_BRD_3\n 4-SSD_BRD_4\nEnter ssd id type\n");
			//scanf("%hhd",&ps_brd_id.ps_ssd_id);
			if(ps_brd_id.ps_id == 1 || ps_brd_id.ps_id == 2)
			{
				printf("Select payload ssd \n 1-SSD_BRD_1\n 2-SSD_BRD_2\n 3-SSD_BRD_3\n 4-SSD_BRD_4\nEnter ssd id type\n");
				scanf("%hhd",&ps_brd_id.ps_ssd_id);
				printf("Received PS board type %d",tc_data[0]);
			}
			else if(ps_brd_id.ps_ssd_id == 1 || ps_brd_id.ps_ssd_id == 2 || ps_brd_id.ps_ssd_id == 3 || ps_brd_id.ps_ssd_id == 4)
			{
				printf("Received PS Board SSD %d",tc_data[1]);
			}
			else if(ps_brd_id.ps_id == 3)
			{
				printf("Received PS board type %d",tc_data[0]);
			}
			else
			{ printf("Invalid Test ID\n");
				status = -1;
			}
			os_memcpy(tc_data, &ps_brd_id, tc_len);
		}
		break;

	    case TC_ES_BRD_SELECT:
                {
                    /* TC for Edge board select*/
                    tc_len = sizeof(uint8_t);
                    tc_data = (uint8_t *) malloc(tc_len);
                    printf("Select Edge Board\n 1 - ES_BRD_1\n 2 - ES_BRD_2\n 3 - BOTH_ES_BRD_OFF\n Enter ES board type\n");
                    scanf("%hhd",&tc_data[0]);
                    if(tc_data[0] == 1 || tc_data[0] == 2 || tc_data[0] == 3)
                    {
                        printf("Received ES board type %d",*tc_data);
                    }

                    else
                    { 
                        printf("Invalid Test ID\n");
                        status = -1;
                    }

                    }
                break;

     	    case TC_AUTO_SENSOR_TEST:
                tc_len = 0;
                tc_data = (uint8_t *)malloc(tc_len);
                break;

            case TC_ADC_SELECT:
                {
                    //adc_board_read adc_brd_read;
                    uint8_t counter;
                    uint8_t counter_1;
                    do{
                        if(counter!=0)
                        {
                            printf("INVALID ADC ID,Enter inputs again \n");
                        }
                        counter ++;
                        printf("SELECT the ADC ID :\n 67-ADC_AD7291_PS_1 \n 70-ADC_AD7291_PS_2\n 81-ADC_AD7291_ORING_CIRCUIT\n");
                        scanf("%hhd",&adc_brd_read.adc_id);
		   // }while(adc_brd_read.adc_id == 67 || adc_brd_read.adc_id == 70 || adc_brd_read.adc_id == 81);
                    }while(adc_brd_read.adc_id < 67 || adc_brd_read.adc_id > 81);

                    do{
                        if(counter_1!=0)
                        {
                            printf("INVALID channel ID,Enter inputs again \n");
                        }
                        counter_1 ++;
                        printf("Select ADC Channel Select:\n 1 - CHNL_1\n 2 - CHNL_2\n 3 - CHNL_3\n 4 - CHNL_4\n 5 - CHNL_5\n 6 - CHNL_6\n 7 - CHNL_7\n 8 - CHNL_8\n");
                        scanf("%hhd",&adc_brd_read.adc_chnl_id);
                    }while(adc_brd_read.adc_chnl_id < 1 || adc_brd_read.adc_chnl_id > 8);
                    tc_len = sizeof(adc_brd_read);
                    tc_data = (uint8_t *) malloc(tc_len);
                    os_memcpy(tc_data,&adc_brd_read,sizeof(adc_brd_read));
                }
                break;

	    case TC_IO_BRD_SELECT:
		{
			/* TC for Edge board select*/
			tc_len = sizeof(uint8_t);
			tc_data = (uint8_t *) malloc(tc_len);
			printf("Select IO Board\n 1-IO_BRD_1\n 2-IO_BRD_2\nEnter IO board type\n");
			scanf("%hhd",&tc_data[0]);
			if(tc_data[0] == 1 || tc_data[0] == 2)
			{
				printf("Received IO board type %d",*tc_data);
			}

			else
			{
				printf("Invalid Test ID\n");
				status = -1;
			}

		}
		break;
/*	    
	    case TC_PS_SSD_BRD_SELECT:
		{
			tc_len = sizeof(uint8_t);
			tc_data = (uint8_t *) malloc(tc_len);
			printf("Select payload ssd \n 1-SSD_BRD_1\n 2-SSD_BRD_2\n 3-SSD_BRD_3\n 4-SSD_BRD_4\nEnter ssd id type\n");
			scanf("%hhd",&tc_data[0]);
			if(tc_data[0] == 1 || tc_data[0] == 2)
			{
				printf("Received IO board type %d",*tc_data);
			}
			else
			{
				printf("Invalid Test ID\n");
				status = -1;
			}
		}
		break;
*/
	    case TC_ES_SSD_BRD_SELECT:
		{
			tc_len = sizeof(uint8_t);
			tc_data = (uint8_t *) malloc(tc_len);
			printf("Select edge board ssd \n 1-ES_1_SSD_1\n 2-ES_1_SSD_2 \n 3-ES_2_SSD_1 \n 4-ES_2_SSD_2 \n Enter ssd id type\n");
			scanf("%hhd",&tc_data[0]);
			if(tc_data[0] == 1 || tc_data[0] == 2 || tc_data[0] == 3 || tc_data[0] == 4)
			{
				printf("Received IO board type %d",*tc_data);
			}
			else
			{
				printf("Invalid Test ID\n");
				status = -1;
			}
		}
		break;

	    case TC_I2C_ADXL345_TEST:
		{
			tc_len = sizeof(uint8_t);
			tc_data = (uint8_t *) malloc(tc_len);
			printf("Select I2C \n 1-I2C_1\n 2-I2C_2 \n 3-I2C_3 \n 4-I2C_4 \n Enter I2C id type\n");
			scanf("%hhd",&tc_data[0]);
			if(tc_data[0] == 1 || tc_data[0] == 2 || tc_data[0] == 3 || tc_data[0] == 4)
			{
				printf("Received IO board type %d",*tc_data);
			}
			else
			{
				printf("Invalid Test ID\n");
				status = -1;
			}

		}
		break;
           
            case TC_SPI_ADXL345_TEST:
                {
                    tc_len = sizeof(uint8_t);
                    tc_data = (uint8_t *) malloc(tc_len);
                    printf("\n");
                    printf("\nSPI ADXL345 TEST STARTED\n\n");
                }
               break;

       case TC_UART_TX_RX_TEST:
       {
                    tc_len = sizeof(uint16_t);
                    tc_data = (uint8_t*)malloc(tc_len);
                    printf("\nSelect UART \n 1 - UART_4\n 2 - UART_5\n Enter UART id type\n");
                    scanf("%hhd",&tc_data[0]);
                    if(tc_data[0] == 1 || tc_data[0] == 2)
                    {
                        printf("\nSelect Transmission Type: \n 1-TX \n 2-RX \n");
                        scanf("%hhd",&tc_data[1]);
                        if(tc_data[1] == 1 ||  tc_data[1] == 2)
                        {
                            printf("\n");
                        }
                        else
                        {
                            printf("\nInvalid Test ID : %hhd\n",tc_data[1]);
                            status = -1;
                        }
                    }
                    else
                    {
                        printf("Invalid Test ID\n");
                        status = -1;
                    }
       }
       break;

            case TC_CAN_TX_RX_TEST:
                {
                    tc_len = sizeof(uint8_t);
                    tc_data = (uint8_t*)malloc(tc_len);
                    printf("\nSelect CAN Transmission Type: \n 1-TX \n 2-RX\n");
                    scanf("%hhd",&tc_data[0]);
                    if(tc_data[0] == 1 || tc_data[0] == 2)
                    {
                        printf("\nReceived IO board type %d",*tc_data);
                    }
                    else
                    {
                        printf("Invalid Test ID\n");
                        status = -1;
                    }
                }
                break;

        case TC_SET_SPI_INTF_PARM:
                {
                    /* pack TC payload */
                    tc_len = sizeof(spii);
                    tc_data = (uint8_t *) malloc(tc_len);
                    spii.mode = 12;
                    spii.direction = 0;
                    spii.datasize = 33;
                    spii.clk_polarity = 34;
                    spii.clk_phase = 35;
                    spii.nss = 31;
                    spii.baudrate_prescaler = 76;
                    spii.firstbit = 32;
                    spii.timode = 14;
                    spii.crc_calculation = 15;
                    spii.crc_polynomial = 16;
                    spii.crc_length = 14;
                    spii.nssp_mode = 11;
                    tc_spi_intf_param_enc(tc_data, &spii);


                }
                break;
            case TC_SET_ETH_INTF_PARM:
                {
                    /* pack TC payload */
                    tc_len = sizeof(eth);
                    tc_data = (uint8_t *) malloc(tc_len);
                    eth.auto_negotiation = 0;
                    eth.speed = 89;
                    eth.duplex_mode = 34;
                    eth.phy_address = 23;
                    eth.mac_addr = (uint8*)21;
                    eth.rx_mode = 21;
                    eth.checksum_mode = 20;
                    eth.media_interface = 10;
                    tc_ethernet_init_param_enc(tc_data, &eth);


                }
                break;
            case TC_SET_CAN_INTF_PARM:
                {
                    /* pack TC payload */
                    tc_len = sizeof(cis);
                    tc_data = (uint8_t *) malloc(tc_len);
                    cis.prescaler = 1;
                    cis.mode = 4;
                    cis.syncjumpwidth = 56;
                    cis.time_seg1 = 23;
                    cis.time_seg2 = 22;
                    cis.time_triggered_mode = 2;
                    cis.autobus_off = 0;
                    cis.autowake_up = 90;
                    cis.auto_retransmission = 12;
                    cis.receive_fifo_locked = 21;
                    cis.transmit_fifo_priority = 11;
                    tc_can_init_param_enc(tc_data, &cis);


                }
                break;
            case TC_SET_I2C_INTF_PARM:
                {
                    /* pack TC payload */
                    tc_len = sizeof(i2ci);
                    tc_data = (uint8_t *) malloc(tc_len);
                    i2ci.timing = 100;
                    i2ci.own_address1 = 24;
                    i2ci.addressing_mode = 26;
                    i2ci.dual_address_mode = 77;
                    i2ci.own_address2 = 9;
                    i2ci.own_address2_masks = 10;
                    i2ci.generalcall_mode = 21;
                    i2ci.no_stretch_mode = 20;
                    tc_i2c_init_param_enc(tc_data, &i2ci);


                }
                break;
            case TC_SET_USB_INTF_PARM:
                {
                    /* pack TC payload */
                    tc_len = sizeof(usbo);
                    tc_data = (uint8_t *) malloc(tc_len);
                    usbo.dev_endpoints = 8;
                    usbo.host_channels = 6;
                    usbo.speed = 2;
                    usbo.dma_enable = 1;
                    usbo.ep0_mps = 23;
                    usbo.phy_itface = 10;
                    usbo.sof_enable = 13;
                    usbo.low_power_enable = 34;
                    usbo.lpm_enable = 22;
                    usbo.battery_charging_enable = 90;
                    usbo.vbus_sensing_enable = 80;
                    usbo.use_dedicated_ep1 = 34;
                    usbo.use_external_vbus = 35;
                    tc_usb_init_param_enc(tc_data, &usbo);


                }
                break;

            case TC_SET_UART_INTF_PARM:
                {
                    /* pack TC payload */
                    tc_len = sizeof(uarti);
                    tc_data = (uint8_t *) malloc(tc_len);
                    uarti.baudrate = 34;
                    uarti.wordlength = 1;
                    uarti.stopbits = 0;
                    uarti.parity = 2;
                    uarti.mode = 5;
                    uarti.hw_flow_ctl = 6;
                    uarti.over_sampling = 9;
                    uarti.onebit_sampling = 11;
                    tc_uart_init_param_enc(tc_data, &uarti);


                }
                break;
            case TC_GET_SPI_INTF_PARM:
                {
                    /* pack TC payload */
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                }
                break;

            case TC_GET_ETH_INTF_PARM:
                {
                    /* pack TC payload */
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);
                }
                break;

            case TC_GET_CAN_INTF_PARM:
                {
                    /* pack TC payload */
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);


                }
                break;

            case TC_GET_I2C_INTF_PARM:
                {
                    /* pack TC payload */
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);
                }
                break;

            case TC_GET_USB_INTF_PARM:
                {
                    /* pack TC payload */
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);
                }
                break;

            case TC_GET_UART_INTF_PARM:
                {
                    /* pack TC payload */
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);
                }
                break;

            case TC_GET_SYS_UPTIME:
                {
                    /* pack TC payload */
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);
                }
                break;

            case TC_GET_PROC_UTIL_INFO:
                {
                    /* pack TC payload */
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);
                }
                break;

            case TC_GET_MEM_UTIL_INFO:
                {
                    /* pack TC payload */
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                }
                break;

            case TC_GET_FTM_SAVECONTEXT_STS:
                {
                    /* pack TC payload */
                    uint8_t module_id;
                    printf("Select below module for SCT status\n");
                    printf("1. OTSU\n");
                    printf("2. ADCS\n");
                    printf("3. COMMS\n");
                    printf("4. EPS\n");
                    scanf("%hhu",&module_id);
                    tc_len  = 1;
                    tc_data = (uint8_t *) malloc(tc_len);
                    memcpy(tc_data, &module_id, tc_len);

                }
                break;

            case TC_OBC_MEM_DOWLOAD:
                {
                    obc_mem_dwldr_def obc_mem_info;
                    printf("Enter the Type of Memory for Download\n");
                    printf("0. I_RAM\n");
                    printf("1. E_RAM\n");
                    printf("2. I_FLASH\n");
                    printf("3. E_QSPI_FLASH\n");
                    printf("4. E_FMC_FLASH\n");
                    scanf("%hhu",&obc_mem_info.mem_type);
                    if(obc_mem_info.mem_type >= 5)
                    {
                        printf("Invalid Memory Type\n");
                    }
                    else
                    {
                        printf("Enter the Memory Address in decimal format ex: 0x20001320 address to be entered as 536875808\n");
                        scanf("%lu",&obc_mem_info.mem_address);
                        printf("Enter the Size to Download\n");
                        scanf("%d",&obc_mem_info.mem_size);
                        printf("Enter the size of MTU\n");
                        scanf("%hu",&obc_mem_info.ftm_mtu_cfg);
                        printf("Enter Satellite FTDS delay in ms\n");
                        scanf("%hu",&obc_mem_info.ftm_ftds_cfg);
                        printf("Sequence loss detection: Enter 1 to enable or 0 to disable\n");
                        printf("        Note: sequnece loss detection uses duplex communication\n");
                        scanf("%hhu",&obc_mem_info.ftm_seq_detct_cfg);
                        tc_len = sizeof(obc_mem_dwldr_def);
                        tc_data = (uint8_t *)malloc(tc_len);
                        os_memcpy(tc_data, &obc_mem_info, tc_len);
                    }
                }
                break;

            case TC_SET_TEMP_SNS_CFG:
                {
                    printf("Enter the instance id of temperature sensor:\n");
                    printf("TEMP_SENSOR_MCP9843_OBC - 10\n");
                    printf("TEMP_SENSOR_MCP9843_PS - 11\n");
                    printf("TEMP_SENSOR_MCP9843_EDGE - 12\n");
                    printf("TEMP_SENSOR_MCP9843_GPS - 13\n");
                    printf("DT_DS620_SOLAR_PANNEL_E01 - 14\n");
                    printf("DT_DS620_SOLAR_PANNEL_E02 - 15\n");
                    printf("DT_DS620_SOLAR_PANNEL_W01 - 16\n");
                    printf("DT_DS620_SOLAR_PANNEL_W02 - 17\n");
                    printf("DT_DS620_SOLAR_PANNEL_B01 - 18\n");

                    scanf("%d",&temp_sns_cfg.instance_id);
                    printf("Enter the Polling timer periodicity in milli seconds:\n");
                    scanf("%d",&temp_sns_cfg.polling_tmr_prdcty);
                    printf("Enter the high temperature threshold of temperature sensor:\n");
                    scanf("%f",&temp_sns_cfg.high_temp_thrsld);
                    printf("Enter the low temperature threshold of temperature sensor:\n");
                    scanf("%f",&temp_sns_cfg.low_temp_thrsld);
                    printf("Enter the adc resolution of temperature sensor:\n");
                    printf("0.5 - 0\n0.25 - 1[Default]\n0.125 - 2\n0.0625 - 3\n");
                    scanf("%hhu",&temp_sns_cfg.adc_resolution);
                    printf("Enter the conversion type for temperature sensor:\n Oneshot - 0\n Continous conv -1[Default]\n");
                    scanf("%hhu",&temp_sns_cfg.conversion_type);
                    printf("Enter the Interrupt enable/disable\n Enable -1[Default]\nDisable -0:\n");
                    scanf("%hhu",&temp_sns_cfg.intr_mask);
                    printf("Enter the interrupt pin polarity\n");
                    printf("Active Low -0[Default]\nActive High -1\n");
                    scanf("%hhu",&temp_sns_cfg.intr_pin_polarity);

                    /* pack TC data */
                    tc_len = sizeof(temp_sens_cfg);
                    tc_data = (uint8_t *) malloc(tc_len);

                    /* encode */
                    memcpy(tc_data,&temp_sns_cfg,tc_len);

                }
                break;

            case TC_GET_TEMP_SNS_CFG:
                {
                    /* pack TC payload */
                    tc_len = 4;
                    tc_data = (uint8_t *) malloc(tc_len);
                    printf("Enter the instance id of Temperature sensor:\n");
                    printf("TEMP_SENSOR_MCP9843_OBC - 10\n");
                    printf("TEMP_SENSOR_MCP9843_PS - 11\n");
                    printf("TEMP_SENSOR_MCP9843_EDGE - 12\n");
                    printf("TEMP_SENSOR_MCP9843_GPS - 13\n");
                    printf("DT_DS620_SOLAR_PANNEL_E01 - 14\n");
                    printf("DT_DS620_SOLAR_PANNEL_E02 - 15\n");
                    printf("DT_DS620_SOLAR_PANNEL_W01 - 16\n");
                    printf("DT_DS620_SOLAR_PANNEL_W02 - 17\n");
                    printf("DT_DS620_SOLAR_PANNEL_B01 - 18\n");
                    scanf("%d",&ahw_id);
                    memcpy(tc_data,&ahw_id,4);
                }
                break;

            case TC_SET_IMU_CFG:
                {

                    printf("Enter the instance id of imu sensor:\n");
                    scanf("%d",&imu_para.instance_id);
                    printf("Enter the power of imu sensor:\n");
                    scanf("%hhd",&imu_para.power);
                    printf("Enter the odr of imu sensor:\n");
                    scanf("%hhd",&imu_para.odr);
                    printf("Enter the range of imu sensor:\n");
                    scanf("%hhd",&imu_para.range);
                    printf("Enter the bandwidth of imu sensor:\n");
                    scanf("%hhd",&imu_para.bw);

#ifdef SNS_GET_INF_PRINT

                    printf("instance_id = %d \n",imu_para.instance_id);
                    printf("power = %d \n",imu_para.power);
                    printf("odr = %d \n",imu_para.odr);
                    printf("bw = %d \n",imu_para.bw);
                    printf("range = %d \n",imu_para.range);
#endif
                    /* pack TC data */
                    tc_len = sizeof(imu_param);
                    tc_data = (uint8_t *) malloc(tc_len);

                    /* encode */
                    memcpy(tc_data,&imu_para,tc_len);
                }
                break;

            case TC_GET_IMU_CFG:
                {
                    /* pack TC payload */
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);
                }
                break;

            case TC_SET_THRUST_CTRL_CFG:
                {
                    thrstr_para.instance_id=3;
                    thrstr_para.unit_num=2;
                    thrstr_para.mode=0;
                    thrstr_para.force=8.89;

#ifdef SNS_GET_INF_PRINT
                    printf("instance_id = %d \n",thrstr_para.instance_id);
                    printf("unit_num = %d \n",thrstr_para.unit_num);
                    printf("mode = %d \n",thrstr_para.mode);
                    printf("force = %f \n",thrstr_para.force);
#endif
                    /* pack TC data */
                    tc_len = sizeof(thruster_param);
                    tc_data = (uint8_t *) malloc(tc_len);
                    /* encode */
                    memcpy(tc_data,&thrstr_para,tc_len);
                }
                break;

            case TC_GET_THRUST_CTRL_CFG:
                {
                    /* pack TC payload */
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);
                }
                break;

            case TC_SET_GPIO_EXP_CFG:
                {
                    printf("Enter the instance  id of gpio expander:\n");
                    scanf("%d",&gpio_expdr_cfg.instance_id);
                    printf("Enter the interrupt pin polarity of gpio expander:\n");
                    scanf("%hhd",&gpio_expdr_cfg.intr_pin_polarity);


#ifdef SNS_GET_INF_PRINT
                    printf("instance_id = %d \n",gpio_expdr_cfg.instance_id);
                    printf("intr_pin_polarity = %d \n",gpio_expdr_cfg.intr_pin_polarity);
#endif
                    /* pack TC data */
                    tc_len = sizeof(gpio_exp_cfg);
                    tc_data = (uint8_t *) malloc(tc_len);
                    /* encode */
                    memcpy(tc_data,&gpio_expdr_cfg,tc_len);

                }
                break;

            case TC_GET_GPIO_EXP_CFG:
                {
                    /* pack TC payload */
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);
                }
                break;

            case TC_SET_DIG_THERM_CFG:
                {

                    printf("Enter the instance id  of digital thermostat:\n");
                    printf("DT_DS620_EDGE - 5\n");
                    printf("DT_DS620_PS - 6\n");

                    scanf("%d",&dgtl_thrmst_cfg.instance_id);
                    printf("Enter the Periodic Polling frequency in milli seconds\n");
                    scanf("%d",&dgtl_thrmst_cfg.polling_tmr_prdcty);
                    printf("Enter the high temperature threshold of digital thermostat:\n");
                    scanf("%f",&dgtl_thrmst_cfg.high_temp_thrsld);
                    printf("Enter the low temperature threshold of digital thermostat:\n");
                    scanf("%f",&dgtl_thrmst_cfg.low_temp_thrsld);
                    printf("Enter the Thermostat enable status\nEnable -1[Default]\nDisable -0\n");
                    scanf("%hhu",&dgtl_thrmst_cfg.thrmst_enable);
                    printf("Enter the Thermostat pin polarity:\n");
                    printf("Active Low -0[Default]\nActive High -1\n");
                    scanf("%hhu",&dgtl_thrmst_cfg.thrmst_pin_polarity);
                    printf("Enter the ADC resolution\n");
                    printf("0.5 - 0\n0.25 - 1\n0.125 - 2\n0.0625 - 3[Default]\n");
                    scanf("%hhu",&dgtl_thrmst_cfg.adc_resolution);
                    printf("Enter the conversion type\nOneshot - 0\nContinous conv - 1[Default]\n");
                    scanf("%hhu",&dgtl_thrmst_cfg.conversion_type);

                    /* pack TC data */
                    tc_len = sizeof(digital_thermostat_cfg);
                    tc_data = (uint8_t *) malloc(tc_len);
                    /* encode */
                    memcpy(tc_data,&dgtl_thrmst_cfg,tc_len);
                }
                break;

            case TC_GET_DIG_THERM_CFG:
                {
                    printf("Enter the Instance id of Digital thermostat sensor:\n");
                    printf("DT_DS620_EDGE - 5\n");
                    printf("DT_DS620_PS - 6\n");
                    /* pack TC payload */
                    tc_len = 4;
                    tc_data = (uint8_t *) malloc(tc_len);
                    scanf("%d",&ahw_id);
                    memcpy(tc_data,&ahw_id,4);
                }
                break;

            case TC_SET_PWR_MON_CFG:
                {
                    printf("Enter the Instance id of power monitor sensor:\n");
                    printf("POWER_SENSE_MONITOR_OBC - 19\n");
                    printf("POWER_SENSE_MONITOR_PS - 20\n");

                    scanf("%d",&pwr_sns_mtr_cfg.instance_id);
                    printf("Enter the Periodic Polling frequency in milli seconds\n");
                    scanf("%d",&pwr_sns_mtr_cfg.polling_tmr_prdcty);
                    printf("Enter the Event trigger type\n");
                    printf("Event None - 0\nOver Current event - 1[Default]\n");
                    scanf("%hhu",&pwr_sns_mtr_cfg.intr_type);
                    printf("Enter the Current threshold in Amps\n");
                    scanf("%f",&pwr_sns_mtr_cfg.current_thrsld);
                    printf("Enter the conversion type\nOneshot - 0\nContinous conv - 1[Default]\n");
                    scanf("%hhu",&pwr_sns_mtr_cfg.conversion_type);
                    printf("Enter the Interrupt pin polarity\n");
                    printf("Active Low -0[Default]\nActive High -1\n");
                    scanf("%hhu",&pwr_sns_mtr_cfg.intr_pin_polarity);

#if 0
                    printf("instance_id = %d \n",pwr_sns_mtr_cfg.instance_id);
                    printf("vbus_thrsld = %f \n",pwr_sns_mtr_cfg.vbus_thrsld);
                    //printf("vshunt_thrsld = %f \n",pwr_sns_mtr_cfg.vshunt_thrsld);
                    //printf("calibration = %d \n",pwr_sns_mtr_cfg.calibration);
#endif
                    /* pack TC data */
                    tc_len = sizeof(power_mntr_sns_cfg);
                    tc_data = (uint8_t *) malloc(tc_len);

                    /* encode */
                    memcpy(tc_data,&pwr_sns_mtr_cfg,tc_len);
                }
                break;
            case TC_GET_PWR_MON_CFG:
                {
                    printf("Enter the Instance id of power monitor sensor:\n");
                    printf("POWER_SENSE_MONITOR_OBC - 19\n");
                    printf("POWER_SENSE_MONITOR_PS - 20\n");

                    /* pack TC payload */
                    tc_len = 4;
                    tc_data = (uint8_t *) malloc(tc_len);
                    scanf("%d",&ahw_id);
                    memcpy(tc_data,&ahw_id,4);

                }
                break;
            case TC_SET_VOLT_CTRL_MON_CFG:
                {
                    printf("Enter the instance id of hotswap controller:\n");
                    printf("HSC_ADM1176_EDGE - 7\n");
                    printf("HSC_ADM1176_PS_2 - 8\n");
                    printf("HSC_ADM1176_PS_1 - 9\n");
                    scanf("%d",&htswp_cntlr_cfg.instance_id);
                    printf("Enter the Periodic Polling frequency in milli seconds\n");
                    scanf("%d",&htswp_cntlr_cfg.polling_tmr_prdcty);
                    printf("Enter the current threshold:\n");
                    scanf("%f",&htswp_cntlr_cfg.current_thrsld);
                    printf("Enter the voltage threshold:\n");
                    scanf("%f",&htswp_cntlr_cfg.voltage_thrsld);
                    printf("Enter the Interrupt Enable/Disable status:\n");
                    printf("Interrupt Enable - 1\nDisable status - 0\n");
                    scanf("%hhu",&htswp_cntlr_cfg.intr_msk);

                    //  printf("Enter the hotswap status of hotswap controller:\n");
                    //    scanf("%d",&htswp_cntlr_para.hotswap_sts);

#if 0
                    printf("instance_id = %d \n",htswp_cntlr_cfg.instance_id);
                    printf("hotswap_sts = %d \n",htswp_cntlr_cfg.hotswap_sts);
#endif

                    tc_len = sizeof(hotswap_cntlr_cfg);
                    tc_data = (uint8_t *) malloc(tc_len);

                    /* encode */
                    memcpy(tc_data,&htswp_cntlr_cfg,tc_len);
                }
                break;

            case TC_GET_VOLT_CTRL_MON_CFG:
                {
                    printf("Enter the instance id of hotswap controller:\n");
                    printf("HSC_ADM1176_EDGE - 7\n");
                    printf("HSC_ADM1176_PS_2 - 8\n");
                    printf("HSC_ADM1176_PS_1 - 9\n");

                    /* pack TC payload */
                    tc_len = 4;
                    tc_data = (uint8_t *) malloc(tc_len);
                    scanf("%d",&ahw_id);
                    memcpy(tc_data,&ahw_id,4);

                }
                break;

            case TC_SET_PWR_SEQ_MON_CFG:
                {

                    printf("Enter the instance id of voltage sequencer:\n");
                    scanf("%d",&vltg_seq_mntr_cfg.instance_id);


#if 0
                    printf("instance_id = %d \n",vltg_seq_mntr_para.instance_id);
                    printf("flash_lock_sts = %d \n",vltg_seq_mntr_para.flash_lock_sts);
                    printf("v_ref_type = %d \n",vltg_seq_mntr_para.v_ref_type);
#endif

                    /* pack TC data */
                    tc_len = sizeof(voltage_seq_mntr_cfg);
                    tc_data = (uint8_t *) malloc(tc_len);

                    /* encode */
                    memcpy(tc_data,&vltg_seq_mntr_cfg,tc_len);
                }
                break;
            case TC_GET_PWR_SEQ_MON_CFG:
                {
                    /* pack TC payload */
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                }
                break;
            case TC_SET_DATA_LOG_CFG:
                {

                    printf("Enter the instance id of data loggerr:\n");
                    scanf("%d",&data_acq_para.instance_id);
                    printf("Enter the channel number of data loggerr:\n");
                    scanf("%hhd",&data_acq_para.chnl_num);
                    printf("Enter the power down option of data loggerr:\n");
                    scanf("%hhd",&data_acq_para.pwr_dwn_optn);

#ifdef SNS_GET_INF_PRINT
                    printf("instance_id = %d \n",data_acq_para.instance_id);
                    printf("chnl_num = %d \n",data_acq_para.chnl_num);
                    printf("pwr_dwn_optn = %d \n",data_acq_para.pwr_dwn_optn);
#endif

                    /* pack TC data */
                    tc_len = sizeof(data_acq_dvc_param);
                    tc_data = (uint8_t *) malloc(tc_len);

                    /* encode */
                    memcpy(tc_data,&data_acq_para,tc_len);
                }
                break;

            case TC_GET_DATA_LOG_CFG:
                {
                    /* pack TC payload */
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                }
                break;

            case TC_TEST_GPIO:
                {
                    uint8_t state = 0;
                    tc_len = sizeof(uint32_t);
                    tc_data = (uint8_t *) malloc(tc_len);
                    printf("\n*******GEN2_V2_BOARD GPIO Pin Toggle Test******\n\r");
                    printf("ENTER THE GPIO TEST TYPE\n");
                    printf("1 - Input Test\n");
                    printf("2 - Output Test\n");
                    scanf("%hhd",&gpio_pin_type);
                    if(gpio_pin_type == 1 || gpio_pin_type == 2)
                    {
                        memcpy(tc_data , &gpio_pin_type , sizeof(uint8_t));
                        switch(tc_data[0])
                        {
                            case 1:
                                {
                                    printf("\n--------------------------------\n");
                                    printf("SSD_EXPANDER_INTRPT	(PA3)   -1\n\r");
                                    printf("SHUTDOWN_REQ		(PB0)   -2\n\r");
                                    printf("CORE_IO1_EXPD_INT	(PC2)   -3\n\r");
                                    printf("EDGE_U40_EXPD_INT	(PC3)   -4\n\r");
                                   // printf("GPIO_PG10    	        (PG10)  -5\n\r");
                                  //  printf("SPI_UART_IRQ    	(PG11)  -6\n\r");
                                    printf("GPS_IO_EXPD_INT		(PJ0)   -5\n\r");
                                    printf("GPIO_PJ10               (PJ10)  -6\n\r");
                                    printf("CORE_IO2_EXPD_INT 	(PJ13)  -7\n\r");
                                    printf("RESETBT_CORE_PCB 	(PJ14)  -8\n\r");
                                    printf("PAYLOAD_PCB_SEN_ALERT 	(PK0)   -9\n\r");
                                    printf("PAYLOAD_TEM_SEN_INT 	(PK2)   -10\n\r");
                                    printf("EDGE_IO_INT 	    	(PK3)   -11\n\r");
                                    printf("CORE_IO3_EXPD_INT 	(PK6)   -12\n\r");
                                    printf("PWRBT_CORE_PCB 		(PK7)   -13\n\r");
                                    printf("\n Select GPIO pin ID= ");
                                    scanf("%hhd",&gpio_pin_id);
                                    if(gpio_pin_id < 1 || gpio_pin_id > 13)
                                    {
                                        state = -1;
                                    }
                                }
                                break;
                            case 2:
                                {
                                    printf("\n--------------------------------\n");
                                    printf("POWER_EN  		    	(PB1)	-1\n\r");
                                    printf("SYS_RESET 	    		(PB5)	-2\n\r");
                                    printf("PS_MUX_PC6			(PC6)	-3\n\r");
                                    printf("OPTICAL_I2C_SEL 		(PC8)	-4\n\r");
                                    printf("PS_TRIGGER_SW_SEL 		(PD8)	-5\n\r");
                                    printf("PS_USB_SEL 			(PG9)	-6\n\r");
                                   // printf("GPIO_PG10    	                (PG10)  -7\n\r");
                                   // printf("SPI_UART_IRQ    	        (PG11)  -8\n\r");
                                    printf("CORE_ETH_UART5_SW_SEL	        (PI8)	-7\n\r");
                                    printf("EDGE_GBE_SEL 	    	        (PI11)	-8\n\r");
                                    printf("GPS_SW_SELECTION 		(PI12)	-9\n\r");
                                    printf("EDGE_UART_SW_SEL 		(PI13)	-10\n\r");
                                    printf("POER10_SEL 	    		(PI14)	-11\n\r");
                                    printf("ADCS_PWR_EN			(PJ1)	-12\n\r");
                                    printf("QUADSPI_BK1_NCS2 		(PJ3)	-13\n\r");
                                    printf("PS_CAN_SW_SEL  		    (PJ5)	-14\n\r");
                                    printf("CORE_1PPS_1 	    	    (PJ6)	-15\n\r");
                                    printf("CORE_PS_SW_SEL  		(PJ7)	-16\n\r");
                                    printf("PS_ETH_SEL			(PJ8)	-17\n\r");
                                    printf("PAY_CAN_SWSELECTION 	        (PJ11)	-18\n\r");
                                    printf("SSD_HEAT_ENABLE  		(PJ12)	-19\n\r");
                                    printf("CORE_EDGE_SW_SEL  		(PJ15)	-20\n\r");
                                    printf("CORE_I2C2_SEL   		(PK1)	-21\n\r");
                                    printf("\n Select GPIO pin ID= ");
                                    scanf("%hhd",&gpio_pin_id);
                                    if(gpio_pin_id < 1 || gpio_pin_id > 21)
                                    {
                                        state = -1;
                                    } 
                                    else
                                    {
                                        printf("\n----------------------------------\n");
                                        printf("ENTER THE GPIO OPERATION\n");
                                        printf("1 - HIGH\n");
                                        printf("2 - LOW\n");
                                        scanf("%hhd",&gpio_pin_op);
                                        if(gpio_pin_op == 1 || gpio_pin_op == 2)
                                        {
                                            memcpy(tc_data + sizeof(uint16_t), &gpio_pin_op, sizeof(uint8_t));
                                        }
                                        else
                                            state = -1;
                                    }
                                }
                                break;
                            default:
                                printf("\nInvaild GPIO Pin Test Type\n");
                        }
                        if(state == 0)
                        {
                            memcpy(tc_data + sizeof(uint8_t), &gpio_pin_id , sizeof(uint8_t));
                        }
                        else
                        {
                            printf("\nInvaild GPIO Pin ID\n");
                        }
                    }
                    else
                        printf("\nInvaild GPIO Pin Test Type\n");
                }
                break;
            case TC_TEST_SENSOR:

                { 
                    uint32_t sensor_id = 0;
                    tc_len = sizeof(uint32_t);
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("\nHSC ADM1176 EDGE                    - 7\n\r");
                    printf("HSC ADM1176 PS_2                      - 8\n\r");
                    printf("HSC ADM1176 PS_1                      - 9\n\r");
                    printf("HSC_ADM1176_PAYLOAD_BRD_IN_SUPPLY     - 47\n\r");
                    printf("HSC_ADM1176_PS_1_IN_SUPPLY            - 65\n\r");
                    printf("HSC_ADM1176_PS_2_IN_SUPPLY            - 68\n\r");
                    printf("HSC_ADM1176_EDGE_1_IN_SUPPLY          - 71\n\r");
                    printf("HSC_ADM1176_EDGE_1_HEAT_COIL          - 73\n\r");
                    printf("HSC_ADM1176_EDGE_2_IN_SUPPLY          - 74\n\r");
                    printf("HSC_ADM1176_EDGE_2_HEAT_COIL          - 76\n\r");
                    printf("HSC_ADM1176_IO_BRD_IN_SUPPLY          - 77\n\r");
                    printf("HSC_ADM1176_IO_BRD_HEAT_COIL_TOP_1    - 79\n\r");
                    printf("HSC_ADM1176_IO_BRD_HEAT_COIL_TOP_2    - 80\n\r");
                    printf("HSC_ADM1176_IO_BRD_HEAT_COIL_BOTTOM_1 - 82\n\r");
                    printf("HSC_ADM1176_IO_BRD_HEAT_COIL_BOTTOM_2 - 83\n\r");
                    printf("\n");

                    printf("TEMPERATURE_SENSOR_MCP9843_OBC        - 10\n\r");
                    printf("TEMPERATURE_SENSOR_MCP9843 PS         - 11\n\r");
                    printf("TEMP_SENSOR_MCP9843_EDGE              - 12\n\r");
                    printf("TEMPERATURE SENSOR MCP9843 GPS        - 13\n\r");
                    printf("\n");
                    
                    printf("TEMP_SENSOR_MCP9824_EDGE_1            - 41\n\r");
                    printf("TEMP_SENSOR_MCP9824_EDGE_2            - 43\n\r");
                    printf("TEMP_SENSOR_MCP9824_PS_GEN_2          - 46\n\r");
                    printf("TEMP_SENSOR_MCP9824_NIC_1             - 53\n\r");
                    printf("TEMP_SENSOR_MCP9824_SSD_1             - 56\n\r");
                    printf("TEMP_SENSOR_MCP9824_SSD_2             - 57\n\r");
                    printf("TEMP_SENSOR_MCP9824_SSD_3             - 58\n\r");
                    printf("TEMP_SENSOR_MCP9824_SSD_4             - 59\n\r");
                    printf("\n");

                    printf("DIGITAL THERMOSTAT DS620 EDGE         - 5\n\r");
                    printf("DIGITAL THERMOSTAT DS620 PS           - 6\n\r");
                    printf("POWER SENSE MONITOR OBC               - 19\n\r");
                    printf("POWER SENSE MONITOR PS                - 20\n\r");
                    printf("\n");
                    
                    printf("PSM_INA230_PS_GEN_2                   - 48\n\r");
                    printf("PSM_INA230_CORE_BRD_A                 - 61\n\r");
                    printf("PSM_INA230_CORE_BRD_B                 - 63\n\r");
                    printf("PSM_INA230_PS_1                       - 66\n\r");
                    printf("PSM_INA230_PS_2                       - 69\n\r");
                    printf("PSM_INA230_EDGE_1                     - 72\n\r");
                    printf("PSM_INA230_EDGE_2_IN_SUPPLY           - 75\n\r");
                    printf("PSM_INA230_IO_BRD_IN_SUPPLY           - 78\n\r");
                    printf("\n");
 
                    printf("ADC_AD7291_PS_1                       -67\n\r");
                    printf("ADC_AD7291_PS_2                       -70\n\r");
                    printf("ADC_AD7291_ORING_CIRCUIT              -81\n\r");

                    printf("ENTER THE SENSOR ID:\n");
                    printf("\n");

                    scanf("%d",&sensor_id);
                    if(sensor_id > 5 || sensor_id < 90)
                   
                        //if ((sensor_id >= 5 && sensor_id <= 13) || sensor_id == 19 || sensor_id == 20)
                    {
                        printf("TEST SENSOR ID =%d\n",sensor_id);
                        memcpy(tc_data ,&sensor_id ,4);
                    }
                    else
                    {
                        printf("Invalid Test ID\n");
                        status = -1;
                    }

                }
                break;

            case TC_TEST_GPIO_EXP:
                {
                    uint32_t gpio_exp_id ;
                    tc_len = sizeof(uint32_t);
                    tc_data = (uint8_t *) malloc(tc_len);
                    printf("ENTER THE GPIO EXP ID\n");
                    printf("GPIO EXP_PCAL6408A PS    -21\n\r");			
                    printf("GPIO EXP_MCP23008 EDGE_1 -22\n\r");			
                    printf("GPIO EXP_MCP23008 EDGE_2 -23\n\r");		
                    printf("GPIO EXP_MCP23008 OBC_1  -24\n\r");	
                    printf("GPIO EXP_MCP23008 OBC_2  -25\n\r");	
                    printf("GPIO EXP_MCP23008 GPS    -26\n\r");		

                    printf("GPIO_EXPANDER_MCP23008_EDGE_1_GEN_2    - 40\n\r");
                    printf("GPIO_EXPANDER_MCP23008_EDGE_2_GEN_2    - 42\n\r");
                    printf("GPIO_EXPANDER_MCP23008_EDGE_3_GEN_2    - 44\n\r");
                    printf("GPIO_EXPANDER_MCP23008_EDGE_4_GEN_2    - 45\n\r");
                    printf("GPIO_EXPANDER_PCAL6408_PS_GEN_2        - 49\n\r");
                    printf("GPIO_EXPANDER_MCP23008_NIC_1           - 50\n\r"); 
                    printf("GPIO_EXPANDER_MCP23008_NIC_2           - 51\n\r");
                    printf("GPIO_EXPANDER_MCP23008_NIC_3           - 52\n\r");
                    printf("GPIO_EXPANDER_MCP23008_SSD_1           - 54\n\r");
                    printf("GPIO_EXPANDER_MCP23008_SSD_2           - 55\n\r");
                    printf("GPIO_EXPANDER_MCP23008_BACK_PLANE      - 60\n\r");
                    printf("GPIO_EXPANDER_MCP23008_POWER_BOARD_1   - 62\n\r");
                    printf("GPIO_EXPANDER_MCP23008_POWER_BOARD_2   - 64\n\r");
                    printf("GPIO_EXPANDER_MCP23008_POWER_BOARD_3   - 84\n\r");

                    scanf("%d",& gpio_exp_id);
                    if(gpio_exp_id < 21 || gpio_exp_id > 84)
                    {
                        printf("Invalid Test ID\n");
                        status = -1;
                    }
                    printf("TEST GPIO EXP ID =%d",gpio_exp_id);
                    memcpy(tc_data ,&gpio_exp_id ,4);


                }
                break;
/*
            case TC_SPI_UART_CONV_TEST:
                {
                    uint8_t counter;
                    uint8_t counter_1;
                    do{
                        if(counter != 0)
                        {
                            printf("INVALID ID, Enter input again \n");
                        }
                        counter ++;
                        printf("Enter the Test mode \n0- Self test mode\n1- TX Test\n2- RX Test\n");
                        scanf("%hhd",&spi_uart_conv.test_mode);
                    }while(spi_uart_conv.test_mode == 0 || spi_uart_conv.test_mode == 1 || spi_uart_conv.test_mode == 2);
                    do {
                        if(counter_1 != 0)
                        {
                            printf("INVALID ID, Enter input again \n");
                        }
                        counter_1 ++;
                        printf("Enter the Channel ID\n0- Channel 0\n1- Channel 1\n2- Channel 2\n3- Channel 3\n");
                        scanf("%hhd",&spi_uart_conv.channel_id);

                    }if(spi_uart_conv.test_mode == 1)
                    {
                        printf("Enter the TX Data, MAX Data length:15 bytes\n");
                        scanf("%15s",&spi_uart_conv.data[0]);
                        printf("Entered string value: %s\n",&spi_uart_conv.data[0]);
                    }
                    tc_len = sizeof(s_test_spi_uart_conv);
                    tc_data = (uint8_t *)malloc(tc_len);
                    memcpy(tc_data,&spi_uart_conv,sizeof(s_test_spi_uart_conv));
                    status =0;
                }
                break;
*/
	    case TC_SPI_UART_CONV_TEST:
		{
			uint8_t counter = 0;
			uint8_t counter_1 = 0;

			do {
				if (counter != 0) {
					printf("INVALID ID, Enter input again \n");
				}
				counter++;
				printf("Enter SPI-UART self test mode \n0- Self test mode\n1- TX Test\n2- RX Test\n");
				scanf("%hhd", &spi_uart_conv.test_mode);
			} while (spi_uart_conv.test_mode != 0 && spi_uart_conv.test_mode != 1 && spi_uart_conv.test_mode != 2);

			do {
				if (counter_1 != 0) {
					printf("INVALID ID, Enter input again \n");
				}
				counter_1++;
				if(spi_uart_conv.test_mode!=0)
				{
					printf("Enter the Channel ID\n0- Channel 0\n1- Channel 1\n2- Channel 2\n3- Channel 3\n");
					scanf("%hhd", &spi_uart_conv.channel_id);
			}
				else
				{
				spi_uart_conv.channel_id =0;
				}
				} while (spi_uart_conv.channel_id != 0 && spi_uart_conv.channel_id != 1 && spi_uart_conv.channel_id != 2 && spi_uart_conv.channel_id != 3);
			if (spi_uart_conv.test_mode == 1) {
				printf("Enter the TX Data, MAX Data length:15 bytes\n");
				scanf("%15s", &spi_uart_conv.data[0]);
				printf("Entered string value: %s\n", &spi_uart_conv.data[0]);
			}
			tc_len = sizeof(s_test_spi_uart_conv);
			tc_data = (uint8_t *)malloc(tc_len);
			memcpy(tc_data, &spi_uart_conv, sizeof(s_test_spi_uart_conv));
			status = 0;
		}
		break;


            case  TC_NVM_COMMIT:
                {		
                    uint8_t nvm_data;
                    tc_len = 1;
                    tc_data = (uint8_t *) malloc(tc_len);
                    printf("Enter 1 to nvm commit \n Enter 2 to exit\n");
                    scanf("%hhd", &nvm_data);
                    if(nvm_data == 1 || nvm_data == 2)
                    {
                        if(nvm_data == 1)
                        {
                            status=0;
                            memcpy(tc_data ,&nvm_data  ,1);
                        }
                        else 
                        {
                            status=1;

                        }
                    }
                    else
                    {
                        printf("Invalid Test ID\n");
                        status = -1;
                    }
                }
                break;

            case  TC_NVM_COMMIT_PRDCTY_TIM_CFG:
                {
                    uint32_t nvm_data_timer;
                    tc_len = 4;
                    tc_data = (uint8_t *) malloc(tc_len);
                    printf("ENTER THE NVM PERIODICITY TIME IN SECONDS\n");
                    scanf("%d", &nvm_data_timer);
                    memcpy(tc_data ,&nvm_data_timer ,1);
                }
                break;

            case TC_SET_CUR_TIME:
                {
                    /* pack TC data */
                    time = malloc(sizeof(tctm_time_par_s));
                    tc_len = sizeof(tctm_time_par_s);
                    get_crnt_time_date(time);
                    tc_data = (uint8_t *) malloc(tc_len);

                    /*time.Hour = 5;
                      time.Minute = 30;
                      time.Seconds = 0;
                      time.Date = 4;
                      time.Month = 11;
                      time.Year = 22;
                      time.Weekday = 2;*/
                    tc_set_cur_time_enc(tc_data,time);
                    free(time);
                    printf(" set Time %d %d %d \r\n",tc_data[0], tc_data[1],tc_data[2]);
                    printf(" set Time %d %d %d \r\n",tc_data[0], tc_data[1],tc_data[2]);
                }
                break;
            case TC_FTCI:
            case TC_FTFCI:
            case TC_FTDS:
            case TC_FTSR:
            case TC_FTDB:
                {
                    status = 1;

                    /* Configure Telecommand ID */
                    tc_orig_cfg_tc_id(tc_orig_app, tc_id);

                    /* Configure Telecommand Length */
                    tc_orig_cfg_tc_len(tc_orig_app, ft_pld_tx.payload_len);
                    /* Configure Telecommand payload */
                    tc_orig_cfg_tc_data (tc_orig_app, ft_pld_tx.payload_ptr);

                    /* Configure Encryption parameters */
                    tc_orig_app->cmac_hmac = (uint8_t *) malloc(SHA256_HASH_SIZE);
                    memcpy(param.iv, iv, 16);
                    param.key_size = 256;
                    param.key = (unsigned char *)malloc(param.key_size);
                    memcpy(param.key, key, param.key_size);
                    param.encrypt_mode = CRYPT_AES_CFB8;
                    tc_orig_select_encryption(&param);

                    /* Generate Telecommand as binary data stream */
                    size = tc_pack(dst, tc_orig_app);
                    /* Send generated Telecommand via socket interface */
                    mfcc_tcp_send(addr, port, dst, size);
                    free(ft_pld_tx.payload_ptr);
                    free(param.key);
                    free(tc_orig_app->cmac_hmac);
                }
                break;




            case TC_OTSU_GET_VERSION:
            case TC_OTSU_CURRENT_STATUS:
            case TC_OTSU_SEND_FW_UPDATE_BOOT_CFG:
            case TC_OTSU_INTEGERATION_TEST_CMD:
            case TC_OTSU_GET_FW_UPDATE_STS:
            case TC_OTSU_GET_BOOT_CFG_INFO:
            case TC_OTSU_READ_GSCONATCT_WAIT_TIME:
            case TC_OTSU_SET_GSCONATCT_WAIT_TIME:
            case TC_OTSU_READ_BOOTABLE_BLT1:
            case TC_OTSU_READ_BOOTABLE_BLT2:
            case TC_OTSU_GET_NVM_FW_VERSION:
            case TC_OTSU_NOTIFICATION:
                {
                    status = 1;
                    printf("[OTSU] TC sent..  \n");

                    /* Configure Telecommand ID */
                    tc_orig_cfg_tc_id(tc_orig_app, tc_id);


                    /* Configure Telecommand Length */
                    tc_orig_cfg_tc_len(tc_orig_app, otsu_tc_tm.tctm_size);
                    /* Configure Telecommand payload */
                    tc_orig_cfg_tc_data (tc_orig_app, otsu_tc_tm.tctm_ptr);

                    /* Configure Encryption parameters */
                    tc_orig_app->cmac_hmac = (uint8_t *) malloc(SHA256_HASH_SIZE);
                    memcpy(param.iv, iv, 16);
                    param.key_size = 256;
                    param.key = (unsigned char *)malloc(param.key_size);
                    memcpy(param.key, key, param.key_size);
                    param.encrypt_mode = CRYPT_AES_CFB8;
                    tc_orig_select_encryption(&param);

                    /* Generate Telecommand as binary data stream */
                    size = tc_pack(dst, tc_orig_app);
                    /* Send generated Telecommand via socket interface */
                    mfcc_tcp_send(addr, port, dst, size);
                    free(otsu_tc_tm.tctm_ptr);
                }
                break;



                /* Telecommand prepartion to set comms TX config */
            case TC_SET_COMMS_TX_CFG:
                {
                    /* pack TC data */
                    tc_len = sizeof(s_comms_tx_cfg);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {                                 
                        set_tx_cfg.tx_cfg_freq = 2242500000;
                        set_tx_cfg.tx_cfg_type = 0;
                        set_tx_cfg.tx_cfg_rate = 1000000;
                        set_tx_cfg.tx_cfg_rolloff = 1;
                        set_tx_cfg.tx_cfg_pout = 33;
                        set_tx_cfg.tx_cfg_alc_mode = 76;
                        set_tx_cfg.tx_cfg_rs = 0;
                        set_tx_cfg.tx_cfg_cc = 1;
                        set_tx_cfg.tx_cfg_rand = 1;
                        set_tx_cfg.tx_cfg_crc = 1;
                        set_tx_cfg.tx_cfg_idletime = 30;
                        if(radio_mod_id == 3)
                        {
                            set_tx_cfg.tx_cfg_size = 1432;
                        }
                        else 
                        {
                            set_tx_cfg.tx_cfg_size = 217;
                        }
                        set_tx_cfg.tx_cfg_id = 0;
                        memcpy(&set_tx_cfg.crypto_cfg.crypto_key,"0",sizeof("0"));
                        set_tx_cfg.crypto_cfg.crypto_encrypt = 0;
                        set_tx_cfg.crypto_cfg.crypto_auth = 0;
                        set_tx_cfg.tx_cfg_pa_templimit = 80;
                        set_tx_cfg.tx_cfg_frames = 0;
                        set_tx_cfg.tx_cfg_pwr_fwd = 0;
                        set_tx_cfg.tx_cfg_pwr_rfl = 0;
                    }
                    else
                    {
                        printf("Transmit frequency: ");
                        scanf("%u",&set_tx_cfg.tx_cfg_freq);
                        printf("Transmit modulation type (0 = BPSK 1 = QPSK 2 = 8PSK): ");
                        scanf("%hhu",&set_tx_cfg.tx_cfg_type);
                        printf("Transmit symbol rate: ");
                        scanf("%d",&set_tx_cfg.tx_cfg_rate);
                        printf("RRC rolloff(0 = 0.20 1 = 0.25 2 = 0.35): ");
                        scanf("%hhu",&set_tx_cfg.tx_cfg_rolloff);
                        printf("Transmit power : ");
                        scanf("%f",&set_tx_cfg.tx_cfg_pout);
                        printf("Automatic Level Control mode (0 = open-loop 1 = closed-loop): ");
                        scanf("%hhu",&set_tx_cfg.tx_cfg_alc_mode);
                        printf("Enable Reed-Solomon coding (Type: 0 is FALSE or 1 is TRUE): ");
                        scanf("%hhu",&set_tx_cfg.tx_cfg_rs);
                        printf("Enable convolutional coding (Type: 0 is FALSE or 1 is TRUE): ");
                        scanf("%hhu",&set_tx_cfg.tx_cfg_cc);
                        printf("Enable randomization (Type: 0 is FALSE or 1 is TRUE): ");
                        scanf("%hhu",&set_tx_cfg.tx_cfg_rand);
                        printf("Enable CRC checksum (Type: 0 is FALSE or 1 is TRUE): ");
                        scanf("%hhu",&set_tx_cfg.tx_cfg_crc);
                        printf("Active transmitter time after each frame: ");
                        scanf("%hi",&set_tx_cfg.tx_cfg_idletime);
                        printf("Maximum payload size: ");
                        scanf("%hi",&set_tx_cfg.tx_cfg_size);
                        printf("Satellite ID/address: ");
                        scanf("%hi",&set_tx_cfg.tx_cfg_id);
                        printf("Encryption key: ");
                        scanf("%s",(char *)&set_tx_cfg.crypto_cfg.crypto_key);
                        printf("Encrypt frames(Type: 0 is FALSE or 1 is TRUE): ");
                        scanf("%hhu",&set_tx_cfg.crypto_cfg.crypto_encrypt);
                        printf("Add authentication tag(Type: 0 is FALSE or 1 is TRUE): ");
                        scanf("%hhu",&set_tx_cfg.crypto_cfg.crypto_auth);
                        printf("PA temperature limit : ");
                        scanf("%hhd",&set_tx_cfg.tx_cfg_pa_templimit);
                    }
                    printf("Transmit frequency :%u\n",set_tx_cfg.tx_cfg_freq);
                    printf("Transmit modulation type (0 = BPSK 1 = QPSK 2 = 8PSK):%hu\n",set_tx_cfg.tx_cfg_type);
                    printf("Transmit symbol rate:%d\n",set_tx_cfg.tx_cfg_rate);
                    printf("RRC rolloff(0 = 0.20 1 = 0.25 2 = 0.35):%hu\n",set_tx_cfg.tx_cfg_rolloff);
                    printf("Transmit power :%f\n", set_tx_cfg.tx_cfg_pout);
                    printf("Automatic Level Control mode (0 = open-loop 1 = closed-loop):%hu\n", set_tx_cfg.tx_cfg_alc_mode);
                    printf("Enable Reed-Solomon coding (Type: 0 is FALSE or 1 is TRUE):%hu\n", set_tx_cfg.tx_cfg_rs);
                    printf("Enable convolutional coding (Type: 0 is FALSE or 1 is TRUE):%hu\n", set_tx_cfg.tx_cfg_cc);
                    printf("Enable randomization (Type: 0 is FALSE or 1 is TRUE):%hu\n",set_tx_cfg.tx_cfg_rand);
                    printf("Enable CRC checksum (Type: 0 is FALSE or 1 is TRUE):%hu\n", set_tx_cfg.tx_cfg_crc);
                    printf("Active transmitter time after each frame:%hi\n",set_tx_cfg.tx_cfg_idletime);
                    printf("Maximum payload size:%hi\n",set_tx_cfg.tx_cfg_size);
                    printf("Satellite ID/address:%hi\n",set_tx_cfg.tx_cfg_id);
                    printf("Encryption key:%s\n",set_tx_cfg.crypto_cfg.crypto_key);
                    printf("Encrypt frames(Type: 0 is FALSE or 1 is TRUE):%hu\n",set_tx_cfg.crypto_cfg.crypto_encrypt);
                    printf("Add authentication tag(Type: 0 is FALSE or 1 is TRUE):%hu\n",set_tx_cfg.crypto_cfg.crypto_auth);
                    printf("PA temperature limit :%d\n",set_tx_cfg.tx_cfg_pa_templimit);


                    os_memcpy(tc_data, &set_tx_cfg, tc_len);

                    status = 0;
                }
                break;

                /* Telecommand prepartion to set comms RX config */
            case TC_SET_COMMS_RX_CFG:
                {
                    /* pack TC data */
                    tc_len = sizeof(s_comms_rx_cfg);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_rx_cfg.rx_cfg_freq = 2042500000;
                        set_rx_cfg.rx_cfg_type = 0;
                        set_rx_cfg.rx_cfg_rate = 500000;
                        set_rx_cfg.rx_cfg_rolloff = 1;
                        set_rx_cfg.afc_cfg.rx_cfg_afc_enable = 1;
                        set_rx_cfg.afc_cfg.rx_cfg_afc_range = 76;
                        set_rx_cfg.rx_cfg_rs = 0;
                        set_rx_cfg.rx_cfg_cc = 0;
                        set_rx_cfg.rx_cfg_rand = 1;
                        set_rx_cfg.rx_cfg_crc = 1;
                        if(radio_mod_id == 3)
                        {
                            set_tx_cfg.tx_cfg_size = 1432;
                        }
                        else 
                        {
                            set_tx_cfg.tx_cfg_size = 217;
                        }
                        set_rx_cfg.rx_cfg_id = 0;
                        memcpy(&set_rx_cfg.crypto_cfg.crypto_key ,"0", sizeof("0"));
                        set_rx_cfg.crypto_cfg.crypto_decrypt = 0;
                        set_rx_cfg.crypto_cfg.crypto_auth = 0;
                        set_rx_cfg.rx_cfg_frames = 0;
                        set_rx_cfg.rx_cfg_detected = 0;
                        set_rx_cfg.rx_cfg_rssi = 0;
                        set_rx_cfg.rx_cfg_freqerr = 0;
                        set_rx_cfg.rx_cfg_symerr = 0;
                        set_rx_cfg.rx_cfg_ebn0 = 0;
                        set_rx_cfg.rx_cfg_carrier_lock = 0;
                        set_rx_cfg.rx_frame_lock = 0;
                    }
                    else
                    {

                        printf("Receive frequency : ");
                        scanf("%u",&set_rx_cfg.rx_cfg_freq);
                        printf("Receive modulation type (0 = BPSK 1 = QPSK) : ");
                        scanf("%hhu",&set_rx_cfg.rx_cfg_type);
                        printf("Receive symbol rate : ");
                        scanf("%d",&set_rx_cfg.rx_cfg_rate);
                        printf("RRC roll-off (0 = 0.20 1 = 0.25 2 = 0.35) : ");
                        scanf("%hhu",&set_rx_cfg.rx_cfg_rolloff);
                        printf("Enable AFC (Type: 0 is FALSE or 1 is TRUE): ");
                        scanf("%hhu",&set_rx_cfg.afc_cfg.rx_cfg_afc_enable);
                        printf("AFC adjustment range : ");
                        scanf("%d",&set_rx_cfg.afc_cfg.rx_cfg_afc_range);
                        printf("Enable Reed-Solomon coding (Type: 0 is FALSE or 1 is TRUE): ");
                        scanf("%hhu",&set_rx_cfg.rx_cfg_rs);
                        printf("Enable convolutional coding (Type: 0 is FALSE or 1 is TRUE): ");
                        scanf("%hhu",&set_rx_cfg.rx_cfg_cc);
                        printf("Enable randomization (Type: 0 is FALSE or 1 is TRUE): ");
                        scanf("%hhu",&set_rx_cfg.rx_cfg_rand);
                        printf("Enable CRC checksum (Type: 0 is FALSE or 1 is TRUE): ");
                        scanf("%hhu",&set_rx_cfg.rx_cfg_crc);
                        printf("Maximum payload size :");
                        scanf("%hu",&set_rx_cfg.rx_cfg_size);
                        printf("Satellite ID/address: ");
                        scanf("%hu",&set_rx_cfg.rx_cfg_id);
                        printf("Decryption key: ");
                        scanf("%s",(char *)&set_rx_cfg.crypto_cfg.crypto_key);
                        printf("Decrypt frames(Type: 0 is FALSE or 1 is TRUE): ");
                        scanf("%hhu",&set_rx_cfg.crypto_cfg.crypto_decrypt);
                        printf("Verify authentication tag(Type: 0 is FALSE or 1 is TRUE): ");
                        scanf("%hhu",&set_rx_cfg.crypto_cfg.crypto_auth);
                    }
                    printf("Receive frequency :%u\n",set_rx_cfg.rx_cfg_freq);
                    printf("Receive modulation type (0 = BPSK 1 = QPSK) :%hu\n",set_rx_cfg.rx_cfg_type);
                    printf("Receive symbol rate :%d\n",set_rx_cfg.rx_cfg_rate);
                    printf("RRC roll-off (0 = 0.20 1 = 0.25 2 = 0.35) :%hu\n",set_rx_cfg.rx_cfg_rolloff);
                    printf("Enable AFC (Type: 0 is FALSE or 1 is TRUE):%hu\n",set_rx_cfg.afc_cfg.rx_cfg_afc_enable);
                    printf("AFC adjustment range :%d\n",set_rx_cfg.afc_cfg.rx_cfg_afc_range);
                    printf("Enable Reed-Solomon coding (Type: 0 is FALSE or 1 is TRUE):%hu\n",set_rx_cfg.rx_cfg_rs);
                    printf("Enable convolutional coding (Type: 0 is FALSE or 1 is TRUE):%hu\n",set_rx_cfg.rx_cfg_cc);
                    printf("Enable randomization (Type: 0 is FALSE or 1 is TRUE): %hu\n",set_rx_cfg.rx_cfg_rand);
                    printf("Enable CRC checksum (Type: 0 is FALSE or 1 is TRUE): %hu\n",set_rx_cfg.rx_cfg_crc);
                    printf("Maximum payload size :%hu\n",set_rx_cfg.rx_cfg_size);
                    printf("Satellite ID/address:%hu\n",set_rx_cfg.rx_cfg_id);
                    printf("Decryption key:%s\n",set_rx_cfg.crypto_cfg.crypto_key);
                    printf("Decrypt frames(Type: 0 is FALSE or 1 is TRUE):%hu\n",set_rx_cfg.crypto_cfg.crypto_decrypt);
                    printf("Verify authentication tag(Type: 0 is FALSE or 1 is TRUE):%hu\n",set_rx_cfg.crypto_cfg.crypto_auth);


                    os_memcpy(tc_data, &set_rx_cfg, tc_len);
                    status = 0;

                }
                break;

                /* Telecommand prepartion to set comms SYS config */
            case TC_SET_COMMS_SYS_CFG:
                {
                    /* pack TC data */
                    tc_len = sizeof(s_comms_sys_cfg);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_sys_cfg.sys_name_cnt = SBAND_SYS_NAME_MAX_SIZE;

                        memcpy(&set_sys_cfg.sys_name ,"srs-4", sizeof("srs-4"));
                        set_sys_cfg.boot_cfg.sys_serial = 0;
                        set_sys_cfg.boot_cfg.sys_sw_version = 0;
                        set_sys_cfg.boot_cfg.sys_bootcount = 0;
                        set_sys_cfg.boot_cfg.sys_reboot = 0;
                        set_sys_cfg.gwdt_cfg.sys_gwdt_counter = 0;
                        set_sys_cfg.gwdt_cfg.sys_gwdt_init = 86400;
                        set_sys_cfg.gwdt_cfg.sys_gwdt_reset = 0;
                        set_sys_cfg.csp_cfg.sys_csp_address = 24;
                        memcpy(&set_sys_cfg.csp_cfg.sys_csp_routes ,"0/0CAN10/11SPACE", sizeof("0/0CAN10/11SPACE"));
                        set_sys_cfg.can_cfg.sys_can_rate = 1000000;
                        set_sys_cfg.can_cfg.sys_can_promisc = 1;
                        set_sys_cfg.uart_cfg.sys_uart_rate = 1000000;
                        set_sys_cfg.uart_cfg.sys_uart_multidrop = 0;
                        set_sys_cfg.net_cfg.sys_net_enable = 0; 
                        memcpy(&set_sys_cfg.net_cfg.sys_net_en_ip ,"192.168.100.2", sizeof("192.168.100.2"));
                        set_sys_cfg.net_cfg.sys_net_en_prefix = 24;
                        memcpy(&set_sys_cfg.net_cfg.sys_net_en_gw ,"192.168.100.1", sizeof("192.168.100.1"));
                        memcpy(&set_sys_cfg.net_cfg.sys_net_rf_ip ,"192.168.200.2", sizeof("192.168.200.2"));
                        set_sys_cfg.net_cfg.sys_net_rf_prefix = 24;
                        memcpy(&set_sys_cfg.net_cfg.sys_net_rf_gw ,"192.168.200.1", sizeof("192.168.200.1"));
                    }
                    else
                    {
                        printf("System name : ");
                        scanf("%s",(char *)&set_sys_cfg.sys_name);
                        printf("System serial : ");
                        scanf("%d",&set_sys_cfg.boot_cfg.sys_serial);
                        printf("System version : ");
                        scanf("%d",&set_sys_cfg.boot_cfg.sys_sw_version);
                        printf("Number of times the system was booted: ");
                        scanf("%d",&set_sys_cfg.boot_cfg.sys_bootcount);
                        printf("GWDT timer reset value: ");
                        scanf("%d",&set_sys_cfg.gwdt_cfg.sys_gwdt_init);
                        printf("GWDT counter: ");
                        scanf("%d",&set_sys_cfg.gwdt_cfg.sys_gwdt_counter);
                        printf("GWDT reset: ");
                        scanf("%d",&set_sys_cfg.gwdt_cfg.sys_gwdt_reset);
                        printf("CSP address of the device : ");
                        scanf("%hhd",&set_sys_cfg.csp_cfg.sys_csp_address);
                        printf("CSP routing table in CIDR notation : ");
                        scanf("%s",(char *)&set_sys_cfg.csp_cfg.sys_csp_routes);
                        printf("CAN-bus bitrate: ");
                        scanf("%d",&set_sys_cfg.can_cfg.sys_can_rate);
                        printf("Accept all CSP CAN-frames (Type: 0 is FALSE or 1 is TRUE): ");
                        scanf("%hhu",&set_sys_cfg.can_cfg.sys_can_promisc);
                        printf("UART baudrate : ");
                        scanf("%d",&set_sys_cfg.uart_cfg.sys_uart_rate);
                        printf("UART multidrop mode(Type: 0 is FALSE or 1 is TRUE): ");
                        scanf("%hhu",&set_sys_cfg.uart_cfg.sys_uart_multidrop);
                        printf("IP stack enable (Type: 0 is FALSE or 1 is TRUE): ");
                        scanf("%hhu",&set_sys_cfg.net_cfg.sys_net_enable);
                        printf("Ethernet IP address : ");
                        scanf("%s",(char *)&set_sys_cfg.net_cfg.sys_net_en_ip);
                        printf("Ethernet network prefix bits : ");
                        scanf("%hhd",&set_sys_cfg.net_cfg.sys_net_en_prefix);
                        printf("Ethernet gateway IP address : ");
                        scanf("%s",(char *)&set_sys_cfg.net_cfg.sys_net_en_gw);
                        printf("Spacelink IP address : ");
                        scanf("%s",(char *)&set_sys_cfg.net_cfg.sys_net_rf_ip);
                        printf("Spacelink network prefix bits : ");
                        scanf("%hhd",&set_sys_cfg.net_cfg.sys_net_rf_prefix);
                        printf("Spacelink gateway IP address : ");
                        scanf("%s",(char *)&set_sys_cfg.net_cfg.sys_net_rf_gw);
                    }
                    printf("System name :%s\n",set_sys_cfg.sys_name);
                    printf("System serial :%d\n",set_sys_cfg.boot_cfg.sys_serial);
                    printf("System version :%d\n",set_sys_cfg.boot_cfg.sys_sw_version);                                
                    printf("Number of times the system was booted:%d\n",set_sys_cfg.boot_cfg.sys_bootcount);                
                    printf("GWDT timer reset value:%d\n",set_sys_cfg.gwdt_cfg.sys_gwdt_init);
                    printf("GWDT counter:%d\n",set_sys_cfg.gwdt_cfg.sys_gwdt_counter);
                    printf("GWDT reset:%d\n",set_sys_cfg.gwdt_cfg.sys_gwdt_reset);
                    printf("CSP address of the device :%hhd\n",set_sys_cfg.csp_cfg.sys_csp_address);
                    printf("CSP routing table in CIDR notation :%s\n",set_sys_cfg.csp_cfg.sys_csp_routes);
                    printf("CAN-bus bitrate:%d\n",set_sys_cfg.can_cfg.sys_can_rate);
                    printf("Accept all CSP CAN-frames (Type: 0 is FALSE or 1 is TRUE):%hu\n",set_sys_cfg.can_cfg.sys_can_promisc);                
                    printf("UART baudrate :%d\n",set_sys_cfg.uart_cfg.sys_uart_rate);
                    printf("UART multidrop mode(Type: 0 is FALSE or 1 is TRUE):%hu\n",set_sys_cfg.uart_cfg.sys_uart_multidrop);
                    printf("IP stack enable (Type: 0 is FALSE or 1 is TRUE):%hu\n",set_sys_cfg.net_cfg.sys_net_enable);
                    printf("Ethernet IP address :%s\n", set_sys_cfg.net_cfg.sys_net_en_ip);
                    printf("Ethernet network prefix bits :%hhd\n", set_sys_cfg.net_cfg.sys_net_en_prefix);
                    printf("Ethernet gateway IP address :%s\n", set_sys_cfg.net_cfg.sys_net_en_gw);
                    printf("Spacelink IP address :%s \n", set_sys_cfg.net_cfg.sys_net_rf_ip);
                    printf("Spacelink network prefix bits :%hhd\n", set_sys_cfg.net_cfg.sys_net_rf_prefix);
                    printf("Spacelink gateway IP address :%s\n", set_sys_cfg.net_cfg.sys_net_rf_gw);


                    os_memcpy(tc_data, &set_sys_cfg, tc_len);
                    status = 0;
                }
                break;
            case TC_SET_COMMS_TX_CFG_CRYPTO:
                {
                    /* pack TC data */
                    tc_len = sizeof(s_comms_tx_crypto_cfg);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set ==1)
                    {
                        memcpy(&set_tx_crypto_cfg.crypto_key,"0",sizeof("0"));
                        set_tx_crypto_cfg.crypto_encrypt = 0;
                        set_tx_crypto_cfg.crypto_auth = 0;
                    }
                    else
                    {
                        printf("Encryption key: ");
                        scanf("%s",(char *)&set_tx_crypto_cfg.crypto_key);
                        printf("Encrypt frames(Type: 0 is FALSE or 1 is TRUE): ");
                        scanf("%hhu",&set_tx_crypto_cfg.crypto_encrypt);
                        printf("Add authentication tag(Type: 0 is FALSE or 1 is TRUE): ");
                        scanf("%hhu",&set_tx_crypto_cfg.crypto_auth);
                    }
                    printf("Encryption key:%s\n",set_tx_crypto_cfg.crypto_key);
                    printf("Encrypt frames(Type: 0 is FALSE or 1 is TRUE):%hu\n",set_tx_crypto_cfg.crypto_encrypt);
                    printf("Add authentication tag(Type: 0 is FALSE or 1 is TRUE):%hu\n",set_tx_crypto_cfg.crypto_auth);


                    os_memcpy(tc_data, &set_tx_crypto_cfg, tc_len);
                    status = 0;
                }
                break;
            case TC_SET_COMMS_RX_CFG_AFC:
                {
                    /* pack TC data */
                    tc_len = sizeof(s_comms_rx_afc_cfg);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_rx_afc_cfg.rx_cfg_afc_enable = 1;
                        set_rx_afc_cfg.rx_cfg_afc_range = 76;
                    }
                    else
                    {
                        printf("RX Enable AFC(Type: 0 is FALSE or 1 is TRUE): ");
                        scanf("%hhu",&set_rx_afc_cfg.rx_cfg_afc_enable);
                        printf("RX AFC adjustment range: ");
                        scanf("%d",&set_rx_afc_cfg.rx_cfg_afc_range);
                    }

                    printf("RX Enable AFC(Type: 0 is FALSE or 1 is TRUE):%hu\n",set_rx_afc_cfg.rx_cfg_afc_enable);
                    printf("RX AFC adjustment range:%d\n",set_rx_afc_cfg.rx_cfg_afc_range);

                    os_memcpy(tc_data, &set_rx_afc_cfg, tc_len);
                    status = 0;
                }
                break;
            case TC_SET_COMMS_RX_CFG_CRYPTO:
                {
                    /* pack TC data */
                    tc_len = sizeof(s_comms_rx_crypto_cfg);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_rx_crypto_cfg.crypto_key_cnt = SBAND_RX_CRYPTO_KEY_MAX_SIZE;

                        memcpy(&set_rx_crypto_cfg.crypto_key ,"0", sizeof("0"));
                        set_rx_crypto_cfg.crypto_decrypt = 0;
                        set_rx_crypto_cfg.crypto_auth = 1;
                    }
                    else
                    {
                        printf("Decryption key: ");
                        scanf("%s",(char *)&set_rx_crypto_cfg.crypto_key);
                        printf("Decrypt frames: ");
                        scanf("%hhu",&set_rx_crypto_cfg.crypto_decrypt);
                        printf("Verify authentication tag: ");
                        scanf("%hhu",&set_rx_crypto_cfg.crypto_auth);
                    }

                    printf("Decryption key:%s\n",set_rx_crypto_cfg.crypto_key);
                    printf("Decrypt frames:%hu\n",set_rx_crypto_cfg.crypto_decrypt);
                    printf("Verify authentication tag:%hu\n",set_rx_crypto_cfg.crypto_auth);

                    os_memcpy(tc_data, &set_rx_crypto_cfg, tc_len);
                    status = 0;
                }
                break;

            case TC_SET_COMMS_BCH_CFG:
                {

                    uint8_t bch_dec = 0;
                    uint8_t bch_acc = 0;
                    uint8_t bch_cnt = 0;
                    tc_len = 3;
                    tc_data = (uint8_t*)malloc(tc_len);

                    if(comms_set == 1)
                    {
                        bch_dec = 0x01;
                        bch_acc = 0x00;
                        bch_cnt = 0x00;
                    }
                    else
                    {
                        printf("Enter bch dec parameter (0 off / 1 on:");
                        scanf("%hhd",&bch_dec);

                        printf("Enter bch acc parameter: (0 off / 1 on)");
                        scanf("%hhd",&bch_acc);

                        printf("Enter bch cnt mode parameter: (0-for ever / 1-rx sync phase only)");
                        scanf("%hhd",&bch_cnt);

                    }
                    printf(" bch_dec parameter (0 off / 1 on: :%u\n",bch_dec);
                    printf(" bch_acc parameter (0 off / 1 on) :%u\n",bch_acc);
                    printf(" bch_cnt parameter (0-for ever / 1-rx sync phase only):%u\n",bch_cnt);

                    os_memcpy(&tc_data[0], &bch_dec, 1);
                    os_memcpy(&tc_data[1], &bch_acc, 1);
                    os_memcpy(&tc_data[2], &bch_cnt, 1);
                    status = 0;

                }
                break;

            case TC_COMMS_RX_SEL_CFG:
                {
                    uint8_t rx_ch_sel = 0;
                    tc_len = 1;
                    tc_data = (uint8_t*)malloc(tc_len);

                    if(comms_set == 1)
                    {
                        rx_ch_sel &= 0x01;
                        printf("\nEntered Rx rcv channel selection is 0\n");	
                    }
                    else
                    {
                        printf("Enter Rx rcv channel selection(ch0: 0 /ch1: 1 - ");
                        scanf("%hhd",&rx_ch_sel);
                    }
                    os_memcpy(&tc_data[0], &rx_ch_sel, tc_len);
                    status = 0;
                }  
                break;

            case TC_COMMS_RX_SEL_DSB:
                {
                    tc_len = 1;
                    tc_data = (uint8_t*)malloc(tc_len);

                    if(comms_set == 1)
                    {
                        printf("\n`SBAND Xlinks RX RCV selection disable\n"); 
                    }
                    status = 0;
                }
                break;

            case TC_COMMS_SBAND_BEACON_CFG:
                {
                    tc_len = 1;
                    tc_data = (uint8_t*)malloc(tc_len);

                    if(comms_set == 1)
                    {
                        printf("SBAND beacon start success"); 
                    }

                    status = 0;
                }
                break;

            case TC_COMMS_SBAND_BEACON_START:
                {
                    tc_len = 1;
                    tc_data = (uint8_t*)malloc(tc_len);

                    if(comms_set == 1)
                    {
                        printf("SBAND beacon start success"); 
                    }

                    status = 0;
                }
                break;

            case TC_COMMS_SBAND_BEACON_STOP:
                {
                    tc_len = 1;
                    tc_data = (uint8_t*)malloc(tc_len);

                    if(comms_set == 1)
                    {
                        printf("SBAND beacon stop success");
                    }

                    status = 0;


                }
                break;

            case TC_SET_COMMS_BOOT_CFG:
                {
                    /* pack TC data */
                    tc_len = sizeof(s_comms_boot_cfg);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_boot_cfg.sys_bootcount = 1;
                    }
                    else
                    {
                        printf("Number of times the system was booted: ");
                        scanf("%d",&set_boot_cfg.sys_bootcount);
                    }

                    printf("Number of times the system was booted:%d\n",set_boot_cfg.sys_bootcount);

                    os_memcpy(tc_data, &set_boot_cfg, tc_len);
                    status = 0;
                }
                break;

            case TC_SET_COMMS_GWDT_CFG:
                {
                    /* pack TC data */
                    tc_len = sizeof(s_comms_gwdt_cfg);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_gwdt_cfg.sys_gwdt_init = 86400;
                        set_gwdt_cfg.sys_gwdt_counter = 0;
                        set_gwdt_cfg.sys_gwdt_reset = 0;
                    }
                    else
                    {
                        printf("GWDT timer reset value: ");
                        scanf("%d",&set_gwdt_cfg.sys_gwdt_init);
                        printf("GWDT counter: ");
                        scanf("%d",&set_gwdt_cfg.sys_gwdt_counter);
                        printf("GWDT reset: ");
                        scanf("%d",&set_gwdt_cfg.sys_gwdt_reset);
                    }

                    printf("GWDT timer reset value:%d\n",set_gwdt_cfg.sys_gwdt_init);
                    printf("GWDT counter:%d\n",set_gwdt_cfg.sys_gwdt_counter);
                    printf("GWDT reset:%d\n",set_gwdt_cfg.sys_gwdt_reset);

                    os_memcpy(tc_data, &set_gwdt_cfg, tc_len);
                    status = 0;
                }
                break;
            case TC_SET_COMMS_CAN_CFG:
                {
                    /* pack TC data */
                    tc_len = sizeof(s_comms_can_cfg);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_can_cfg.sys_can_rate = 1000000;
                        set_can_cfg.sys_can_promisc = 1;
                    }
                    else
                    {

                        printf("CAN-bus bitrate: ");
                        scanf("%d",&set_can_cfg.sys_can_rate);
                        printf("Accept all CSP CAN-frames (Type: 0 is FALSE or 1 is TRUE): ");
                        scanf("%hhu",&set_can_cfg.sys_can_promisc);
                    }

                    printf("CAN-bus bitrate:%d\n",set_can_cfg.sys_can_rate);
                    printf("Accept all CSP CAN-frames (Type: 0 is FALSE or 1 is TRUE):%hu\n",set_can_cfg.sys_can_promisc);


                    os_memcpy(tc_data, &set_can_cfg, tc_len);
                    status = 0;
                }
                break;

            case TC_SET_COMMS_UART_CFG:
                {
                    /* pack TC data */
                    tc_len = sizeof(s_comms_uart_cfg);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_uart_cfg.sys_uart_rate = 1000000;
                        set_uart_cfg.sys_uart_multidrop = 0;
                    }
                    else
                    {
                        printf("UART baudrate : ");
                        scanf("%d",&set_uart_cfg.sys_uart_rate);
                        printf("UART multidrop mode(Type: 0 is FALSE or 1 is TRUE): ");
                        scanf("%hhu",&set_uart_cfg.sys_uart_multidrop);
                    }

                    printf("UART baudrate :%d\n",set_uart_cfg.sys_uart_rate);
                    printf("UART multidrop mode(Type: 0 is FALSE or 1 is TRUE):%hu\n",set_uart_cfg.sys_uart_multidrop);

                    os_memcpy(tc_data, &set_uart_cfg, tc_len);
                    status = 0;
                }
                break;
            case TC_SET_COMMS_CSP_CFG:
                {
                    /* pack TC data */
                    tc_len = sizeof(s_comms_csp_cfg);
                    tc_data = (uint8_t *) malloc(tc_len);

                    if(comms_set == 1)
                    {
                        set_csp_cfg.sys_csp_address = 24;
                        memcpy(&set_csp_cfg.sys_csp_routes ,"0/0CAN10/11SPACE", sizeof("0/0CAN10/11SPACE"));
                    }
                    else
                    {
                        printf("CSP address of the device : ");
                        scanf("%hhd",&set_csp_cfg.sys_csp_address);
                        printf("CSP routing table in CIDR notation : ");
                        scanf("%s",(char *)&set_csp_cfg.sys_csp_routes);
                    }

                    printf("CSP address of the device :%hhd\n",set_csp_cfg.sys_csp_address);
                    printf("CSP routing table in CIDR notation :%s\n",set_csp_cfg.sys_csp_routes);

                    os_memcpy(tc_data, &set_csp_cfg, tc_len);
                    status = 0;
                }
                break;
            case TC_SET_COMMS_NET_CFG:
                {
                    /* pack TC data */
                    tc_len = sizeof(s_comms_net_cfg);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_net_cfg.sys_net_ip_cnt = SBAND_SYS_ETH_IP_MAX_SIZE;
                        set_net_cfg.sys_net_gw_cnt= SBAND_SYS_GT_IP_MAX_SIZE;
                        set_net_cfg.sys_net_rf_ip_cnt = SBAND_SYS_SPACELINK_IP_MAX_SIZE;
                        set_net_cfg.sys_net_rf_gw_cnt = SBAND_SYS_SPACELINK_GT_IP_MAX_SIZE;

                        set_net_cfg.sys_net_enable = 0;
                        memcpy(&set_net_cfg.sys_net_en_ip ,"192.168.100.2", sizeof("192.168.100.2"));
                        set_net_cfg.sys_net_en_prefix = 24;
                        memcpy(&set_net_cfg.sys_net_en_gw ,"192.168.100.1", sizeof("192.168.100.1"));
                        memcpy(&set_net_cfg.sys_net_rf_ip ,"192.168.200.2", sizeof("192.168.200.2"));
                        set_net_cfg.sys_net_rf_prefix = 24;
                        memcpy(&set_net_cfg.sys_net_rf_gw ,"192.168.200.1", sizeof("192.168.200.1"));
                    }
                    else
                    {
                        printf("IP stack enable : ");
                        scanf("%hhu",&set_net_cfg.sys_net_enable);
                        printf("Ethernet IP address : ");
                        scanf("%s",(char *)&set_net_cfg.sys_net_en_ip);
                        printf("Ethernet network prefix bits : ");
                        scanf("%hhd",&set_net_cfg.sys_net_en_prefix);
                        printf("Ethernet gateway IP address : ");
                        scanf("%s",(char *)&set_net_cfg.sys_net_en_gw);
                        printf("Spacelink IP address : ");
                        scanf("%s",(char *)&set_net_cfg.sys_net_rf_ip);
                        printf("Spacelink network prefix bits : ");
                        scanf("%hhd",&set_net_cfg.sys_net_rf_prefix);
                        printf("Spacelink gateway IP address : ");
                        scanf("%s",(char *)&set_net_cfg.sys_net_rf_gw);
                    }

                    printf("IP stack enable :%hu\n",set_net_cfg.sys_net_enable);
                    printf("Ethernet IP address :%s\n",set_net_cfg.sys_net_en_ip);
                    printf("Ethernet network prefix bits :%hhd\n",set_net_cfg.sys_net_en_prefix);
                    printf("Ethernet gateway IP address :%s\n",set_net_cfg.sys_net_en_gw);
                    printf("Spacelink IP address :%s\n",set_net_cfg.sys_net_rf_ip);
                    printf("Spacelink network prefix bits :%hhd\n",set_net_cfg.sys_net_rf_prefix);
                    printf("Spacelink gateway IP address :%s\n",set_net_cfg.sys_net_rf_gw);


                    os_memcpy(tc_data, &set_net_cfg, tc_len);
                    status = 0;
                }
                break;

            case TC_SET_COMMS_TX_CFG_FREQ:
                {
                    /* pack TC data */
                    tc_len = sizeof(set_tx_cfg.tx_cfg_freq);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_tx_cfg.tx_cfg_freq = 2242500000;
                    }
                    else
                    {
                        printf("Enter tx frequency:");
                        scanf("%u",&set_tx_cfg.tx_cfg_freq);
                    }
                    printf("Transmit frequency :%u\n",set_tx_cfg.tx_cfg_freq);

                    os_memcpy(tc_data, &set_tx_cfg.tx_cfg_freq, tc_len);
                    status = 0;
                }
                break;
            case TC_SET_COMMS_TX_CFG_TYPE: 
                {
                    /* pack TC data */
                    tc_len = sizeof(set_tx_cfg.tx_cfg_type);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_tx_cfg.tx_cfg_type = 0;
                    }
                    else
                    {
                        printf("Transmit modulation type (0 = BPSK 1 = QPSK 2 = 8PSK): ");
                        scanf("%hhu",&set_tx_cfg.tx_cfg_type);
                    }
                    printf("Transmit modulation type (0 = BPSK 1 = QPSK 2 = 8PSK):%hu\n",set_tx_cfg.tx_cfg_type);

                    os_memcpy(tc_data, &set_tx_cfg.tx_cfg_type, tc_len);
                    status = 0;
                }
                break;
            case TC_SET_COMMS_TX_CFG_RATE:
                {
                    /* pack TC data */
                    tc_len = sizeof(set_tx_cfg.tx_cfg_rate);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_tx_cfg.tx_cfg_rate = 1000000;
                    }
                    else
                    {
                        printf("Transmit symbol rate: ");
                        scanf("%d",&set_tx_cfg.tx_cfg_rate);
                    }
                    printf("Transmit symbol rate:%d\n",set_tx_cfg.tx_cfg_rate);

                    os_memcpy(tc_data, &set_tx_cfg.tx_cfg_rate, tc_len);
                    status = 0;
                }
                break;
            case TC_SET_COMMS_TX_CFG_ROLLOFF:
                {
                    /* pack TC data */
                    tc_len = sizeof(set_tx_cfg.tx_cfg_rolloff);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_tx_cfg.tx_cfg_rolloff = 1;
                    }
                    else
                    {
                        printf("RRC rolloff(0 = 0.20 1 = 0.25 2 = 0.35): ");
                        scanf("%hhu",&set_tx_cfg.tx_cfg_rolloff);
                    }
                    printf("RRC rolloff(0 = 0.20 1 = 0.25 2 = 0.35):%hu\n",set_tx_cfg.tx_cfg_rolloff);

                    os_memcpy(tc_data, &set_tx_cfg.tx_cfg_rolloff, tc_len);
                    status = 0;
                }
                break;
            case TC_SET_COMMS_TX_CFG_POUT:
                {
                    /* pack TC data */
                    tc_len = sizeof(set_tx_cfg.tx_cfg_pout);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_tx_cfg.tx_cfg_pout = 33;
                    }
                    else
                    {
                        printf("Enter the o/p power:");
                        scanf("%f",&set_tx_cfg.tx_cfg_pout);
                    }
                    printf("Transmit power :%f\n", set_tx_cfg.tx_cfg_pout);

                    os_memcpy(tc_data, &set_tx_cfg.tx_cfg_pout, tc_len);
                    status = 0;
                }
                break;
            case TC_SET_COMMS_TX_CFG_ALC_MODE:
                {
                    /* pack TC data */
                    tc_len = sizeof(set_tx_cfg.tx_cfg_alc_mode);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_tx_cfg.tx_cfg_alc_mode = 1;
                    }
                    else
                    {
                        printf("Automatic Level Control mode (0 = open-loop 1 = closed-loop): ");
                        scanf("%hhu",&set_tx_cfg.tx_cfg_alc_mode);
                    }

                    os_memcpy(tc_data, &set_tx_cfg.tx_cfg_alc_mode, tc_len);
                    status = 0;
                }
                break;
            case TC_SET_COMMS_TX_CFG_RS:
                {
                    /* pack TC data */
                    tc_len = sizeof(set_tx_cfg.tx_cfg_rs);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_tx_cfg.tx_cfg_rs = 1;
                    }
                    else
                    {
                        printf("Enable Reed-Solomon coding: ");
                        scanf("%hhd\n",&set_tx_cfg.tx_cfg_rs);
                    }                
                    printf("Enable Reed-Solomon coding :%hu\n", set_tx_cfg.tx_cfg_rs);

                    os_memcpy(tc_data, &set_tx_cfg.tx_cfg_rs, tc_len);
                    status = 0;
                }
                break;
            case TC_SET_COMMS_TX_CFG_CC:
                {
                    /* pack TC data */
                    tc_len = sizeof(set_tx_cfg.tx_cfg_cc);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_tx_cfg.tx_cfg_cc = 1;
                    }
                    else
                    {
                        printf("Enable convolutional coding : ");
                        scanf("%hhu",&set_tx_cfg.tx_cfg_cc);
                    }
                    printf("Enable convolutional coding :%hu\n", set_tx_cfg.tx_cfg_cc);

                    os_memcpy(tc_data, &set_tx_cfg.tx_cfg_cc, tc_len);
                    status = 0;
                }
                break;
            case TC_SET_COMMS_TX_CFG_RAND:
                {
                    /* pack TC data */
                    tc_len = sizeof(set_tx_cfg.tx_cfg_rand);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_tx_cfg.tx_cfg_rand = 1;
                    }
                    else
                    {
                        printf("Enable randomization : ");
                        scanf("%hhu",&set_tx_cfg.tx_cfg_rand);
                    }
                    printf("Enable randomization :%hu\n",set_tx_cfg.tx_cfg_rand);

                    os_memcpy(tc_data, &set_tx_cfg.tx_cfg_rand, tc_len);
                    status = 0;
                }
                break;
            case TC_SET_COMMS_TX_CFG_CRC:
                {
                    /* pack TC data */
                    tc_len = sizeof(set_tx_cfg.tx_cfg_crc);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_tx_cfg.tx_cfg_crc = 1;
                    }
                    else
                    {
                        printf("Enable CRC checksum : ");
                        scanf("%hhu",&set_tx_cfg.tx_cfg_crc);
                    }
                    printf("Enable CRC checksum :%hu\n", set_tx_cfg.tx_cfg_crc);

                    os_memcpy(tc_data, &set_tx_cfg.tx_cfg_crc, tc_len);
                    status = 0;
                }
                break;
            case TC_SET_COMMS_TX_CFG_IDLETIME:
                {
                    /* pack TC data */
                    tc_len = sizeof(set_tx_cfg.tx_cfg_idletime);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_tx_cfg.tx_cfg_idletime = 30;
                    }
                    else
                    {
                        printf("Active transmitter time after each frame: ");
                        scanf("%hi",&set_tx_cfg.tx_cfg_idletime);
                    }
                    printf("Active transmitter time after each frame:%hi\n",set_tx_cfg.tx_cfg_idletime);
                    os_memcpy(tc_data, &set_tx_cfg.tx_cfg_idletime, tc_len);
                    status = 0;
                }
                break;
            case TC_SET_COMMS_TX_CFG_SIZE:
                {
                    /* pack TC data */
                    tc_len = sizeof(set_tx_cfg.tx_cfg_size);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        if(radio_mod_id == 3)
                        {
                            set_tx_cfg.tx_cfg_size = 1432;
                        }
                        else 
                        {
                            set_tx_cfg.tx_cfg_size = 217;
                        }
                    }
                    else
                    {
                        printf("Maximum payload size: ");
                        scanf("%hi",&set_tx_cfg.tx_cfg_size);
                    }

                    printf("Maximum payload size:%hi\n",set_tx_cfg.tx_cfg_size);
                    os_memcpy(tc_data, &set_tx_cfg.tx_cfg_size, tc_len);
                    status = 0;
                }
                break;
            case TC_SET_COMMS_TX_CFG_ID:
                {
                    /* pack TC data */
                    tc_len = sizeof(set_tx_cfg.tx_cfg_id);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_tx_cfg.tx_cfg_id = 0;
                    }
                    else
                    {
                        printf("Satellite ID/address: ");
                        scanf("%hi",&set_tx_cfg.tx_cfg_id);
                    }
                    printf("Satellite ID/address:%hi\n",set_tx_cfg.tx_cfg_id);
                    os_memcpy(tc_data, &set_tx_cfg.tx_cfg_id, tc_len);
                    status = 0;
                }
                break;
            case TC_SET_COMMS_TX_CFG_PA_TEMPLIMIT:
                {
                    /* pack TC data */
                    tc_len = sizeof(set_tx_cfg.tx_cfg_pa_templimit);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_tx_cfg.tx_cfg_pa_templimit = 80;
                    }
                    else
                    {
                        printf("PA temperature limit : ");
                        scanf("%hhd",&set_tx_cfg.tx_cfg_pa_templimit);
                    }
                    printf("PA temperature limit :%hhd\n",set_tx_cfg.tx_cfg_pa_templimit);

                    os_memcpy(tc_data, &set_tx_cfg.tx_cfg_pa_templimit, tc_len);
                    status = 0;
                }
                break;

            case TC_SET_COMMS_ASM_CFG:
                {
                    uint8_t asm_cfg=8;
                    tc_len = 1;
                    tc_data = (uint8_t*)malloc(tc_len);

                    if(comms_set == 1)
                    {
                        asm_cfg = 8;
                    }
                    else
                    {
                        printf("Enter asm cfg parameter:");
                        scanf("%hhd",&asm_cfg);
                    }
                    printf("ASM CFG :%hhn\n",&asm_cfg);
                    os_memcpy(tc_data, &asm_cfg, tc_len);
                    status = 0;
                }
                break;

            case TC_SET_COMMS_RX_CFG_FREQ:
                {
                    /* pack TC data */
                    tc_len = sizeof(set_rx_cfg.rx_cfg_freq);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_rx_cfg.rx_cfg_freq = 2042500000;
                    }
                    else
                    {
                        printf("Enter the rx frequency:");
                        scanf("%u",&set_rx_cfg.rx_cfg_freq);
                    }
                    printf("Receive frequency :%u\n",set_rx_cfg.rx_cfg_freq);
                    os_memcpy(tc_data, &set_rx_cfg.rx_cfg_freq, tc_len);
                    status = 0;
                }
                break;
            case TC_SET_COMMS_RX_CFG_TYPE: 
                {
                    /* pack TC data */
                    tc_len = sizeof(set_rx_cfg.rx_cfg_type);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_rx_cfg.rx_cfg_type = 0;
                    }
                    else
                    {
                        printf("Receive modulation type (0 = BPSK 1 = QPSK) : ");
                        scanf("%hhu",&set_rx_cfg.rx_cfg_type);
                    }
                    printf("Receive modulation type (0 = BPSK 1 = QPSK) :%hu\n",set_rx_cfg.rx_cfg_type);

                    os_memcpy(tc_data, &set_rx_cfg.rx_cfg_type, tc_len);
                    status = 0;
                }
                break;
            case TC_SET_COMMS_RX_CFG_RATE:
                {
                    /* pack TC data */
                    tc_len = sizeof(set_rx_cfg.rx_cfg_rate);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_rx_cfg.rx_cfg_rate = 500000;
                    }
                    else
                    {
                        printf("Receive symbol rate : ");
                        scanf("%d",&set_rx_cfg.rx_cfg_rate);
                    }
                    printf("Receive symbol rate :%d\n",set_rx_cfg.rx_cfg_rate);
                    os_memcpy(tc_data, &set_rx_cfg.rx_cfg_rate, tc_len);
                    status = 0;
                }
                break;
            case TC_SET_COMMS_RX_CFG_ROLLOFF:
                {
                    /* pack TC data */
                    tc_len = sizeof(set_rx_cfg.rx_cfg_rolloff);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_rx_cfg.rx_cfg_rolloff = 1;
                    }
                    else
                    {
                        printf("RRC roll-off (0 = 0.20 1 = 0.25 2 = 0.35) : ");
                        scanf("%hhu",&set_rx_cfg.rx_cfg_rolloff);
                    }
                    printf("RRC roll-off (0 = 0.20 1 = 0.25 2 = 0.35) :%hu\n",set_rx_cfg.rx_cfg_rolloff);
                    os_memcpy(tc_data, &set_rx_cfg.rx_cfg_rolloff, tc_len);
                    status = 0;
                }
                break;
            case TC_SET_COMMS_RX_CFG_RS:
                {


                    /* pack TC data */
                    tc_len = sizeof(set_rx_cfg.rx_cfg_rs);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_rx_cfg.rx_cfg_rs = 0;
                    }
                    else
                    {
                        printf("Enable Reed-Solomon coding : ");
                        scanf("%hhu",&set_rx_cfg.rx_cfg_rs);
                    }
                    printf("Enable Reed-Solomon coding :%hu\n",set_rx_cfg.rx_cfg_rs);
                    os_memcpy(tc_data, &set_rx_cfg.rx_cfg_rs, tc_len);
                    status = 0;


                }
                break;
            case TC_SET_COMMS_RX_CFG_CC:
                {
                    /* pack TC data */
                    tc_len = sizeof(set_rx_cfg.rx_cfg_cc);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_rx_cfg.rx_cfg_cc = 1;
                    }
                    else
                    {
                        printf("Enable convolutional coding : ");
                        scanf("%hhu",&set_rx_cfg.rx_cfg_cc);
                    }
                    printf("Enable convolutional coding :%hu\n",set_rx_cfg.rx_cfg_cc);
                    os_memcpy(tc_data, &set_rx_cfg.rx_cfg_cc, tc_len);
                    status = 0;
                }
                break;
            case TC_SET_COMMS_RX_CFG_RAND:
                {
                    /* pack TC data */
                    tc_len = sizeof(set_rx_cfg.rx_cfg_rand);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_rx_cfg.rx_cfg_rand = 1;
                    }
                    else
                    {
                        printf("Enable randomization :");
                        scanf("%hhu",&set_rx_cfg.rx_cfg_rand);
                    }

                    printf("Enable randomization : %hu\n",set_rx_cfg.rx_cfg_rand);

                    os_memcpy(tc_data, &set_rx_cfg.rx_cfg_rand, sizeof(set_rx_cfg.rx_cfg_rand));
                    status = 0;
                }
                break;
            case TC_SET_COMMS_RX_CFG_CRC:
                {
                    /* pack TC data */
                    tc_len = sizeof(s_comms_rx_cfg);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_rx_cfg.rx_cfg_crc = 1;
                    }
                    else
                    {
                        printf("Enable CRC checksum : ");
                        scanf("%hhu",&set_rx_cfg.rx_cfg_crc);
                    }
                    printf("Enable CRC checksum : %hu\n",set_rx_cfg.rx_cfg_crc);
                    os_memcpy(tc_data, &set_rx_cfg.rx_cfg_crc, tc_len);
                    status = 0;

                }
                break;
            case TC_SET_COMMS_RX_CFG_SIZE:
                {
                    /* pack TC data */
                    tc_len = sizeof(set_rx_cfg.rx_cfg_size);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        if(radio_mod_id == 3)
                        {
                            set_tx_cfg.tx_cfg_size = 1432;
                        }
                        else 
                        {
                            set_tx_cfg.tx_cfg_size = 217;
                        }
                    }
                    else
                    {
                        printf("Maximum payload size : ");
                        scanf("%hu",&set_rx_cfg.rx_cfg_size);
                    }

                    printf("Maximum payload size :%hu\n",set_rx_cfg.rx_cfg_size);
                    os_memcpy(tc_data, &set_rx_cfg.rx_cfg_size, tc_len);
                    status = 0;
                }
                break;
            case TC_SET_COMMS_RX_CFG_ID:
                {
                    /* pack TC data */
                    tc_len = sizeof(set_rx_cfg.rx_cfg_id);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(comms_set == 1)
                    {
                        set_rx_cfg.rx_cfg_id = 0;
                    }
                    else
                    {
                        printf("Satellite ID/address: ");
                        scanf("%hu",&set_rx_cfg.rx_cfg_id);
                    }
                    printf("Satellite ID/address:%hu\n",set_rx_cfg.rx_cfg_id);
                    os_memcpy(tc_data, &set_rx_cfg.rx_cfg_id, tc_len);
                    status = 0;
                }
                break;
            case TC_SET_COMMS_ERR_CFG:
                {
                    /* pack TC data */
                    tc_len = 0; //sizeof(set_sys_cfg.sys_name);
                    tc_data = (uint8_t *) malloc(tc_len);

                    status = 0;
                }
                break;
            case TC_COMMS_LOAD_CFG:
                {
                    /* pack TC data */
                    tc_len = sizeof(group) + sizeof(fallback);
                    tc_data = (uint8_t *) malloc(tc_len);
                    printf("Enter the group 1 to 5:");                
                    scanf("%hu",&group);
                    printf("\nEnter th fallback (0):");                
                    scanf("%hhu",&fallback);                
                    os_memcpy(tc_data, &group, sizeof(group));
                    os_memcpy(tc_data + sizeof(group), &fallback, sizeof(fallback));
                    status = 0;
                }
                break;

            case TC_COMMS_SAVE_CFG:
                {
                    /* pack TC data */
                    tc_len = sizeof(group) + sizeof(fallback);
                    tc_data = (uint8_t *) malloc(tc_len);
                    printf("Enter the group 1 to 5:");                
                    scanf("%hu",&group);
                    printf("\nEnter the fallback (0):");                
                    scanf("%hhu",&fallback);                
                    os_memcpy(tc_data, &group, sizeof(group));
                    os_memcpy(tc_data + sizeof(group), &fallback, sizeof(fallback));
                    status = 0;
                }
                break;

            case TC_COMMS_RESET_CFG:
                {
                    /* pack TC data */
                    tc_len = sizeof(group) + sizeof(fallback);
                    tc_data = (uint8_t *) malloc(tc_len);
                    printf("Enter the group 1 to 5:");                
                    scanf("%hu",&group);
                    os_memcpy(tc_data, &group, sizeof(group));
                    status = 0;
                }
                break;

            case TC_COMMS_LOCK_CFG:
                {
                    /* pack TC data */
                    tc_len = sizeof(group) + sizeof(fallback);
                    tc_data = (uint8_t *) malloc(tc_len);
                    printf("Enter the group 1 to 5:");                
                    scanf("%hu",&group);
                    printf("\nEnter the fallback (0):");                
                    scanf("%hhu",&fallback);                
                    os_memcpy(tc_data, &group, sizeof(group));
                    os_memcpy(tc_data + sizeof(group), &fallback, sizeof(fallback));
                    status = 0;
                }
                break;

            case TC_COMMS_UNLOCK_CFG:
                {
                    /* pack TC data */
                    tc_len = sizeof(group) + sizeof(fallback);
                    tc_data = (uint8_t *) malloc(tc_len);
                    printf("Enter the group 1 to 5:");                
                    scanf("%hu",&group);
                    printf("\nEnter the fallback (0):");                
                    scanf("%hhu",&fallback);                
                    os_memcpy(tc_data, &group, sizeof(group));
                    os_memcpy(tc_data + sizeof(group), &fallback, sizeof(fallback));
                    status = 0;
                }
                break;

            case TC_COMMS_ERASE_CFG:
                {
                    /* pack TC data */
                    tc_len = sizeof(group) + sizeof(fallback);
                    tc_data = (uint8_t *) malloc(tc_len);
                    printf("Enter the group 1 to 5:");                
                    scanf("%hu",&group);
                    printf("\nEnter the fallback (0):");                
                    scanf("%hhu",&fallback);                
                    os_memcpy(tc_data, &group, sizeof(group));
                    os_memcpy(tc_data + sizeof(group), &fallback, sizeof(fallback));
                    status = 0;
                }
                break;

            case TC_COMMS_FW_CFG:
                {

                    uint32_t tmpv; 
                    uint8_t  no_of_file;

                    printf("Enter No of File to be update - ");
                    scanf("%hhu", &no_of_file);
                    tc_len = (sizeof(xver.prog_version) * no_of_file) + 1;
                    tc_data = (uint8*)malloc(tc_len);

                    os_memcpy(tc_data,&no_of_file,sizeof(uint8_t));

                    if(comms_set == 1)
                    {

                        xver1.prog_version[0].Seconds = 00;
                        xver1.prog_version[0].Minutes = 43;
                        xver1.prog_version[0].Hours = 10;
                        xver1.prog_version[0].Year = 23;
                        xver1.prog_version[0].Months = 03;
                        xver1.prog_version[0].Day = 14;
                        memcpy(&xver1.prog_version[0].FileName ,"SWAP", sizeof("SWAP"));
                        xver1.prog_version[0].start_adr = 90000;
                        xver1.prog_version[0].len = 526072;
                        xver1.prog_version[0].Flags = 1;
                    }
                    else
                    {
                        int j = 2;
                        for(int i = 0; i < no_of_file; i++ )
                        {
                            printf("Enter the seconds:");
                            scanf("%d",&tmpv);
                            xver1.prog_version[i].Seconds = tmpv & 0x3f;

                            printf("Enter the Minute:");
                            scanf("%d",&tmpv);
                            xver1.prog_version[i].Minutes = tmpv & 0x3f;                

                            printf("Enter the hours:");
                            scanf("%d",&tmpv);
                            xver1.prog_version[i].Hours = tmpv & 0x1f;                

                            printf("Enter the year (2 digit) 0 to 63 (to note year 2000 to 2063):");
                            scanf("%d",&tmpv);
                            xver1.prog_version[i].Year = tmpv & 0x3f;                

                            printf("Enter the months:");
                            scanf("%d",&tmpv);
                            xver1.prog_version[i].Months = tmpv & 0xf;                

                            printf("Enter the day:");
                            scanf("%d",&tmpv);
                            xver1.prog_version[i].Day = tmpv & 0x1f;                

                            printf("Enter the start address:");
                            scanf("%d",&tmpv);
                            xver1.prog_version[i].start_adr = tmpv;                

                            printf("Enter the length:");
                            scanf("%d",&tmpv);
                            xver1.prog_version[i].len = tmpv & 0xfffffff;                

                            printf("Enter the flags(SOLL-1; RUN- 0x2;...):");
                            scanf("%d",&tmpv);
                            xver1.prog_version[i].Flags = tmpv & 0xf;   

                            os_memcpy(&tc_data[j],&xver1.prog_version[i],sizeof(xver.prog_version));
                            j = j + sizeof(xver.prog_version);

                        }
                    }

                    status = 0;

                    printf("\n\r TC_SBAND_SET_VERSION is sent");


                }
                break;

            case TC_COMMS_CUSTOM_TX:
                {

                    comms_sync_s sync;
                    tc_len =sizeof(comms_sync_s);
                    tc_data = (uint8_t *) malloc(tc_len);
                    printf("1 - payload with all zeros\n");
                    printf("2 - payload with all ones\n");
                    printf("3 - payload with incrementing number in each bytes as per length configuration\n");
                    printf("4 - payload with decrementing number in each bytes as per length configuration\n");
                    printf("5 - payload with all zeros with sequence number\n");
                    printf("6 - payload with all ones with sequence number\n");
                    printf("7 - payload with incrementing data with sequence number\n");
                    printf("8 - payload with decrementing data with sequence number\n");
                    printf("9 - CSP Ping Payload\n");
                    printf("Enter the Type: ");
                    scanf("%d",&sync.type);
                    if(sync.type < 1 || sync.type > 9)
                    {
                        printf("Invalid Test ID\n");
                        status = -1;
                    }
                    printf("Enter the size: ");
                    scanf("%d",&sync.size);
                    printf("Enter the periodicity: ");
                    scanf("%d",&sync.periodicity);
                    printf("Enter the Sequence count: ");
                    scanf("%d",&sync.pld_count);
                    if(sync.type == 9)
                    {
                        printf("Enter the Node");
                        scanf("%d",&sync.node);
                    }
                    memcpy(tc_data,&sync,sizeof(comms_sync_s));


                    status = 0;
                }
                break;

            case TC_COMMS_RESERVED:
                {
                    /* pack TC data */
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);
                    status = 0;
                }
                break;
            case TC_COMMS_INITIAL_SYNC:
                {
                    /* pack TC data */
                    uint8_t *crnt_time_date = malloc(sizeof(tctm_time_par_s));
                    get_crnt_time_date((tctm_time_par_s*)crnt_time_date);
                    tc_len = sizeof("Hello Janus1");
                    tc_len +=sizeof(tctm_time_par_s);
                    tc_data = (uint8_t *) malloc(tc_len);
                    os_memcpy(tc_data, "Hello Janus1",sizeof("Hello Janus1"));
                    os_memcpy(tc_data+sizeof("Hello Janus1"),crnt_time_date,sizeof(tctm_time_par_s));
                    free(crnt_time_date);
                    status = 0;
                }
                break;

            case TC_SBAND_GET_TM_STORE:
                {

                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;

                }
                break;

            case TC_SBAND_GET_TM_ALL :
                {
                    tc_len = 0;
                    tc_data = (uint8_t*)malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;

            case TC_COMMS_BEACON_TX:
                {
                    tc_len = 1;
                    tc_data = (uint8_t*)malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;

            case TC_GET_COMMS_ASM_CFG:
                {
                    tc_len = 1;
                    tc_data = (uint8_t*)malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;

            case TC_GET_COMMS_BCH_CFG:
                {
                    tc_len = 1;
                    tc_data = (uint8_t*)malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;

            case TC_GET_COMMS_BEACON_CFG:
                {
                    tc_len = 1;
                    tc_data = (uint8_t*)malloc(tc_len);

                    printf("In telemetry request case \n");

                    status = 0;
                }
                break;


            case TC_GET_COMMS_TX_CFG:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;

            case TC_GET_COMMS_TX_CFG_FREQ:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;
            case TC_GET_COMMS_TX_CFG_TYPE:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;
            case TC_GET_COMMS_TX_CFG_RATE:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;

            case TC_GET_COMMS_TX_CFG_ROLLOFF:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;

            case TC_GET_COMMS_TX_CFG_POUT:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;

            case TC_GET_COMMS_TX_CFG_ALC_MODE:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;

            case TC_GET_COMMS_TX_CFG_RS:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;

            case TC_GET_COMMS_TX_CFG_CC:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;

            case TC_GET_COMMS_TX_CFG_RAND:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;

            case TC_GET_COMMS_TX_CFG_CRC:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;

            case TC_GET_COMMS_TX_CFG_IDLETIME:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;

            case TC_GET_COMMS_TX_CFG_SIZE:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;

            case TC_GET_COMMS_TX_CFG_ID:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;

            case TC_GET_COMMS_TX_CFG_CRYPTO:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;

            case TC_GET_COMMS_TX_CFG_PA_TEMPLIMIT:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;

            case TC_GET_COMMS_TX_CFG_FRAMES:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;

            case TC_GET_COMMS_TX_CFG_PWR_FWD:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;

            case TC_GET_COMMS_TX_CFG_PWR_RFL:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;

            case TC_GET_COMMS_RX_CFG:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_GET_COMMS_RX_CFG_FREQ:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_GET_COMMS_RX_CFG_TYPE:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_GET_COMMS_RX_CFG_RATE:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_GET_COMMS_RX_CFG_ROLLOFF:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_GET_COMMS_RX_CFG_AFC:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_GET_COMMS_RX_CFG_RS:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_GET_COMMS_RX_CFG_CC:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_GET_COMMS_RX_CFG_RAND:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_GET_COMMS_RX_CFG_CRC:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_GET_COMMS_RX_CFG_SIZE:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_GET_COMMS_RX_CFG_ID:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_GET_COMMS_RX_CFG_CRYPTO:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_GET_COMMS_RX_CFG_FRAMES:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_GET_COMMS_RX_CFG_DETECTED:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;

            case TC_GET_COMMS_RX_CFG_RSSI:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_GET_COMMS_RX_CFG_FREQERR:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_GET_COMMS_RX_CFG_SYMERR:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_GET_COMMS_RX_CFG_EBN0:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_GET_COMMS_RX_CFG_CARRIER_LOCK:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_GET_COMMS_RX_FRAME_LOCK:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;

            case TC_GET_COMMS_SYS_CFG:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_GET_COMMS_BOOT_ACTIVATE:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_GET_COMMS_BOOT_CFG:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_GET_COMMS_GWDT_CFG:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_GET_COMMS_CAN_CFG:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_GET_COMMS_UART_CFG:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_GET_COMMS_CSP_CFG:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_GET_COMMS_NET_CFG:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_GET_COMMS_TM_INFO:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_GET_COMMS_RX_TM_INFO:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_GET_COMMS_TX_TM_INFO:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_GET_COMMS_CSP_TM_INFO:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_OBC_IPCC_TEST:
                {
                    uint16_t vm_id = 0;
                    printf("Enter IPCC Message ID to initiate IPCC Message\n");
                    if(autom_i < autom_user_input.autom_arg_cnt && autom_user_input.autom_argv_valid[autom_i])
                    {
                        autom_i++;
                        ipcc_test = atoi((char*)autom_user_input.autom_argv[autom_i]);
                    }
                    else
                    {
                        scanf("%hd",&ipcc_test);
                    }
                    printf("Entered IPCC Message ID: %d\n",ipcc_test);
                    switch(ipcc_test)
                    {
                        uint8_t ip_address[4];
                        uint8_t trans_mode;
                        uint16_t port;
                        char file_name[51];
                        char file_del[100];
                        //    uint8_t del_no = 0;

                        case 1:
                        case 2:
                        case 5:
                        case 6:
                        case 7:
                        case 8:
                        case 9:
                        case 10:
                        case 11:
                        case 12:
                        case 13:
                        case 14:
                        case 15:
                        case 16:
                        case 17:
                        case 18:
                        case 19:
                        case 20:
                        case 21:
                        case 22:
                        case 23:
                        case 24:
                        case 25:
                        case 26:
                        case 27:
                        case 28:
                        case 29:
                        case 30:
                        case 31:
                        tc_len = sizeof(ipcc_test);
                        tc_data= (uint8_t *)malloc(tc_len);
                        memcpy(tc_data,&ipcc_test,tc_len);
                        break;
                        case 3:
                        case 4:
                        tc_len = 4;
                        tc_data= (uint8_t *)malloc(tc_len);
                        memcpy(tc_data,&ipcc_test,2);
                        printf("Enter the VM ID\n");
                        scanf("%hd", &vm_id);
                        memcpy(&tc_data[2], &vm_id, 2);
                        break;
                        /*SBand Firmware update - TFTP file start message
                         * TC data frame ---> CRRNID - 2Byte, IP address - 4byte, Port no- 2Byte, FileTransfer mode- 1Byte, Filename- 51Byte
                         */
                        case 32:
                        tc_len = 60;
                        tc_data= (uint8_t *)malloc(tc_len);
                        memcpy(tc_data,&ipcc_test,2);
                        printf("Enter the IP address \n");
                        scanf("%hhd",&ip_address[0]);
                        scanf("%hhd",&ip_address[1]);
                        scanf("%hhd",&ip_address[2]);
                        scanf("%hhd",&ip_address[3]);
                        memcpy(&tc_data[2], &ip_address[0], 4);
                        printf("Enter the port number\n");
                        scanf("%hd",&port);
                        printf("Select the file transfer mode\n");
                        printf("0.Binary\n1.Hexadecimal\n");
                        scanf("%hhd",&trans_mode);
                        printf("Select the file name to start TFTP transfer to SBAND\n");
                        scanf("%s",file_name);
                        memcpy(&tc_data[6], &port, 2);
                        tc_data[8] = trans_mode;
                        memcpy(&tc_data[9], &file_name, 51);
                        break;
                        /*SBand Firmware update - TFTP file delete message
                         * TC data frame ---> CRRNID - 2Byte, NO of files to delete - 1Byte, File names - 100Byte
                         */
                        case 33:
                        tc_len = 103;
                        tc_data= (uint8_t *)malloc(tc_len);
                        memcpy(tc_data,&ipcc_test,2);
                        printf("Enter the no of firmware files to delete in PS\n");
                        printf("0-To delete all files\n N-To delete multiple files\n");
                        scanf("%hhd",&tc_data[2]);
                        if(0 != tc_data[2])
                        {
                            printf("Enter the firmware files to delete in PS\n");
                            scanf("%s",file_del);
                        }
                        memcpy(&tc_data[3], &file_del, 100);
                        break;

                        default:
                        printf("invalid selection\n");
                        break;

                    }

                }
                break;

            case TC_OBC_ES_IPCC_TEST:
                {
                    uint16_t vm_id = 0;
                    printf("Enter IPCC Message ID to initiate IPCC Message\n");
                    if(autom_i < autom_user_input.autom_arg_cnt && autom_user_input.autom_argv_valid[autom_i])
                    {
                        autom_i++;
                        ipcc_test = atoi((char*)autom_user_input.autom_argv[autom_i]);
                    }
                    else
                    {
                        scanf("%hd",&ipcc_test);
                    }
                    printf("Entered IPCC Message ID: %d\n",ipcc_test);
                    if((ipcc_test == 3) || (ipcc_test == 4))
                    {
                        tc_len = 4;
                        tc_data= (uint8_t *)malloc(tc_len);
                        memcpy(tc_data,&ipcc_test,2);
                        printf("Enter the VM ID\n");
                        scanf("%hd", &vm_id);
                        memcpy(&tc_data[2], &vm_id, 2);

                    }
                    else
                    {
                        tc_len = sizeof(ipcc_test);
                        tc_data= (uint8_t *)malloc(tc_len);
                        memcpy(tc_data,&ipcc_test,tc_len);
                    }
                    status = 0;
                }
                break;

            case TC_COMMS_UHF_GET_TM_INFO:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;

            case TC_COMMS_UHF_SET_CFG:
                {
                    tc_len =  46;
                    tc_data = (uint8_t *) malloc(tc_len);

                    uint8_t uhf_regs[46]={0xD3,0x91,0xFF,0x04,0x05,0x00,0x14,0x0C,0x00,0x22,0xB1,0x3B,0x2D,0x3B,0x13,0x22,0xF8,0x62,0x07,0x30,0x18,0x1D,0x1C,0xC7,0x00,0xB0,0xB6,0x10,0xEA,0x2A,0x00,0x1F,0x88,0x31,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x8E,0x00,0x00,0x06};
                    memcpy(tc_data,&uhf_regs[0],46);

                }
                break;


            case TC_COMMS_UHF_SET_TX_CFG:
                {
                    tc_len = sizeof(s_uhf_rf_cfg);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(uhf_set == 1)
                    {
                        set_rf_cfg.Base_Frequency = 400200000;
                        set_rf_cfg.IF_Frequnecy = 158203;
                        set_rf_cfg.Channel_Number = 0;
                        set_rf_cfg.Channel_Spacing= 363372.8027;
                        set_rf_cfg.Frequency_Offset = 0;
                        set_rf_cfg.Modulation_Type = 0;
                        set_rf_cfg.Sync_Mode = 3;
                        set_rf_cfg.Data_Rate =7415.771;
                        set_rf_cfg.Enable_DC_filter = 0;
                        set_rf_cfg.FEC_enable = 1;
                        set_rf_cfg.Preamble_Num = 2;
                        set_rf_cfg.Channel_BW = 60267;
                        set_rf_cfg.Manchester_Enable =0;
                        set_rf_cfg.Frequency_deviation = 3707.866;
                    }

                    else
                    {
                        printf("Enter base frequency:");
                        scanf("%f",&set_rf_cfg.Base_Frequency);
                        printf("\nEnter IF frequency:");
                        scanf("%f",&set_rf_cfg.IF_Frequnecy);
                        printf("\nEnter channle number:");
                        scanf("%hhu",&set_rf_cfg.Channel_Number);
                        printf("\nEnter channel spacing:");
                        scanf("%f",&set_rf_cfg.Channel_Spacing);
                        printf("\nEnter frequency offset:");
                        scanf("%f",&set_rf_cfg.Frequency_Offset);
                        printf("\nEnter modulation type:");
                        scanf("%hhu",&set_rf_cfg.Modulation_Type);
                        printf("\nEnter sync mode:");
                        scanf("%hhu",&set_rf_cfg.Sync_Mode);
                        printf("\nEnter data rate:");
                        scanf("%f",&set_rf_cfg.Data_Rate);
                        printf("\nEnter enable dc filter:");
                        scanf("%hhu",&set_rf_cfg.Enable_DC_filter);
                        printf("\nEnter fec enable:");
                        scanf("%hhu",&set_rf_cfg.FEC_enable);
                        printf("\nEnter preamble number:");
                        scanf("%hhu",&set_rf_cfg.Preamble_Num);
                        printf("\nEnter channel bw:");
                        scanf("%f",&set_rf_cfg.Channel_BW);
                        printf("\nEnter manchester enable:");
                        scanf("%hhu",&set_rf_cfg.Manchester_Enable);
                        printf("\nEnter frequency deviation:");
                        scanf("%f",&set_rf_cfg.Frequency_deviation);

                    }
                    memcpy(tc_data,&set_rf_cfg,sizeof(s_uhf_rf_cfg));

                    printf("base frequency :%f\n",set_rf_cfg.Base_Frequency);
                    printf("if frequency :%f\n",set_rf_cfg.IF_Frequnecy);
                    printf("channel number :%hhu\n",set_rf_cfg.Channel_Number);
                    printf("channel spacing :%f\n",set_rf_cfg.Channel_Spacing);
                    printf("frequency offset :%f\n",set_rf_cfg.Frequency_Offset);
                    printf("modulation type :%hhu\n",set_rf_cfg.Modulation_Type);
                    printf("sync mode :%hhu\n",set_rf_cfg.Sync_Mode);
                    printf("data rate :%f\n",set_rf_cfg.Data_Rate);
                    printf("enable dc filter :%hhu\n",set_rf_cfg.Enable_DC_filter);
                    printf("fec enable :%hhu\n",set_rf_cfg.FEC_enable);
                    printf("preamble number :%hhu\n",set_rf_cfg.Preamble_Num);
                    printf("channel bw :%f\n",set_rf_cfg.Channel_BW);
                    printf("manchester enable :%hhu\n",set_rf_cfg.Manchester_Enable);
                    printf("frequency deviation :%f\n",set_rf_cfg.Frequency_deviation);
                    status = 0;
                }
                break;

            case TC_COMMS_UHF_GET_TX_CFG:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);
                    status = 0;
                }
                break; 
            case TC_COMMS_UHF_SET_RX_CFG:
                {
                    tc_len = sizeof(s_uhf_rf_rx_cfg);
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(uhf_set == 1)

                    {
                        set_rf_rx_cfg.Base_Frequency = 450100000;
                        set_rf_rx_cfg.IF_Frequnecy = 158203;
                        set_rf_rx_cfg.Channel_Number = 0;
                        set_rf_rx_cfg.Channel_Spacing= 363372.8027;
                        set_rf_rx_cfg.Frequency_Offset = 0;
                        set_rf_rx_cfg.Modulation_Type = 0;
                        set_rf_rx_cfg.Sync_Mode = 3;
                        set_rf_rx_cfg.Data_Rate =7415.771;
                        set_rf_rx_cfg.Enable_DC_filter = 0;
                        set_rf_rx_cfg.FEC_enable = 1;
                        set_rf_rx_cfg.Preamble_Num = 2;
                        set_rf_rx_cfg.Channel_BW = 60267.857;
                        set_rf_rx_cfg.Manchester_Enable =0;
                        set_rf_rx_cfg.Frequency_deviation = 3707.866;
                        set_rf_rx_cfg.RX_Sync_Time_Out = 7;
                        set_rf_rx_cfg.RX_Attenuation = 0;

                    }

                    else 
                    {
                        printf("Enter base frequency : ");
                        scanf("%f",&set_rf_rx_cfg.Base_Frequency);
                        printf("\nEnter if frequency: ");
                        scanf("%f",&set_rf_rx_cfg.IF_Frequnecy);
                        printf("\nEnter channel number: ");
                        scanf("%hhu",&set_rf_rx_cfg.Channel_Number);
                        printf("\nEnter channel spacing: ");
                        scanf("%f",&set_rf_rx_cfg.Channel_Spacing);
                        printf("\nEnter frequency offset: ");
                        scanf("%f",&set_rf_rx_cfg.Frequency_Offset);
                        printf("\nEnter modulation type: ");
                        scanf("%hhu",&set_rf_rx_cfg.Modulation_Type);
                        printf("\nEnter sync mode: ");
                        scanf("%hhu",&set_rf_rx_cfg.Sync_Mode);
                        printf("\nEnter data rate: ");
                        scanf("%f",&set_rf_rx_cfg.Data_Rate);
                        printf("\nEnter enable dc filter: ");
                        scanf("%hhu",&set_rf_rx_cfg.Enable_DC_filter);
                        printf("\nEnter fec enable: ");
                        scanf("%hhu",&set_rf_rx_cfg.FEC_enable);
                        printf("\nEnter preamble number: ");
                        scanf("%hhu",&set_rf_rx_cfg.Preamble_Num);
                        printf("\nEnter channel bw: ");
                        scanf("%f",&set_rf_rx_cfg.Channel_BW);
                        printf("\nEnter manchester enable: ");
                        scanf("%hhu",&set_rf_rx_cfg.Manchester_Enable);
                        printf("\nEnter frequency deviation: ");
                        scanf("%f",&set_rf_rx_cfg.Frequency_deviation);
                        printf("\nEnter rx sync timeout: ");
                        scanf("%f",&set_rf_rx_cfg.RX_Sync_Time_Out);
                        printf("\nEnter rx attenuation: ");
                        scanf("%hhu",&set_rf_rx_cfg.RX_Attenuation);
                    }
                    memcpy(tc_data,&set_rf_rx_cfg,sizeof(s_uhf_rf_rx_cfg));

                    printf("Base Frequency:%f\n",set_rf_rx_cfg.Base_Frequency);
                    printf("IF Frequency:%f\n",set_rf_rx_cfg.IF_Frequnecy);
                    printf("Channel Number:%hhu\n",set_rf_rx_cfg.Channel_Number);
                    printf("Channel Spacing:%f\n",set_rf_rx_cfg.Channel_Spacing);
                    printf("Frequency Offset:%f\n",set_rf_rx_cfg.Frequency_Offset);
                    printf("Modulation Type:%hhu\n",set_rf_rx_cfg.Modulation_Type);
                    printf("Sync Mode:%hhu\n",set_rf_rx_cfg.Sync_Mode);
                    printf("Data Rate:%f\n",set_rf_rx_cfg.Data_Rate);
                    printf("Enable DC filter:%hhu\n",set_rf_rx_cfg.Enable_DC_filter);
                    printf("FEC enable:%hhu\n",set_rf_rx_cfg.FEC_enable);
                    printf("Preamble Number:%hhu\n",set_rf_rx_cfg.Preamble_Num);
                    printf("Channel BW:%f\n",set_rf_rx_cfg.Channel_BW);
                    printf("Manchester Enable:%hhu\n",set_rf_rx_cfg.Manchester_Enable);
                    printf("Frequency deviation:%f\n",set_rf_rx_cfg.Frequency_deviation);
                    printf("RX Sync Time Out:%f\n",set_rf_rx_cfg.RX_Sync_Time_Out);
                    printf("RX Attenuation:%hhu\n",set_rf_rx_cfg.RX_Attenuation);


                    status = 0;
                }
                break;

            case TC_COMMS_UHF_GET_RX_CFG:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);
                    status = 0;
                }
                break;

            case TC_COMMS_UHF_SET_TX_PKT_CFG:
                {
                    tc_len = sizeof(s_uhf_rf_tx_pkt_cfg);
                    tc_data = (uint8_t *) malloc(tc_len);

                    if(uhf_set ==1)
                    {
                        set_rx_tc_pkt_cfg.Demod_Sync_Word = 37331;
                        set_rx_tc_pkt_cfg.Max_Packet_Length = 255;
                        set_rx_tc_pkt_cfg.Whitening_Enable = 1;
                        set_rx_tc_pkt_cfg.Packet_Format = 0;
                        set_rx_tc_pkt_cfg.CRC_Enable = 0;
                        set_rx_tc_pkt_cfg.Pkt_Len_Config = 1;
                        set_rx_tc_pkt_cfg.Device_Addr = 0;
                    }

                    else
                    {
                        printf("Enter demod sync word: ");
                        scanf("%hu",&set_rx_tc_pkt_cfg.Demod_Sync_Word);
                        printf("\nEnter maximum packet length: ");
                        scanf("%hhu",&set_rx_tc_pkt_cfg.Max_Packet_Length);
                        printf("\nEnter whitening enable: ");
                        scanf("%hhu",&set_rx_tc_pkt_cfg.Whitening_Enable);
                        printf("\nEnter packet format: ");
                        scanf("%hhu",&set_rx_tc_pkt_cfg.Packet_Format);
                        printf("\nEnter crc enable: ");
                        scanf("%hhu",&set_rx_tc_pkt_cfg.CRC_Enable);
                        printf("\nEnter packet length configuration: ");
                        scanf("%hhu",&set_rx_tc_pkt_cfg.Pkt_Len_Config);
                        printf("\nEnter device address: ");
                        scanf("%hhu",&set_rx_tc_pkt_cfg.Device_Addr);
                    }
                    memcpy(tc_data,&set_rx_tc_pkt_cfg,sizeof(s_uhf_rf_tx_pkt_cfg));

                    printf("Demod Sync Word:%hu\n",set_rx_tc_pkt_cfg.Demod_Sync_Word);
                    printf("Maximum Packet Length:%hhu\n",set_rx_tc_pkt_cfg.Max_Packet_Length);
                    printf("Whitening Enable:%hhu\n",set_rx_tc_pkt_cfg.Whitening_Enable);
                    printf("Packet Format:%hhu\n",set_rx_tc_pkt_cfg.Packet_Format);
                    printf("CRC Enable:%hhu\n",set_rx_tc_pkt_cfg.CRC_Enable);
                    printf("Pkt Length Config:%hhu\n",set_rx_tc_pkt_cfg.Pkt_Len_Config);
                    printf("Device Address:%hhu\n",set_rx_tc_pkt_cfg.Device_Addr);


                    status = 0;
                    break;
                }
                break;

            case TC_COMMS_UHF_GET_TX_PKT_CFG:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);
                    status = 0;
                }
                break;

            case TC_COMMS_UHF_SET_RX_PKT_CFG:
                {
                    tc_len = sizeof(s_uhf_rf_rx_pkt_cfg);
                    tc_data = (uint8_t *) malloc(tc_len);

                    if(uhf_set == 1)
                    {
                        set_rf_rx_pkt_cfg.Demod_Sync_Word = 37331;
                        set_rf_rx_pkt_cfg.Max_Packet_Length = 255;
                        set_rf_rx_pkt_cfg.Whitening_Enable = 1;
                        set_rf_rx_pkt_cfg.Packet_Format = 0;
                        set_rf_rx_pkt_cfg.CRC_Enable = 0;
                        set_rf_rx_pkt_cfg.Pkt_Len_Config = 1;
                        set_rf_rx_pkt_cfg.Device_Addr = 0;
                    }

                    else
                    {
                        printf("Enter demod sync word: ");
                        scanf("%hu",&set_rf_rx_pkt_cfg.Demod_Sync_Word);
                        printf("\nEnter maximum packet length: ");
                        scanf("%hhu",&set_rf_rx_pkt_cfg.Max_Packet_Length);
                        printf("\nEnter whitening enable ");
                        scanf("%hhu",&set_rf_rx_pkt_cfg.Whitening_Enable);
                        printf("\nEnter packet format: ");
                        scanf("%hhu",&set_rf_rx_pkt_cfg.Packet_Format);
                        printf("\nEnter crc enable: ");
                        scanf("%hhu",&set_rf_rx_pkt_cfg.CRC_Enable);
                        printf("\nEnter packet length configuration: ");
                        scanf("%hhu",&set_rf_rx_pkt_cfg.Pkt_Len_Config);
                        printf("\nEnter device address ");
                        scanf("%hhu",&set_rf_rx_pkt_cfg.Device_Addr);
                    }
                    memcpy(tc_data,&set_rf_rx_pkt_cfg,sizeof(s_uhf_rf_rx_pkt_cfg));

                    printf("Demod Sync Word:%hu\n",set_rf_rx_pkt_cfg.Demod_Sync_Word);
                    printf("Maximum Packet Length:%hhu\n",set_rf_rx_pkt_cfg.Max_Packet_Length);
                    printf("Whitening Enable:%hhu\n",set_rf_rx_pkt_cfg.Whitening_Enable);
                    printf("Packet Format:%hhu\n",set_rf_rx_pkt_cfg.Packet_Format);
                    printf("CRC Enable:%hhu\n",set_rf_rx_pkt_cfg.CRC_Enable);
                    printf("Pkt Length Config:%hhu\n",set_rf_rx_pkt_cfg.Pkt_Len_Config);
                    printf("device address :%hhu\n",set_rf_rx_pkt_cfg.Device_Addr);

                    status =0;
                }
                break;

            case TC_COMMS_UHF_GET_RX_PKT_CFG:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);
                    status = 0;
                }
                break;

            case TC_COMMS_UHF_SET_PWR_CFG:
                {
                    tc_len = sizeof(s_uhf_set_pwr_stng);
                    tc_data = (uint8_t *) malloc(tc_len);

                    if(uhf_set ==1)
                    {
                        set_pwr_stng.Max_DVGA_Gain = 0;
                        set_pwr_stng.Max_LNA_Gain = 0;
                        set_pwr_stng.LNA_Sel = 1;
                        set_pwr_stng.Filter_Len = 1;
                        set_pwr_stng.Power_Table_sel = 0;
                        set_pwr_stng.RF_Output_Power = 192;
                    }
                    else
                    {
                        printf("Enter maximum dvgs gain: ");
                        scanf("%hhu",&set_pwr_stng.Max_DVGA_Gain);
                        printf("\nEnter maximum lna gain: ");
                        scanf("%hhu",&set_pwr_stng.Max_LNA_Gain);
                        printf("\nEnter lna set: ");
                        scanf("%hhu",&set_pwr_stng.LNA_Sel);
                        printf("\nEnter filter length: ");
                        scanf("%hhu",&set_pwr_stng.Filter_Len);
                        printf("\nEnter power table set: ");
                        scanf("%hhu",&set_pwr_stng.Power_Table_sel);
                        printf("\nEnter rf output power: ");
                        scanf("%hhu",&set_pwr_stng.RF_Output_Power);
                    }
                    memcpy(tc_data,&set_pwr_stng,sizeof(s_uhf_set_pwr_stng));

                    printf("Maximum DVGA Gain :%hhu\n",set_pwr_stng.Max_DVGA_Gain);
                    printf("Maximum LNA Gain: %hhu\n",set_pwr_stng.Max_LNA_Gain);
                    printf("LNA_Sel :%hhu\n",set_pwr_stng.LNA_Sel);
                    printf("Filter Length:%hhu\n",set_pwr_stng.Filter_Len);
                    printf("Power table selection:%hhu\n",set_pwr_stng.Power_Table_sel);
                    printf("RF Output Power:%hhu\n",set_pwr_stng.RF_Output_Power);


                    status = 0;
                }
                break;

            case TC_COMMS_UHF_GET_PWR_CFG:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);
                    status = 0;
                }
                break;

            case TC_COMMS_UHF_BEACON_CFG:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);
                    status = 0;
                }
                break;

            case TC_COMMS_UHF_BEACON_TX_ST:
                {
                    uint8_t beacon_op = 0;
                    tc_len = 1;
                    tc_data = (uint8_t *) malloc(tc_len);
                    printf("Enter Beacon start 1-UHF or 2-OBC or 3-UHF+OBC:");
                    scanf("%hhd",&beacon_op);
                    memcpy(tc_data,&beacon_op, tc_len);

                    status = 0;
                }
                break;

            case TC_COMMS_UHF_BEACON_TX_STOP:
                {
                    uint8_t beacon_op = 0;
                    tc_len = 1;
                    tc_data = (uint8_t *) malloc(tc_len);
                    printf("Enter Beacon stop 1-UHF or 2-OBC or 3-UHF+OBC:");
                    scanf("%hhd",&beacon_op);
                    memcpy(tc_data,&beacon_op, tc_len);

                    status = 0;
                }
                break;

            case TC_COMMS_UHF_BEACON_DATA:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    status = 0;
                }
                break;


            case TC_COMMS_UHF_FW_CFG:
                {
                    tc_len = 32;
                    tc_data = (uint8_t *) malloc(tc_len);
                    char sign_key[32] = {0}; 
                    printf("Enter UHF FW Signature Key");
                    scanf("%s",sign_key);

                    memcpy(tc_data,sign_key,tc_len);


                    status = 0;
                }
                break;


            case TC_COMMS_UHF_FW_CFG_ACTIVATE:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);
                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;

            case TC_COMMS_UHF_CSP_TM_INFO:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("In telemetry request case \n");
                    status = 0;
                }
                break;


            case TC_COMMS_UHF_GET_TM_STORE:
                {
                    tc_len = 0;
                    tc_data = (uint8_t*)malloc(tc_len);

                    printf("In telemetry request case \n");

                    status = 0;

                }
                break;

            case TC_COMMS_UHF_GET_FW_STS:
                {
                    char loc_str[50];
                    uint32_t file_size,checksum;

                    tc_len = 8;
                    tc_data = (uint8_t *)malloc(tc_len);
                    printf("\r\nEnter input file name\r\n");
                    scanf("%s",loc_str);
                    FILE *fp = fopen(loc_str, "r");
                    if (fp == NULL)
                    {
                        printf("File %s Not Found! Enter again\n",loc_str);

                    }
                    else
                    {
                        fclose(fp);
                        file_size = file_findSize(loc_str);
                        if ((file_size != -1) && (file_size != 0))
                        {
                            checksum = file_checksum(loc_str, file_size);
                            memcpy(&tc_data[0],&file_size,4);
                            memcpy(&tc_data[4],&checksum,4);
                            printf("Size = %d\n", file_size);
                            printf("CRC = %x\n", checksum);
                        }
                        else
                        {
                            printf("NO data in the selected file\n");
                        }

                    }

                    status =0;
                }
                break;

            case TC_MEMD:
                {
                    tc_len = 1;
                    tc_data = (uint8_t*)malloc(tc_len);

                    tc_data[0] = obc_mem_debug_tc_enc();

                    status = 0;
                }
                break;

            case TC_SET_SDR_CFG:
                {

                    uint8_t num_sdr=2;
                    int sdr_idx = 0;
                    /*printf("Enter number of SDRs\n ");
                      scanf("%hhd",&num_sdr);*/

                    tc_len = (sizeof(s_sdr_cfg)*num_sdr)+sizeof(uint8_t);
                    tc_data = (uint8_t *) malloc(tc_len);

                    memcpy(tc_data,&num_sdr,sizeof(uint8_t));

                    for(sdr_idx = 0; sdr_idx<num_sdr;sdr_idx++)
                    {
                        printf("Enter radio ID: \n1 - SRS-4 \n2 - UHF \n3 - IQS SBAND\n ");
                        scanf("%hhd",&set_sdr_cfg.radio_id);
                        if(set_sdr_cfg.radio_id < 1 || set_sdr_cfg.radio_id > 3)
                        {
                            printf("Invalid Test ID\n");
                            status = -1;
                        }
                        else
                        {
                            printf("\nEnter sdr status: ");
                            scanf("%hhu",&set_sdr_cfg.sdr_sts);
                            printf("\nEnter sdr duplex type: ");
                            scanf("%hhu",&set_sdr_cfg.sdr_dplx_typ);
                            printf("\nEnter sdr number of rx: ");
                            scanf("%hhu",&set_sdr_cfg.sdr_num_rx);
                            printf("\nEnter sdr number of tx: ");
                            scanf("%hhu",&set_sdr_cfg.sdr_num_tx);
                            printf("\nEnter sdr combined rx support: ");
                            scanf("%hhu",&set_sdr_cfg.combined_rx_support);
                            printf("\nEnter sdr combined tx support: ");
                            scanf("%hhu",&set_sdr_cfg.combined_tx_support);
                            printf("\nEnter sdr minimum frequency: ");
                            scanf("%u",&set_sdr_cfg.min_frequency);
                            printf("\nEnter sdr maximum frequency: ");
                            scanf("%u",&set_sdr_cfg.max_frequency);
                            printf("\nEnter minimum rx frequency: ");
                            scanf("%u",&set_sdr_cfg.min_frequency_rx);
                            printf("\nEnter maximum rx frquency: ");
                            scanf("%u",&set_sdr_cfg.max_frequency_rx);

                            memcpy((tc_data + sizeof(uint8_t) + (sizeof(s_sdr_cfg)*sdr_idx)),&set_sdr_cfg,sizeof(s_sdr_cfg));

                            printf("sdr status :%hhu\n",set_sdr_cfg.sdr_sts);
                            printf("sdr duplex type: :%hhu\n",set_sdr_cfg.sdr_dplx_typ);
                            printf("sdr number of rx :%hhu\n",set_sdr_cfg.sdr_num_rx);
                            printf("sdr number of tx :%hhu\n",set_sdr_cfg.sdr_num_tx);
                            printf("sdr combined rx support :%hhu\n",set_sdr_cfg.combined_rx_support);
                            printf("sdr combined tx support :%hhu\n",set_sdr_cfg.combined_tx_support);
                            printf("sdr minimum frequency :%u\n",set_sdr_cfg.min_frequency);
                            printf("sdr maximum frequency :%u\n",set_sdr_cfg.max_frequency);
                            printf("minimum rx frequency :%hhu\n",set_sdr_cfg.min_frequency_rx);
                            printf("maximum rx frquency :%hhu\n",set_sdr_cfg.max_frequency_rx);
                            status = 0;
                        }
                    }

                }

                break;
            case TC_GET_SDR_CFG:


                {
                    printf("Enter radio ID: \n1 - SRS-4 \n2 - UHF \n3 - IQS SBAND\n ");
                    scanf("%hhd",&sdr_radio_mod_id);
                    if(sdr_radio_mod_id < 1 || sdr_radio_mod_id > 3)
                    {
                        printf("Invalid Test ID\n");
                        status = -1;
                    } 
                    else
                    {
                        tc_len = sizeof(sdr_radio_mod_id);
                        tc_data = (uint8_t *) malloc(tc_len);
                        memcpy(tc_data, &sdr_radio_mod_id,sizeof(sdr_radio_mod_id));
                        printf("Get Radio ID CFG: %d %d", sdr_radio_mod_id, tc_data[0]);
                        status = 0;
                    }
                }
                break;

            case TC_SET_SDR_STS:
                {
                    tc_len = sizeof(s_sdr_set_sts);



                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("Enter radio ID:  \n1 - SRS-4 \n2 - UHF \n3 - IQS SBAND");
                    scanf("%hhd",&sdr_radio_mod_id);
                    if(sdr_radio_mod_id < 1 || sdr_radio_mod_id > 3)
                    {
                        printf("Invalid Test ID\n");
                        status = -1;
                    }
                    else 
                    {
                        printf("\nEnter sdr status: ");
                        scanf("%hhu",&sdr_set_sts.sdr_sts);

                        memcpy(tc_data,&sdr_set_sts,sizeof(s_sdr_set_sts));

                        printf("SDR status :%hhu\n",sdr_set_sts.sdr_sts);

                        status = 0;
                    }
                }
                break;

            case TC_GET_SDR_STS:
                {
                    printf("Enter radio ID:  \n1 - SRS-4 \n2 - UHF \n3 - IQS SBAND");
                    scanf("%hhd",&sdr_radio_mod_id);
                    if(sdr_radio_mod_id < 1 || sdr_radio_mod_id > 3)
                    {
                        printf("Invalid Test ID\n");
                        status = -1;
                    }
                    else
                    {
                        tc_len = 0;
                        tc_data = (uint8_t *) malloc(tc_len);

                        printf("In telemetry request case \n");
                        status = 0;
                    }
                }
                break;

            case TC_SET_SDR_TMR_CFG:
                {

                    tc_len = sizeof(s_sdr_tmr_cfg)+sizeof(sdr_radio_mod_id);
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("Enter radio ID:  \n1 - SRS-4 \n2 - UHF \n3 - IQS SBAND\n");
                    scanf("%hhd",&sdr_radio_mod_id);
                    if(sdr_radio_mod_id < 1 || sdr_radio_mod_id > 3)
                    {
                        printf("Invalid Test ID\n");
                        status = -1;
                    }
                    else
                    {
                        memcpy(tc_data,&sdr_radio_mod_id,sizeof(sdr_radio_mod_id));
                        printf("Enter beacon enable timer: ");
                        scanf("%u",&sdr_tmr_cfg.beacon_enb_tmr);
                        printf("\nEnter beacon periodicity timer: ");
                        scanf("%u",&sdr_tmr_cfg.beacon_prd_tmr);
                        printf("\nEnter beacon rep timer: ");
                        scanf("%u",&sdr_tmr_cfg.beaocn_rep_tmr);
                        printf("\nEnter tx data rep count: ");
                        scanf("%u",&sdr_tmr_cfg.tx_data_rep_cnt);
                        printf("\nEnter sdr tm timer: ");
                        scanf("%u",&sdr_tmr_cfg.sdr_tm_tmr);
                        printf("\nEnter sdr tx on timer: ");
                        scanf("%u",&sdr_tmr_cfg.sdr_tx_on_tmr);
                        printf("\nEnter sdr rx on timer: ");
                        scanf("%u",&sdr_tmr_cfg.sdr_rx_on_tmr);
                        printf("\nEnter sdr tm read timer: ");
                        scanf("%u",&sdr_tmr_cfg.sdr_tm_read_tmr);

                        memcpy(&tc_data[1],&sdr_tmr_cfg,sizeof(s_sdr_tmr_cfg));

                        printf("beacon enable timer :%u\n",sdr_tmr_cfg.beacon_enb_tmr);
                        printf("beacon periodicity timer :%u\n",sdr_tmr_cfg.beacon_prd_tmr);
                        printf("beacon rep timer :%u\n",sdr_tmr_cfg.beaocn_rep_tmr);
                        printf("tx data rep cnt :%u\n",sdr_tmr_cfg.tx_data_rep_cnt);
                        printf("sdr tm timer :%u\n",sdr_tmr_cfg.sdr_tm_tmr);
                        printf("sdr tx on timer :%u\n",sdr_tmr_cfg.sdr_tx_on_tmr);
                        printf("sdr rx on timer :%u\n",sdr_tmr_cfg.sdr_rx_on_tmr);
                        printf("sdr tm read timer :%u\n",sdr_tmr_cfg.sdr_tm_read_tmr);

                        status = 0;
                        break;
                    }
                }

            case TC_GET_SDR_TMR_CFG:
                {
                    printf("Enter radio ID:  \n1 - SRS-4 \n2 - UHF \n3 - IQS SBAND\n");
                    scanf("%hhd",&sdr_radio_mod_id);

                    if(sdr_radio_mod_id < 1 || sdr_radio_mod_id > 3)
                    {
                        printf("Invalid Test ID\n");
                        status = -1;
                    }
                    else
                    {
                        tc_len = sizeof(sdr_radio_mod_id);
                        tc_data = (uint8_t *) malloc(tc_len);
                        memcpy(tc_data, &sdr_radio_mod_id,sizeof(sdr_radio_mod_id));
                        status = 0;
                    }
                }
                break;

            case TC_SET_SDR_RX_RSSI_CFG:
                {

                    tc_len = sizeof(s_sdr_rx_rssi_cfg)+sizeof(sdr_radio_mod_id);
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("Enter radio ID:  \n1 - SRS-4 \n2 - UHF \n3 - IQS SBAND\n");
                    scanf("%hhd",&sdr_radio_mod_id);
                    if(sdr_radio_mod_id < 1 || sdr_radio_mod_id > 3)
                    {
                        printf("Invalid Test ID\n");
                        status = -1;
                    }
                    else
                    {
                        memcpy(tc_data,&sdr_radio_mod_id,sizeof(sdr_radio_mod_id));
                        printf("\nEnter valid rssi count: ");
                        scanf("%hhu",&sdr_rx_rssi_cfg.valid_rssi_cnt);
                        printf("\nEnter inv rssi count: ");
                        scanf("%hhu",&sdr_rx_rssi_cfg.inv_rssi_cnt);
                        printf("\nEnter rssi minimum: ");
                        scanf("%f",&sdr_rx_rssi_cfg.rssi_min);
                        printf("\nEnter rssi typical: ");
                        scanf("%f",&sdr_rx_rssi_cfg.rssi_typ);
                        printf("\nEnter rssi periodicity timer: ");
                        scanf("%u",&sdr_rx_rssi_cfg.rssi_prd_tmr);
                        printf("\nEnter short rx on timer: ");
                        scanf("%u",&sdr_rx_rssi_cfg.short_rx_on_timer);
                        printf("\nEnter long rx on timer: ");
                        scanf("%u",&sdr_rx_rssi_cfg.long_rx_on_timer);

                        memcpy(&tc_data[1],&sdr_rx_rssi_cfg,sizeof(s_sdr_rx_rssi_cfg));

                        printf("valid rssi count :%hhu\n",sdr_rx_rssi_cfg.valid_rssi_cnt);
                        printf("inv rssi count :%hhu\n",sdr_rx_rssi_cfg.inv_rssi_cnt);
                        printf("rssi minimum :%f\n",sdr_rx_rssi_cfg.rssi_min);
                        printf("rssi typical :%f\n",sdr_rx_rssi_cfg.rssi_typ);
                        printf("rssi periodicity timer :%u\n",sdr_rx_rssi_cfg.rssi_prd_tmr);
                        printf("short rx on tmr :%u\n",sdr_rx_rssi_cfg.short_rx_on_timer);
                        printf("long rx on tmr :%u\n",sdr_rx_rssi_cfg.long_rx_on_timer);


                        status = 0;
                        break;
                    }
                }

            case TC_GET_SDR_RX_RSSI_CFG:
                {
                    printf("Enter radio ID:  \n1 - SRS-4 \n2 - UHF \n3 - IQS SBAND\n");
                    scanf("%hhd",&sdr_radio_mod_id);

                    if(sdr_radio_mod_id < 1 || sdr_radio_mod_id > 3)
                    {
                        printf("Invalid Test ID\n");
                        status = -1;
                    }
                    else
                    {
                        tc_len = sizeof(sdr_radio_mod_id);
                        tc_data = (uint8_t *) malloc(tc_len);
                        memcpy(tc_data, &sdr_radio_mod_id,sizeof(sdr_radio_mod_id));
                        status = 0;

                    }
                }
                break;

            case TC_SET_SDR_TM_CFG:
                {

                    tc_len = sizeof(s_sdr_tm_cfg)+sizeof(sdr_radio_mod_id);
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("Enter radio ID:  \n1 - SRS-4 \n2 - UHF \n3 - IQS SBAND\n");
                    scanf("%hhd",&sdr_radio_mod_id);
                    if(sdr_radio_mod_id < 1 || sdr_radio_mod_id > 3)
                    {
                        printf("Invalid Test ID\n");
                        status = -1;
                    }
                    else
                    {
                        memcpy(tc_data,&sdr_radio_mod_id,sizeof(sdr_radio_mod_id));
                        printf("\nEnter tm auto read status: ");
                        scanf("%hhu",&sdr_tm_cfg.tm_auto_read_sts);
                        printf("\nEnter tm read periodicity: ");
                        scanf("%d",&sdr_tm_cfg.tm_read_periodicity);
                        printf("\nEnter tm short storage duration: ");
                        scanf("%d",&sdr_tm_cfg.tm_short_storage_duration);
                        printf("\nEnter tm long storage duration: ");
                        scanf("%d",&sdr_tm_cfg.tm_long_storage_duration);

                        memcpy(&tc_data[1],&sdr_tm_cfg,sizeof(s_sdr_tm_cfg));

                        printf("TM auto read sts :%hhu\n",sdr_tm_cfg.tm_auto_read_sts);
                        printf("TM read periodicity :%hhu\n",sdr_tm_cfg.tm_read_periodicity);
                        printf("TM short storage :%hhu\n",sdr_tm_cfg.tm_short_storage_duration);
                        printf("TM long storage :%hhu\n",sdr_tm_cfg.tm_long_storage_duration);

                        status = 0;
                        break;
                    }
                }


            case TC_GET_SDR_TM_CFG:
                {
                    printf("Enter radio ID:  \n1 - SRS-4 \n2 - UHF \n3 - IQS SBAND\n");
                    scanf("%hhd",&sdr_radio_mod_id);

                    if(sdr_radio_mod_id < 1 || sdr_radio_mod_id > 3)
                    {
                        printf("Invalid Test ID\n");
                        status = -1;
                    }
                    else
                    {
                        tc_len = sizeof(sdr_radio_mod_id);
                        tc_data = (uint8_t *) malloc(tc_len);
                        memcpy(tc_data, &sdr_radio_mod_id,sizeof(sdr_radio_mod_id));
                        status = 0;
                    }
                }
                break;

            case TC_SET_SDR_SENS_CFG:
                {

                    uint8_t temp_count =0;
                    uint8_t volt_count =0;
                    uint8_t cur_count =0;
                    uint8_t i = 0;

                    tc_len = sizeof(s_sdr_sens_cfg)+sizeof(sdr_radio_mod_id);
                    tc_data = (uint8_t *) malloc(tc_len);

                    printf("Enter radio ID:  \n1 - SRS-4 \n2 - UHF \n3 - IQS SBAND\n");
                    scanf("%hhd",&sdr_radio_mod_id);
                    if(sdr_radio_mod_id < 1 || sdr_radio_mod_id > 3)
                    {
                        printf("Invalid Test ID\n");
                        status = -1;
                    }
                    else
                    {
                        memcpy(tc_data,&sdr_radio_mod_id,sizeof(sdr_radio_mod_id));
                        printf("\nEnter Temp sensor count: ");
                        scanf("%hhd",&temp_count);
                        printf("\nEnter volt sensor count: ");
                        scanf("%hhd",&volt_count);
                        printf("\nEnter cur sensor count: ");
                        scanf("%hhd",&cur_count);
                        for(i = 0;i<temp_count;i++)
                        {
                            printf("\nEnter Temp sens type thrs: ");
                            scanf("%hu",&sdr_sns_cfg.temp_sensor[i].temp_sens_typ_thrs);
                            printf("\nEnter Temp sens min thrs: ");
                            scanf("%hu",&sdr_sns_cfg.temp_sensor[i].temp_sens_min_thrs);
                            printf("\nEnter Temp sens max thrs: ");
                            scanf("%hu",&sdr_sns_cfg.temp_sensor[i].temp_sens_max_thrs);
                        }

                        for(i = 0;i<volt_count;i++)
                        {
                            printf("\nEnter Volt sens type thrs: ");
                            scanf("%hu",&sdr_sns_cfg.volt_sensor[i].volt_sens_typ_thrs);
                            printf("\nEnter Volt sens min thrs: ");
                            scanf("%hu",&sdr_sns_cfg.volt_sensor[i].volt_sens_min_thrs);
                            printf("\nEnter Volt sens max thrs: ");
                            scanf("%hu",&sdr_sns_cfg.volt_sensor[i].volt_sens_max_thrs);
                        }

                        for(i = 0;i<cur_count;i++)
                        {
                            printf("\nEnter Cur sens type thrs: ");
                            scanf("%hu",&sdr_sns_cfg.current_sensor[i].cur_sens_typ_thrs);
                            printf("\nEnter Cur sens min thrs: ");
                            scanf("%hu",&sdr_sns_cfg.current_sensor[i].cur_sens_min_thrs);
                            printf("\nEnter Cur sens max thrs: ");
                            scanf("%hu",&sdr_sns_cfg.current_sensor[i].cur_sens_max_thrs);
                        }

                        memcpy(&tc_data[1],&sdr_sns_cfg,sizeof(s_sdr_sens_cfg));
                    }
                }
                break;

            case TC_GET_SDR_SENS_CFG:
                {
                    printf("Enter radio ID:  \n1 - SRS-4 \n2 - UHF \n3 - IQS SBAND\n");
                    scanf("%hhd",&sdr_radio_mod_id);
                    if(sdr_radio_mod_id < 1 || sdr_radio_mod_id > 3)
                    {
                        printf("Invalid Test ID\n");
                        status = -1;
                    }
                    else
                    {
                        tc_len = sizeof(sdr_radio_mod_id);
                        tc_data = (uint8_t *) malloc(tc_len);
                        memcpy(tc_data, &sdr_radio_mod_id,sizeof(sdr_radio_mod_id));
                        status = 0;
                    }
                }
                break;
            case TC_SET_SDR_OVER_RULE_CFG:
                {
                    uint8_t counter;
                    counter =0;
                    tc_len = sizeof(s_tctm_rm_overrule);
                    tc_data = (uint8_t *) malloc(tc_len);

                     do{
                         if(counter!=0)
                         {
                             printf("INVALID Overrule Input,Enter inputs again \n");
                         }
                         counter ++;
                         printf("Enter overule provision status \n0- Disable \n1- Enable\n");
                         scanf("%hhu",&tctm_overrule.overrule_enb);
                     }while(tctm_overrule.overrule_enb < 0 || tctm_overrule.overrule_enb > 1);

                     counter =0;
                     do{
                         if(counter!=0)
                         {
                             printf("INVALID Overrule Input,Enter inputs again \n");
                         }
                         counter ++;
                         printf("Enter normal radio ID \n1- SRS-4 \n2- UHF \n3- IQS SBAND \n4- Backdoor socket\n");
                         scanf("%hhu",&tctm_overrule.norm_radio_id);
                     }while(tctm_overrule.norm_radio_id < 1 || tctm_overrule.norm_radio_id > 4);

                     counter =0;
                     do{
                         if(counter!=0)
                         {
                             printf("INVALID Overrule Input,Enter inputs again \n");
                         }
                         counter ++;
                         printf("Enter safe radio ID \n1- SRS-4 \n2- UHF \n3- IQS SBAND \n4- Backdoor socket\n");
                         scanf("%hhu",&tctm_overrule.safe_radio_id);
                     }while(tctm_overrule.safe_radio_id < 1 || tctm_overrule.safe_radio_id > 4);

                     memcpy(tc_data,&tctm_overrule,sizeof(s_tctm_rm_overrule));
                     printf("Overrule provision status :%hhu\n",tctm_overrule.overrule_enb);
                     printf("Normal radio ID :%hhu\n",tctm_overrule.norm_radio_id);
                     printf("Safe radio ID :%hhu\n",tctm_overrule.safe_radio_id);

                        status = 0;
                    }
                break;

                case TC_GET_SDR_OVER_RULE_CFG:
                {

                tc_len = 0;
                tc_data = (uint8_t *) malloc(tc_len);
                status = 0;

                }
                break;
                
                case TC_SET_SDR_SCH_BEACON_CFG:
                {
                    tc_len = sizeof(s_gpass_beacon_cfg);
                    tc_data = (uint8_t *) malloc(tc_len);
                    printf("Enter radio ID \n2- UHF \n3- IQS SBAND \n");
                    scanf("%hhd",&gpass_beacon_cfg.radio_id);
                    printf("Enter gpass beacon tx enb\n");
                    scanf("%hhd",&gpass_beacon_cfg.gpass_beacon_tx_enb);
                    printf("Enter gpass beacon tx count\n");
                    scanf("%hhd",&gpass_beacon_cfg.beacon_tx_count);
                    printf("Enter gpass beacon tx interval\n");
                    scanf("%d",&gpass_beacon_cfg.beacon_tx_interval);
                    memcpy(tc_data,&gpass_beacon_cfg,sizeof(s_gpass_beacon_cfg));
                    status = 0;
                }
                break;

                case TC_GET_SDR_SCH_BEACON_CFG:
                {
                    printf("Enter radio ID: \n2 - UHF \n3 - IQS SBAND\n");
                    scanf("%hhd",&sdr_radio_mod_id);
                    printf("Entered radio ID:%hhu",sdr_radio_mod_id);
                    if(sdr_radio_mod_id < 1 || sdr_radio_mod_id > 3)
                    {
                        printf("Invalid Test ID\n");
                        status = -1;
                    }
                    else
                    {
                        tc_len = sizeof(sdr_radio_mod_id);
                        tc_data = (uint8_t *) malloc(tc_len);
                        memcpy(tc_data, &sdr_radio_mod_id,sizeof(sdr_radio_mod_id));
                        status = 0;
                    }

                }
                break;


                /** XLINK IQ Spacecom */
            case TC_SBAND_SET_IDLE_CFG:
                {
                    tc_len = 0;
                    printf("\n\r TC_SBAND_SET_IDLE_CFG is sent");
                    //tc_data = NULL;
                    tc_data = (uint8*)malloc(tc_len);
                    status = 0; 
                }
                break;
            case TC_SBAND_SET_RESET:
                {
                    tc_len = 0;
                    printf("\n\r TC_SBAND_SET_RESET is sent");
                    //tc_data = NULL;
                    tc_data = (uint8*)malloc(tc_len);
                    status = 0; 
                }
                break;
            case TC_SBAND_SET_START_RF_RCV:
                {
                    uint32_t tmpv; 

                    printf("\n\r TC_SBAND_SET_START_RF_RCV is sent");
                    tc_len = sizeof(SERVICE_START_RF_RCV_STRUCT);
                    tc_data = (uint8*)malloc(tc_len);
                    if(comms_set == 1)
                    {

                        /*  memcpy(&xrf_r.ip_address ,"192.168.100.1", sizeof("192.168.100.1"));*/
                        xrf_r.ip_address = inet_addr ("111.1.168.192");
                        xrf_r.port = 51004;
                        xrf_r.send_format = RF_RCV_SEND_CLTU;
                        xrf_r.output_interface = RF_RCV_OUTPUT_UDP;
                        xrf_r.Reserve = 0;
                    }
                    else
                    {
                        char ip_address[50] = {0};
                        //xrf_r.ip_address = inet_addr ("192.168.1.10");
                        printf("enter IP address: ");
                        scanf("%s",ip_address);
                        xrf_r.ip_address = inet_addr (ip_address);

                        printf("Enter the port:");
                        scanf("%d",&tmpv);
                        xrf_r.port = tmpv & 0xffff;

                        printf("Enter the send_format:");
                        scanf("%d",&tmpv);
                        xrf_r.send_format = tmpv & 0xf;

                        //xrf_r.Reserve = 1;
                        printf("Enter the output interface:");
                        scanf("%d",&tmpv);
                        xrf_r.output_interface = tmpv & 0xf;
                    }

                    printf("port:%d\n",xrf_r.port);
                    printf("send format:%d\n",xrf_r.send_format);
                    printf("output_interface:%d\n",xrf_r.output_interface);
                    xrf_r.Reserve = 0;
                    os_memcpy(tc_data,&xrf_r,sizeof(SERVICE_START_RF_RCV_STRUCT));
                    status = 0;
                }
                break;

            case TC_SBAND_SET_RF_XMT_DATA:
                {
                    uint32_t tmpv;             

                    printf("\n\r TC_SBAND_SET_RF_XMT_DATA is sent");
                    tc_len = sizeof(xrf_xmt);
                    tc_data = (uint8*)malloc(tc_len);

                    if(comms_set == 1)
                    {
                        xrf_xmt.PktType = 2;
                        xrf_xmt.ErrInf = 1;
                        xrf_xmt.PktLen = 1432;
                        xrf_xmt.EthFirst = 1;
                        xrf_xmt.EthLast = 1;
                        xrf_xmt.EthNumByte = 10;
                        xrf_xmt.MoreInfo = 0xDEADAFFE;
                    }
                    else
                    {
                        printf("Enter the type of Packet:");
                        scanf("%d", &tmpv);
                        xrf_xmt.PktType = tmpv & 0x3;

                        printf("Enter the error information:");
                        scanf("%d", &tmpv);
                        xrf_xmt.ErrInf = tmpv & 0x1f;                

                        printf("Enter the packet length:");
                        scanf("%d", &tmpv);
                        xrf_xmt.PktLen = tmpv & 0xfff;

                        printf("Enter the First Ethernet packet:");
                        scanf("%d", &tmpv);
                        xrf_xmt.EthFirst = tmpv & 0x1;

                        printf("Enter the last Ethernet packet:");
                        scanf("%d", &tmpv);
                        xrf_xmt.EthLast = tmpv & 0x1;

                        printf("Enter the no.of.bytes in this Ethernet packet:");
                        scanf("%d", &tmpv);
                        xrf_xmt.EthNumByte = tmpv & 0x7ff;

                        xrf_xmt.MoreInfo = 0xDEADAFFE;
                        //printf("Enter the moreinfo:");
                        //scanf("%d", &tmpv);
                        //xrf_xmt.MoreInfo = tmpv;

                        memcpy(&xrf_xmt.Payload ,"1", sizeof("1"));                
                    }
                    os_memcpy(tc_data,&xrf_xmt,tc_len);
                    status = 0;
                }
                break;
            case TC_SBAND_SET_DVBS2_CONF:
                { 
                    uint32_t tmpv;

                    printf("\n\r TC_SBAND_SET_DVBS2_CONF is sent");
                    tc_len = sizeof(xdvbs2);
                    tc_data = (uint8*)malloc(tc_len);

                    if(comms_set == 1)
                    {
                        xdvbs2.ModCod_0 = 1;
                        xdvbs2.FrmType_0 = 2;
                        xdvbs2.InsertPilots_0 = 0;
                        xdvbs2.Acm_Ccm_0 = 0;
                        xdvbs2.RollOffVal_0 = 4;
                        xdvbs2.PlSpreadNumber_0 = 5;
                        xdvbs2.Reserve_0 = 2;
                        xdvbs2.Reserve_1 = 4;
                    }
                    else
                    {

                        printf("Enter the MODCOD:");
                        scanf("%d",&tmpv);
                        xdvbs2.ModCod_0 = tmpv & 0x1f;

                        printf("Enter the frame type:");
                        scanf("%d",&tmpv);
                        xdvbs2.FrmType_0 = tmpv & 0x3;                

                        printf("Enter the Pilots insertion 0-Off, 1-On:");
                        scanf("%d",&tmpv);
                        xdvbs2.InsertPilots_0 = tmpv & 0x1;

                        printf("Enter the 0-ACM(Adaptive-CM), 1-CCM(Constant-CM):");
                        scanf("%d",&tmpv);
                        xdvbs2.Acm_Ccm_0 = tmpv & 0x1;

                        printf("Enter the RollOff Factor 2 - 0.20:");
                        scanf("%d",&tmpv);
                        xdvbs2.RollOffVal_0 = tmpv & 0x7;

                        printf("Enter the PL spreading sequence number:");
                        scanf("%d",&tmpv);
                        xdvbs2.PlSpreadNumber_0 = tmpv & 0x3fff;

                        printf("Enter the reserve_0 bits:");
                        scanf("%d",&tmpv);
                        xdvbs2.Reserve_0 = tmpv & 0x3;

                        printf("Enter the reserve_1 bits:");
                        scanf("%d",&tmpv);
                        xdvbs2.Reserve_1 = tmpv;
                    }

                    os_memcpy(tc_data,&xdvbs2,tc_len);
                    status = 0;
                }
                break;

            case TC_SBAND_SET_IP_ADR_SAVE:
                {

                    printf("\n\r TC_SBAND_SET_IP_ADR_SAVE is sent");
                    tc_len = sizeof(xip_adr);
                    tc_data = (uint8*)malloc(tc_len);
                    if(comms_set == 1)
                    {
                        //                memcpy(&xip_adr.ip_address ,"192.168.100.1", sizeof("192.168.100.1"));               
                        xrf_r.ip_address = inet_addr ("192.168.1.1");
                    }
                    else
                    {
                        printf("Enter ip_address: ");
                        scanf("%u",&xip_adr.ip_address);               
                    }
                    os_memcpy(tc_data,&xip_adr,tc_len);
                    status = 0;
                }
                break;

            case TC_SBAND_SET_IP_ADR:
                {
                    printf("\n\r TC_SBAND_SET_IP_ADR is sent");
                    tc_len = sizeof(xip_adr);
                    tc_data = (uint8*)malloc(tc_len);
                    if(comms_set == 1)
                    {

                        xip_adr.ip_address = inet_addr ("192.168.1.100");
                        printf("Enter ip_address: %hhu", xip_adr.ip_address);
                    }
                    else
                    {
                        printf("Enter ip_address: ");
                        scanf("%u",&xip_adr.ip_address);               
                    }
                    os_memcpy(tc_data,&xip_adr,tc_len);
                    status = 0;
                }
                break;
            case TC_SBAND_SET_DEVICE_CONF:
                {
                    uint32_t tmpv;
                    printf("\n\r TC_SBAND_SET_DEVICE_CONF is sent");
                    tc_len = sizeof(xdev);
                    tc_data = (uint8*)malloc(tc_len);

                    if(comms_set == 1)
                    {
#if 0
                        xdev.HwPins.RfeRx0On = 0;
                        xdev.HwPins.RfeTx0On = 0;
                        xdev.HwPins.RfePa0On = 0;
                        xdev.HwPins.RfeRxTx0 = 0;
                        xdev.HwPins.RfeRx1On = 0;
                        xdev.HwPins.RfeTx1On = 0;
                        xdev.HwPins.RfePa1On = 0;
                        xdev.HwPins.RfeRxTx1 = 0;
                        xdev.HwPins.RfeOutEn = 0;
                        xdev.HwPins.RfeGpio0 = 0;
                        xdev.HwPins.RfeLoopDet = 0;
                        xdev.HwPins.RfeLoMux = 0;
                        xdev.HwPins.RfePowOn = 0;
                        xdev.HwPins.RfeDA = 0;
                        xdev.HwPins.RfeCL = 0;
                        xdev.HwPins.RfeEnAD5304 = 0;
                        xdev.HwPins.RfeEnSynth = 0;
                        xdev.HwPins.RfeEn3 = 0;
                        xdev.HwPins.RfeEn4 = 0;
                        xdev.HwPins.RfeEn5 = 0;
                        xdev.HwPins.Rfe7V0En = 0;
                        xdev.HwPins.RfeRsvuint32 = 0;


                        xdev.RfeFreq.RxMix[0] = 0;
                        xdev.RfeFreq.RxMix[1] = 0;
                        xdev.RfeFreq.TxMix[0] = 1;
                        xdev.RfeFreq.TxMix[1] = 1;
                        xdev.RfeFreq.RxFreq[0] = 2042500;
                        xdev.RfeFreq.RxFreq[1] = 2042500;
                        xdev.RfeFreq.TxFreq[0] = 2242500;
                        xdev.RfeFreq.TxFreq[1] = 2242500;
                        xdev.LimFreq.RxLow[0] = 0;
                        xdev.LimFreq.RxLow[1] = 0;
                        xdev.LimFreq.RxHigh[0] = 12000000;
                        xdev.LimFreq.RxHigh[1] = 12000000;
                        xdev.LimFreq.TxLow[0] = 0;
                        xdev.LimFreq.TxLow[1] = 0;
                        xdev.LimFreq.TxHigh[0] = 12000000;
                        xdev.LimFreq.TxHigh[1] = 12000000;
                        //memset(&xdev.RfeFreq.RxMix ,0, sizeof(xdev.RfeFreq.RxMix));
                        //memset(&xdev.RfeFreq.TxMix ,1, sizeof(xdev.RfeFreq.TxMix));
                        //memset(&xdev.RfeFreq.RxFreq ,2070001, sizeof(xdev.RfeFreq.RxFreq));
                        //memset(&xdev.RfeFreq.TxFreq ,2245000, sizeof(xdev.RfeFreq.TxFreq));
                        //memset(&xdev.LimFreq.RxLow ,0, sizeof(xdev.LimFreq.RxLow));
                        //memset(&xdev.LimFreq.RxHigh ,12000000, sizeof(xdev.LimFreq.RxHigh));
                        //memset(&xdev.LimFreq.TxLow ,0, sizeof(xdev.LimFreq.TxLow));
                        //memset(&xdev.LimFreq.TxHigh ,12000000, sizeof(xdev.LimFreq.TxHigh));

                        xdev.AdCtr._2Rx2Tx = 1;
                        xdev.AdCtr.TxLevel_0 = 880;
                        xdev.AdCtr.TxLevel_1 = 880;
                        xdev.AdCtr.RefClk = 59;
                        xdev.AdCtr.Reserve = 0;
                        xdev.XmtCtr0.Modulat_0 = 2;
                        xdev.XmtCtr0.Mode_0 = 8;
                        xdev.XmtCtr0.Fec_0 = 1;
                        xdev.XmtCtr0.ChEn_0 = 1;
                        xdev.XmtCtr0.PRnd_0 = 1;
                        xdev.XmtCtr0.ASMStart_0 = 1;
                        xdev.XmtCtr0.OffsetMod_0 = 0;
                        xdev.XmtCtr0.Ch1_diff_Ch2 = 0;
                        xdev.XmtCtr0.ChSwitchOn_0 = 1;
                        xdev.XmtCtr0.Modulat_1 = 2;
                        xdev.XmtCtr0.Mode_1 = 8;
                        xdev.XmtCtr0.Fec_1 = 1;
                        xdev.XmtCtr0.ChEn_1 = 0;
                        xdev.XmtCtr0.PRnd_1 = 1;
                        xdev.XmtCtr0.ASMStart_1 = 1;
                        xdev.XmtCtr0.OffsetMod_1 = 0;
                        xdev.XmtCtr0.ChSwitchOn_1 = 0;
                        xdev.XmtCtr0.OffsetModNormaly = 0;


                        xdev.XmtCtr3.AttTxGain_0 = 205;
                        xdev.XmtCtr3.AttTxGain_1 = 210;
                        xdev.XmtCtr3.TrFrmSz = 1432;

                        xdev.XmtCtr4.PhiOffset16 = 0;
                        xdev.XmtCtr4.Y16 = 0;
                        xdev.XmtCtr4.TxSampFact = 1;
                        xdev.XmtCtr4.RsMode = 0;

                        xdev.RcvCtrCh[0].RxGainMax = 76;
                        xdev.RcvCtrCh[0].ChEn = 1;
                        xdev.RcvCtrCh[0].Modulat = 1;
                        xdev.RcvCtrCh[0].MsbFirst = 1;
                        xdev.RcvCtrCh[0].Fec = 6;
                        xdev.RcvCtrCh[0].PRnd = 1;
                        xdev.RcvCtrCh[0].BchDec = 1;
                        xdev.RcvCtrCh[0].AccBchErr = 0;
                        xdev.RcvCtrCh[0].BchCountMode = 0;
                        xdev.RcvCtrCh[0].PwrOff = 37;
                        xdev.RcvCtrCh[0].RcvCalib = 0;
                        xdev.RcvCtrCh[1].RxGainMax = 76;
                        xdev.RcvCtrCh[1].ChEn = 0;
                        xdev.RcvCtrCh[1].Modulat = 1;
                        xdev.RcvCtrCh[1].MsbFirst = 1;
                        xdev.RcvCtrCh[1].Fec = 6;
                        xdev.RcvCtrCh[1].PRnd = 1;
                        xdev.RcvCtrCh[1].BchDec = 1;
                        xdev.RcvCtrCh[1].AccBchErr = 0;
                        xdev.RcvCtrCh[1].BchCountMode = 0;
                        xdev.RcvCtrCh[1].PwrOff = 37;
                        xdev.RcvCtrCh[1].RcvCalib = 0;

                        xdev.SymbFreq.XmtSymbFreq = 2048;
                        xdev.SymbFreq.RcvSymbFreq = 64;

                        xdev.RcvCtr_0.RcvMode = 0;
                        xdev.RcvCtr_0.RcvChannel = 0;
                        xdev.RcvCtr_0.ChSwitchOn_0 = 1;
                        xdev.RcvCtr_0.ChSwitchOn_1 = 0;
                        xdev.RcvCtr_0.DropSample = 0;
                        xdev.RcvCtr_0.dT_minus = 0;
                        xdev.RcvCtr_0.dT_plus = 0;
                        xdev.RcvCtr_0.Reserve = 0;
#endif 

                        xdev.HwPins.RfeRx0On = 1;
                        xdev.HwPins.RfeTx0On = 1;
                        xdev.HwPins.RfePa0On = 1;
                        xdev.HwPins.RfeRxTx0 = 1;
                        xdev.HwPins.RfeRx1On = 0;
                        xdev.HwPins.RfeTx1On = 1;
                        xdev.HwPins.RfePa1On = 1;
                        xdev.HwPins.RfeRxTx1 = 1;
                        xdev.HwPins.RfeOutEn = 1;
                        xdev.HwPins.RfeGpio0 = 0;
                        xdev.HwPins.RfeLoopDet = 0;
                        xdev.HwPins.RfeLoMux = 0;
                        xdev.HwPins.RfePowOn = 0;
                        xdev.HwPins.RfeDA = 0;
                        xdev.HwPins.RfeCL = 0;
                        xdev.HwPins.RfeEnAD5304 = 0;
                        xdev.HwPins.RfeEnSynth = 0;
                        xdev.HwPins.RfeEn3 = 0;
                        xdev.HwPins.RfeEn4 = 0;
                        xdev.HwPins.RfeEn5 = 0;
                        xdev.HwPins.Rfe7V0En = 1;
                        xdev.HwPins.RfeRsvuint32 = 0;


                        xdev.RfeFreq.RxMix[0] = 0;
                        xdev.RfeFreq.RxMix[1] = 0;
                        xdev.RfeFreq.TxMix[0] = 2;
                        xdev.RfeFreq.TxMix[1] = 2;
                        xdev.RfeFreq.RxFreq[0] = 2042500;
                        xdev.RfeFreq.RxFreq[1] = 2044000;
                        xdev.RfeFreq.TxFreq[0] = 2242500;
                        xdev.RfeFreq.TxFreq[1] = 2244500;
                        xdev.LimFreq.RxLow[0] = 0;
                        xdev.LimFreq.RxLow[1] = 0;
                        xdev.LimFreq.RxHigh[0] = 12000000;
                        xdev.LimFreq.RxHigh[1] = 12000000;
                        xdev.LimFreq.TxLow[0] = 0;
                        xdev.LimFreq.TxLow[1] = 0;
                        xdev.LimFreq.TxHigh[0] = 12000000;
                        xdev.LimFreq.TxHigh[1] = 12000000;
                        //memset(&xdev.RfeFreq.RxMix ,0, sizeof(xdev.RfeFreq.RxMix));
                        //memset(&xdev.RfeFreq.TxMix ,1, sizeof(xdev.RfeFreq.TxMix));
                        //memset(&xdev.RfeFreq.RxFreq ,2070000, sizeof(xdev.RfeFreq.RxFreq));
                        //memset(&xdev.RfeFreq.TxFreq ,2245000, sizeof(xdev.RfeFreq.TxFreq));
                        //memset(&xdev.LimFreq.RxLow ,0, sizeof(xdev.LimFreq.RxLow));
                        //memset(&xdev.LimFreq.RxHigh ,12000000, sizeof(xdev.LimFreq.RxHigh));
                        //memset(&xdev.LimFreq.TxLow ,0, sizeof(xdev.LimFreq.TxLow));
                        //memset(&xdev.LimFreq.TxHigh ,12000000, sizeof(xdev.LimFreq.TxHigh));

                        xdev.AdCtr._2Rx2Tx = 1;
                        xdev.AdCtr.TxLevel_0 = 880;
                        xdev.AdCtr.TxLevel_1 = 880;
                        xdev.AdCtr.RefClk = 59;
                        xdev.AdCtr.Reserve = 0;
                        xdev.XmtCtr0.Modulat_0 = 1;
                        xdev.XmtCtr0.Mode_0 = 8;
                        xdev.XmtCtr0.Fec_0 = 1;
                        xdev.XmtCtr0.ChEn_0 = 1;
                        xdev.XmtCtr0.PRnd_0 = 1;
                        xdev.XmtCtr0.ASMStart_0 = 1;
                        xdev.XmtCtr0.OffsetMod_0 = 0;
                        xdev.XmtCtr0.Ch1_diff_Ch2 = 0;
                        xdev.XmtCtr0.ChSwitchOn_0 = 1;
                        xdev.XmtCtr0.Modulat_1 = 1;
                        xdev.XmtCtr0.Mode_1 = 8;
                        xdev.XmtCtr0.Fec_1 = 1;
                        xdev.XmtCtr0.ChEn_1 = 1;
                        xdev.XmtCtr0.PRnd_1 = 1;
                        xdev.XmtCtr0.ASMStart_1 = 1;
                        xdev.XmtCtr0.OffsetMod_1 = 0;
                        xdev.XmtCtr0.ChSwitchOn_1 = 1;
                        xdev.XmtCtr0.OffsetModNormaly = 1;


                        xdev.XmtCtr3.AttTxGain_0 = 3;
                        xdev.XmtCtr3.AttTxGain_1 = 3;
                        xdev.XmtCtr3.TrFrmSz = 1432;

                        xdev.XmtCtr4.PhiOffset16 = 0;
                        xdev.XmtCtr4.Y16 = 0;
                        xdev.XmtCtr4.TxSampFact = 2;
                        xdev.XmtCtr4.RsMode = 0;

                        xdev.RcvCtrCh[0].RxGainMax = 70;
                        xdev.RcvCtrCh[0].ChEn = 1;
                        xdev.RcvCtrCh[0].Modulat = 1;
                        xdev.RcvCtrCh[0].MsbFirst = 1;
                        xdev.RcvCtrCh[0].Fec = 0;
                        xdev.RcvCtrCh[0].PRnd = 1;
                        xdev.RcvCtrCh[0].BchDec = 1;
                        xdev.RcvCtrCh[0].AccBchErr = 0;
                        xdev.RcvCtrCh[0].BchCountMode = 0;
                        xdev.RcvCtrCh[0].PwrOff = 37;
                        xdev.RcvCtrCh[0].RcvCalib = 0;
                        xdev.RcvCtrCh[1].RxGainMax = 73;
                        xdev.RcvCtrCh[1].ChEn = 1;
                        xdev.RcvCtrCh[1].Modulat = 1;
                        xdev.RcvCtrCh[1].MsbFirst = 1;
                        xdev.RcvCtrCh[1].Fec = 0;
                        xdev.RcvCtrCh[1].PRnd = 1;
                        xdev.RcvCtrCh[1].BchDec = 1;
                        xdev.RcvCtrCh[1].AccBchErr = 0;
                        xdev.RcvCtrCh[1].BchCountMode = 0;
                        xdev.RcvCtrCh[1].PwrOff = 37;
                        xdev.RcvCtrCh[1].RcvCalib = 0;

                        xdev.SymbFreq.XmtSymbFreq = 2048;
                        xdev.SymbFreq.RcvSymbFreq = 512;

                        xdev.RcvCtr_0.RcvMode = 0;
                        xdev.RcvCtr_0.RcvChannel = 0;
                        xdev.RcvCtr_0.ChSwitchOn_0 = 1;
                        xdev.RcvCtr_0.ChSwitchOn_1 = 0;
                        xdev.RcvCtr_0.DropSample = 0;
                        xdev.RcvCtr_0.dT_minus = 0;
                        xdev.RcvCtr_0.dT_plus = 0;
                        xdev.RcvCtr_0.Reserve = 0;

                        printf("RX-Mixer: %d\n",xdev.HwPins.RfeRx0On);
                        printf("TX-Mixer: %d\n",xdev.HwPins.RfeTx0On);
                        printf("RfePa0On: %d\n",xdev.HwPins.RfePa0On);
                        printf("RfeRxTx0: %d\n",xdev.HwPins.RfeRxTx0);
                        printf("RfeRx1On: %d\n",xdev.HwPins.RfeRx1On);
                        printf("ERfeTx1On: %d\n",xdev.HwPins.RfeTx1On);
                        printf("RfeRxTx1: %d\n",xdev.HwPins.RfeRxTx1);
                        printf("RfePa1On: %d\n",xdev.HwPins.RfePa1On);
                        printf("RfeOutEn: %d\n",xdev.HwPins.RfeOutEn);
                        printf("RfeGpio0: %d\n",xdev.HwPins.RfeGpio0);
                        printf("RfeLoopDet: %d\n",xdev.HwPins.RfeLoopDet);
                        printf("RfeLoMux: %d\n",xdev.HwPins.RfeLoMux);
                        printf("RfePowOn: %d\n",xdev.HwPins.RfePowOn);
                        printf("RfeDA: %d\n",xdev.HwPins.RfeDA);
                        printf("RfeCL: %d\n",xdev.HwPins.RfeCL);
                        printf("RfeEnAD5304: %d\n",xdev.HwPins.RfeEnAD5304);
                        printf("RfeEnSynth: %d\n",xdev.HwPins.RfeEnSynth);
                        printf("RfeEn3: %d\n",xdev.HwPins.RfeEn3);
                        printf("RfeEn4r: %d\n",xdev.HwPins.RfeEn4);
                        printf("RfeEn5: %d\n",xdev.HwPins.RfeEn5);
                        printf("7V0 PowerOn enable: %d\n",xdev.HwPins.Rfe7V0En);
                        printf("Rfe reserve to uint32: %d\n",xdev.HwPins.RfeRsvuint32);
                        printf("receive DownConversionFrequency channel 0: %d\n",xdev.RfeFreq.RxMix[0]);
                        printf("receive DownConversionFrequency channle 1: %d\n",xdev.RfeFreq.RxMix[1]);
                        printf("transmit UpConversionFrequency channel 0: %d\n",xdev.RfeFreq.TxMix[0]);
                        printf("transmit UpConversionFrequency channel 1: %d\n",xdev.RfeFreq.TxMix[1]);
                        printf("receive Frequency Channel0: %d\n",xdev.RfeFreq.RxFreq[0]);
                        printf("receive Frequency Channel1: %d\n",xdev.RfeFreq.RxFreq[1]);
                        printf("transmit Frequency Channel0: %d\n",xdev.RfeFreq.TxFreq[0]);
                        printf("transmit Frequency Channel1: %d\n",xdev.RfeFreq.TxFreq[1]);
                        printf("Rcv lowest  possible frequency Channel0: %d\n",xdev.LimFreq.RxLow[0]);
                        printf("Rcv lowest  possible frequency Channel1: %d\n",xdev.LimFreq.RxLow[1]);
                        printf("Rcv highest possible frequency Channel0: %u\n",xdev.LimFreq.RxHigh[0]);
                        printf("Rcv highest possible frequency Channel1: %u\n",xdev.LimFreq.RxHigh[1]);
                        printf("Xmt lowest  possible frequency Channel0: %d\n",xdev.LimFreq.TxLow[0]);
                        printf("Xmt lowest  possible frequency Channel1: %d\n",xdev.LimFreq.TxLow[1]);
                        printf("Xmt highest possible frequency Channel0: %d\n",xdev.LimFreq.TxHigh[0]);
                        printf("Xmt highest possible frequency Channel1: %d\n",xdev.LimFreq.TxHigh[1]);
                        printf("Flag for use 2Rx2Tx mode: %d\n",xdev.AdCtr._2Rx2Tx);
                        printf("Tx Level for XmtChannel 0 (0...2047): %d\n",xdev.AdCtr.TxLevel_0);
                        printf("Tx Level for XmtChannel 1 (0...2047): %d\n",xdev.AdCtr.TxLevel_1);
                        printf("AD9361 reference clock in MHz: %d\n",xdev.AdCtr.RefClk);
                        printf("Reserve: %d\n",xdev.AdCtr.Reserve);
                        printf("Xmt Modulation Channel_0 : %d\n",xdev.XmtCtr0.Modulat_0);
                        printf("Xmt Mode Channel_0: %d\n",xdev.XmtCtr0.Mode_0);
                        printf("Xmt FEC Channel_0: %d\n",xdev.XmtCtr0.Fec_0);
                        printf("Xmt Enable Channel 0: %d\n",xdev.XmtCtr0.ChEn_0);
                        printf("Xmt PseudoRanomizer 0: %d\n",xdev.XmtCtr0.PRnd_0 );
                        printf("Xmt ASM at FrmStart 0: %d\n",xdev.XmtCtr0.ASMStart_0);
                        printf("Xmt Offset Modulation 0: %d\n",xdev.XmtCtr0.OffsetMod_0);
                        printf("set FPGA output XmtOut_Data: %d\n",xdev.XmtCtr0.Ch1_diff_Ch2);
                        printf("Xmt On/Off Channel_0: %d\n",xdev.XmtCtr0.ChSwitchOn_0);
                        printf("Xmt Modulation Channel_1: %d\n",xdev.XmtCtr0.Modulat_1);
                        printf("Xmt Mode Channel_1: %d\n",xdev.XmtCtr0.Mode_1);
                        printf("Xmt FEC Channel_1: %d\n",xdev.XmtCtr0.Fec_1);
                        printf("Xmt Enable Channel 0: %d\n",xdev.XmtCtr0.ChEn_1);
                        printf("Xmt PseudoRanomizer 1: %d\n",xdev.XmtCtr0.PRnd_1);
                        printf("Xmt ASM at FrmStart 1: %d\n",xdev.XmtCtr0.ASMStart_1);
                        printf("Xmt Offset Modulation 1: %d\n",xdev.XmtCtr0.OffsetMod_1);
                        printf("Xmt On/Off Channel 1: %d\n",xdev.XmtCtr0.ChSwitchOn_1);
                        printf("Xmt 1-Offset Modulation normaly;: %d\n",xdev.XmtCtr0.OffsetModNormaly);
                        printf("AttTxGain_0: %d\n",xdev.XmtCtr3.AttTxGain_0);
                        printf("AttTxGain_1: %d\n",xdev.XmtCtr3.AttTxGain_1);
                        printf("TrFrmSz: %d\n",xdev.XmtCtr3.TrFrmSz);
                        printf("PhiOffset16: %d\n",xdev.XmtCtr4.PhiOffset16);
                        printf("y16: %d\n",xdev.XmtCtr4.Y16);
                        printf("TxSampFact: %d\n",xdev.XmtCtr4.TxSampFact);
                        printf("RsMode: %d\n",xdev.XmtCtr4.RsMode);
                        printf("RxGainMax: %d\n",xdev.RcvCtrCh[0].RxGainMax);
                        printf("ChEn: %d\n",xdev.RcvCtrCh[0].ChEn);
                        printf("Modulat: %d\n",xdev.RcvCtrCh[0].Modulat);
                        printf("MsbFirst: %d\n",xdev.RcvCtrCh[0].MsbFirst);
                        printf("Fec: %d\n",xdev.RcvCtrCh[0].Fec);
                        printf("PRnd: %d\n",xdev.RcvCtrCh[0].PRnd);
                        printf("BchDec: %d\n",xdev.RcvCtrCh[0].BchDec);
                        printf("AccBchErr: %d\n",xdev.RcvCtrCh[0].AccBchErr);
                        printf("RBchCountMode: %d\n",xdev.RcvCtrCh[0].BchCountMode);
                        printf("PowerOff: %d\n",xdev.RcvCtrCh[0].PwrOff);
                        printf("RcvCalib: %d\n",xdev.RcvCtrCh[0].RcvCalib);
                        printf("RxGainMax: %d\n",xdev.RcvCtrCh[1].RxGainMax);
                        printf("ChEn: %d\n",xdev.RcvCtrCh[1].ChEn);
                        printf("Modulat: %d\n",xdev.RcvCtrCh[1].Modulat);
                        printf("MsbFirst: %d\n",xdev.RcvCtrCh[1].MsbFirst);
                        printf("Fec: %d\n",xdev.RcvCtrCh[1].Fec);
                        printf("PRnd: %d\n",xdev.RcvCtrCh[1].PRnd);
                        printf("BchDec: %d\n",xdev.RcvCtrCh[1].BchDec);
                        printf("AccBchErr: %d\n",xdev.RcvCtrCh[1].AccBchErr);
                        printf("RBchCountMode: %d\n",xdev.RcvCtrCh[1].BchCountMode);
                        printf("PowerOff: %d\n",xdev.RcvCtrCh[1].PwrOff);
                        printf("RcvCalib: %d\n",xdev.RcvCtrCh[1].RcvCalib);
                        printf("XmtSymbFreq: %d\n",xdev.SymbFreq.XmtSymbFreq);
                        printf("RcvSymbFreq: %d\n",xdev.SymbFreq.RcvSymbFreq);
                        printf("RcvMode: %d\n",xdev.RcvCtr_0.RcvMode);
                        printf("RcvChannel: %d\n",xdev.RcvCtr_0.RcvChannel);
                        printf("ChSwitchOn_0: %d\n",xdev.RcvCtr_0.ChSwitchOn_0);
                        printf("ChSwitchOn_1: %d\n",xdev.RcvCtr_0.ChSwitchOn_1);
                        printf("DropSample: %d\n",xdev.RcvCtr_0.DropSample);
                        printf("dT_minus: %d\n",xdev.RcvCtr_0.dT_minus);
                        printf("dT_plus: %d\n",xdev.RcvCtr_0.dT_plus);
                        printf("Reserve: %d\n",xdev.RcvCtr_0.Reserve);
                    }
                    else
                    {
                        //scanf("%d",&tmpv);
                        //xdev.HwPins.RfeRx0On = tmpv & 0x1;
                        //printf("Enter the TX-Mixer:");
                        //scanf("%d",&tmpv);
                        //xdev.HwPins.RfeRsvuint32 = tmpv & 0x7ff;

                        //printf("receive DownConversionFrequency:");
                        //scanf("%d",&xdev.RfeFreq.RxMix[0]);
                        //printf("transmit UpConversionFrequency:");
                        //scanf("%d",&xdev.RfeFreq.TxMix[0]);
                        printf("receive Frequency Channel:");
                        scanf("%d",&xdev.RfeFreq.RxFreq[0]);
                        xdev.RfeFreq.RxFreq[1] = xdev.RfeFreq.RxFreq[0];
                        printf("transmit Frequency Channel:");
                        scanf("%d",&xdev.RfeFreq.TxFreq[0]);

                        xdev.RfeFreq.TxFreq[1] = xdev.RfeFreq.TxFreq[0];
                        //printf("Rcv lowest  possible frequency Channel:");
                        //scanf("%d",&xdev.LimFreq.RxLow[0]);
                        //printf("Rcv highest possible frequency Channel:");
                        //scanf("%d",&xdev.LimFreq.RxHigh[0]);
                        //printf("Xmt lowest  possible frequency Channel:");

                        //scanf("%d",&tmpv);
                        //xdev.AdCtr.RefClk = tmpv & 0xff;
                        //printf("Reserve:");
                        //scanf("%d",&tmpv);
                        //xdev.AdCtr.Reserve = tmpv & 0x1;

                        printf("Xmt Modulation Channel_0 :");
                        scanf("%d",&tmpv);
                        xdev.XmtCtr0.Modulat_0 = tmpv & 0x7;
                        //printf("Xmt Mode Channel_0:");
                        //scanf("%d",&tmpv);
                        xdev.XmtCtr0.Mode_0 = 8;
                        printf("Xmt FEC Channel_0:");
                        scanf("%d",&tmpv);
                        xdev.XmtCtr0.Fec_0 = tmpv & 0x7;
                        printf("Xmt Enable Channel 0;	-> 0-Disable / 1-Enable:");
                        scanf("%d",&tmpv);
                        xdev.XmtCtr0.ChEn_0 = tmpv & 0x1;
                        printf("Xmt PseudoRanomizer 0;	-> 0-Off / 1-On:");
                        scanf("%d",&tmpv);
                        xdev.XmtCtr0.PRnd_0 = tmpv & 0x1;
                        //printf("Xmt ASM at FrmStart 0;	-> 0-Off / 1-On:");
                        //scanf("%d",&tmpv);
                        xdev.XmtCtr0.ASMStart_0 = 1;
                        //printf("Xmt Offset Modulation 0;	-> 0-Off / 1-On:");
                        //scanf("%d",&tmpv);
                        xdev.XmtCtr0.OffsetMod_0 = 0;
                        //printf("set FPGA output XmtOut_Data:");
                        //scanf("%d",&tmpv);
                        //xdev.XmtCtr0.Ch1_diff_Ch2 = tmpv & 0x1;
                        printf("Xmt On/Off Channel_0;	-> 0-Off / 1-On:");
                        scanf("%d",&tmpv);
                        xdev.XmtCtr0.ChSwitchOn_0 = tmpv & 0x1;
                        printf("Xmt Modulation Channel_1:");
                        scanf("%d",&tmpv);
                        xdev.XmtCtr0.Modulat_1 = tmpv & 0x7;
                        printf("Xmt Mode Channel_1:");
                        scanf("%d",&tmpv);
                        xdev.XmtCtr0.Mode_1 = tmpv & 0xf;
                        printf("Xmt FEC Channel_1:");
                        scanf("%d",&tmpv);
                        xdev.XmtCtr0.Fec_1 = tmpv & 0x7;
                        printf("Xmt Enable Channel 0;	-> 0-Disable / 1-Enable:");
                        scanf("%d",&tmpv);
                        xdev.XmtCtr0.ChEn_1 = tmpv & 0x1;
                        printf("Xmt PseudoRanomizer 1;	-> 0-Off / 1-On:");
                        scanf("%d",&tmpv);
                        xdev.XmtCtr0.PRnd_1 = tmpv & 0x1;
                        printf("Xmt ASM at FrmStart 1;	-> 0-Off / 1-On:");
                        scanf("%d",&tmpv);
                        xdev.XmtCtr0.ASMStart_1 = tmpv & 0x1;
                        printf("Xmt Offset Modulation 1;	-> 0-Off / 1-On:");
                        scanf("%d",&tmpv);
                        xdev.XmtCtr0.OffsetMod_1 = tmpv & 0x1;
                        printf("Xmt On/Off Channel 1;	-> 0-Off / 1-On:");
                        scanf("%d",&tmpv);
                        xdev.XmtCtr0.ChSwitchOn_1 = tmpv & 0x1;
                        printf("Xmt 1-Offset Modulation normaly;:");
                        scanf("%d",&tmpv);
                        xdev.XmtCtr0.OffsetModNormaly = tmpv & 0x1;

                        printf("Tx Attenuation Channel 0:");
                        scanf("%d",&tmpv);
                        xdev.XmtCtr3.AttTxGain_0 = tmpv & 0x3ff;
                        printf("Tx Attenuation Channel 1:");
                        scanf("%d",&tmpv);
                        xdev.XmtCtr3.AttTxGain_1 = tmpv & 0x3ff;
                        printf("Transfer Frame Size in Bytes:");
                        scanf("%d",&tmpv);
                        xdev.XmtCtr3.TrFrmSz = tmpv & 0xfff;

                        printf("Enter the Phase Offset:");
                        scanf("%d",&tmpv);
                        xdev.XmtCtr4.PhiOffset16 = tmpv &0x1f;                
                        printf("Enter the y16:");
                        scanf("%d",&tmpv);
                        xdev.XmtCtr4.Y16 = tmpv &0x1fff;                
                        printf("Factor for the TxSymbol:");
                        scanf("%d",&tmpv);
                        xdev.XmtCtr4.TxSampFact = tmpv &0x3ff;                
                        printf("Enter the rsmode:");
                        scanf("%d",&tmpv);
                        xdev.XmtCtr4.RsMode = tmpv &0xf;                

                        printf("Rcv max RxGain Value-> 0..76:");
                        scanf("%d",&tmpv);
                        xdev.RcvCtrCh[0].RxGainMax = tmpv &0xff;                
                        printf("Enable channel enable(0)/disable(1):");
                        scanf("%d",&tmpv);
                        xdev.RcvCtrCh[0].ChEn = tmpv &0x1;                
                        printf("Rcv Modulation:");
                        scanf("%d",&tmpv);
                        xdev.RcvCtrCh[0].Modulat = tmpv &0x7;                
                        printf("Rcv Bit Direction:");
                        scanf("%d",&tmpv);
                        xdev.RcvCtrCh[0].MsbFirst = tmpv &0x1;                
                        printf("Rcv FEC:");
                        scanf("%d",&tmpv);
                        xdev.RcvCtrCh[0].Fec = tmpv &0x7;                
                        printf("Rcv PseudoRanomizer:");
                        scanf("%d",&tmpv);
                        xdev.RcvCtrCh[0].PRnd = tmpv &0x1;                
                        printf("Rcv BCH Decoder:");
                        scanf("%d",&tmpv);
                        xdev.RcvCtrCh[0].BchDec = tmpv &0x1;                
                        printf("Rcv accept BCH Error:");
                        scanf("%d",&tmpv);
                        xdev.RcvCtrCh[0].AccBchErr = tmpv &0x1;                
                        printf("Rcv bch count mode:");
                        scanf("%d",&tmpv);
                        xdev.RcvCtrCh[0].BchCountMode = tmpv &0x1;                
                        printf("PowerOff:");
                        scanf("%d",&tmpv);
                        xdev.RcvCtrCh[0].PwrOff = tmpv &0x3f;                
                        printf("Rcv Calibration Offset:");
                        scanf("%d",&tmpv);
                        xdev.RcvCtrCh[0].RcvCalib = tmpv &0x3f;                

                        printf("Transmit Symbol Frequency in kHz (1...56.000):");
                        scanf("%d",&tmpv);
                        xdev.SymbFreq.XmtSymbFreq = tmpv & 0xffff;
                        printf("Receive Symbol Frequency in kHz (1...56.000):");
                        scanf("%d",&tmpv);
                        xdev.SymbFreq.RcvSymbFreq = tmpv & 0xffff;

                        printf("Enter the receive mode:");
                        scanf("%d",&tmpv);
                        xdev.RcvCtr_0.RcvMode = tmpv & 0xf;
                        printf("Enter the receive channel:");
                        scanf("%d",&tmpv);
                        xdev.RcvCtr_0.RcvChannel = tmpv & 0x3;
                        printf("Enter the channel_0 ON(0)/OFF(1):");
                        scanf("%d",&tmpv);
                        xdev.RcvCtr_0.ChSwitchOn_0 = tmpv & 0x1;
                        printf("Enter the channel_1 ON(0)/OFF(1):");
                        scanf("%d",&tmpv);
                        xdev.RcvCtr_0.ChSwitchOn_1 = tmpv & 0x1;
                        printf("Enter the Drop Samples (0...3499):");
                        scanf("%d",&tmpv);
                        xdev.RcvCtr_0.DropSample = tmpv & 0xfff;
                        printf("Enter the current dt minus:");
                        scanf("%d",&tmpv);
                        xdev.RcvCtr_0.dT_minus = tmpv & 0x1;
                        printf("Enter the current dt plus:");
                        scanf("%d",&tmpv);
                        xdev.RcvCtr_0.dT_plus = tmpv & 0x1;
                        printf("Enter the reserve:");
                        scanf("%d",&tmpv);
                        xdev.RcvCtr_0.Reserve = tmpv & 0x3ff;
                    }

                    os_memcpy(tc_data,&xdev,tc_len);
                    status = 0;

                }
                break;
            case TC_SBAND_SET_FLAGS_CONF:
                {
                    printf("\n\r TC_SBAND_SET_FLAGS_CONF is sent");
                    tc_len = 0;
                    tc_data = (uint8*)malloc(tc_len);
                    status = 0;

                }
                break;
            case TC_SBAND_SET_VERSION:
                {
                    uint32_t tmpv; 
                    printf("\n\r TC_SBAND_SET_VERSION is sent");
                    tc_len = sizeof(xver);
                    tc_data = (uint8*)malloc(tc_len);

                    if(comms_set == 1)
                    {

                        xver.prog_version.Seconds = 00;
                        xver.prog_version.Minutes = 43;
                        xver.prog_version.Hours = 10;
                        xver.prog_version.Year = 23;
                        xver.prog_version.Months = 03;
                        xver.prog_version.Day = 14;
                        memcpy(&xver.prog_version.FileName ,"SWAP", sizeof("SWAP"));
                        xver.prog_version.start_adr = 90000;
                        xver.prog_version.len = 526072;
                        xver.prog_version.Flags = 1;
                    }
                    else
                    {

                        printf("Enter the seconds:");
                        scanf("%d",&tmpv);
                        xver.prog_version.Seconds = tmpv & 0x3f;

                        printf("Enter the Minute:");
                        scanf("%d",&tmpv);
                        xver.prog_version.Minutes = tmpv & 0x3f;                

                        printf("Enter the hours:");
                        scanf("%d",&tmpv);
                        xver.prog_version.Hours = tmpv & 0x1f;                

                        printf("Enter the year 0 to 63 (to note year 2000 to 2063):");
                        scanf("%d",&tmpv);
                        xver.prog_version.Year = tmpv & 0x3f;                

                        printf("Enter the months:");
                        scanf("%d",&tmpv);
                        xver.prog_version.Months = tmpv & 0xf;                

                        printf("Enter the day:");
                        scanf("%d",&tmpv);
                        xver.prog_version.Day = tmpv & 0x1f;                

                        printf("Enter the start address:");
                        scanf("%d",&tmpv);
                        xver.prog_version.start_adr = tmpv;                

                        printf("Enter the length:");
                        scanf("%d",&tmpv);
                        xver.prog_version.len = tmpv & 0xfffffff;                

                        printf("Enter the flags(SOLL-1; RUN- 0x2;...):");
                        scanf("%d",&tmpv);
                        xver.prog_version.Flags = tmpv & 0xf;                
                    }

                    os_memcpy(tc_data,&xver,tc_len);
                    status = 0;
                }
                break;

            case TC_SBAND_GET_IP_ADR:
                {
                    tc_len = 0;
                    tc_data = (uint8*)malloc(tc_len);
                    status = 0; 
                }
                break;
            case TC_SBAND_GET_FLAGS_CONF:
                {
                    tc_len = 0;
                    tc_data = (uint8*)malloc(tc_len);
                    status = 0; 
                }
                break;
            case TC_SBAND_GET_VERSION:
                {
                    tc_len = 0;
                    tc_data = (uint8*)malloc(tc_len);
                    status = 0; 
                }
                break;
            case TC_SBAND_GET_DEVICE_CONF:
                {
                    tc_len = 0;
                    tc_data = (uint8*)malloc(tc_len);
                    status = 0; 
                }
                break;
            case TC_SBAND_GET_FEATURE_SELECT:
                {
                    tc_len = 0;
                    tc_data = (uint8*)malloc(tc_len);
                    status = 0; 
                }
                break;
            case TC_SBAND_GET_COMMS_TM_INFO:
                {
                    tc_len = 0;
                    tc_data = (uint8*)malloc(tc_len);
                    status = 0; 
                }
                break;
            case TC_SBAND_GET_XPA_INF:
                {
                    tc_len = 0;
                    tc_data = (uint8*)malloc(tc_len);
                    status = 0; 
                }
                break;

            case TC_SBAND_SET_PROD_KEY:
                {
                    uint32_t prod_key[4] ={0};
                    uint8_t	prod_key_no;
                    tc_len = sizeof(prod_key);
                    tc_data = (uint8*)malloc(tc_len);

                    if (comms_set == 1)
                    {
                        printf("Product key - selection No : ");
                        scanf("%hhu",&prod_key_no);
                        printf("the selected prod key no is %d", prod_key_no);
                        if(prod_key_no > 32)
                        {
                            printf("INvalid Test ID\n");
                            status = -1;
                        }
                        else
                        {
                            os_memcpy(tc_data,&prod_key_table[prod_key_no - 1], tc_len);	
                            printf("\n\nProduct Key is %x-%x-%x-%x TX rate %x; RX rate %x\n\n", prod_key_table[prod_key_no - 1][0],prod_key_table[prod_key_no - 1][1], prod_key_table[prod_key_no - 1][2], prod_key_table[prod_key_no - 1][3], prod_key_table[prod_key_no - 1][4],prod_key_table[prod_key_no - 1][5]);
                            status = 0;
                        }
                    }
                    else
                    {
                        printf("Product key-[1]: ");
                        scanf("%x",&prod_key[0]);
                        printf("%x",prod_key[0]);
                        printf("Product key-[2]: ");
                        scanf("%x",&prod_key[1]);
                        printf("%x",prod_key[1]);
                        printf("Product key-[3]: ");
                        scanf("%x",&prod_key[2]);
                        printf("%x",prod_key[2]);
                        printf("Product key-[4]: ");
                        scanf("%x",&prod_key[3]);
                        printf("%x",prod_key[3]);

                        os_memcpy(tc_data,prod_key, tc_len);
                        status = 0;
                    }


                }
                break;

            case TC_XBAND:
                {
                    uint32 xband_cmd[50]={0xC9C694FB,0xDEAC9B61,0x19EA8546,0x09C58891,0x50000004,0x00000000,0x00000000,0x3FEECC60,0x00000000,0x3FFD1DE0,0x00000000,0x3FEECCC0,0x00000000,0x3FF00470,0x00000000,0x3FFD1CF0,0x00000000,0x3FF5B460,0x00262520,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00400000,0x00400000,0x00002208};
                    //uint32 xband_cmd[30] = {0xC9C694FB,0xDEAC9B61,0x19EA8546,0x09C58891,0x50000003,0x54AACA6C,0x31555043,0x001A0000,0x30018E96,0x7B2CB712,0x41475046,0x00310000,0x30111097,0x1DACEAD0,0x50415753,0x006B0000,0x3007379F,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF};
                    //uint32 xband_cmd[30] = {0xC9C694FB,0xDEAC9B61,0x19EA8546,0x09C58891,0x10000001};
                    //uint32 xband_cmd[50] = {0xC9C694FB,0xDEAC9B61,0x19EA8546,0x09C58891,0x50000001,0x00000000,0x00000000,0x005A06E0,0x005A06E0,0x005A06E0,0x001F95F0,0x001F95F0,0x007D1F40,0x007D1F40,0x00000000,0x00000000,0x00B71B00,0x00B71B00,0x00000000,0x00000000,0x00B71B00,0x00B71B00,0x1DB706E1,0x98421C42,0x59815414,0x00040000,0x0253134C,0x02531239,0x0040DA00,0x00000000};

                    printf("\nEnter XBAND command value ");
                    //scanf("%x",&xband_cmd[4]);

                    tc_len = sizeof(xband_cmd);
                    tc_data= (uint8_t *)malloc(tc_len);

                    os_memcpy(tc_data,xband_cmd,tc_len);

                    printf("\nX-Band command sent : %x %x %x %x %x",xband_cmd[0],xband_cmd[1],xband_cmd[2],xband_cmd[3],xband_cmd[4]);

                    status = 0;

                }
                break;

            case TC_XBAND_SET_IDLE_CFG:
                {
                    tc_len = 0;
                    printf("\n\r TC_XBAND_SET_IDLE_CFG is sent");
                    //tc_data = NULL;
                    tc_data = (uint8*)malloc(tc_len);
                    status = 0; 
                }
                break;
            case TC_XBAND_SET_RESET:
                {
                    tc_len = 0;
                    printf("\n\r TC_XBAND_SET_RESET is sent");
                    //tc_data = NULL;
                    tc_data = (uint8*)malloc(tc_len);
                    status = 0; 
                }
                break;
            case TC_XBAND_SET_START_RF_RCV:
                {
                    uint32_t tmpv; 

                    printf("\n\r TC_XBAND_SET_START_RF_RCV is sent");
                    tc_len = sizeof(SERVICE_START_RF_RCV_STRUCT);
                    tc_data = (uint8*)malloc(tc_len);
                    /*                memcpy(&xrf_r.ip_address ,"192.168.100.1", sizeof("192.168.100.1"));
                                      xrf_r.port = 20;
                                      xrf_r.send_format = 1; 
                                      xrf_r.Reserve = 3;*/

                    printf("Enter the port:");
                    scanf("%d",&tmpv);
                    xrf_r.port = tmpv & 0xffff;

                    printf("Enter the send_format:");
                    scanf("%d",&tmpv);
                    xrf_r.send_format = tmpv & 0xf;

                    printf("Enter the reserve:");
                    scanf("%d",&tmpv);
                    xrf_r.Reserve = tmpv & 0xfff;                

                    printf("port:%d\n",xrf_r.port);
                    printf("send format:%d\n",xrf_r.send_format);
                    printf("reserve:%d\n",xrf_r.Reserve);                                
                    os_memcpy(tc_data,&xrf_r,sizeof(uint32_t));
                    status = 0;
                }
                break;

            case TC_XBAND_SET_RF_XMT_DATA:
                {
                    uint32_t tmpv;             

                    printf("\n\r TC_XBAND_SET_RF_XMT_DATA is sent");
                    tc_len = sizeof(xrf_xmt);
                    tc_data = (uint8*)malloc(tc_len);

                    /*                xrf_xmt.PktType = 1;
                                      xrf_xmt.ErrInf = 1;
                                      xrf_xmt.PktLen = 10;
                                      xrf_xmt.EthFirst = 1;
                                      xrf_xmt.EthLast = 1;
                                      xrf_xmt.EthNumByte = 1;
                                      xrf_xmt.MoreInfo = 1;*/

                    printf("Enter the type of Packet:");
                    scanf("%d", &tmpv);
                    xrf_xmt.PktType = tmpv & 0x3;

                    printf("Enter the error information:");
                    scanf("%d", &tmpv);
                    xrf_xmt.ErrInf = tmpv & 0x1f;                

                    printf("Enter the packet length:");
                    scanf("%d", &tmpv);
                    xrf_xmt.PktLen = tmpv & 0xfff;

                    printf("Enter the First Ethernet packet:");
                    scanf("%d", &tmpv);
                    xrf_xmt.EthFirst = tmpv & 0x1;

                    printf("Enter the last Ethernet packet:");
                    scanf("%d", &tmpv);
                    xrf_xmt.EthLast = tmpv & 0x1;

                    printf("Enter the no.of.bytes in this Ethernet packet:");
                    scanf("%d", &tmpv);
                    xrf_xmt.EthNumByte = tmpv & 0x7ff;

                    printf("Enter the moreinfo:");
                    scanf("%d", &tmpv);
                    xrf_xmt.MoreInfo = tmpv;

                    memcpy(&xrf_xmt.Payload ,"1", sizeof("1"));                
                    os_memcpy(tc_data,&xrf_xmt,tc_len);
                    status = 0;
                }
                break;
            case TC_XBAND_SET_DVBS2_CONF:
                { 
                    uint32_t tmpv;

                    printf("\n\r TC_XBAND_SET_DVBS2_CONF is sent");
                    tc_len = sizeof(xdvbs2);
                    tc_data = (uint8*)malloc(tc_len);

                    /*                xdvbs2.ModCod_0 = 1;
                                      xdvbs2.FrmType_0 = 2;
                                      xdvbs2.InsertPilots_0 = 3;
                                      xdvbs2.Acm_Ccm_0 = 3;
                                      xdvbs2.RollOffVal_0 = 4;
                                      xdvbs2.PlSpreadNumber_0 = 5;
                                      xdvbs2.Reserve_0 = 2;
                                      xdvbs2.Reserve_1 = 4;*/  

                    printf("Enter the MODCOD:");
                    scanf("%d",&tmpv);
                    xdvbs2.ModCod_0 = tmpv & 0x1f;

                    printf("Enter the frame type:");
                    scanf("%d",&tmpv);
                    xdvbs2.FrmType_0 = tmpv & 0x3;                

                    printf("Enter the Pilots insertion:");
                    scanf("%d",&tmpv);
                    xdvbs2.InsertPilots_0 = tmpv & 0x1;

                    printf("Enter the 0-ACM(Adaptive-CM), 1-CCM(Constant-CM):");
                    scanf("%d",&tmpv);
                    xdvbs2.Acm_Ccm_0 = tmpv & 0x1;

                    printf("Enter the RollOff Factor 2 - 0.20:");
                    scanf("%d",&tmpv);
                    xdvbs2.RollOffVal_0 = tmpv & 0x7;

                    printf("Enter the PL spreading sequence number:");
                    scanf("%d",&tmpv);
                    xdvbs2.PlSpreadNumber_0 = tmpv & 0x3fff;

                    printf("Enter the reserve_0 bits:");
                    scanf("%d",&tmpv);
                    xdvbs2.Reserve_0 = tmpv & 0x3;

                    printf("Enter the reserve_1 bits:");
                    scanf("%d",&tmpv);
                    xdvbs2.Reserve_1 = tmpv;

                    os_memcpy(tc_data,&xdvbs2,tc_len);
                    status = 0;
                }
                break;
            case TC_XBAND_SET_IP_ADR_SAVE:
                {

                    printf("\n\r TC_XBAND_SET_IP_ADR_SAVE is sent");
                    tc_len = sizeof(xip_adr);
                    tc_data = (uint8*)malloc(tc_len);
                    //                memcpy(&xip_adr.ip_address ,"192.168.100.1", sizeof("192.168.100.1"));               

                    printf("Enter ip_address: ");
                    scanf("%u",&xip_adr.ip_address);               
                    os_memcpy(tc_data,&xip_adr,tc_len);
                    status = 0;
                }
                break;
            case TC_XBAND_SET_IP_ADR:
                {
                    printf("\n\r TC_XBAND_SET_IP_ADR is sent");
                    tc_len = sizeof(xip_adr);
                    //memcpy(&xip_adr.ip_address ,"192.168.100.1", sizeof("192.168.100.1"));

                    printf("Enter ip_address: ");
                    scanf("%u",&xip_adr.ip_address);               
                    tc_data = (uint8*)malloc(tc_len);
                    os_memcpy(tc_data,&xip_adr,tc_len);
                    status = 0;
                }
                break;
            case TC_XBAND_SET_DEVICE_CONF:
                {
                    uint32_t tmpv;
                    printf("\n\r TC_XBAND_SET_DEVICE_CONF is sent");
                    tc_len = sizeof(xdev);
                    tc_data = (uint8*)malloc(tc_len);


                    /*                xdev.HwPins.RfeRx0On = 1;
                                      xdev.HwPins.RfeTx0On = 1;
                                      xdev.HwPins.RfePa0On = 1;
                                      xdev.HwPins.RfeRxTx0 = 1;
                                      xdev.HwPins.RfeRx1On = 1;
                                      xdev.HwPins.RfeTx1On = 1;
                                      xdev.HwPins.RfePa1On = 1;
                                      xdev.HwPins.RfeRxTx1 = 1;
                                      xdev.HwPins.RfeOutEn = 1;
                                      xdev.HwPins.RfeGpio0 = 1;
                                      xdev.HwPins.RfeLoopDet = 1;
                                      xdev.HwPins.RfeLoMux = 1;
                                      xdev.HwPins.RfePowOn = 1;
                                      xdev.HwPins.RfeDA = 1;
                                      xdev.HwPins.RfeCL = 1;
                                      xdev.HwPins.RfeEnAD5304 = 1;
                                      xdev.HwPins.RfeEnSynth = 1;
                                      xdev.HwPins.RfeEn3 = 1;
                                      xdev.HwPins.RfeEn4 = 1;
                                      xdev.HwPins.RfeEn5 = 1;
                                      xdev.HwPins.Rfe7V0En = 1;
                                      xdev.HwPins.RfeRsvuint32 = 1;


                                      memcpy(&xdev.RfeFreq.RxMix ,5900000, sizeof("5900000"));
                                      memcpy(&xdev.RfeFreq.TxMix ,5900000, sizeof(xdev.RfeFreq.TxMix));
                                      memcpy(&xdev.RfeFreq.RxFreq ,2020000, sizeof(xdev.RfeFreq.RxFreq));
                                      memcpy(&xdev.RfeFreq.TxFreq ,8300000, sizeof(xdev.RfeFreq.TxFreq));                                
                                      memcpy(&xdev.LimFreq.RxLow ,0, sizeof(xdev.LimFreq.RxLow));
                                      memcpy(&xdev.LimFreq.RxHigh ,12000000, sizeof(xdev.LimFreq.RxHigh));
                                      memcpy(&xdev.LimFreq.TxLow ,0, sizeof(xdev.LimFreq.TxLow));
                                      memcpy(&xdev.LimFreq.TxHigh ,12000000, sizeof(xdev.LimFreq.TxHigh));                                

                                      xdev.AdCtr._2Rx2Tx = 1;
                                      xdev.AdCtr.TxLevel_0 = 512;
                                      xdev.AdCtr.TxLevel_1 = 64;
                                      xdev.AdCtr.RefClk = 30;
                                      xdev.AdCtr.Reserve = 1;
                                      xdev.XmtCtr0.Modulat_0 = 3;
                                      xdev.XmtCtr0.Mode_0 = 2;
                                      xdev.XmtCtr0.Fec_0 = 5;
                                      xdev.XmtCtr0.ChEn_0 = 0;
                                      xdev.XmtCtr0.PRnd_0 = 1;
                                      xdev.XmtCtr0.ASMStart_0 = 1;
                                      xdev.XmtCtr0.OffsetMod_0 = 0;
                                      xdev.XmtCtr0.Ch1_diff_Ch2 = 1;
                                      xdev.XmtCtr0.ChSwitchOn_0 = 1;
                                      xdev.XmtCtr0.Modulat_1 = 4;
                                      xdev.XmtCtr0.Mode_1 = 2;
                                      xdev.XmtCtr0.Fec_1 = 3;
                                      xdev.XmtCtr0.ChEn_1 = 1;
                                      xdev.XmtCtr0.PRnd_1 = 0;
                                      xdev.XmtCtr0.ASMStart_1 = 1;
                                      xdev.XmtCtr0.OffsetMod_1 = 0;
                                      xdev.XmtCtr0.ChSwitchOn_1 = 1;
                                      xdev.XmtCtr0.OffsetModNormaly = 0;


                                      xdev.XmtCtr3.AttTxGain_0 = 20;
                                      xdev.XmtCtr3.AttTxGain_1 = 30;
                                      xdev.XmtCtr3.TrFrmSz = 1024;

                                      xdev.XmtCtr4.PhiOffset16 = 1;
                                      xdev.XmtCtr4.Y16 = 1;
                                      xdev.XmtCtr4.TxSampFact = 25;
                                      xdev.XmtCtr4.RsMode = 5;

                                      xdev.RcvCtrCh[0].RxGainMax = 5;
                                      xdev.RcvCtrCh[0].ChEn = 1;
                                      xdev.RcvCtrCh[0].Modulat = 3;
                                      xdev.RcvCtrCh[0].MsbFirst = 4;
                    xdev.RcvCtrCh[0].Fec = 1;
                    xdev.RcvCtrCh[0].PRnd = 0;
                    xdev.RcvCtrCh[0].BchDec = 1;
                    xdev.RcvCtrCh[0].AccBchErr = 1;
                    xdev.RcvCtrCh[0].BchCountMode = 0;
                    xdev.RcvCtrCh[0].PwrOff = 12;
                    xdev.RcvCtrCh[0].RcvCalib = 21;

                    xdev.SymbFreq.XmtSymbFreq = 1;
                    xdev.SymbFreq.RcvSymbFreq = 1;

                    memcpy(xdev.RcvCtr_0.RcvMode ,"1", sizeof("1"));                
                    xdev.RcvCtr_0.RcvChannel = 1;
                    xdev.RcvCtr_0.ChSwitchOn_0 = 1;
                    xdev.RcvCtr_0.ChSwitchOn_1 = 1;
                    xdev.RcvCtr_0.DropSample = 250;
                    xdev.RcvCtr_0.dT_minus = 1;
                    xdev.RcvCtr_0.dT_plus = 1;
                    xdev.RcvCtr_0.Reserve = 1;*/

                        printf("Enter the RX-Mixer:");
                    scanf("%d",&tmpv);
                    xdev.HwPins.RfeRx0On = tmpv & 0x1;
                    printf("Enter the TX-Mixer:");
                    scanf("%d",&tmpv);
                    xdev.HwPins.RfeTx0On = tmpv & 0x1;
                    printf("Power Amplifier Tx0-Path:");
                    scanf("%d",&tmpv);
                    xdev.HwPins.RfePa0On = tmpv & 0x1;
                    printf("PLL and VCO power on/off:");
                    scanf("%d",&tmpv);
                    xdev.HwPins.RfeRx1On = tmpv & 0x1;
                    printf("Enter the RfeTx1On:");
                    scanf("%d",&tmpv);
                    xdev.HwPins.RfeTx1On = tmpv & 0x1;
                    printf("Enter Power Amplifier Tx1-Path:");
                    scanf("%d",&tmpv);
                    xdev.HwPins.RfePa1On = tmpv & 0x1;
                    printf("Output RF_Out_EN Pin LO:");
                    scanf("%d",&tmpv);
                    xdev.HwPins.RfeOutEn = tmpv & 0x1;
                    printf("RfeGpio0 set to '1':");
                    scanf("%d",&tmpv);
                    xdev.HwPins.RfeGpio0 = tmpv & 0x1;
                    printf("Input Loop Detect Pin:");
                    scanf("%d",&tmpv);
                    xdev.HwPins.RfeLoopDet = tmpv & 0x1;
                    printf("Input LO MUX_Pin:");
                    scanf("%d",&tmpv);
                    xdev.HwPins.RfeLoMux = tmpv & 0x1;
                    printf("RfePowOn:");
                    scanf("%d",&tmpv);
                    xdev.HwPins.RfePowOn = tmpv & 0x1;
                    printf("Data (3-wire-Bus):");
                    scanf("%d",&tmpv);
                    xdev.HwPins.RfeDA = tmpv & 0x1;
                    printf("Clock (3-wire-Bus):");
                    scanf("%d",&tmpv);
                    xdev.HwPins.RfeCL = tmpv & 0x1;
                    printf("EN DAC (AD5304) A:XO_VC; B:Bias1; C:Bias2;:");
                    scanf("%d",&tmpv);
                    xdev.HwPins.RfeEnAD5304 = tmpv & 0x1;
                    printf("Syntheser Max2870:");
                    scanf("%d",&tmpv);
                    xdev.HwPins.RfeEnSynth = tmpv & 0x1;
                    printf("RfeEn3:");
                    scanf("%d",&tmpv);
                    xdev.HwPins.RfeEn3 = tmpv & 0x1;
                    printf("RfeEn4r:");
                    scanf("%d",&tmpv);
                    xdev.HwPins.RfeEn4 = tmpv & 0x1;
                    printf("RfeEn5:");
                    scanf("%d",&tmpv);
                    xdev.HwPins.RfeEn5 = tmpv & 0x1;
                    printf("7V0 PowerOn enable:");
                    scanf("%d",&tmpv);
                    xdev.HwPins.Rfe7V0En = tmpv & 0x1;
                    printf("Rfe reserve to uint32:");
                    scanf("%d",&tmpv);
                    xdev.HwPins.RfeRsvuint32 = tmpv & 0x7ff;

                    printf("receive DownConversionFrequency:");
                    scanf("%d",&xdev.RfeFreq.RxMix[0]);
                    printf("transmit UpConversionFrequency:");
                    scanf("%d",&xdev.RfeFreq.TxMix[0]);
                    printf("receive Frequency Channel:");
                    scanf("%d",&xdev.RfeFreq.RxFreq[0]);
                    printf("transmit Frequency Channel:");
                    scanf("%d",&xdev.RfeFreq.TxFreq[0]);

                    printf("Rcv lowest  possible frequency Channel:");
                    scanf("%d",&xdev.LimFreq.RxLow[0]);
                    printf("Rcv highest possible frequency Channel:");
                    scanf("%d",&xdev.LimFreq.RxHigh[0]);
                    printf("Xmt lowest  possible frequency Channel:");
                    scanf("%d",&xdev.LimFreq.TxLow[0]);
                    printf("Xmt highest possible frequency Channel:");
                    scanf("%d",&xdev.LimFreq.TxHigh[0]);

                    printf("Flag for use 2Rx2Tx mode:");
                    scanf("%d",&tmpv);
                    xdev.AdCtr._2Rx2Tx = tmpv & 0x1;                
                    printf("Tx Level for XmtChannel 0 (0...2047):");
                    scanf("%d",&tmpv);
                    xdev.AdCtr.TxLevel_0 = tmpv & 0x1f;                
                    printf("Tx Level for XmtChannel 1 (0...2047):");
                    scanf("%d",&tmpv);
                    xdev.AdCtr.TxLevel_1 = tmpv & 0x1f;                
                    printf("AD9361 reference clock in MHz:");
                    scanf("%d",&tmpv);
                    xdev.AdCtr.RefClk = tmpv & 0xff;                
                    printf("Reserve:");
                    scanf("%d",&tmpv);
                    xdev.AdCtr.Reserve = tmpv & 0x1;                

                    printf("Xmt Modulation Channel_0 :");
                    scanf("%d",&tmpv);
                    xdev.XmtCtr0.Modulat_0 = tmpv & 0x7;
                    printf("Xmt Mode Channel_0:");
                    scanf("%d",&tmpv);
                    xdev.XmtCtr0.Mode_0 = tmpv & 0xf;
                    printf("Xmt FEC Channel_0:");
                    scanf("%d",&tmpv);
                    xdev.XmtCtr0.Fec_0 = tmpv & 0x7;
                    printf("Xmt Enable Channel 0;	-> 0-Disable / 1-Enable:");
                    scanf("%d",&tmpv);
                    xdev.XmtCtr0.ChEn_0 = tmpv & 0x1;
                    printf("Xmt PseudoRanomizer 0;	-> 0-Off / 1-On:");
                    scanf("%d",&tmpv);
                    xdev.XmtCtr0.PRnd_0 = tmpv & 0x1;
                    printf("Xmt ASM at FrmStart 0;	-> 0-Off / 1-On:");
                    scanf("%d",&tmpv);
                    xdev.XmtCtr0.ASMStart_0 = tmpv & 0x1;
                    printf("Xmt Offset Modulation 0;	-> 0-Off / 1-On:");
                    scanf("%d",&tmpv);
                    xdev.XmtCtr0.OffsetMod_0 = tmpv & 0x1;
                    printf("set FPGA output XmtOut_Data:");
                    scanf("%d",&tmpv);
                    xdev.XmtCtr0.Ch1_diff_Ch2 = tmpv & 0x1;
                    printf("Xmt On/Off Channel_0;	-> 0-Off / 1-On:");
                    scanf("%d",&tmpv);
                    xdev.XmtCtr0.ChSwitchOn_1 = tmpv & 0x1;
                    printf("Xmt Modulation Channel_1:");
                    scanf("%d",&tmpv);
                    xdev.XmtCtr0.Modulat_1 = tmpv & 0x7;
                    printf("Xmt Mode Channel_1:");
                    scanf("%d",&tmpv);
                    xdev.XmtCtr0.Mode_1 = tmpv & 0xf;
                    printf("Xmt FEC Channel_1:");
                    scanf("%d",&tmpv);
                    xdev.XmtCtr0.Fec_1 = tmpv & 0x7;
                    printf("Xmt Enable Channel 0;	-> 0-Disable / 1-Enable:");
                    scanf("%d",&tmpv);
                    xdev.XmtCtr0.ChEn_1 = tmpv & 0x1;
                    printf("Xmt PseudoRanomizer 1;	-> 0-Off / 1-On:");
                    scanf("%d",&tmpv);
                    xdev.XmtCtr0.PRnd_1 = tmpv & 0x1;
                    printf("Xmt ASM at FrmStart 1;	-> 0-Off / 1-On:");
                    scanf("%d",&tmpv);
                    xdev.XmtCtr0.ASMStart_1 = tmpv & 0x1;
                    printf("Xmt Offset Modulation 1;	-> 0-Off / 1-On:");
                    scanf("%d",&tmpv);
                    xdev.XmtCtr0.OffsetMod_1 = tmpv & 0x1;
                    printf("Xmt On/Off Channel 1;	-> 0-Off / 1-On:");
                    scanf("%d",&tmpv);
                    xdev.XmtCtr0.ChSwitchOn_1 = tmpv & 0x1;
                    printf("Xmt 1-Offset Modulation normaly;:");
                    scanf("%d",&tmpv);
                    xdev.XmtCtr0.OffsetModNormaly = tmpv & 0x1;

                    printf("Tx Attenuation Channel 0:");
                    scanf("%d",&tmpv);
                    xdev.XmtCtr3.AttTxGain_0 = tmpv & 0x3ff;
                    printf("Tx Attenuation Channel 1:");
                    scanf("%d",&tmpv);
                    xdev.XmtCtr3.AttTxGain_1 = tmpv & 0x3ff;
                    printf("Transfer Frame Size in Bytes:");
                    scanf("%d",&tmpv);
                    xdev.XmtCtr3.TrFrmSz = tmpv & 0xfff;

                    printf("Enter the Phase Offset:");
                    scanf("%d",&tmpv);
                    xdev.XmtCtr4.PhiOffset16 = tmpv &0x1f;                
                    printf("Enter the y16:");
                    scanf("%d",&tmpv);
                    xdev.XmtCtr4.Y16 = tmpv &0x1fff;                
                    printf("Factor for the TxSymbol:");
                    scanf("%d",&tmpv);
                    xdev.XmtCtr4.TxSampFact = tmpv &0x3ff;                
                    printf("Enter the rsmode:");
                    scanf("%d",&tmpv);
                    xdev.XmtCtr4.RsMode = tmpv &0xf;                

                    printf("Rcv max RxGain Value-> 0..76:");
                    scanf("%d",&tmpv);
                    xdev.RcvCtrCh[0].RxGainMax = tmpv &0xff;                
                    printf("Enable channel enable(0)/disable(1):");
                    scanf("%d",&tmpv);
                    xdev.RcvCtrCh[0].ChEn = tmpv &0x1;                
                    printf("Rcv Modulation:");
                    scanf("%d",&tmpv);
                    xdev.RcvCtrCh[0].Modulat = tmpv &0x7;                
                    printf("Rcv Bit Direction:");
                    scanf("%d",&tmpv);
                    xdev.RcvCtrCh[0].MsbFirst = tmpv &0x1;                
                    printf("Rcv FEC:");
                    scanf("%d",&tmpv);
                    xdev.RcvCtrCh[0].Fec = tmpv &0x7;                
                    printf("Rcv PseudoRanomizer:");
                    scanf("%d",&tmpv);
                    xdev.RcvCtrCh[0].PRnd = tmpv &0x1;                
                    printf("Rcv BCH Decoder:");
                    scanf("%d",&tmpv);
                    xdev.RcvCtrCh[0].BchDec = tmpv &0x1;                
                    printf("Rcv accept BCH Error:");
                    scanf("%d",&tmpv);
                    xdev.RcvCtrCh[0].AccBchErr = tmpv &0x1;                
                    printf("Rcv bch count mode:");
                    scanf("%d",&tmpv);
                    xdev.RcvCtrCh[0].BchCountMode = tmpv &0x1;                
                    printf("PowerOff:");
                    scanf("%d",&tmpv);
                    xdev.RcvCtrCh[0].PwrOff = tmpv &0x3f;                
                    printf("Rcv Calibration Offset:");
                    scanf("%d",&tmpv);
                    xdev.RcvCtrCh[0].RcvCalib = tmpv &0x3f;                

                    printf("Transmit Symbol Frequency in kHz (1...56.000):");
                    scanf("%d",&tmpv);
                    xdev.SymbFreq.XmtSymbFreq = tmpv & 0xffff;
                    printf("Receive Symbol Frequency in kHz (1...56.000):");
                    scanf("%d",&tmpv);
                    xdev.SymbFreq.RcvSymbFreq = tmpv & 0xffff;

                    printf("Enter the receive mode:");
                    scanf("%d",&tmpv);
                    xdev.RcvCtr_0.RcvMode = tmpv & 0xf;
                    printf("Enter the receive channel:");
                    scanf("%d",&tmpv);
                    xdev.RcvCtr_0.RcvChannel = tmpv & 0x3;
                    printf("Enter the channel_0 ON(0)/OFF(1):");
                    scanf("%d",&tmpv);
                    xdev.RcvCtr_0.ChSwitchOn_0 = tmpv & 0x1;
                    printf("Enter the channel_1 ON(0)/OFF(1):");
                    scanf("%d",&tmpv);
                    xdev.RcvCtr_0.ChSwitchOn_1 = tmpv & 0x1;
                    printf("Enter the Drop Samples (0...3499):");
                    scanf("%d",&tmpv);
                    xdev.RcvCtr_0.DropSample = tmpv & 0xfff;
                    printf("Enter the current dt minus:");
                    scanf("%d",&tmpv);
                    xdev.RcvCtr_0.dT_minus = tmpv & 0x1;
                    printf("Enter the current dt plus:");
                    scanf("%d",&tmpv);
                    xdev.RcvCtr_0.dT_plus = tmpv & 0x1;
                    printf("Enter the reserve:");
                    scanf("%d",&tmpv);
                    xdev.RcvCtr_0.Reserve = tmpv & 0x3ff;

                    os_memcpy(tc_data,&xdev,tc_len);
                    status = 0;

                }
                break;
            case TC_XBAND_SET_FLAGS_CONF:
                {
                    printf("\n\r TC_XBAND_SET_FLAGS_CONF is sent");
                    tc_len = 0;
                    tc_data = (uint8*)malloc(tc_len);
                    status = 0;

                }
                break;
            case TC_XBAND_SET_VERSION:
                {
                    uint32_t tmpv; 
                    printf("\n\r TC_XBAND_SET_VERSION is sent");
                    tc_len = sizeof(xver);
                    tc_data = (uint8*)malloc(tc_len);
                    /*                xver.prog_version.Seconds = 60;
                                      xver.prog_version.Minutes = 60;
                                      xver.prog_version.Hours = 24;
                                      xver.prog_version.Year = 2023;
                                      xver.prog_version.Months = 12;
                                      xver.prog_version.Day = 31;
                                      memcpy(&xver.prog_version.FileName ,"FPGA", sizeof("FPGA"));
                                      xver.prog_version.start_adr = 1; 
                                      xver.prog_version.len = 5;
                                      xver.prog_version.Flags = 1;*/

                    printf("Enter the seconds:");
                    scanf("%d",&tmpv);
                    xver.prog_version.Seconds = tmpv & 0x3f;

                    printf("Enter the Minute:");
                    scanf("%d",&tmpv);
                    xver.prog_version.Minutes = tmpv & 0x3f;                

                    printf("Enter the hours:");
                    scanf("%d",&tmpv);
                    xver.prog_version.Hours = tmpv & 0x1f;                

                    printf("Enter the year:");
                    scanf("%d",&tmpv);
                    xver.prog_version.Year = tmpv & 0x3f;                

                    printf("Enter the months:");
                    scanf("%d",&tmpv);
                    xver.prog_version.Months = tmpv & 0xf;                

                    printf("Enter the day:");
                    scanf("%d",&tmpv);
                    xver.prog_version.Day = tmpv & 0x1f;                

                    printf("Enter the start address:");
                    scanf("%d",&tmpv);
                    xver.prog_version.start_adr = tmpv;                

                    printf("Enter the length:");
                    scanf("%d",&tmpv);
                    xver.prog_version.len = tmpv & 0xfffffff;                

                    printf("Enter the flags(SOLL-1; RUN- 0x2;...):");
                    scanf("%d",&tmpv);
                    xver.prog_version.Flags = tmpv & 0xf;                

                    os_memcpy(tc_data,&xver,tc_len);
                    status = 0;
                }
                break;

            case TC_XBAND_GET_IP_ADR:
                {
                    tc_len = 0;
                    tc_data = (uint8*)malloc(tc_len);
                    status = 0; 
                }
                break;
            case TC_XBAND_GET_FLAGS_CONF:
                {
                    tc_len = 0;
                    tc_data = (uint8*)malloc(tc_len);
                    status = 0; 
                }
                break;
            case TC_XBAND_GET_VERSION:
                {
                    tc_len = 0;
                    tc_data = (uint8*)malloc(tc_len);
                    status = 0; 
                }
                break;
            case TC_XBAND_GET_DEVICE_CONF:
                {
                    tc_len = 0;
                    tc_data = (uint8*)malloc(tc_len);
                    status = 0; 
                }
                break;
            case TC_XBAND_GET_FEATURE_SELECT:
                {
                    tc_len = 0;
                    tc_data = (uint8*)malloc(tc_len);
                    status = 0; 
                }
                break;
            case TC_XBAND_GET_HOUSE_KEEP:
                {
                    tc_len = 0;
                    tc_data = (uint8*)malloc(tc_len);
                    status = 0; 
                }
                break;
            case TC_XBAND_GET_XPA_INF:
                {
                    tc_len = 0;
                    tc_data = (uint8*)malloc(tc_len);
                    status = 0; 
                }
                break;

            case TC_XBAND_SET_PROD_KEY:
                {
                    uint32 prod_key[4] = {0xc9c694fb,0xdeac9b61,0x19ea8546,0x09c58891}; 
                    tc_len = sizeof(prod_key);
                    tc_data = (uint8*)malloc(tc_len);
                    status = 0; 
                }
                break;

            case TC_GET_OBC_SW_STS:
                {
                    tc_len = 0;
                    tc_data = (uint8*)malloc(tc_len);
                    printf("TC OBC SW status \n");
                    status = 0;

                }
                break;

            case TC_SET_SSD_SLOT:
                {
                    tc_len = sizeof(uint16_t);
                    tc_data = (uint8_t *)malloc(tc_len); 
                    uint8_t ssd_slot_slec_2;
                    printf("SELECT THE BOARD \n [PS-1 AND EDGE-2]:\n");
                    scanf("%hhu",&ssd_brd_slec);
                    os_memcpy(tc_data,&ssd_brd_slec,tc_len-1);
                    if(ssd_brd_slec <= 2)
                    {
                        printf("SELECT THE SLOT 1,\n ENABLE 1 AND DISABLE 0 :\n");
                        scanf("%hhd",&ssd_slot_slec);
                        if(ssd_slot_slec <=1)
                        {
                            printf("SELECT THE SLOT 2,\n ENABLE 1 AND DISABLE 0:\n");
                            scanf("%hhd",&ssd_slot_slec_2);
                            if(ssd_slot_slec_2 <=1)
                            {
                                ssd_slot_slec|=ssd_slot_slec_2 << 1;
                                os_memcpy(tc_data+1,&ssd_slot_slec,tc_len-1);
                            }             
                            else
                            {
                                printf("Invalid Input\n");
                                status = -1;
                            }
                        }
                        else
                        {
                            printf("Invalid Input\n");

                            status = -1;
                        }

                    }
                    else
                    {
                        printf("Invalid Input\n");
                        status = -1;
                    }

                }
                break;

            case TC_SET_SSD_HEAT_ENABLE:
                {
                    tc_len = 2; 
                    tc_data = (uint8_t *)malloc(tc_len);
                    uint8_t ssd_board_slec;
                    uint8_t ssd_heat_slec;
                    printf("SELECT THE BOARD\n [ PS BOARD 1 And EDGE BOARD 2 ]\n");
                    scanf("%hhd",&ssd_board_slec);
                    printf("Select Heatcoil state\n [Enable - 1/Disable - 0]\n");
                    scanf("%hhd",&ssd_heat_slec);

                    if(ssd_board_slec <= 2)
                    {
                        os_memcpy(tc_data,&ssd_board_slec,1);

                        if((ssd_heat_slec < 2))
                        {
                            os_memcpy(tc_data+1,&ssd_heat_slec,1);    
                        }

                        else
                        {
                            printf("Invalid Input\n");
                            status = -1;
                        }
                    }
                }
                break;


            case	TC_GET_SSD_HEAT_ENABLE:
                {
                    tc_len = 1;
                    tc_data = (uint8_t *) malloc(tc_len);
                    printf("\nENTER THE BOARD ID \nPayload server - 1\nEdge server - 2\n");
                    scanf("%hhu" ,&board_id);
                    if(!(board_id == 1 || board_id == 2))
                    {
                        printf("Invalid Test ID\n");
                        status = -1;
                    }

                    memcpy(tc_data ,&board_id ,1);
                }
                break;

            case	TC_GET_SSD_SLOT:
                {
                    tc_len = 1;
                    tc_data = (uint8_t *) malloc(tc_len);
                    printf("\nENTER THE BOARD ID \nPayload server - 1\nEdge server - 2\n");
                    scanf("%hhu" ,&board_id);
                    if(!(board_id == 1 || board_id == 2))
                    {
                        printf("Invalid Test ID\n");
                        status = -1;
                    }

                    memcpy(tc_data ,&board_id ,1);
                }
                break;


            case TC_PS_STAGED_TC:
                {
                    tc_len = 4;
                    tc_data = (uint8 *)malloc(tc_len);
                    printf("Enter PS Staged TC ID\n");
                    scanf("%u",&ps_staged_tc_id);
                    memcpy(tc_data,&ps_staged_tc_id,4);

                    status = 0;
                }
                break;
            case TC_SET_SCH_ON_OFF:
                {
                    uint8_t size = 5;
                    //  uint8_t i;
                    tc_len = sizeof(sch_sband_ctrl_s)*size + sizeof(uint8_t);
                    tc_data = (uint8_t *)malloc(tc_len);
                    //uint8_t size = 3;
                    // sch_sband_ctrl_s = malloc(tc_len);
                    sband_on_off_state_ctrl((sch_sband_ctrl_s *)&tc_data[1],&tc_data[0]);
                    tc_data[0] = size;
                    //os_memcpy(&tc_data[1],&sch_sband_ctrl_s,tc_len);
                    /*for(i=0;i<3;i++){

                      printf("decode data state_onstate %d\n",sch_sband_ctrl_s[i].state);

                      printf("onstate decode rtc time %d\n",sch_sband_ctrl_s[i].time.hour);
                      printf("onstate decode rtc time %d\n",sch_sband_ctrl_s[i].time.min);
                      printf("onstate decode rtc time %d\n",sch_sband_ctrl_s[i].time.sec);

                      printf("decode data state-offstate %d\n",sch_sband_ctrl_s[i].state);

                      printf("offstate decode rtc time %d\n",sch_sband_ctrl_s[i].time.hour);
                      printf("offstate decode rtc time %d\n",sch_sband_ctrl_s[i].time.min);
                      printf("offstate decode rtc time %d\n",sch_sband_ctrl_s[i].time.sec);
                      }*/
                    status = 0;
                }
                break;

            case TC_LOG_DOWNLOAD_BLOCKS:
                {
                    log_data data_l;
                    uint8_t input_via_tm_ftm = 0;
                    uint8_t input_seq_loss_enable = 0;
                    tc_len = sizeof(log_data);
                    tc_data = (uint8_t *)malloc(tc_len);
                    printf("Enter download of log through\n");
                    printf("1. Telementary\n");
                    printf("2. File tranfer(FTM)\n");
                    scanf("%hhu",&input_via_tm_ftm);
                    data_l.down_via_tm_or_ftm = input_via_tm_ftm;
                    if(input_via_tm_ftm == 2)
                    {
                        printf("Enter no.of blocks to download (Range 1-64)\n");
                        scanf("%hu",&data_l.down_blocks);
                        printf("Enter MTU:\n");
                        scanf("%hd",&data_l.down_mtu);
                        printf("Enter Satellite FTDS delay in ms:\n");
                        scanf("%hu",&data_l.sat_ftds);
                        printf("Sequence loss detection: Enter 1 to enable or 0 to disable\n");
                        printf("	Note: sequnece loss detection uses duplex communication\n");
                        scanf("%hhu",&input_seq_loss_enable);
                        data_l.seq_loss_enable = input_seq_loss_enable;
                        if(data_l.down_mtu == 0)
                        {
                            data_l.down_mtu = 64;
                        }
                    }
                    else
                    {
                        printf("Enter the Block ID\n");
                        scanf("%hu",&data_l.down_blocks);
                    }
                    os_memcpy(tc_data,&data_l,tc_len);
                }
                break;

            case TC_READ_LOG_INFO:
                {
                    tc_data=malloc(1);
                    tc_len=1;
                    printf("Enter your selection\n");
                    printf("1.Read logger configuration for all modules\n");
                    printf("2.Get log storage handle info\n");
                    scanf("%hhu",&tc_data[0]);

                }
                break;

            case TC_LOG_LEVEL_FILTER_CONFIG:
                {
                    tc_data= log_lev_cfg_encode(&tc_len);
                    printf("LOGz:%hu,%hhu\n",tc_len,tc_data[0]);
                }
                break;

            case TC_LOG_DOWNLOAD_BACKUP_BLOCKS:
                {   

                    log_data log_bkup;
                    uint8_t bkup_size = 0;
                    uint8_t input_seq_loss_enable = 0;
                    uint8_t log_backup_dow_en = 0;
                    uint8_t input_log_backup_cfg = 0;
                    printf("\n1. Log backup Download\n");
                    printf("2. Enable / Disable Log backup Download\n");
                    scanf("%hhu",&log_backup_dow_en);
                    if(log_backup_dow_en == 2)
                    { 
                        tc_len = sizeof(log_data)+1;   // one byte to add download size
                        tc_data = (uint8_t *)malloc(tc_len);
                        printf(" To Disable log backup Download - 3\n ");
                        printf("To Enable log backup Download - 4\n");
                        scanf("%hhu",&input_log_backup_cfg);
                        log_bkup.reserved = input_log_backup_cfg;
                        if(input_log_backup_cfg == 4)
                        {
                            printf("Enter the Threshold for Log Backup Download (1-12)\n");
                            scanf("%hu",&log_bkup.down_mtu);
                        }

                    }
                    else if (log_backup_dow_en == 1)
                    {

                        tc_len = sizeof(log_data)+1;   // one byte to add download size
                        tc_data = (uint8_t *)malloc(tc_len);
                        printf("Enter the partition number to download(Range 1-3)\n");
                        scanf("%hu",&log_bkup.down_blocks);
                        printf("Enter MTU:\n");
                        scanf("%hd",&log_bkup.down_mtu);
                        printf("Enter Satellite FTDS delay in ms:\n");
                        scanf("%hu",&log_bkup.sat_ftds);
                        printf("Sequence loss detection: Enter 1 to enable or 0 to disable\n");
                        printf("	Note: sequnece loss detection uses duplex communication\n");
                        scanf("%hhu",&input_seq_loss_enable);
                        log_bkup.seq_loss_enable = input_seq_loss_enable;
                        printf("Enter the size to be downloaded in KB(1-64)\n");
                        scanf("%hhu",&bkup_size);
                        log_bkup.reserved = input_log_backup_cfg;
                    }
                    else
                    {
                        printf("Invalid ID");
                    }
                    os_memcpy(tc_data, &log_bkup, tc_len);
                    tc_data[7] = bkup_size;
                }
                break;

            case TC_SET_CONTROL_FLAG_TM_BUFFER:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *)malloc(tc_len);

                }
                break;

            case TC_SET_COMMS_TM_DLREQ:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *)malloc(tc_len);
                }
                break;

            case TC_DEFERRED_STRG:
                {
                    status = handle_tc_deferred_storage();
                    status = -1;
                }
                break;

            case TC_CONOPS_SCH_LUT_CFG:
            case TC_CONOPS_SCH_LUT_RUN_CTRL:
            case TC_CONOPS_SCH_STS_INFO:
			    status =  conops_sch_tc(tc_id, &tc_data, &tc_len);
                break;
				

            case TC_EXTRNL_MEM_TEST:
                {

                    if(mem_type.mem_intf_type < 0 || mem_type.mem_intf_type > 3)
                    {
                        printf("Invalid Memory type selected\n");
                        status = -1;
                    }
                    else
                    {
                        tc_len = sizeof(ext_mem_test_tc_tm_s);
                        tc_data = (uint8_t *)malloc(tc_len);
                        memcpy(tc_data,&mem_type,tc_len);
                        status = 0;
                    }
                    break;
                }
            case TC_SNS_THRSLD_STS:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *)malloc(tc_len);
                    status = 0;
                }
                break;

            case TC_GET_OBC_NVM_REVISION_NUM:
                {
                    tc_len = 0;
                    tc_data = (uint8_t *)malloc(tc_len);
                    status = 0;
                }
                break;

            case TC_NVM:
                {
                    uint8 sts = 1;
                    uint16 i=0;
                    printf("Enter the mode(0 - Read/1 - Write/2 - Flash_Read/3 - Flash_write_witherase/4 - Flash_write_withouterase/5 - NVM_Read/6 - NVM_Write/7 - Flash_Erase/8-encryption_disabled/9-encryption_enabled/10-authentication disabled/11-authentication enabled)/20 SEC KEY:\n");
                    scanf("%hhd",&nvm_data_hdr.mode);
                    printf("Enter the Base address:\n");
                    scanf("%x",&nvm_data_hdr.address);
                    printf("Enter the Length of the data:\n");
                    scanf("%hd",&nvm_data_hdr.len);
                    // printf("Type of the memory(0 - SDRAM/1 - QSPI/2 - External NOR_FLASH/3 - Internal Flash):\n");
                    // scanf("%d",&nvm_data_hdr.mem_type);
                    if(nvm_data_hdr.mode == 0 || nvm_data_hdr.mode == 1 || nvm_data_hdr.mode == 2 || nvm_data_hdr.mode == 3 || nvm_data_hdr.mode == 4 || nvm_data_hdr.mode == 7)
                    {
                        if(nvm_data_hdr.address  >= 0x20000000 && nvm_data_hdr.address < 0x20080000)
                        {
                            nvm_data_hdr.mem_type = MEM_TYPE_IRAM;
                        }
                        else if(nvm_data_hdr.address >= 0xC0000000 && nvm_data_hdr.address < 0xC0800000)
                        {
                            nvm_data_hdr.mem_type = MEM_TYPE_SDRAM;
                        }
                        else if(nvm_data_hdr.address >= 0x8000000 && nvm_data_hdr.address < 0x8200000)
                        {
                            nvm_data_hdr.mem_type = MEM_TYPE_IFLASH;
                        }
                        else if(nvm_data_hdr.address >= 0x60000000 && nvm_data_hdr.address < 0x61000000)
                        {
                            nvm_data_hdr.mem_type = MEM_TYPE_NOR_FLASH;
                        }
                        else if(nvm_data_hdr.address >= 0x9000000 && nvm_data_hdr.address < 0x94000000)
                        {
                            nvm_data_hdr.mem_type = MEM_TYPE_QSPI;
                        }
                        else
                        {
                            sts = 0;
                            printf("invalid address\n");
                        }
                    }
                    else if(nvm_data_hdr.mode == 5 || nvm_data_hdr.mode == 6 )
                    {
                        nvm_data_hdr.mem_type = 0;
                    }
                    else if(nvm_data_hdr.mode == 8 || nvm_data_hdr.mode == 9 ||nvm_data_hdr.mode == 10 || nvm_data_hdr.mode == 11 || nvm_data_hdr.mode == 20)
                    {
                        nvm_data_hdr.mem_type = 0;
                    }
                    else
                    {
                        printf("Invalid mode\n");
                        sts = 0;
                    }
                    if(sts == 1)
                    {
                        if(nvm_data_hdr.mode == 1 || nvm_data_hdr.mode == 3 || nvm_data_hdr.mode == 4 || nvm_data_hdr.mode == 6)
                        {
                            tc_len = sizeof(nvm_param) + nvm_data_hdr.len;
                            tc_data = (uint8_t*)malloc(tc_len);
                            os_memcpy(tc_data,&nvm_data_hdr,sizeof(nvm_param));
                            nvm_data_pld = tc_data+sizeof(nvm_param);
                            printf("Enter the Data to be written\n");
                            for(i = 0; i < nvm_data_hdr.len;i++)
                            {
                                //scanf("%d",&nvm_data_pld[i]);
                                nvm_data_pld[i]=i;
                            }
                            status = 0;
                        }
                        else if(nvm_data_hdr.mode == 0 || nvm_data_hdr.mode == 2 || nvm_data_hdr.mode == 5 || nvm_data_hdr.mode == 7)
                        {
                            tc_len = sizeof(nvm_param);
                            tc_data = (uint8_t*)malloc(tc_len);
                            os_memcpy(tc_data,&nvm_data_hdr,sizeof(nvm_param));
                            status = 0;
                        }
                        else if(nvm_data_hdr.mode == 8 || nvm_data_hdr.mode == 9 ||nvm_data_hdr.mode == 10 || nvm_data_hdr.mode == 11)
                        {
                            tc_len = sizeof(nvm_param);
                            tc_data = (uint8_t*)malloc(tc_len);
                            os_memcpy(tc_data,&nvm_data_hdr,sizeof(nvm_param));
                            status = 0;
                        }
                        else if(nvm_data_hdr.mode == 20)
                        {
                            nvm_data_hdr.mode = 6;
                            tc_len = sizeof(nvm_param) + nvm_data_hdr.len;
                            tc_data = (uint8_t*)malloc(tc_len);
                            os_memcpy(tc_data,&nvm_data_hdr,sizeof(nvm_param));
                            os_memcpy(tc_data+sizeof(nvm_param),tc_tm_mngr_key,nvm_data_hdr.len);
                            nvm_data_pld = tc_data+sizeof(nvm_param);
                            /*for(i = 0; i < nvm_data_hdr.len;i++)
                              {
#if 0
nvm_data_pld[i]=0xAA;
#else
nvm_data_pld[i] = tc_tm_mngr_key[i];
#endif
}*/
                            status = 0;
                            }
else
{
    printf("Invalid mode\n");
    status = -1;
}
}
else
{
    status = -1;
}
}
break;

case TC_TM_MNGR_GS_CONTACT:
{
    tc_len = 1;
    tc_data = (uint8 *)malloc(tc_len);

    printf("Set GS contact flag: \n\
            \r1 - GS contact TRUE\n\
            \r0 - GS contact FALSE\n");

    scanf("%hhd",&tc_data[0]);
    status = 0;
}
break;

case TC_GET_CUR_TIME:
{
    /* pack TC payload */
    tc_len = 0;
    tc_data = (uint8_t *) malloc(tc_len);
    status = 0;
}
break;

case TC_TCTM_DEQUEUE:
{
    uint16_t flush_cnt;
    printf("Enter Flush cnt:\n");
    scanf("%hd",&flush_cnt);
    tc_len = 2;
    tc_data = (uint8_t *) malloc(tc_len);
    os_memcpy(tc_data,&flush_cnt,tc_len);
    status = 0;
}
break;
case TC_SET_RADIO_MODULE_ID:
{

    uint8_t radio_id;
    printf("1. S Band\n2. UHF\n3. X Band\nEnter Radio Id:-");
    scanf("%hhd",&radio_id);
    if(radio_id < MAX_RADIO_MOD)
    {
        tc_len = 1;
        tc_data = (uint8_t *) malloc(tc_len);
        os_memcpy(tc_data,&radio_id,tc_len);
        status = 0;
    }
    else
    {
        printf("Invalid Id\r\n");
        status = -1;
    }
}
break;

case TC_ERR_HANDLER_READ_FAULTS:
{
    tc_len  = 1;
    tc_data = (uint8_t*) malloc(tc_len);
    tc_data[0] = 0;
}
break;

case TC_ERR_HANDER_READ_GROUP_ERROR_STATUS:
{
    uint8_t grp_id;
    uint8_t tctm_crtl_byte;
    printf("\nEnter the Group id \n");
    printf("Get IO status - 0\n");
    printf("Get Ahw_Set_1 status - 1\n");
    printf("Get Ahw_Set_2 status - 2\n");
    printf("Get System status- 3\n");
    printf("Get Service status - 4\n");
    printf("Get Comms_modules status - 5\n");
    printf("Get ADCS status - 6\n");
    printf("Get EPS status - 7\n");

    scanf("%hhd",&grp_id);
    if(grp_id > 7)
    {
        printf("Invalid Group id\n");
    }

    tctm_crtl_byte = 1 | (grp_id <<3);
    tc_len = 1;
    tc_data = (uint8_t*) malloc(tc_len);
    memcpy(tc_data, &tctm_crtl_byte, tc_len);
}
break;

case TC_ERR_HANDLER_GET_ERROR_HISTORY:
{  
    tc_len = 1;
    tc_data = (uint8_t*) malloc(tc_len);
    tc_data[0] = 2;
}
break;

case TC_ERR_HANDLER_RUN_BIST:
{
    uint8_t bist_option;
    uint8_t grp_id;
    uint32_t err_code_num;


    printf("\nTo run bist for all modules      		- 0\n");
    printf("To run bist for particular error 		- 1\n");
    printf("To set fault bit for all error   		- 2\n");
    printf("To clear all fault bit			 		- 3\n");
    printf("To set particular error as fault 		- 4\n");
    printf("To clear particular error as fault 		- 5\n");
    printf("To set a module as error				- 6\n");
    printf("To clear a module as error				- 7\n");
    scanf("%hhu",&bist_option);
    if(bist_option == 0)
    {
        tc_len = 1;
        tc_data = (uint8_t*) malloc(tc_len);
        tc_data[0] = 0 << 4;
    }
    else if (bist_option == 1)
    {
        printf("\nEnter the Group id \n");
        printf("Get IO status 				- 0\n");
        printf("Get Ahw_Set_1 status		- 1\n");
        printf("Get Ahw_Set_2 status 		- 2\n");
        printf("Get System status			- 3\n");
        printf("Get Service status 			- 4\n");
        printf("Get Comms_modules status 		- 5\n");
        printf("Get ADCS status 			- 6\n");
        printf("Get EPS status 				- 7\n");
        scanf("%hhd",&grp_id);

        if(grp_id > ERR_GROUP_MAX)
        {
            grp_id = 1;
            printf("You have entered unknwon grp id so it is giving default grp id\n");
        }
        if(grp_id == 0)
        {
        	printf("Enter the error code number from 0 to 4:\n");
        }
        else if (grp_id == 1)
        {
        	printf("Enter the error code number from 0 to 31:\n");
        }
        else if (grp_id == 2)
        {
        	printf("Enter the error code number 0 :\n");
        }
        else if (grp_id == 3)
        {
        	printf("Enter the error code number from 0 to 5 :\n");
        }
        else if (grp_id == 4)
        {
        	printf("Enter the error code number  0 :\n");
        }
        else if (grp_id == 5)
        {
        	printf("Enter the error code number from 0 to 13:\n");
        }
        else if (grp_id == 6)
        {
        	printf("Enter the error code number from 0 to 3:\n");
        }

        else if (grp_id == 7)
        {
        	printf("Enter the error code number from 0 to 3:\n");
        }

        scanf("%d",&err_code_num);

        tc_len = 5;
        tc_data = (uint8_t*) malloc(tc_len);
        tc_data[0] = 1 << 4 | grp_id;
        memcpy(&tc_data[1], &err_code_num, tc_len);
    }
    else if(bist_option == 2)
    {
        tc_len = 1;
        tc_data = (uint8_t*) malloc(tc_len);
        tc_data[0] = 2 << 4;

    }
    else if(bist_option == 3)
    {
        tc_len = 1;
        tc_data = (uint8_t*) malloc(tc_len);
        tc_data[0] = 3 << 4;

    }
    else if(bist_option == 4)
    {
        printf("\nEnter the Group id \n");
        printf("To SET IO as fault 				- 0\n");
        printf("To SET Ahw_Set_1 as fault 		- 1\n");
        printf("To SET Ahw_Set_2 as fault 		- 2\n");
        printf("To SET System as fault    		- 3\n");
        printf("To SET Service as fault 		- 4\n");
        printf("To SET Comms_modules as fault 	- 5\n");
        printf("To SET ADCS as fault 			- 6\n");
        printf("To SET EPS as fault 			- 7\n");
        scanf("%hhd",&grp_id);

        if(grp_id > ERR_GROUP_MAX)
        {
            grp_id = 1;
            printf("You have entered unknwon grp id so it is giving default grp id\n");
        }

        if(grp_id == 0)
        {
        	printf("Enter the error code number from 0 to 4:\n");
        }
        else if (grp_id == 1)
        {
        	printf("Enter the error code number from 0 to 31:\n");
        }
        else if (grp_id == 2)
        {
        	printf("Enter the error code number 0 :\n");
        }
        else if (grp_id == 3)
        {
        	printf("Enter the error code number from 0 to 5 :\n");
        }
        else if (grp_id == 4)
        {
        	printf("Enter the error code number  0 :\n");
        }
        else if (grp_id == 5)
        {
        	printf("Enter the error code number from 0 to 13:\n");
        }
        else if (grp_id == 6)
        {
        	printf("Enter the error code number from 0 to 3:\n");
        }

        else if (grp_id == 7)
        {
        	printf("Enter the error code number from 0 to 3:\n");
        }
        scanf("%d",&err_code_num);

        tc_len = 5;
        tc_data = (uint8_t*) malloc(tc_len);
        tc_data[0] = 4 << 4 | grp_id;
        memcpy(&tc_data[1], &err_code_num, tc_len);


    }
    else if(bist_option == 5)
    {
        printf("\nEnter the Group id \n");
        printf("To CLEAR IO as fault 				- 0\n");
        printf("To CLEAR Ahw_Set_1 as fault 		- 1\n");
        printf("To CLEAR Ahw_Set_2 as fault 		- 2\n");
        printf("To CLEAR System as fault    		- 3\n");
        printf("To CLEAR Service as fault 			- 4\n");
        printf("To CLEAR Comms_modules as fault 		- 5\n");
        printf("To CLEAR ADCS as fault 				- 6\n");
        printf("To CLEAR EPS as fault 				- 7\n");
        scanf("%hhd",&grp_id);

        if(grp_id > ERR_GROUP_MAX)
        {
            grp_id = 1;
            printf("You have entered unknwon grp id so it is giving default grp id\n");
        }

        if(grp_id == 0)
        {
        	printf("Enter the error code number from 0 to 4:\n");
        }
        else if (grp_id == 1)
        {
        	printf("Enter the error code number from 0 to 31:\n");
        }
        else if (grp_id == 2)
        {
        	printf("Enter the error code number 0 :\n");
        }
        else if (grp_id == 3)
        {
        	printf("Enter the error code number from 0 to 5 :\n");
        }
        else if (grp_id == 4)
        {
        	printf("Enter the error code number  0 :\n");
        }
        else if (grp_id == 5)
        {
        	printf("Enter the error code number from 0 to 13:\n");
        }
        else if (grp_id == 6)
        {
        	printf("Enter the error code number from 0 to 3:\n");
        }

        else if (grp_id == 7)
        {
        	printf("Enter the error code number from 0 to 3:\n");
        }
        scanf("%d",&err_code_num);

        tc_len = 5;
        tc_data = (uint8_t*) malloc(tc_len);
        tc_data[0] = 5 << 4 | grp_id;
        memcpy(&tc_data[1], &err_code_num, tc_len);


    }
    else if(bist_option == 6)
    {
        printf("\nEnter the Group id \n");
        printf("To SET IO as error 				- 0\n");
        printf("To SET Ahw_Set_1 as error 		- 1\n");
        printf("To SET Ahw_Set_2 as error 		- 2\n");
        printf("To SET System as error    		- 3\n");
        printf("To SET Service as error 		- 4\n");
        printf("To SET Comms_modules as error 	- 5\n");
        printf("To SET ADCS as error 			- 6\n");
        printf("To SET EPS as error 			- 7\n");
        scanf("%hhd",&grp_id);

        if(grp_id > ERR_GROUP_MAX)
        {
            grp_id = 1;
            printf("You have entered unknwon grp id so it is giving default grp id\n");
        }

        if(grp_id == 0)
        {
        	printf("Enter the error code number from 0 to 4:\n");
        }
        else if (grp_id == 1)
        {
        	printf("Enter the error code number from 0 to 31:\n");
        }
        else if (grp_id == 2)
        {
        	printf("Enter the error code number 0 :\n");
        }
        else if (grp_id == 3)
        {
        	printf("Enter the error code number from 0 to 5 :\n");
        }
        else if (grp_id == 4)
        {
        	printf("Enter the error code number  0 :\n");
        }
        else if (grp_id == 5)
        {
        	printf("Enter the error code number from 0 to 13:\n");
        }
        else if (grp_id == 6)
        {
        	printf("Enter the error code number from 0 to 3:\n");
        }

        else if (grp_id == 7)
        {
        	printf("Enter the error code number from 0 to 3:\n");
        }
        scanf("%d",&err_code_num);

        tc_len = 5;
        tc_data = (uint8_t*) malloc(tc_len);
        tc_data[0] = 6 << 4 | grp_id;
        memcpy(&tc_data[1], &err_code_num, tc_len);


    }
    else if(bist_option == 7)
    {
        printf("\nEnter the Group id \n");
        printf("To CLEAR IO as error 				- 0\n");
        printf("To CLEAR Ahw_Set_1 as error 		- 1\n");
        printf("To CLEAR Ahw_Set_2 as error 		- 2\n");
        printf("To CLEAR System as error    		- 3\n");
        printf("To CLEAR Service as error 			- 4\n");
        printf("To CLEAR Comms_modules as error 		- 5\n");
        printf("To CLEAR ADCS as error 				- 6\n");
        printf("To CLEAR EPS as error				- 7\n");
        scanf("%hhd",&grp_id);

        if(grp_id > ERR_GROUP_MAX)
        {
            grp_id = 1;
            printf("You have entered unknwon grp id so it is giving default grp id\n");
        }

        if(grp_id == 0)
        {
        	printf("Enter the error code number from 0 to 4:\n");
        }
        else if (grp_id == 1)
        {
        	printf("Enter the error code number from 0 to 31:\n");
        }
        else if (grp_id == 2)
        {
        	printf("Enter the error code number 0 :\n");
        }
        else if (grp_id == 3)
        {
        	printf("Enter the error code number from 0 to 5 :\n");
        }
        else if (grp_id == 4)
        {
        	printf("Enter the error code number  0 :\n");
        }
        else if (grp_id == 5)
        {
        	printf("Enter the error code number from 0 to 13:\n");
        }
        else if (grp_id == 6)
        {
        	printf("Enter the error code number from 0 to 3:\n");
        }

        else if (grp_id == 7)
        {
        	printf("Enter the error code number from 0 to 3:\n");
        }
        scanf("%d",&err_code_num);

        tc_len = 5;
        tc_data = (uint8_t*) malloc(tc_len);
        tc_data[0] = 7 << 4 | grp_id;
        memcpy(&tc_data[1], &err_code_num, tc_len);


    }

    else if(bist_option > 8)
    {
        printf("Invalid option\n");
    }
    else
    {
        /*
         *
         */
    }

}
break;


case TC_GET_MCU_EXT_MEM_INFO:
{

    tc_len = 1;
    tc_data = (uint8_t *) malloc(tc_len);
    printf("Enter the device ID : 0.OBC / 1.PS /2.Edge\n");
    scanf("%hhu",&tc_data[0]);
    status = 0;
}
break;

case TC_GET_MCU_CHIP_INFO:
{

    tc_len = 1;
    tc_data = (uint8_t *) malloc(tc_len);
    printf("Enter the device ID : 0.OBC / 1.PS /2.Edge\n");
    scanf("%hhu",&tc_data[0]);
    status = 0;
}
break;
case TC_GET_PS_TEMP:
{
    tc_len = 1;
    tc_data = (uint8_t *) malloc(tc_len);
    printf("Enter the device ID : 0.OBC / 1.PS /2.Edge\n");
    scanf("%hhu",&tc_data[0]);
    status = 0;
}
break;
case TC_GET_PS_TIME:
{
    tc_len = 1;
    tc_data = (uint8_t *) malloc(tc_len);
    printf("Enter the device ID : 0.OBC / 1.PS /2.Edge\n");
    scanf("%hhu",&tc_data[0]);
    status = 0;
}
break;
case TC_GET_MCU_INT_MEM_INFO:
{
    tc_len = 0;
    tc_data = (uint8_t *) malloc(tc_len);
    status = 0;
}break;

case TC_GET_MCU_INT_PHERIPHARL_INFO:
{
    tc_len = 0;
    tc_data = (uint8_t *) malloc(tc_len);
    status = 0;
}break;

case TC_GET_MCU_EXT_PHERIPHARL_INFO:
{
    tc_len = 0;
    tc_data = (uint8_t *) malloc(tc_len);
    status = 0;
}break;

case TC_GET_MCU_RST_INFO:
{
    tc_len = 0;
    tc_data = (uint8_t *) malloc(tc_len);
    status = 0;
}break;

case TC_HM_TEST_CASE_REQ:
{
    uint32_t inst_size =0;
    uint16_t no_inst = 0;
    uint16_t no_queue = 0;
    uint8_t queue_id = 0;

    printf("\nEnter the Test Case ID :\n");
    printf("1.  BUFFER REQ   - SINGLE QUEUE \n");
    printf("2.  BUFFER REQ   - MULTIPLE QUEUE \n");
    printf("3.  ENQUEUE REQ  - SINGLE QUEUE \n");
    printf("4.  ENQUEUE REQ  - MULTIPLE QUEUE \n");
    printf("5.  BUFFER REQ   - WITHOUT PAYLOAD\n");
    printf("6.  BUFFER REQ   - INVALID QUEUE ID\n");
    printf("7.  ENQUEUE REQ  - WIHTOUT PAYLOAD\n");
    printf("8.  ENQUEUE REQ  - INVALID QUEUE ID\n");
    printf("9. ENQUEUE REQ  - QUEUE NOT ACTIVE\n");
    printf("10. ENQUEUE REQ  - WRAP DISABLED DROPPING DATA\n");
    printf("11. ENQUEUE REQ  - QUEUE FULL \n");
    printf("12. BUFFER REQ   - QUEUE CREATE FAIL\n");
    printf("13. FLUSH SUCC   - VALID SUBMODULE, VALID QUEUE, ACTIVE QUEUE\n");
    printf("14. FLUSH FAIL   - INVALID SUBMODULE, INVALID QUEUE, INVALID PRIORITY\n");
    printf("15. FLUSH SUCC   - INVALID SUBMODULE, INVALID QUEUE, VALID PRIORITY\n");
    printf("16. FLUSH FAIL   - VALID SUBMODULE, INVALID QUEUE, INVALID PRIORITY\n");
    printf("17. FLUSH SUCC   - VALID SUBMODULE, INVALID QUEUE, VALID PRIORITY\n");
    printf("18. FLUSH FAIL   - VALID SUBMODULE, VALID QUEUE, QUEUE NOT ACTIVE\n");
    printf("19. CHANGE QUEUE PRIORITY SUCC - INVALID SUBMODULE, INVALID QUEUE\n");
    printf("20. CHANGE QUEUE PRIORITY FAIL - VALID SUBMODULE, INVALID QUEUE, INVALID PRIORITY\n");
    printf("21. CHANGE QUEUE PRIORITY SUCC - VALID SUBMODULE, INVALID QUEUE, VALID PRIORITY\n");
    printf("22. CHANGE QUEUE PRIORITY FAIL - VALID SUBMODULE, VALID QUEUE, NOT ACTIVE QUEUE\n");
    printf("23. CHANGE QUEUE PRIORITY SUCC - VALID SUBMODULE, VALID QUEUE, ACTIVE QUEUE\n");
    printf("24. DELETE QUEUE FAIL          - NOT ACTIVE QUEUE\n");
    printf("25. DELETE QUEUE SUCC          - ACTIVE QUEUE\n");
    printf("26. CHANGE MODULE PRIORITY FAIL- INVALID SUBMODULE\n");
    printf("27. CHANGE MODULE PRIORITY FAIL- VALID SUBMODULE, INVALID PRIORITY\n");
    printf("28. CHANGE MODULE PRIORITY SUCC- VALID SUBMODULE, VALID PRIORITY\n");
    printf("29. DL REQ FAIL                - VALID SUBMODULE, VALID QUEUE, NOT ACTIVE QUEUE\n");
    printf("30. DL REQ SUCC                - VALID SUBMODULE, VALID QUEUE, QUEUE ACTIVE \n");
    printf("31. DL REQ FAIL                - INVALID SUBMODULE, INVALID QUEUE, INVALID PRIORITY\n");
    printf("32. DL REQ SUCC                - INVALID SUBMODULE, INVALID QUEUE, VALID PRIORITY\n");
    printf("33. DL REQ FAIL                - VALID SUBMODULE, INVALID QUEUE, INVALID PRIORITY\n");
    printf("34. DL REQ SUCC                - VALID SUBMODULE, INVALID QUEUE, VALID PRIORITY\n");
    printf("35. EPS STRESS TEST SIMULATION\n");
    printf("36. ADCS STRESS TEST SIMULATION\n");
    printf("37. COMMS SBAND STRESS TEST SIMULATION\n");
    printf("38. COMMS UHF STRESS TEST SIMULATION\n");
    printf("39. SENSORS STRESS TEST SIMULATION\n");
    printf("40. OBC STRESS TEST SIMULATION\n");
    printf("41. ERROR HANDLER STRESS TEST SIMULATION\n");
    printf("42. DISPLAY SIZE OF HEALTH DATA OF ALL MODULES\n");
    printf("43. MAXIMUM TM DOWNLOAD - 62K\n");
    printf("44. TCTM SEGMENTED PACKET TEST\n");

    tc_len = 10;
    tc_data = (uint8_t *) malloc(tc_len);
    if(tc_data)
    {
        scanf("%hhu",&tc_data[0]);
        status = 0;
        printf("Entered test case id is %d\n",*tc_data);
        hm_fw_cb.test_case_id=(uint16_t)tc_data[0];
        if(tc_data[0] == 1)
        {
            printf("Enter the instance size\n");
            scanf("%u",&inst_size);
            memcpy(&tc_data[1], &inst_size, sizeof(inst_size));
            printf("Enter the Number of instance\n");
            scanf("%hu",&no_inst);
            memcpy(&tc_data[5], &no_inst, sizeof(no_inst));
            printf("Enter the Queue ID\n");
            scanf("%hhu",&queue_id);
            tc_data[7] =  queue_id;
        }
        else if(tc_data[0] == 2)
        {

            printf("Enter the instance size\n");
            scanf("%u",&inst_size);
            memcpy(&tc_data[1], &inst_size, sizeof(inst_size));
            printf("Enter the Number of instance\n");
            scanf("%hu",&no_inst);
            memcpy(&tc_data[5], &no_inst, sizeof(no_inst));
            printf("Enter the no of queue to be requested \n");
            scanf("%hu",&no_queue);
            memcpy(&tc_data[7], &no_queue, sizeof(no_queue));
        }

        else if(tc_data[0] == 3)
        {

            printf("Enter the instance size\n");
            scanf("%u",&inst_size);
            memcpy(&tc_data[1], &inst_size, sizeof(inst_size));
            printf("Enter the Number of instance\n");
            scanf("%hu",&no_inst);
            memcpy(&tc_data[5], &no_inst, sizeof(no_inst));
            printf("Enter the Queue ID\n");
            scanf("%hhu",&queue_id);
            tc_data[7] = queue_id;
        }

        else if(tc_data[0] == 4)
        {
            printf("Enter the instance size\n");
            scanf("%u",&inst_size);
            memcpy(&tc_data[1], &inst_size, sizeof(inst_size));
            printf("Enter the Number of instance\n");
            scanf("%hu",&no_inst);
            memcpy(&tc_data[5], &no_inst, sizeof(no_inst));
            printf("Enter the no of queue to be requested \n");
            scanf("%hu",&no_queue);
            memcpy(&tc_data[7], &no_queue, sizeof(no_queue));
        }
        else 
        {
              //do nothing

        }
    }
    else
    {
        printf("Memory allocation failed in TC_BUFF_REQ\n");
    }
}
break;
case TC_GET_HEALTH_METRICS:
{
    unsigned char sub_mod;
    unsigned char queue_id;
    unsigned char priority;
    unsigned char type;

    printf("\nEnter the following \n");
    printf("1. To get one submodule, one queue:\n");
    printf("2. To get priority based in one submodule\n");
    printf("3. To get priority based in all submodules\n");
    scanf("%hhu",&type);
    switch(type)
    {
        /** To get one submodules, one or multiple queues */
        case 1:
            {
                printf("\nEnter submodule id\n");
                printf("0. EPS_TASK\n");
                printf("1. ADCS Controller\n");
                printf("2. COMMS_SBAND\n");
                printf("3. COMMS_UHF\n");
                printf("4. SENSOR\n");
                printf("5. OBC\n");
                printf("6. ERROR_HANDLER\n");
#ifdef TEST_LAYER
                printf("7. TEST TASK \n");
#endif 
                scanf("%hhu",&sub_mod);
                sub_mod = get_sub_mod_task_id(sub_mod);
                if(-1 != sub_mod)
                {
                    printf("Enter queue id\n");
                    scanf("%hhu",&queue_id);
                    tc_len = 5;
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(tc_data)
                    {
                        tc_data[0] = sub_mod;
                        tc_data[1] = queue_id;
                        tc_data[2] = 0xFF;//priority is invalid in this case
                        tc_data[3] = type;
                        printf("Entered submodule id %d and queue id is %d\n", tc_data[0], tc_data[1]);
                    }
                    else
                    {
                        printf("Memory allocation failed in TC_BUFF_REQ\n");
                    }
                }
                else
                {
                }
            }
            break;
            /** To get one submodules, priority based */
        case 2:
            {
                printf("\nEnter submodule id\n");
                printf("0. EPS_TASK\n");
                printf("1. ADCS Controller\n");
                printf("2. COMMS_SBAND\n");
                printf("3. COMMS_UHF\n");
                printf("4. SENSOR\n");
                printf("5. OBC\n");
                printf("6. ERROR_HANDLER\n");
#ifdef TEST_LAYER
                printf("7. TEST TASK \n");
#endif
                scanf("%hhu",&sub_mod);
                sub_mod = get_sub_mod_task_id(sub_mod);
                if(-1 != sub_mod)
                {
                    printf("Enter the priority\n");
                    scanf("%hhu",&priority);
                    tc_len = 4;
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(tc_data)
                    {
                        tc_data[0] = sub_mod;
                        tc_data[1] = 0xFF;//Queue id is invalid in this case
                        tc_data[2] = priority;
                        tc_data[3] = type;
                        printf("Entered submodule id %d and priority is %d\n", tc_data[0], tc_data[2]);
                    }
                    else
                    {
                        printf("Memory allocation failed in TC_BUFF_REQ\n");
                    }
                }
                else
                {
                    printf("Invalid submodule\n");
                }
            }
            break;
            /** To get All submodules, priority based */
        case 3:
            {
                printf("Enter the priority\n");
                scanf("%hhu",&priority);
                tc_len = 4;
                tc_data = (uint8_t *) malloc(tc_len);
                if(tc_data)
                {
                    tc_data[0] = 0xFF;
                    tc_data[1] = 0xFF;//Queue id is invalid in this case
                    tc_data[2] = priority;
                    tc_data[3] = type;
                    printf("Entered submodule id %d and priority is %d\n", tc_data[0], tc_data[2]);
                }
                else
                {
                    printf("Memory allocation failed in TC_BUFF_REQ\n");
                }
            }
            break;
        default:
            {
            }
            break;
    }
}
break;

case TC_CHNGE_QUEUE_PRIORITY:
{
    unsigned char sub_mod;
    unsigned char queue_id;
    unsigned char priority;
    unsigned char cur_priority;
    unsigned char type;

    printf("\nEnter the following \n");
    printf("1. To change one submodule, one queue's priority:\n");
    printf("2. To change multiple queues priority in a single submodule\n");
    printf("3. To change multiple queues priority in a all submodule\n");
    scanf("%hhu",&type);
    switch(type)
    {
        /** To change one submodule, one queue's priority  */
        case 1:
            {
                printf("\nEnter submodule id\n");
                printf("0. EPS_TASK\n");
                printf("1. ADCS Controller\n");
                printf("2. COMMS_SBAND\n");
                printf("3. COMMS_UHF\n");
                printf("4. SENSOR\n");
                printf("5. OBC\n");
                printf("6. ERROR_HANDLER\n");
#ifdef TEST_LAYER
                printf("7. TEST TASK \n");
#endif
                scanf("%hhu",&sub_mod);
                sub_mod = get_sub_mod_task_id(sub_mod);
                if(-1 != sub_mod)
                {
                    printf("Enter queue id\n");
                    scanf("%hhu",&queue_id);
                    printf("Enter The priority to change\n");
                    scanf("%hhu",&priority);
                    tc_len = 5;
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(tc_data)
                    {
                        tc_data[0] = sub_mod;
                        tc_data[1] = queue_id;
                        tc_data[2] = priority;
                        tc_data[3] = 0; //current priority, this is invalid in this case
                        tc_data[4] = type;
                        printf("Entered submodule id %d queue id is %d and priority is %d\n", tc_data[0], tc_data[1], tc_data[2]);
                    }
                    else
                    {
                        printf("Memory allocation failed\n");
                    }
                }
                else
                {
                    printf("Invalid submodule id\n");
                }
            }
            break;
            /** To change one submodules multiple queues, priority based */
        case 2:
            {
                printf("\nEnter submodule id\n");
                printf("0. EPS_TASK\n");
                printf("1. ADCS Controller\n");
                printf("2. COMMS_SBAND\n");
                printf("3. COMMS_UHF\n");
                printf("4. SENSOR\n");
                printf("5. OBC\n");
                printf("6. ERROR_HANDLER\n");
#ifdef TEST_LAYER
                printf("7. TEST TASK \n");
#endif
                scanf("%hhu",&sub_mod);
                sub_mod = get_sub_mod_task_id(sub_mod);
                if(-1 != sub_mod)
                {
                    printf("Enter The current priority of Queue's to be changed\n");
                    scanf("%hhu",&cur_priority);

                    printf("Enter The priority to change\n");
                    scanf("%hhu",&priority);
                    tc_len = 5;
                    tc_data = (uint8_t *) malloc(tc_len);
                    if(tc_data)
                    {
                        tc_data[0] = sub_mod;
                        tc_data[1] = 0xFF;
                        tc_data[2] = priority; //priority to be changed
                        tc_data[3] = cur_priority; //current priority of queue
                        tc_data[4] = type;
                        printf("Sumodule %d's queue's with priority %d will be changed to priority %d\n", tc_data[0], tc_data[3], tc_data[2]);
                    }
                    else
                    {
                        printf("Memory allocation failed\n");
                    }
                }
                else
                {
                    printf("Invalid submodule id\n");
                }
            }
            break;
            /** To change All submodules queue's, priority based */
        case 3:
            {
                printf("Enter The current priority of Queue's to be changed\n");
                scanf("%hhu",&cur_priority);

                printf("Enter The priority to change\n");
                scanf("%hhu",&priority);
                tc_len = 5;
                tc_data = (uint8_t *) malloc(tc_len);
                if(tc_data)
                {
                    tc_data[0] = 0xFF;
                    tc_data[1] = 0xFF;
                    tc_data[2] = priority; //priority to be changed
                    tc_data[3] = cur_priority; //current priority of queue
                    tc_data[4] = type;
                    printf("Sumodule %d's queue's with priority %d will be changed to priority %d\n", tc_data[0], tc_data[3], tc_data[2]);
                }
                else
                {
                    printf("Memory allocation failed\n");
                }
            }
            break;
        default:
            {
            }
            break;
    }
}
break;

case TC_CHNGE_MODULE_PRIORITY:
{
    unsigned char sub_mod;
    unsigned char priority;
    unsigned char cur_priority;

    printf("\nEnter submodule id\n");
    printf("0. EPS_TASK\n");
    printf("1. ADCS Controller\n");
    printf("2. COMMS_SBAND\n");
    printf("3. COMMS_UHF\n");
    printf("4. SENSOR\n");
    printf("5. OBC\n");
    printf("6. ERROR_HANDLER\n");
#ifdef TEST_LAYER
    printf("7. TEST TASK \n");
#endif
    scanf("%hhu",&sub_mod);
    sub_mod = get_sub_mod_task_id(sub_mod);
    if(-1 != sub_mod)
    {
        printf("Enter The current priority of module\n");
        scanf("%hhu",&cur_priority);

        printf("Enter The priority to change\n");
        scanf("%hhu",&priority);
        tc_len = 3;
        tc_data = (uint8_t *) malloc(tc_len);
        if(tc_data)
        {
            tc_data[0] = sub_mod;
            tc_data[1] = priority; //priority to be changed
            tc_data[2] = cur_priority; //current priority of queue
            printf("Submodule %d Current priority %d will be changed to priority %d\n", tc_data[0], tc_data[2], tc_data[1]);
        }
        else
        {
            printf("Memory allocation failed\n");
        }
    }
    else
    {
        printf("Invalid submodule id\n");
    }

}
break;
case TC_PRINT_MEM_LEAK:
{
    tc_len = 0;
    tc_data = (uint8_t *) malloc(tc_len);
    status = 0;
}
break;

case TC_GET_TCTM_DBG_INFO:
{
    tc_len = 0;
    tc_data = NULL;
    status = 0;
}
break;

default :
{
    status = -1;
    printf("Invalid TC ID Received - %d. Please try again. \n",tc_id);
}
}
}
if(0 == status)
{

    /* Configure Telecommand ID */
    tc_orig_cfg_tc_id(tc_orig_app, tc_id);
    /* Configure Telecommand Length */
    tc_orig_cfg_tc_len(tc_orig_app, tc_len);
    /* Configure Telecommand payload */
    tc_orig_cfg_tc_data (tc_orig_app, tc_data);

    /* Configure Encryption parameters */
    tc_orig_app->cmac_hmac = (uint8_t *) malloc(SHA256_HASH_SIZE);
    memcpy(param.iv, iv, 16);
    param.key_size = 256;
    param.key = (unsigned char *)malloc(param.key_size);
    memcpy(param.key, key, param.key_size);
    param.encrypt_mode = CRYPT_AES_CFB8;
    tc_orig_select_encryption(&param);


    printf("MFCC APP: TC payload : ");
    for(loop = 0; loop < tc_len; loop++)
        printf("%x ", tc_data[loop]);
    printf("\n");
    /* Generate Telecommand as binary data stream */
    size = tc_pack(dst, tc_orig_app);
    printf("TC Sent Time:- %u\n",tc_orig_app->time_stamp);

    conv_epoch_to_localtime(&tc_time, tc_orig_app->time_stamp);

    printf("TC Sent Local Date:- %hhu/%hhu/%hu, Time:- %hhu:%hhu:%hhu\n",\
            tc_time.day,tc_time.month,tc_time.year,tc_time.hour,tc_time.min,tc_time.sec);


#ifdef ENBL_DBG_PRNT
    printf("MFCC APP: TC payload encrypted : ");
    for(loop = 0; loop < tc_len; loop++)
        printf("%x ", tc_data[loop]);
    printf("\n");
#endif

    printf("MFCC APP: Transmitted TC byte stream: ");
    for(loop = 0; loop < size; loop++)
        printf("%x ", dst[loop]);
    printf("\n");

    /* Send generated Telecommand via socket interface */
    if(sch_tc_store_en == 0)
    {
        mfcc_tcp_send(addr, port, dst, size);
    }
    else if(sch_tc_store_en == 1)
    {
        /*
         * Refer Conops_Scheduler UserManual for file format releated information
         */
        uint8_t itr = 0;
        //        printf("SCH TC DATA Writted: %d,%d,%d,%d", wr_offset,tc_len,tc_orig_app->da_id,tc_orig_app->tc_id);
        fprintf(file_w,"0x01,"); 
        fprintf(file_w,"0x00000032,"); 
        fprintf(file_w,"0x%08x,0x%04x,0x%02x,0x%04x", wr_offset,tc_len,tc_orig_app->da_id,tc_orig_app->tc_id);
        // Add Radio Id to payload data
        fprintf(file_w,",0x%02x", tc_orig_app->rm_id);
        for(itr = 0;itr<tc_len;itr++)
        {
            fprintf(file_w,",0x%02x", tc_orig_app->tc_data[itr]);
        }
        fprintf(file_w,"\n");
        // 1 byte added for radio id
        wr_offset = wr_offset + tc_len + 1;
        printf("\nSCH TC Write to File Success\n");
    }
    if(param.key != NULL)
    {
        free(param.key);
    }
    if(tc_data != NULL)
    {
        free(tc_data);
    }
    if(tc_orig_app->cmac_hmac)
    {
        free(tc_orig_app->cmac_hmac);
    }
}

if(tc_orig_app != NULL)
{
    free(tc_orig_app);
}
if(dst != NULL)
{
    free(dst);
}

}


uint8_t ft_payload_transmitter(uint16 tc_tm_id, uint16_t src_dst_id, uint8_t *payload_ptr, uint16_t payload_len)
{
    uint8_t ret_busy_sts = 0;
    uint16_t u16cnt;
    if(payload_ptr != NULL)
    {
        if(ft_pld_tx.send_request != 1)
        {
            ft_pld_tx.payload_ptr = malloc(payload_len);
            if(ft_pld_tx.payload_ptr != NULL)
            {
                for(u16cnt = 0; u16cnt< payload_len; u16cnt++)
                {
                    ft_pld_tx.payload_ptr[u16cnt] = payload_ptr[u16cnt];
                }
                ft_pld_tx.tc_tm_id = tc_tm_id;
                ft_pld_tx.payload_len = payload_len;
                ft_pld_tx.send_request = 1;
                ret_busy_sts = 1;
            }


            ft_destination_set(src_dst_id);
        }
    }
    return ret_busy_sts;
}



void ft_destination_set(uint16_t set)
{
    ft_pld_tx.dest_node = set;
    //    printf("FTM Node set %x\n",ft_pld_tx.dest_node);
}




void *mfcc_ft_tc_sender_thread(void *params)
{
    sleep(3);

    while(1)
    {
        usleep(1000);
        if(ft_pld_tx.send_request ==1)
        {
            //            printf("FT-TC ID:%d to NODE:0x%x\n",ft_pld_tx.tc_tm_id,ft_pld_tx.dest_node);

            mfcc_tc_send(ft_pld_tx.tc_tm_id, ft_pld_tx.dest_node);
            ft_pld_tx.tc_tm_id = 0;
            ft_pld_tx.payload_len = 0;
            ft_pld_tx.send_request = 0;
        }
    }

}

uint8_t obc_mem_debug_tc_enc()
{
    return mem_debug_data ; 

}


/**
 * @brief call back function for expiry timer
 */
void rx_dec_resudial_clean_tmr_exp(void)
{
    if(residue_pac)
    {
        free((void*)residue_pac);
        residue_pac = NULL;
    }
}

/**
 * @brief Function that parses Telemetry payload
 * and invokes corresponding Telemetry decoder
 */
int mfcc_tm_parser(uint8 *tm_stream_data,uint32_t recv_byte_size)
{
    s_tm_frame tm_frame;
    s_crypt_params param;
    s_tm_ctrl ctrl_param;
    uint16 tm_len = 0;
    uint16 seq_no = 0;
    uint16 tm_src_id, tm_dst_id;
    uint16 tm_id = 0;
    uint8 sts;
    uint32_t obc_mem_data = 0;
    int32 tm_unpack_sts;
    s_uhf_rf_cfg get_rf_tx_cfg;
    s_uhf_rf_rx_cfg get_rf_rx_cfg;
    s_uhf_rf_tx_pkt_cfg get_rf_tx_pkt_cfg;
    s_uhf_rf_rx_pkt_cfg get_rf_rx_pkt_cfg;
    s_uhf_set_pwr_stng get_pwr_stng;
    s_sdr_beacon_pld sdr_beacon_pld;
    s_sdr_cfg set_sdr_cfg;
    //s_sdr_set_sts sdr_set_sts;
    s_sdr_tmr_cfg sdr_tmr_cfg;
    s_sdr_rx_rssi_cfg sdr_rx_rssi_cfg;
    s_sdr_tm_cfg sdr_tm_cfg;
    s_tctm_rm_overrule tctm_overrule = {0};
    s_gpass_beacon_cfg gpass_beacon_cfg={0};
    s_sdr_sens_cfg sdr_sns_cfg;
    //s_uhf_get_basic_tm get_tm;
    s_uhf_get_full_tm get_full_tm;
    //s_uhf_cc1110_reg_map get_reg_map;
    s_comms_tx_cfg get_tx_cfg;
    s_comms_rx_cfg get_rx_cfg;
    s_comms_sys_cfg get_sys_cfg;
    s_comms_uart_cfg get_uart_cfg;
    s_comms_csp_cfg get_csp_cfg;
    s_comms_can_cfg get_can_cfg;
    s_comms_gwdt_cfg get_gwdt_cfg;
    s_comms_boot_cfg get_boot_cfg;
    s_comms_net_cfg get_net_cfg;
    s_comms_tx_crypto_cfg get_tx_crypto_cfg;
    s_comms_rx_crypto_cfg get_rx_crypto_cfg;
    s_comms_rx_afc_cfg get_rx_afc_cfg;
    s_comms_tm_prop get_tm_prop;
    //	s_comms_tm_prop_xlink get_tm_prop_xlink;
    //s_comms_tm_prop get_tm_prop_xlink_s;
    s_comms_rx_tm_xlink get_rx_tm_xlink;
    s_comms_tx_tm get_tx_tm;
    s_comms_rx_tm get_rx_tm;
    s_comms_uhf_get_tm_prop uhf_get_tm_stor;
    s_comms_csp_tm get_csp_tm;
    SERVICE_VERSION_STRUCT xver;
    SERVICE_IP_ADR_STRUCT xip_adr;
    SERVICE_DEVICE_CONF_STRUCT xdev;
    SERVICE_FEATURE_SELECT_STRUCT fur;
    RCV_CTR rcv_counter;
    s_sband_periodic_get_tm xlink_tm_stor;
    SERVICE_VERSION_STRUCT_SET xver1;
    //s_sband_periodic_tm s_t_stor;
    sys_time_date_s cur_time_rsp_sts;
    nvm_param *nvm_data_hdr_rec;
    uint8* nvm_data_pld_rec;
    //int loop = 0;
    uint8* tm_data = 0;
    uint32 rem_size = 0;
    uint32 offset = 0;
   // int8_t eps_sts_var;
    evnt_time tm_time;
    uint8 cnt = 0;
    s_test_spi_uart_conv spi_uart_conv;

    /* Define decryption key */
    uint8 key[] = {0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};

    /* Define IV parameter for AES decryption */
    uint8 iv[16] = {0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};

    /* Allocation of memory for TM data */
    tm_frame.cmac_hmac = (uint8 *) malloc(SHA256_HASH_SIZE);
    tm_frame.tm_data = (uint8 *) malloc(MAX_TM_BUFF_SIZE);

    rem_size = recv_byte_size;

    // print Received Data
   // printf("\nSize is %d and TM Received Data:- ", recv_byte_size);
   //for(int i = 0; i < recv_byte_size; i++) //recv_byte_size; i++)
   // {
   //     printf("%x ",tm_stream_data[i]);
   // }
   // printf("\n");

    //Check if the previous transmission had any residual packets
    if(residue_pac)
    {
        stop_timer(rx_timer_id);
        rem_size +=residue_size;
        tm_data = malloc(rem_size);
        memcpy(tm_data, (void*)residue_pac,residue_size);
        free((void*)residue_pac);
        residue_pac = NULL;
        memcpy(&tm_data[residue_size],tm_stream_data,recv_byte_size);
        residue_size = 0;
    }
    else
    {
        tm_data = tm_stream_data;
    }

    do
    {
        memset(tm_frame.tm_data, 0, MAX_TM_BUFF_SIZE);
        /* Unpack TM from binary stream of bytes */
        tm_unpack_sts = tm_unpack(&tm_data[offset], rem_size, &tm_frame);

        /* Decode TM header and payload information */
        if((0 <= tm_unpack_sts) && (NULL != tm_frame.tm_data))
        {
            /* Extract TM sequence number */
            tm_term_extract_seq_no(&tm_frame, &seq_no);
            /* Validate sequence number */
            mfcc_validate_seq_num(seq_no);
            /* Extract TM Source ID */
            tm_term_extract_sa_id(&tm_frame, &tm_src_id);
            /* Extract TM Destination ID */
            tm_term_extract_da_id(&tm_frame, &tm_dst_id);
            uint8_t radio_id;
            tm_term_extract_rm_id(&tm_frame, &radio_id);
            printf("\nRadio Id %d\r\n",radio_id);
            printf("TM Received Time:- %u\n",tm_frame.time_stamp);
            printf("Received TM Id:- %u\n",tm_frame.tm_id);

            conv_epoch_to_localtime(&tm_time, tm_frame.time_stamp);

            printf("TM Recv Local Date:- %hhu/%hhu/%hu, Time:- %hhu:%hhu:%hhu\n",\
                    tm_time.day,tm_time.month,tm_time.year,tm_time.hour,tm_time.min,tm_time.sec);

            if(TM_SRC_OBC == tm_dst_id)
                printf("MFCC APP: Received TM Data from OBC\n");
            else if(TM_SRC_PS == tm_dst_id)
                printf("MFCC APP: Received TM Data from PS\n");
            else
            {}
            /* Extract Telemetry ID */
            tm_term_extract_tm_id(&tm_frame, &tm_id);
            /* Extract Encryption configuration */
            tm_term_extract_tm_ctrl(&tm_frame, &ctrl_param);
            /* When encryption is enabled in received TM */
            if(ctrl_param.encrypt)
            {
                printf("Encryption Enable\n");
                tm_term_extract_tm_len(&tm_frame, &tm_len);

                /* Configure decryption parameters */
                memcpy(param.iv, iv, 16);
                param.key_size = 256;
                param.key = (unsigned char *)malloc(param.key_size);
                memcpy(param.key, key, param.key_size);
                param.encrypt_mode = CRYPT_AES_CFB8;
                /* Extract TM payload length */
                tm_term_extract_tm_len(&tm_frame, &tm_len);

                /* Decrypt Telemetry data */
                tm_orig_decrypt_data(&param,
                        (const unsigned char *)tm_frame.tm_data,tm_len,
                        (unsigned char *)tm_frame.tm_data);

                // printf("MFCC APP: Decrypted TM data is ");
                // for(loop = 0; loop < tm_len; loop++)
                //     printf("%x ", tm_frame.tm_data[loop]);
                // printf("\n");
            }
            else
            {
                printf("Encryption Disable\n");
                /* Extract TM payload length */
                tm_term_extract_tm_len(&tm_frame, &tm_len);
#ifdef ENBL_DBG_PRNT
                printf("MFCC APP: Received Data is unencrypted \n");
                printf("MFCC APP: Received Data length is %d\n",tm_len);
                printf("MFCC APP: Data is ");
                for(loop = 0; loop < tm_len; loop++)
                    printf("%x ", tm_frame.tm_data[loop]);
                printf("\n");
#endif
            }
            /*
             * Data has more than one TC frame. Parse the next TC
             * by changing the offset. handle_status will have the
             * size of previous TC frame
             */
            offset = offset + tm_unpack_sts;
            rem_size = rem_size - tm_unpack_sts;

#ifdef IQS_S_SIM
            rem_size = 0;
#endif
        }
        else
        {
            if(TC_TM_FULL_PLD_NOT_PRSNT == tm_unpack_sts || TC_TM_MIN_LEN_ERROR == tm_unpack_sts)
            {
                /*
                 * Probably a segmented packet. Copy the remaining
                 * bytes and keep for next iteration or this can be a
                 * disintegrated packet too. Need to handle this logic
                 */
                residue_size = rem_size;
                residue_pac = malloc(residue_size);
                memcpy((void*)residue_pac, &tm_data[offset], residue_size);
                rx_timer_id = start_timer(MAX_RX_DEC_WAIT_TIME_MS,(time_handler)&rx_dec_resudial_clean_tmr_exp,TIMER_SINGLE_SHOT,NULL);
                break;
            }
            else
            {
                printf("MFCC APP: TM unpack failure or Data is NULL : %d \n", tm_unpack_sts);
                break;
            }

        }
        /*TM is from ADCS */
        if(130 == tm_src_id)
        {
            /* Handle the ADCS TM separately */
            tm_adcs_dec(tm_frame.tm_data, tm_frame.tm_len, tm_id);
        }
        else
        {
            /* Decode TM payload information */
            switch(tm_id)
            {
                
            case TM_THRUSTER_SET_MODE:
            case TM_THRUSTER_GET_MODE:
            case TM_THRUSTER_SET_FIRING_DURATION:
            case TM_THRUSTER_GET_FIRING_DURATION:
            case TM_THRUSTER_GET_INPUT_POWER_CONSMP: 
            case TM_THRUSTER_SET_RADIATOR_TEMP_LIMIT:
            case TM_THRUSTER_GET_RADIATOR_TEMP_LIMIT:
            case TM_THRUSTER_SET_TANK_PRESSURE_LIMIT:
            case TM_THRUSTER_GET_TANK_PRESSURE_LIMIT:
            case TM_THRUSTER_GET_REMAINING_PROPELLANT: 
            //case TM_THRUSTER_GET_ACTIVE_STATUS:
            case TM_THRUSTER_GET_ONBOARD_TEMPERATURE:
                     mfcc_thruster_tm_hdlr(tm_id,tm_frame.tm_data,tm_frame.tm_len);
                break; 

                case TM_GPS_GET_NMEA_GPGGA:
                    if(tm_frame.tm_len ==1)
                    {
                        printf("GPS LOCATION DATA 1 READ FAILED\n");
                    }
                    else
                    {
                        memcpy(&gps_loc_data1,tm_frame.tm_data,tm_frame.tm_len);
                        printf("GPS TIME = %d:%d:%d:%d\n",gps_loc_data1.time.hours,\
                                gps_loc_data1.time.minutes,gps_loc_data1.time.seconds,gps_loc_data1.time.microseconds);
                        printf("LATITUDE = %f\n",gps_loc_data1.latitude);
                        printf("LONGITUDE =%f\n",         gps_loc_data1.longitude);
                        printf("FIX_QUALITY =%d\n",       gps_loc_data1.fix_quality);
                        printf("SATELLITES_TRACKED =%d\n", gps_loc_data1.satellites_tracked);
                        printf(" HDOP =%f\n",              gps_loc_data1. hdop);
                        printf("ALTITUDE  =%f\n",          gps_loc_data1.altitude);
                        printf("ALTITUDE_UNITS =%c\n",     gps_loc_data1.altitude_units);
                        printf("HEIGHT = %f\n",            gps_loc_data1.height);
                        printf("HEIGHT_UNITS =%c\n",       gps_loc_data1.height_units);
                        printf("DGPS_AGE = %f\n",          gps_loc_data1.dgps_age);
                    }
                    break;

                case TM_GPS_GET_NMEA_GPRMC:
                    if(tm_frame.tm_len ==1)
                    {
                        printf("GPS LOCATION DATA 2 READ FAILED\n");
                    }
                    else
                    {
                        memcpy(&gps_loc_data2,tm_frame.tm_data,tm_frame.tm_len);
                        printf("GPS TIME = %d:%d:%d:%d\n",gps_loc_data2.time.hours,\
                                gps_loc_data2.time.minutes,gps_loc_data2.time.seconds,gps_loc_data2.time.microseconds);

                        printf("VALID =%d\n",      gps_loc_data2.valid);
                        printf("LATITUDE=%f\n",   gps_loc_data2.latitude);
                        printf("LONGITUDE =%f\n",  gps_loc_data2.longitude);
                        printf("SPEED=%f\n",  gps_loc_data2. speed);;
                        printf("COURSE%f\n", gps_loc_data2.course);    
                        printf("GPS_DATE DATE =%d:%d:%d\n",    gps_loc_data2.date.day ,gps_loc_data2.date.month ,gps_loc_data2.date.year);
                        printf("VARIATION =%f\n", gps_loc_data2.variation);
                    }
                    break;

                case TM_GPS_GET_DATE_TIME:
                    if(tm_frame.tm_len ==1)
                    {
                        printf("GPS DATE/TIME DATA READ FAILED\n");
                    }
                    else
                    {
                        memcpy(&gps_date_time,tm_frame.tm_data,tm_frame.tm_len);
                        printf("GPS_DATE DATE =%d:%d:%d\n",gps_date_time.date.day ,gps_date_time.date.month ,gps_date_time.date.year);
                        printf("GPS TIME = %d:%d:%d:%d\n",gps_date_time.time.hours,\
                                gps_date_time.time.minutes,gps_date_time.time.seconds,gps_date_time.time.microseconds);
                        printf(" hour_offset =%d\n", gps_date_time.hour_offset);

                        printf("minute_offset =%d\n",gps_date_time.minute_offset);
                    }
                    break;

                case TM_GPS_GET_3D_POSITION_VELOCITY:
                    if(tm_frame.tm_len == 1)
                    {
                        printf("GPS POSITION VELOCITY READ FAILED\n");
                    }
                    else
                    {
                        memcpy(&gps_pos_vel,tm_frame.tm_data,tm_frame.tm_len);
                        printf("GPS POSITION TYPE = %d\n",gps_pos_vel.p_type);
                        printf("GPS POSITION STS = %d\n",gps_pos_vel.p_sts);
                        printf("GPS POSITION X = %lf\n",gps_pos_vel.p_x);
                        printf("GPS POSITION Y = %lf\n",gps_pos_vel.p_y);
                        printf("GPS POSITION Z = %lf\n",gps_pos_vel.p_z);
                        printf("GPS VELOCITY TYPE = %d\n",gps_pos_vel.v_type);
                        printf("GPS VELOCITY STS = %d\n",gps_pos_vel.v_sts);
                        printf("GPS VELOCITY X = %lf\n",gps_pos_vel.v_x);
                        printf("GPS VELOCITY Y = %lf\n",gps_pos_vel.v_y);
                        printf("GPS VELOCITY Z = %lf\n",gps_pos_vel.v_z);
                    }
                    break;

                case TM_GPS_GET_LOCATION_INFO:
                    if(tm_frame.tm_len == 1)
                    {
                        printf("GPS LOCATION READ FAILED\n");
                    }
                    else
                    {
                        memcpy(&gps_loc,tm_frame.tm_data,tm_frame.tm_len);
                        printf("GPS LATITUDE TYPE = %lf\n",gps_loc.latitude);
                        printf("GPS LONGITUDE Z = %lf\n",gps_loc.longitude);
                        printf("GPS altitude above/below mean sealevel in meters TYPE = %lf\n",gps_loc.altitude);
                        printf("GPS height between the geoid and the WGS84 ellipsoid in meters Z = %lf\n",gps_loc.height);
                        printf("GPS ground speed in knots = %lf\n",gps_loc.speed);
                        printf("GPS satellites = %d\n",gps_loc.satellites_tracked);
                        printf("GPS position status = %d\n",gps_loc.valid);
                        printf("GPS epoch time = %d\n",gps_loc.time);
                    }
                    break;

                case TM_GPS_COMPUTE_TLE:
                    if(tm_frame.tm_len == 1)
                    {
                        printf("GPS Compute TLE FAILED\n");
                    }
                    else
                    {
                        memcpy(&gps_tle,tm_frame.tm_data,tm_frame.tm_len);
                        printf("Computed TLE Semi major axis  : %lf km\n",gps_tle.smjaxs);
                        printf("Computed TLE Argumment of perigee  : %lf radians\n",gps_tle.argp);
                        printf("Computed TLE Angle of right ascending node  : %lf radians\n",gps_tle.ascn);
                        printf("Computed TLE Dragterm  : %lf\n",gps_tle.bstar);
                        printf("Computed TLE Eccentricity  : %lf\n",gps_tle.ecc);
                        printf("Computed TLE Inclination  : %lf radians\n",gps_tle.eqinc);
                        printf("Computed TLE Mean anomaly  : %lf radians\n",gps_tle.mnan);
                        printf("Computed TLE Mean Revolution  : %lf radians\n",gps_tle.rev);
                    }
                    break;


                    /*                case TM_TRGT_PT:
                                      {
                                      memcpy(&trgt_pt_rsp_sts,tm_frame.tm_data,4);
                    //Check target pointing configuration response status
                    if(!trgt_pt_rsp_sts)
                    printf("Target point configuration success\n");
                    else
                    printf("Target point configuration failure\n");

                    }
                    break;

                    case TM_LOC_INFO:
                    {
                    // Decode Location information 
                    tm_gnss_loc_info_dec(tm_frame.tm_data, &gli);
                    }
                    break;*/

                case TM_OBC_SOFT_RESET:
                    {
                        /* Decode Location information */
                        tm_obc_soft_reset_dec(tm_frame.tm_data, &tm_obc_sw_rst_sts);

                        if(tm_obc_sw_rst_sts == 1)
                            printf("OBC OTSU software reset success\n");
                        else
                            printf("OBC normal software reset success\n");
                    }
                    break;

                case TM_OTSU_GET_VERSION:
                case TM_OTSU_CURRENT_STATUS:
                case TM_OTSU_SEND_FW_UPDATE_BOOT_CFG:
                case TM_OTSU_INTEGERATION_TEST_CMD:
                case TM_OTSU_GET_FW_UPDATE_STS:
                case TM_OTSU_GET_BOOT_CFG_INFO:
                case TM_OTSU_READ_GSCONATCT_WAIT_TIME:
                case TM_OTSU_SET_GSCONATCT_WAIT_TIME:
                case TM_OTSU_READ_BOOTABLE_BLT1:
                case TM_OTSU_READ_BOOTABLE_BLT2:
                case TM_OTSU_GET_NVM_FW_VERSION:
                case TM_OTSU_NOTIFICATION:
                    {
                        otsu_tm_decode(tm_id,tm_frame.tm_data, tm_len);
                    }
                    break;

                case TM_PS_BRD_SELECT:
                    {
                        uint8_t ps_brd_sts = 0;
                        memcpy(&ps_brd_sts, tm_frame.tm_data, 1);
                        if(ps_brd_sts == 0)
                        {
                            printf("Payload board & SSD select success\n");
                        }
			else if(ps_brd_sts == 1)
			{
                            printf("Payload A & B power off success\n");
			}
                        else
                        {
                           printf("Payload board select Fail\n");
                        }
                    }
                   break; 
                
                case TM_ES_BRD_SELECT:
                    {
                        uint8_t es_brd_sts = 0;
                        memcpy(&es_brd_sts, tm_frame.tm_data, 1);
                        if(es_brd_sts == 0)
                        {
                            printf("Edge board select success\n");
                        }
			else if(es_brd_sts == 1)
			{
                            printf("Edge A & B power off success\n");
			}
                        else
                        {
                           printf("Edge board select Fail\n");
                        }
                    }
                   break; 

		case TM_ADC_SELECT:
		    {
			    memcpy(&adc_brd_read,tm_data,tm_len);
			    if(adc_brd_read.adc_id == 67)
			    {
				    printf("1 - ADC_AD7291_PS_1%d\n",adc_brd_read.adc_id);
			    }
			    else if(adc_brd_read.adc_id == 70)
			    {
				    printf("2 - ADC_AD7291_PS_2%d\n",adc_brd_read.adc_id);
			    }
			    else if(adc_brd_read.adc_id == 81)
			    {
				    printf("3 - ADC_AD7291_ORING_CIRCUIT%d\n",adc_brd_read.adc_id);
			    }
			    printf(" ADC channel ID = %d\n",adc_brd_read.adc_chnl_id);
			    printf(" ADC Voltage = %f\n",adc_brd_read.adc_vltge); 
		    }
		    break;
	
		case TM_IO_BRD_SELECT:
		    {
			    uint8_t io_brd_sts = 0;
			    memcpy(&io_brd_sts, tm_frame.tm_data, 1);
			    if(io_brd_sts == 0)
			    {
				    printf("io board select success\n");
			    }
			    else
			    {
				    printf("io board select Fail\n");
			    }
		    }
		    break;

		case TM_I2C_ADXL345_TEST:
		    {
			    uint8_t i2c_sts = 0;
			    memcpy(&i2c_sts, tm_frame.tm_data, 1);
			    if(i2c_sts == 0)
			    {
				    printf("I2C Test success\n");
			    }
			    else
			    {
				    printf("I2c TEST Fail\n");
			    }
		    }
		    break;

                case TM_SPI_ADXL345_TEST:
                    {
                        uint8_t spi_sts = 1;
                        memcpy(&spi_sts, tm_frame.tm_data, 1);
                        if(spi_sts == 0)
                        {
                            printf("SPI Test success\n");
                            printf("Received Data from SPI: ");
                            for (size_t i = 1; i < tm_frame.tm_len; i++)
                            {
                                printf("0x%02X ", tm_frame.tm_data[i]);
                            }
                            printf("\n");
                        }
                        else
                        {
                            printf("SPI Test Fail\n");
                        }
                    }
                    break;

                case TM_UART_TX_RX_TEST: 
                    {
                        uint8_t uart_sts = 1; 
                        if (tm_frame.tm_len == sizeof(uint8_t)) 
                        { 
                            memcpy(&uart_sts, tm_frame.tm_data, 1);
                            if(uart_sts == 0) 
                            {
                                printf("UART Transfer Test Success\n");
                            } else 
                            {
                                printf("UART Transfer Test Fail\n");
                            }
                        } 
                        else if (tm_frame.tm_len > sizeof(uint8_t)) 
                        { 
                            memcpy(&uart_sts, tm_frame.tm_data, 1);
                            if (uart_sts == 0) 
                            { 
                                printf("\nUART Receive Test Success\n");
                                printf("Received Data from UART: %s",tm_frame.tm_data+1);
                                printf("\n");
                            }
                        }
                    }
                    break;

                case TM_CAN_TX_RX_TEST: 
                    {
                        uint8_t can_sts = 1;  // Default fail status
                        if (tm_frame.tm_len == sizeof(uint8_t)) {
                            // TX operation: Status only
                            memcpy(&can_sts, tm_frame.tm_data, 1);
                            if (can_sts == 0) {
                                printf("CAN Transfer Test Success\n");
                            } else {
                                printf("CAN Transfer Test Fail\n");
                            }
                        } 
                        else if (tm_frame.tm_len > sizeof(uint8_t)) {
                            // RX operation: Status + Data
                            memcpy(&can_sts, tm_frame.tm_data, 1);  // Extract status

                            if (can_sts == 0) { // Success case
                                printf("\nCAN Receive Test Success\n");

                                // Print received data
                                printf("Received Data from CAN: ");
                                for (size_t i = 1; i < tm_frame.tm_len; i++) {
                                    printf("0x%02X ", tm_frame.tm_data[i]);
                                }
                                printf("\n");
                            }
                        }
                    }
                    break;

                case TM_PS_SSD_BRD_SELECT:
                    {
                        uint8_t ps_ssd_brd_sts = 0;
                        memcpy(&ps_ssd_brd_sts, tm_frame.tm_data, 1);
			    if(ps_ssd_brd_sts == 0)
			    {
				    printf("payload board ssd select success\n");
			    }
			    else
			    {
				    printf("payload board ssd select Fail\n");
			    }
		    }
		    break;

		case TM_ES_SSD_BRD_SELECT:
		    {
			    uint8_t es_ssd_brd_sts = 0;
			    memcpy(&es_ssd_brd_sts, tm_frame.tm_data, 1);
			    if(es_ssd_brd_sts == 0)
			    {
				    printf("edge board ssd select success\n");
			    }
			    else
			    {
				    printf("edge board ssd select Fail\n");
			    }
		    }
		    break;
		
		case TM_AUTO_SENSOR_TEST:
		    {
			    uint64_t sns_id = 0;
			    memcpy(&sns_id, tm_frame.tm_data, 8);

			    if(!(sns_id & (0x01<<0)))
			    {
				    printf("TEMP_SENSOR_MCP9843_OBC init SUCCESS\n");
			    }
			    else
			    {
				    printf("TEMP_SENSOR_MCP9843_OBC init FAIL\n");
			    }

			    if(!(sns_id & (0x01<<1)))
			    {
				    printf("TEMP_SENSOR_MCP9843_EDGE_1 init SUCCESS\n");
			    }
			    else
			    {
				    printf("TEMP_SENSOR_MCP9843_EDGE_1 init FAIL\n");
			    }
			    if(!(sns_id & (0x01<<2)))
			    {
				    printf("TEMP_SENSOR_MCP9843_EDGE_2 init SUCCESS\n");
			    }
			    else
			    {
				    printf("TEMP_SENSOR_MCP9843_EDGE_2 init FAIL\n");
			    }
			    if(!(sns_id & (0x01<<3)))
			    {
				    printf("TEMP_SENSOR_MCP9843_PS_GEN_2 init SUCCESS\n");
			    }
			    else
			    {
				    printf("TEMP_SENSOR_MCP9843_PS_GEN_2 init FAIL\n");
			    }
			    if(!(sns_id & (0x01<<4)))
			    {
				    printf("TEMP_SENSOR_MCP9843_NIC_1 init SUCCESS\n");
			    }
			    else
			    {
				    printf("TEMP_SENSOR_MCP9843_NIC_1 init FAIL\n");
			    }
			    if(!(sns_id & (0x01<<5)))
			    {
				    printf("TEMP_SENSOR_MCP9843_SSD_1 init SUCCESS\n");
			    }
			    else
			    {
				    printf("TEMP_SENSOR_MCP9843_SSD_1 init FAIL\n");
			    }
			    if(!(sns_id & (0x01<<6)))
			    {
				    printf("TEMP_SENSOR_MCP9843_SSD_2 init SUCCESS\n");
			    }
			    else
			    {
				    printf("TEMP_SENSOR_MCP9843_SSD_2 init FAIL\n");
			    }
			    if(!(sns_id & (0x01<<7)))
			    {
				    printf("TEMP_SENSOR_MCP9843_SSD_3 init SUCCESS\n");
			    }
			    else
			    {
				    printf("TEMP_SENSOR_MCP9843_SSD_3 init FAIL\n");
			    }
			    if(!(sns_id & (0x01<<8)))
			    {
				    printf("TEMP_SENSOR_MCP9843_SSD_4 init SUCCESS\n");
			    }
			    else
			    {
				    printf("TEMP_SENSOR_MCP9843_SSD_4 init FAIL\n");
			    }
			    if(!(sns_id & (0x01<<9)))
			    {
				    printf("PSM_INA230_CORE_BRD_A init SUCCESS\n");
			    }
			    else
			    {
				    printf("PSM_INA230_CORE_BRD_A init FAIL\n");
			    }
			    if(!(sns_id & (0x01<<10)))
			    {
				    printf("PSM_INA230_CORE_BRD_B init SUCCESS\n");
			    }
			    else
			    {
				    printf("PSM_INA230_CORE_BRD_B init FAIL\n");
			    }
			    if(!(sns_id & (0x01<<11)))
			    {
				    printf("PSM_INA230_PS_GEN_2 init SUCCESS\n");
			    }
			    else
			    {
				    printf("PSM_INA230_PS_GEN_2 init FAIL\n");
			    }
			    if(!(sns_id & (0x01<<12)))
			    {
				    printf("PSM_INA230_PS_1 init SUCCESS\n");
			    }
			    else
			    {
				    printf("PSM_INA230_PS_1 init FAIL\n");
			    }
			    if(!(sns_id & (0x01<<13)))
			    {
				    printf("PSM_INA230_PS_2 init SUCCESS\n");
			    }
			    else
			    {
				    printf("PSM_INA230_PS_2 init FAIL\n");
			    }
			    if(!(sns_id & (0x01<<14)))
			    {
				    printf("PSM_INA230_EDGE_1 init SUCCESS\n");
			    }
			    else
			    {
				    printf("PSM_INA230_EDGE_1 init FAIL\n");
			    }
			    if(!(sns_id & (0x01<<15)))
			    {
				    printf("PSM_INA230_EDGE_2_IN_SUPPLY init SUCCESS\n");
			    }
			    else
			    {
				    printf("PSM_INA230_EDGE_2_IN_SUPPLY init FAIL\n");
			    }
			    if(!(sns_id & (0x01<<16)))
			    {
				    printf("PSM_INA230_IO_BRD_IN_SUPPLY init SUCCESS\n");
			    }
			    else
			    {
				    printf("PSM_INA230_IO_BRD_IN_SUPPLY init FAIL\n");
			    }
			    if(!(sns_id & (0x01<<17)))
			    {
				    printf("HSC_ADM1176_PAYLOAD_BRD_IN_SUPPLY init SUCCESS\n");
			    }
			    else
			    {
				    printf("HSC_ADM1176_PAYLOAD_BRD_IN_SUPPLY init FAIL\n");

			    }
			    if(!(sns_id & (0x01<<18)))
			    {
				    printf("HSC_ADM1176_PS_1_IN_SUPPLY init SUCCESS\n");
			    }
			    else
			    {
				    printf("HSC_ADM1176_PS_1_IN_SUPPLY init FAIL\n");
			    }
			    if(!(sns_id & (0x01<<19)))
			    {
				    printf("HSC_ADM1176_PS_2_IN_SUPPLY init SUCCESS\n");
			    }
			    else
			    {
				    printf("HSC_ADM1176_PS_2_IN_SUPPLY init FAIL\n");
			    }
			    if(!(sns_id & (0x01<<20)))
			    {
				    printf("HSC_ADM1176_EDGE_1_IN_SUPPLY init SUCCESS\n");
			    }
			    else
			    {
				    printf("HSC_ADM1176_EDGE_1_IN_SUPPLY init FAIL\n");
			    }
			    if(!(sns_id & (0x01<<21)))
			    {
				    printf("HSC_ADM1176_EDGE_1_HEAT_COIL init SUCCESS\n");
			    }
			    else
			    {
				    printf("HSC_ADM1176_EDGE_1_HEAT_COIL init FAIL\n");
			    }
			    if(!(sns_id & (0x01<<22)))
			    {
				    printf("HSC_ADM1176_EDGE_2_IN_SUPPLY init SUCCESS\n");
			    }
			    else
			    {
				    printf("HSC_ADM1176_EDGE_2_IN_SUPPLY init FAIL\n");
			    }
			    if(!(sns_id & (0x01<<23)))
			    {
				    printf("HSC_ADM1176_EDGE_2_HEAT_COIL init SUCCESS\n");
			    }
			    else
			    {
				    printf("HSC_ADM1176_EDGE_2_HEAT_COIL init FAIL\n");
			    }
			    if(!(sns_id & (0x01<<24)))
			    {
				    printf("HSC_ADM1176_IO_BRD_IN_SUPPLY init SUCCESS\n");
			    }
			    else
			    {
				    printf("HSC_ADM1176_IO_BRD_IN_SUPPLY init FAIL\n");
			    }
			    if(!(sns_id & (0x01<<25)))
			    {
				    printf(" HSC_ADM1176_IO_BRD_HEAT_COIL_TOP_1init SUCCESS\n");
			    }
			    else
			    {
				    printf("HSC_ADM1176_IO_BRD_HEAT_COIL_TOP_1 init FAIL\n");
			    }
			    if(!(sns_id & (0x01<<26)))
			    {
				    printf("HSC_ADM1176_IO_BRD_HEAT_COIL_TOP_2 init SUCCESS\n");
			    }
			    else
			    {
				    printf("HSC_ADM1176_IO_BRD_HEAT_COIL_TOP_2 init FAIL\n");
			    }
			    if(!(sns_id & (0x01<<27)))
			    {
				    printf("HSC_ADM1176_IO_BRD_HEAT_COIL_BOTTOM_1 init SUCCESS\n");
			    }
			    else
			    {
				    printf("HSC_ADM1176_IO_BRD_HEAT_COIL_BOTTOM_1 init FAIL\n");
			    }
			    if(!(sns_id & (0x01<<28)))
			    {
				    printf("HSC_ADM1176_IO_BRD_HEAT_COIL_BOTTOM_2 init SUCCESS\n");
			    }
			    else
			    {
				    printf(" HSC_ADM1176_IO_BRD_HEAT_COIL_BOTTOM_2 init FAIL\n");
			    }
			    if(!(sns_id & (0x01<<29)))
			    {
				    printf("ADC_AD7291_PS_1 init SUCCESS\n");
			    }
			    else
			    {
				    printf("ADC_AD7291_PS_1 init FAIL\n");
			    }
			    if(!(sns_id & (0x01<<30)))
			    {
				    printf("ADC_AD7291_ORING_CIRCUIT init SUCCESS\n");
			    }
			    else
			    {
				    printf("ADC_AD7291_ORING_CIRCUIT init FAIL\n");
			    }
			    if(!(sns_id & (0x01<<31)))
			    {
				    printf("ADC_AD7291_PS_2 init SUCCESS\n");
			    }
			    else
			    {
				    printf("ADC_AD7291_PS_2 init FAIL\n");
			    }
		    }
		    break;


#if 0
                case TM_PWR_CTRL_SBAND:
                case TM_PWR_CTRL_XBAND:
                case TM_PWR_CTRL_ADCS:
                case TM_PWR_CTRL_THRUSTER:
                case TM_PWR_CTRL_EDGE_BOARD:
                    {
                        memcpy(&pwr_ctrl_rsp_sts,tm_frame.tm_data,1);
                        if(!pwr_ctrl_rsp_sts)
                            printf("Power Control request success\n");
                        else
                            printf("Power Control request failure\n");
                    }
                    break;

                case TM_PS_PWR_ON:
                    {
                        memcpy(&ps_pwr_on_rsp_sts,tm_frame.tm_data,4);
                        /* Check PS power ON response status */
                        if(!ps_pwr_on_rsp_sts)
                            printf("PS Power ON request success\n");
                        else
                            printf("PS Power ON request failure\n");
                    }
                    break;


                case TM_PLD_HW_PWR_ON:
                    {
                        memcpy(&pld_hw_pwr_on_rsp_sts,tm_frame.tm_data,4);
                        /* Check PS power ON response status */
                        if(!pld_hw_pwr_on_rsp_sts)
                            printf("PLD HW Power ON request success\n");
                        else
                            printf("PLD HW Power ON request failure\n");
                    }
                    break;
#endif
                case TM_PLD_VM_PWR_ON:
                    {
                        memcpy(&pld_vm_pwr_on_rsp_sts,tm_frame.tm_data,4);
                        /* Check PS power ON response status */
                        if(!pld_vm_pwr_on_rsp_sts)
                            printf("PLD VM Power ON request success\n");
                        else
                            printf("PLD VM Power ON request failure\n");
                        tc_test_state = 0;
                    }
                    break;
#if 0
                case TM_PLD_HW_PWR_OFF:
                    {
                        memcpy(&pld_hw_pwr_off_rsp_sts,tm_frame.tm_data,4);
                        /* Check PS power ON response status */
                        if(!pld_hw_pwr_off_rsp_sts)
                            printf("PLD HW Power OFF request success\n");
                        else
                            printf("PLD HW Power OFF request failure\n");
                    }
                    break;
#endif
                case TM_PLD_VM_PWR_OFF:
                    {
                        memcpy(&pld_vm_pwr_off_rsp_sts,tm_frame.tm_data,4);
                        /* Check PS power ON response status */
                        if(!pld_vm_pwr_off_rsp_sts)
                            printf("PLD VM Power OFF request success\n");
                        else
                            printf("PLD VM Power OFF request failure\n");
                        tc_test_state = 0;
                    }
                    break;
#if 0
                case TM_PS_PWR_OFF:
                    {
                        memcpy(&ps_pwr_off_rsp_sts,tm_frame.tm_data,4);
                        /* Check PS power ON response status */
                        if(!ps_pwr_on_rsp_sts)
                            printf("PS Power OFF request success\n");
                        else
                            printf("PS Power OFF request failure\n");
                    }
                    break;

#endif      

                case TM_SET_CUR_TIME:
                    {
                        //memcpy(&cur_time_rsp_sts,tm_frame.tm_data,4);
                        memcpy(&sts,tm_frame.tm_data,1);
                        if(sts == 0)
                        {
                            printf("RTC STATUS - SUCCESS\n");
                        }
                        else if(sts == 2)
                        {
                            printf("INVALID INSTANCE\n");
                        }
                        else if(sts == 5)
                        {
                            printf("COMMUNICATION ERROR\n");
                        }
                        else
                        {
                            printf("INVALID STATUS\n");
                        }
                        memcpy(&cur_time_rsp_sts,&tm_frame.tm_data[1],tm_frame.tm_len-1);
                        printf("SOS Time: %d :%d :%d \n",cur_time_rsp_sts.hour,cur_time_rsp_sts.minute,cur_time_rsp_sts.seconds);
                        printf("SOS Date: %d :%d :%d \n",cur_time_rsp_sts.date,cur_time_rsp_sts.month,cur_time_rsp_sts.year);

                        /* if(!cur_time_rsp_sts)
                           printf("Current time configuration success\n");
                           else
                           printf("Current time configuration failure\n");*/
                    }
                    break;

                case TM_TTY_START:
                    {
                        memcpy(&tty_start_rsp_sts,tm_frame.tm_data,4);
                        /* Check PS power ON response status */
                        if(!tty_start_rsp_sts)
                            printf("TTY start request success\n");
                        else
                            printf("TTY start request failure\n");
                    }
                    break;

                case TM_TTY_END:
                    {
                        memcpy(&tty_end_rsp_sts,tm_frame.tm_data,4);
                        /* Check PS power ON response status */
                        if(!tty_end_rsp_sts)
                            printf("TTY end request success\n");
                        else
                            printf("TTY end request failure\n");
                    }
                    break;

                case TM_ERR_HANDLER_READ_FAULTS:
                    {
                        uint8_t inc, tot_err_cnt, msg_id,error_cnt;
                        uint8_t tot_grp_cnt;
                        uint32_t err_fault_set;
                        uint8_t offset = 2;
                        msg_id = tm_frame.tm_data[0] & 0x07;
                        if(msg_id == 0)
                        {  
                            tot_grp_cnt = tm_frame.tm_data[1];
                            printf("\nTotal Fault status Groups received %d\n",tot_grp_cnt);
                            printf("------------------------------\n");
                            for (inc = 0; inc < tot_grp_cnt; inc++)
                            {
                                tot_err_cnt = tm_frame.tm_data[offset];
                                if(inc == 0) printf("\nFault Status for IO as follows:");
                                else if(inc == 1) printf("\nFault Status for AHW set 1 as follows:");
                                else if(inc == 2) printf("\nFault Status for AHW set 2 as follows:");
                                else if(inc == 3) printf("\nFault Status for System as follows:");
                                else if(inc == 4) printf("\nFault Status for Services as follows:");
                                else if(inc == 5) printf("\nFault Status for Comms_Module as follows:");
                                else if(inc == 6) printf("\nFault Status for ADCS as follows:");
                                else if(inc == 7) printf("\nFault Status for Eps as follows:");
                                else
                                    printf("Invalid TC\n");

                                printf("\nTotal Error codes: %d\n",tot_err_cnt);
                                offset = offset + 1;
                                memcpy(&err_fault_set, &tm_frame.tm_data[offset], 4);
                                for(error_cnt = 0; error_cnt < tot_err_cnt; error_cnt++)
                                {
                                    if((err_fault_set >> error_cnt) &0x01)
                                    { 
                                        printf("Bit%02d - Fault\n", error_cnt);
                                    }
                                    else
                                    {
                                        printf("Bit%02d - No Fault\n", error_cnt);
                                    }         
                                }
                                printf("----------------------------------------------------\n");	    
                                offset = offset + 4;
                            }
                        } 
                    }
                    break;

                case TM_ERR_HANDER_READ_GROUP_ERROR_STATUS:
                    {                       
                        uint8_t msg_id = tm_frame.tm_data[0] & 0x07;
                        uint8_t grp_id, inc;
                        uint8_t tot_err_cnt;
                        uint8_t offset = 0;

                        if(msg_id == 1)
                        {
                            err_logs *err_cnt;
                            grp_id=tm_frame.tm_data[1];
                            tot_err_cnt = tm_frame.tm_data[2];
                            printf("\n");
                            if(grp_id == 0) printf("Error Status for Group-IO as follows:");
                            else  if(grp_id == 1) printf("Error Status for Group-AHW set 1 as follows:");
                            else  if(grp_id == 2) printf("Error Status for Group-AHW set 2 as follows:");
                            else  if(grp_id == 3) printf("Error Status for Group-System as follows:");
                            else  if(grp_id == 4) printf("Error Status for Group-Services as follows:");
                            else  if(grp_id == 5) printf("Error Status for Group-Comms_Module  as follows:");
                            else  if(grp_id == 6) printf("Error Status for Group-ADCS as follows:");
                            else  if(grp_id == 7) printf("Error Status for Group-Eps as follows:");
                            else 
                                printf("Invalid group id\n");
                            printf("\n------------------------------------------------\n");
                            printf("Total Error Codes =  %d\n ",tot_err_cnt);
                            offset = 3;
                            for(inc = 0; inc < tot_err_cnt; inc++)
                            {
                                err_cnt =(err_logs*) &tm_frame.tm_data[offset];
                                printf("\nStatus for Error code : %d\n", inc);
                                printf("  a.Error apperance count %d\n",err_cnt->err_apperance_cntr);
                                printf("  b.Recovery success count %d\n",err_cnt->recovery_success_cntr);
                                printf("  c.Recovery failure count %d\n",err_cnt->recovery_failure_cntr);    
                                offset = offset+sizeof(err_logs);
                            }

                        }

                        else
                        {
                            printf("Input TC Group id was invalid");                           
                        }                
                    }
                    break;

                case TM_ERR_HANDLER_RUN_BIST:
                    {
                        uint8_t grp_id;
                        uint8_t err_code_id;


                        if((tm_frame.tm_data[0] >> 4) == 0)
                        {
                            printf("Status of BIST for all errors\n");

                        }
                        else if((tm_frame.tm_data[0] >> 4) == 1)
                        {
                            grp_id = tm_frame.tm_data[0] & 0xf;
                            err_code_id = tm_frame.tm_data[1];
                            printf("Status of BIST for specific errors\n");
                            if(grp_id == 0) printf("Group-IO - %hhu ",err_code_id);
                            else  if(grp_id == 1) printf("Group-AHW set 1 - %hhu\n",err_code_id);
                            else  if(grp_id == 2) printf("Group-AHW set 2 - %hhu\n",err_code_id);
                            else  if(grp_id == 3) printf("Group-System - %hhu\n",err_code_id);
                            else  if(grp_id == 4) printf("Group-Services - %hhu\n",err_code_id);
                            else  if(grp_id == 5) printf("Group-Comms_Module - %hhu\n",err_code_id);
                            else  if(grp_id == 6) printf("Group-ADCS - %hhu\n",err_code_id);
                            else  if(grp_id == 7) printf("Group-EPS - %hhu\n",err_code_id);
                            else
                                printf("Invalid group id\n");



                            if(tm_frame.tm_data[2] == 0) printf("RECOVERY - PASS\n");
                            else if(tm_frame.tm_data[2] == 1) printf("RECOVERY - FAIL\n");
                            else if(tm_frame.tm_data[2]==4) printf("- REJECTED Invalid Input");
                        }
                        else if((tm_frame.tm_data[0] >> 4) == 2)
                        {
                            printf("Fault bit set for all errors\n");

                        }
                        else if((tm_frame.tm_data[0] >> 4) == 3)
                        {
                            printf("Fault bit clear for all errors\n");

                        }
                        else if((tm_frame.tm_data[0] >> 4) == 4)
                        {
                            grp_id = tm_frame.tm_data[0] & 0xf;
                            err_code_id = tm_frame.tm_data[1];
                            printf("Fault status set for specific errors\n");
                            if(grp_id == 0) printf("Group-IO - %hhu ",err_code_id);
                            else  if(grp_id == 1) printf("Group-AHW set 1 - %hhu\n",err_code_id);
                            else  if(grp_id == 2) printf("Group-AHW set 2 - %hhu\n",err_code_id);
                            else  if(grp_id == 3) printf("Group-System - %hhu\n",err_code_id);
                            else  if(grp_id == 4) printf("Group-Services - %hhu\n",err_code_id);
                            else  if(grp_id == 5) printf("Group-Comms_Module - %hhu\n",err_code_id);
                            else  if(grp_id == 6) printf("Group-ADCS - %hhu\n",err_code_id);
                            else  if(grp_id == 7) printf("Group-EPS - %hhu\n",err_code_id);
                            else
                                printf("Invalid group id\n");



                            if(tm_frame.tm_data[2] == 3) printf("FAULT SET - SUCCESS\n");
                            else if(tm_frame.tm_data[2]==4) printf("- REJECTED Invalid Input");
                        }

                        else if((tm_frame.tm_data[0] >> 4) == 5)
                        {
                            grp_id = tm_frame.tm_data[0] & 0xf;
                            err_code_id = tm_frame.tm_data[1];
                            printf("Fault status clear for specific errors\n");
                            if(grp_id == 0) printf("Group-IO - %hhu ",err_code_id);
                            else  if(grp_id == 1) printf("Group-AHW set 1 - %hhu\n",err_code_id);
                            else  if(grp_id == 2) printf("Group-AHW set 2 - %hhu\n",err_code_id);
                            else  if(grp_id == 3) printf("Group-System - %hhu\n",err_code_id);
                            else  if(grp_id == 4) printf("Group-Services - %hhu\n",err_code_id);
                            else  if(grp_id == 5) printf("Group-Comms_Module - %hhu\n",err_code_id);
                            else  if(grp_id == 6) printf("Group-ADCS - %hhu\n",err_code_id);
                            else  if(grp_id == 7) printf("Group-EPS - %hhu\n",err_code_id);
                            else
                                printf("Invalid group id\n");



                            if(tm_frame.tm_data[2] == 3) printf("FAULT CLEAR - SUCCESS\n");
                            else if(tm_frame.tm_data[2]==4) printf("- REJECTED Invalid Input");
                        }

                        else if((tm_frame.tm_data[0] >> 4) == 6)
                        {
                            grp_id = tm_frame.tm_data[0] & 0xf;
                            err_code_id = tm_frame.tm_data[1];
                            printf("Error set status for specific errors\n");
                            if(grp_id == 0) printf("Group-IO - %hhu ",err_code_id);
                            else  if(grp_id == 1) printf("Group-AHW set 1 - %hhu\n",err_code_id);
                            else  if(grp_id == 2) printf("Group-AHW set 2 - %hhu\n",err_code_id);
                            else  if(grp_id == 3) printf("Group-System - %hhu\n",err_code_id);
                            else  if(grp_id == 4) printf("Group-Services - %hhu\n",err_code_id);
                            else  if(grp_id == 5) printf("Group-Comms_Module - %hhu\n",err_code_id);
                            else  if(grp_id == 6) printf("Group-ADCS - %hhu\n",err_code_id);
                            else  if(grp_id == 7) printf("Group-EPS - %hhu\n",err_code_id);
                            else
                                printf("Invalid group id\n");



                            if(tm_frame.tm_data[2] == 3) printf("ERROR SET - SUCCESS\n");
                            else if(tm_frame.tm_data[2]==4) printf("- REJECTED Invalid Input");
                        }
                        else if((tm_frame.tm_data[0] >> 4) == 7)
                        {
                            grp_id = tm_frame.tm_data[0] & 0xf;
                            err_code_id = tm_frame.tm_data[1];
                            printf("Error clear status for specific errors\n");
                            if(grp_id == 0) printf("Group-IO - %hhu ",err_code_id);
                            else  if(grp_id == 1) printf("Group-AHW set 1 - %hhu\n",err_code_id);
                            else  if(grp_id == 2) printf("Group-AHW set 2 - %hhu\n",err_code_id);
                            else  if(grp_id == 3) printf("Group-System - %hhu\n",err_code_id);
                            else  if(grp_id == 4) printf("Group-Services - %hhu\n",err_code_id);
                            else  if(grp_id == 5) printf("Group-Comms_Module - %hhu\n",err_code_id);
                            else  if(grp_id == 6) printf("Group-ADCS - %hhu\n",err_code_id);
                            else  if(grp_id == 7) printf("Group-EPS - %hhu\n",err_code_id);
                            else
                                printf("Invalid group id\n");



                            if(tm_frame.tm_data[2] == 3) printf("ERROR CLEAR - SUCCESS\n");
                            else if(tm_frame.tm_data[2]==4) printf("- REJECTED Invalid Input");
                        }

                        else
                        {

                        }
                        printf("\n------------------------------------------------\n");
                    }
                    break;

                case TM_ERR_HANDLER_GET_ERROR_HISTORY:
                    {
                        uint32_t tot_hstry_cnt;
                        uint8_t fault_sts, inc;
                        uint8_t msg_id = tm_frame.tm_data[0] & 0x07;
                        uint8_t offset = 0;
                        if(msg_id == 2)
                        {
                            err_handler_history err_hstry_data;
                            tot_hstry_cnt=tm_frame.tm_data[1];
                            printf("\nNumber of error historys received  %d\n",tot_hstry_cnt);
                            printf("----------------------------------------------------\n");
                            for (inc=0;inc<tot_hstry_cnt;inc++)
                            {
                                printf("\r\n");
                                memcpy(&err_hstry_data, &tm_frame.tm_data[2+offset], 10);

                                if(err_hstry_data.group_id == 7 && err_hstry_data.error_code == 31 && err_hstry_data.reported_module_id == 127)
                                {
                                	printf("Balance Error history to be filled\n");
                                }
                                else
                                {

                                printf("\nGroup id %d\n", err_hstry_data.group_id);
                                //if(grp_id == 0) printf("Group-IO - %hhu ",err_code_id);
                                           if(err_hstry_data.group_id == 1) printf("Group-AHW set 1\n");
                                         else  if(err_hstry_data.group_id == 2) printf("Group-AHW set 2\n");
                                         else  if(err_hstry_data.group_id == 3) printf("Group-System\n");
                                         else  if(err_hstry_data.group_id == 4) printf("Group-Services\n");
                                         else  if(err_hstry_data.group_id == 5) printf("Group-Comms_Module\n");
                                         else  if(err_hstry_data.group_id == 6) printf("Group-ADCS\n");
                                         else  if(err_hstry_data.group_id == 7) printf("Group-EPS\n");
                                         else
                                             printf("Invalid group id\n");


                                printf("Error code %d\n", err_hstry_data.error_code);
                                fault_sts = err_hstry_data.fault_set;
                                if (fault_sts == 0)
                                {
                                    printf("Recovery Pass\n");
                                }

                                else 
                                {
                                    printf("Recovery Fail\n");
                                }
                                printf("Reported module id %d\n", err_hstry_data.reported_module_id);
                                //       printf("Reported time %d %d %d\n", tot_err_hstry_cnt.reported_time.hours, tot_err_hstry_cnt.reported_time.min, tot_err_hstry_cnt.reported_time.seconds);
                                }
                                offset = offset + 10;//sizeof(err_handler_history);
                            }

                        }
                    }
                    break;

                case TM_TTY_DEBUG:
                    {
                        int8_t sts = 0;
                        memset(tty_drdu,0,sizeof(tty_drdu));
                        tm_tty_data_dec(tm_frame.tm_data,tty_drdu,tm_frame.tm_len);
                        sts = tty_drdu[0];
                        if(sts != -1)
                        {
                            //tty_drdu[tm_frame.tm_len] = '\0';
                            printf("TTY Debug Response data:\n%.*s\n",tm_frame.tm_len,(char*)tty_drdu);
                        }
                        else
                        {
                            printf("TTY Debug failure\n");
                        }

                    }
                    break;
                case TM_SET_MIN_REBOOT_TIME:
                    {
                        tm_tty_data_dec((uint8_t*)&set_min_rbt_tm_rsp,tm_frame.tm_data,tm_frame.tm_len);
                        if(!set_min_rbt_tm_rsp )
                            printf("SET minimum reboot time  success\n");
                        else
                            printf("SET minimum reboot time  failure\n");
                    }
                    break;

                case TM_GET_SYS_UPTIME:
                    {
                        memcpy(&cpu_uptime,tm_frame.tm_data,tm_frame.tm_len);
                        printf("CPU UPTIME = %lu minutes\n",(cpu_uptime/60));
                    }
                    break;    

                case TM_GET_PROC_UTIL_INFO:
                    {
                        memcpy(&cpu_ld,tm_frame.tm_data,tm_frame.tm_len);
                        printf("CPU LOAD = %f percentage\n",cpu_ld);
                    }
                    break;    

                case TM_GET_MEM_UTIL_INFO:
                    {
                        memcpy(&cur_rct,tm_frame.tm_data,sizeof(sys_time_date_s));
                        printf("DATE = %d.%d.%d\nTIME = %d:%d:%d\n",cur_rct.date,cur_rct.month,cur_rct.year,cur_rct.hour,cur_rct.minute,cur_rct.seconds);

                        memcpy(&mem_sts,tm_frame.tm_data+sizeof(sys_time_date_s)+1,sizeof(sys_mem_status));
                        printf("\nSYSTEM MEMORY USAGE:\n");
                        printf("\nERAM MEMORY");
                        printf("\nTOTAL: %lu bytes\n",mem_sts.eram_mem_total);
                        printf("USED : %lu bytes\n",mem_sts.eram_mem_used);
                        printf("\nEFLASH QSPI MEMORY:");
                        printf("\nTOTAL: %lu bytes\n",mem_sts.eflash_qspi_mem_total);
                        printf("USED : %lu bytes\n",mem_sts.eflash_qspi_mem_used);
                        printf("\nFLASH FMC MEMORY:");
                        printf("\nTOTAL: %lu bytes\n",mem_sts.eflash_fmc_mem_total);
                        printf("USED : %lu bytes\n",mem_sts.eflash_fmc_mem_used);
                        printf("\nIRAM HEAP MEMORY:");
                        printf("\nTOTAL    : %lu bytes\n",mem_sts.iram_heap_mem_total);
                        printf("REMAINING: %lu bytes\n",mem_sts.iram_heap_mem_total-mem_sts.iram_heap_mem_used);
                        printf("\nERAM HEAP MEMORY:");
                        printf("\nTOTAL    : %lu bytes\n",mem_sts.eram_heap_mem_total);
                        printf("REMAINING: %lu bytes\n",mem_sts.eram_heap_mem_total-mem_sts.eram_heap_mem_used);
                    }
                    break;    

                case TM_GET_FTM_SAVECONTEXT_STS:
                    {
                        uint8_t ftm_sts = 0;
                        memcpy(&ftm_sts, tm_frame.tm_data, 1);
                        if(ftm_sts == 0)
                        {
                            printf("Savecontext Success - Rct can be initiate\n");
                        }
                        else if (ftm_sts == 1)
                        {
                            printf("Savecontext failed - file data is corrupted\n");
                        }
                        else if (ftm_sts == 2)
                        {
                            printf("Savecontext failed - file copy error\n");
                        }
                        else if (ftm_sts == 3)
                        {
                            printf("Savecontext failed - file context checksum error\n");
                        }
                        else if (ftm_sts == 4)
                        {
                            printf("Savecontext failed - ftm context and file context mismatch\n");
                        }
                        else if (ftm_sts == 5)
                        {
                            printf("Savecontext failed - ftm context data checksum error\n");
                        }
                        else if (ftm_sts == 6)
                        {
                            printf("Savecontext failed - ftm context not available\n");
                        }
                        else if (ftm_sts == 7)
                        {
                            printf("Savecontext failed - malloc fail\n");
                        }
                        else
                        {
                            printf("Invalid Module Id\n");
                        }
                        break;

                    }

                case TM_OBC_MEM_DOWLOAD:
                    {
                        uint8_t obc_mem_sts = 0;
                        memcpy(&obc_mem_sts, tm_frame.tm_data, 1);
                        if(obc_mem_sts == 0)
                        {
                            printf("OBC Memory Download has been initiate\n");
                        }
                        else if (obc_mem_sts == 1)
                        {
                            printf("OBC Memory Download failed - Invalid Memory type has been choose\n");
                        }
                        else if (obc_mem_sts == 2)
                        {
                            printf("OBC Memory Download failed - Invalid Memory Address or Memory Range \n");
                        }
                        else 
                        {
                            printf("Invalid Status\n");
                        }

                    }
                    break;
#if 0
                case TM_EPS_FW_UPDATE:
                    {

                        eps_fw_data_s fw_info;
                        if (tm_frame.tm_data[0] == FIRMWARE_AVAILABILITY_CHECK)
                        {
                            //if(tm_frame.tm_data[1] == CONVERTOR_BOARD)
                            if(tm_frame.tm_data[1] == 1)
                            {
                                memcpy(&fw_info,&tm_frame.tm_data[2],9);
                                printf("Convertor Board Firmware status\n");
                            }
                            else 
                            {
                                memcpy(&fw_info,&tm_frame.tm_data[2],9);
                                printf("Output channel Board Firmware status\n");
                            }
                            if(fw_info.fw_status == 1)
                            {

                                printf("Firmware available to update\n");
                                printf("Firmware size = %d\n",fw_info.fw_size);
                                printf("Firmware crc = %x\n",fw_info.fw_crc);
                            }
                            else
                            {
                                printf("Firmware not available\n");
                            }
                        }

                        else if(tm_frame.tm_data[0] == FIRMWARE_UPDATE || tm_frame.tm_data[0] == BCKUP_FIRMWARE_UPDATE)
                        {
                            //if(tm_frame.tm_data[1] == CONVERTOR_BOARD)
                            if(tm_frame.tm_data[1] == 1 && tm_frame.tm_data[0] == FIRMWARE_UPDATE )
                            {
                                printf("Convertor Board Firmware Update Status:\n");
                            }
			    else if(tm_frame.tm_data[1] == 1 && tm_frame.tm_data[0] == BCKUP_FIRMWARE_UPDATE)
			    {
                                printf("Convertor Board Backup Firmware Update Status:\n");
			    }
			    else if(tm_frame.tm_data[1] == 2 && tm_frame.tm_data[0] == FIRMWARE_UPDATE)
			    {

                                printf("Output channel Board Firmware Update Status:\n");
			    }
                            else if(tm_frame.tm_data[1] == 2 && tm_frame.tm_data[0] == BCKUP_FIRMWARE_UPDATE)
                            {
                                printf("Output channel Board backup Firmware Update Status:\n");
                            }
			    else
			    {
				    printf("invalid id\n");
			    }
                            if(tm_frame.tm_data[2] == 0)
                            {
                                printf("Firmware update success\n");
                                printf("Trial one:%d\n",tm_frame.tm_data[4]);
                                printf("Trial two:%d\n",tm_frame.tm_data[5]);
                                printf("Trial three:%d\n",tm_frame.tm_data[6]);
				if(tm_frame.tm_data[4]!= 0xff && tm_frame.tm_data[5]!=0xff && tm_frame.tm_data[6]==0xff)
				{
					printf("Firmware update passed at 3rd attempt\n");
				}
				else if(tm_frame.tm_data[4]!=0xff && tm_frame.tm_data[5]==0xff)
				{
					printf("Firmware update passed at 2nd attempt\n");
				}
				else if(tm_frame.tm_data[4]==0xff && tm_frame.tm_data[5]==0xff && tm_frame.tm_data[6]==0xff)
				{
					printf("Firmware update passed at 1st attempt\n");
				}
				else
				{
				}

                            }
                            else if(tm_frame.tm_data[2] == 1)
                            {
                                printf("Firmware update failure\n");
                                printf("ERROR CODE: %d",tm_frame.tm_data[3]);
                                switch(tm_frame.tm_data[3])
                                {
                                    case 1:
                                        printf("Boot command rejected\n");
                                        break;
                                    case 2:
                                        printf("Received NACK for command frame\n");
                                        break;
                                    case 3:
                                        printf("Received NACK for data frame\n");
                                        break;
                                    case 6:
                                        printf("Received NACK for write command\n");
                                        break;
                                    case 7:
                                        printf("Data transmit fail\n");
                                        break;
                                    case 8:
                                        printf("Received NACK for address frame\n");
                                        break;
                                    case 9:
                                        printf("Address transmit fail\n");
                                        break;
                                    case 10:
                                        printf("Read data fail\n");
                                        break;
                                    case 11:
                                        printf("Received NACK for Read\n");
                                        break;
                                    case 12:
                                        printf("BOOT startup fail\n");
                                        break;
                                    case 13:
                                        printf("Recieved NACK for sector count\n");
                                        break;
                                    case 14:
                                        printf("Received sector count fail\n");
                                        break;
                                    case 15:
                                        printf("Received NACK for sector id \n");
                                        break;
                                    case 16:
                                        printf("Received sector id fail\n");
                                        break;
                                    case 20:
                                        printf("Read and write mismatch\n");
                                        break;
                                    case 21:
                                        printf("Invalid ACK for sector count\n");
                                        break;
                                    case 23:
                                        printf("Invalid ACK for sector id\n");
                                        break;
                                    case 24:
                                        printf("Invalid ACK for write\n");
                                        break;
                                    case 25:
                                        printf("Invalid ACK for read\n");
                                        break;
                                }


                            }
                            else if(tm_frame.tm_data[2] == 2)
                            {
                                printf("Downloaded firmware integrity check failed\n");
                            }
                            else if(tm_frame.tm_data[2] == 3)
                            {
                                printf("Size or CRC mismatch\n");			    
                            }
                            else if(tm_frame.tm_data[2] == 4)
                            {
                                printf("No firmware available\n");
                            }
			    else if(tm_frame.tm_data[2] == 5)
                            {
                                printf("Backup Firmware integrity fail\n");
                            }
                            else
                            {
                                //do nothing
                            }
                           //if(tm_frame.tm_data[4] == 0xFF && tm_frame.tm_data[5] == 0xFF && tm_frame.tm_data[6] == 0xFF)
                           // {
                           // }
                           // else
                           // {
//                                printf("Warning!!! EPS FW update failed\n");

                           // }
                        }

                        else if(tm_frame.tm_data[0] == FIRMWARE_UPDATE_STATUS_CHECK)
                        {

                            //if(tm_frame.tm_data[1] == CONVERTOR_BOARD)
                            if(tm_frame.tm_data[1] == 1)
                            {
                                printf("Convertor Board Firmware Update Status:\n");
                            }
                            else
                            {
                                printf("Output channel Board Firmware Update Status:\n");
                            }

                            if(tm_frame.tm_data[2] == 0)
                            {
                                printf("No Firmware Available\n");
                            }
                            else if(tm_frame.tm_data[2] == 1)
                            {
                                printf("Firmware Available to update\n");
                            }
                            else if(tm_frame.tm_data[2] == 2)
                            {
                                printf("Firmware update pass\n");
                            }
                            else if(tm_frame.tm_data[2] == 3)
                            {
                                printf("Firmware update Fail\n");
                            }
                            else
                            {
                            }

                        }
			else if (tm_frame.tm_data[0] == BCKUP_FIRMWARE_AVAILABILITY_CHECK)
                        {
                            //if(tm_frame.tm_data[1] == CONVERTOR_BOARD)
                            if(tm_frame.tm_data[1] == 1)
                            {
                                memcpy(&fw_info,&tm_frame.tm_data[2],9);
                                printf("Convertor Board Firmware status\n");
                            }
                            else 
                            {
                                memcpy(&fw_info,&tm_frame.tm_data[2],9);
                                printf("Output channel Board Firmware status\n");
                            }
                            if(fw_info.fw_status == 1)
                            {

                                printf("Firmware available to update\n");
                                printf("Firmware size = %d\n",fw_info.fw_size);
                                printf("Firmware crc = %x\n",fw_info.fw_crc);
                            }
                            else
                            {
                                printf("Firmware not available\n");
                            }
                        }

                        else {
                            printf("invalid input");
                        }

                    }
                    break;
#endif
                case TM_LOG_LEVEL_FILTER_CONFIG:
                    {
                        if((CONFIG_MODULE_SPECIFIC!= tm_frame.tm_data[0]))
                        {
                            printf("\nLOGGER LEVEL CONFIGURATION:");
                            printf("\nADCS: ");
                            module_level_display(tm_frame.tm_data[LOG_ADCS+2]);
                            printf("\nOTSU: ");
                            module_level_display(tm_frame.tm_data[LOG_OTSU+2]);
                            printf("\nCOMMS: ");
                            module_level_display(tm_frame.tm_data[LOG_COMMS+2]);
                            printf("\nFTM: ");
                            module_level_display(tm_frame.tm_data[LOG_FTM+2]);
                            printf("\nOBC: ");
                            module_level_display(tm_frame.tm_data[LOG_OBC+2]);
                            printf("\nEPS: ");
                            module_level_display(tm_frame.tm_data[LOG_EPS+2]);
                            printf("\nTCTM: ");
                            module_level_display(tm_frame.tm_data[LOG_TCTM+2]);
                            printf("\nSCHEDULER: ");
                            module_level_display(tm_frame.tm_data[LOG_SCHEDULER+2]);
                            printf("\nAHW: ");
                            module_level_display(tm_frame.tm_data[LOG_AHW+2]);
                            printf("\nLOGGER: ");
                            module_level_display(tm_frame.tm_data[LOG_LOGGER+2]);
                            printf("\nERROR HANDLER: ");
                            module_level_display(tm_frame.tm_data[LOG_ERROR_HANDLER+2]);
                            printf("\nHM");
                            module_level_display(tm_frame.tm_data[LOG_HM+2]);
                            printf("\nIPCC");
                            module_level_display(tm_frame.tm_data[LOG_IPCC+2]);
                            printf("\n");

                        }

                        else if(CONFIG_MODULE_SPECIFIC == tm_frame.tm_data[0])
                        {

                            printf("LOGGER LEVEL CONFIGURATION OF\n");
                            switch(tm_frame.tm_data[1])
                            {
                                case LOG_ADCS:
                                    {
                                        printf("ADCS:\n ");
                                        module_level_display(tm_frame.tm_data[2]);
                                        printf("\n");
                                        break;
                                    }
                                case LOG_OTSU:
                                    {
                                        printf("OTSU:\n ");
                                        module_level_display(tm_frame.tm_data[2]);
                                        printf("\n");
                                        break;
                                    }
                                case LOG_COMMS:
                                    {
                                        printf("COMMS:\n ");
                                        module_level_display(tm_frame.tm_data[2]);
                                        printf("\n");
                                        break;
                                    }
                                case LOG_FTM:
                                    {
                                        printf("FTM: ");
                                        module_level_display(tm_frame.tm_data[2]);
                                        printf("\n");
                                        break;
                                    }
                                case LOG_OBC:
                                    {
                                        printf("OBC: ");
                                        module_level_display(tm_frame.tm_data[2]);
                                        printf("\n");
                                        break;
                                    }
                                case LOG_EPS:
                                    {
                                        printf("EPS: ");
                                        module_level_display(tm_frame.tm_data[2]);
                                        printf("\n");
                                        break;
                                    }
                                case LOG_TCTM:
                                    {
                                        printf("TCTM: ");
                                        module_level_display(tm_frame.tm_data[2]);
                                        printf("\n");
                                        break;
                                    }
                                case LOG_SCHEDULER:
                                    {
                                        printf("SCHEDULER: ");
                                        module_level_display(tm_frame.tm_data[2]);
                                        printf("\n");
                                        break;
                                    }
                                case LOG_AHW:
                                    {
                                        printf("AHW: ");
                                        module_level_display(tm_frame.tm_data[2]);
                                        printf("\n");
                                        break;
                                    }
                                case LOG_LOGGER:
                                    {
                                        printf("LOGGER: ");
                                        module_level_display(tm_frame.tm_data[2]);
                                        printf("\n");
                                        break;
                                    }
                                case LOG_ERROR_HANDLER:
                                    {
                                        printf("ERROR HANDLER: ");
                                        module_level_display(tm_frame.tm_data[2]);
                                        printf("\n");
                                        break;
                                    }
                                case LOG_HM:
                                    {
                                        printf("HEALTH METRIC: ");
                                        module_level_display(tm_frame.tm_data[2]);
                                        printf("\n");
                                        break;
                                    }
                                case LOG_IPCC:
                                    {
                                        printf("IPCC: ");
                                        module_level_display(tm_frame.tm_data[2]);
                                        printf("\n");
                                        break;
                                    }

                                default:
                                    {
                                        printf("INVALID SELECTION");
                                        break;
                                    }
                            }
                        }
                    }
                    break;


                case TM_READ_LOG_INFO:
                    {
                        uint8_t log_backup_en_dis;
                        if(READ_LOG_HANDLE_INFO == tm_frame.tm_data[0])
                        {
                            printf("LOGGER HANDLER INFO:\n");
                            printf("Current block ID: %d\n",*((uint16_t*)&tm_frame.tm_data[1]));
                            printf("Start block ID: %d\n", *((uint16_t*)&tm_frame.tm_data[3]));
                            printf("End block ID: %d\n", *((uint16_t*)&tm_frame.tm_data[5]));
                            printf("Backup Erase Count: %d\n",*((uint16_t*)&tm_frame.tm_data[7]));
                            printf("Backup Partition No: %d\n",*((uint8_t*)&tm_frame.tm_data[9]));
                            log_backup_en_dis = tm_frame.tm_data[10];
                            if(log_backup_en_dis == 0)
                            {
                                printf("Log Backup Disable\n");
                            }
                            else if (log_backup_en_dis == 0x5A)
                            {
                                printf("Log Backup Enable\n");
                            }
                            else
                            {
                                printf("INVALID ID");
                            }

                        }
                        else if(READ_LOG_LEVEL_FILTER == tm_frame.tm_data[0])
                        {
                            printf("\nLOGGER LEVEL CONFIGURATION:");
                            printf("\nADCS: ");
                            module_level_display(tm_frame.tm_data[LOG_ADCS+2]);
                            printf("\nOTSU: ");
                            module_level_display(tm_frame.tm_data[LOG_OTSU+2]);
                            printf("\nCOMMS: ");
                            module_level_display(tm_frame.tm_data[LOG_COMMS+2]);
                            printf("\nFTM: ");
                            module_level_display(tm_frame.tm_data[LOG_FTM+2]);
                            printf("\nOBC: ");
                            module_level_display(tm_frame.tm_data[LOG_OBC+2]);
                            printf("\nEPS: ");
                            module_level_display(tm_frame.tm_data[LOG_EPS+2]);
                            printf("\nTCTM: ");
                            module_level_display(tm_frame.tm_data[LOG_TCTM+2]);
                            printf("\nSCHEDULER: ");
                            module_level_display(tm_frame.tm_data[LOG_SCHEDULER+2]);
                            printf("\nAHW: ");
                            module_level_display(tm_frame.tm_data[LOG_AHW+2]);
                            printf("\nLOGGER: ");
                            module_level_display(tm_frame.tm_data[LOG_LOGGER+2]);
                            printf("\nERROR HANDLER: ");
                            module_level_display(tm_frame.tm_data[LOG_ERROR_HANDLER+2]);
                            printf("\nHM: ");
                            module_level_display(tm_frame.tm_data[LOG_HM+2]);
                            printf("\nIPCC: ");
                            module_level_display(tm_frame.tm_data[LOG_IPCC+2]);
                            printf("\n");
                        }
                    }
                    break;

                case TM_LOG_DOWNLOAD_BACKUP_BLOCKS:
                    {
                        if(1 == tm_frame.tm_data[0])
                        {
                            printf("Response backup data download fail\n");
                        }

                        else if(2 == tm_frame.tm_data[0])
                        {
                            printf("Configuration of logger backup SUCCESS\n");
                        }
                        else
                        {
                            printf("INVALID LOGGER BACKUP CONFIG FAILED / DOWNLOAD FAILED");
                        }

                    }
                    break;
                case TM_LOG_DOWNLOAD_BLOCKS:
                    {
                        uint16_t u16cnt;
                        FILE *fptr_write;
                        fptr_write = fopen("obc_log_via_tm.bin","wb");
                        for (u16cnt = 0; u16cnt < tm_frame.tm_len ; u16cnt++)
                        {
                            fwrite(&tm_frame.tm_data[u16cnt], sizeof(unsigned char), 1, fptr_write);
                        }
                        fclose(fptr_write);
                    }
                    break;
                case TM_SET_CONTROL_FLAG_TM_BUFFER:
                    {
                        if(1==tm_frame.tm_data[0])
                            printf("Set control flag for TM download buffer success\n");
                    }
                    break;

                case TM_SET_COMMS_TM_DLREQ:
                    {
                        if(1==tm_frame.tm_data[0])
                            printf("SET COMMS TM DLREQ success\n");

                    }
                    break;
                case TM_SET_TEMP_SNS_CFG:
                    {
                        memcpy(&set_temp_sen_parm_sts,tm_frame.tm_data,4);
                        /* Check target pointing configuration response status */
                        if(!set_temp_sen_parm_sts)
                            printf("Set temperature sensor parameter success\n");
                        else
                            printf("Set temperature sensor parameter failure\n");

                    }
                    break;
                case TM_GET_TEMP_SNS_CFG:
                    {
                        /* Decode Location information */
                        memcpy(&temp_sns_cfg,tm_frame.tm_data, sizeof(temp_sens_cfg));

#ifdef SNS_GET_INF_PRINT
                        printf("instance_id = %d\n",temp_sns_cfg.instance_id);
                        printf("Polling timer periodicity = %d\n",temp_sns_cfg.polling_tmr_prdcty);
                        printf("Low_temp_thrsld = %f\n",temp_sns_cfg.low_temp_thrsld);
                        printf("High_temp_thrsld = %f\n",temp_sns_cfg.high_temp_thrsld);
                        printf("ADC resolution = %d\n",temp_sns_cfg.adc_resolution);
                        printf("Interrupt Enable status = %d\n",temp_sns_cfg.intr_mask);
                        printf("Interrupt pin polarity = %d\n",temp_sns_cfg.intr_pin_polarity);
#endif
                    }
                    break;

                case TM_SET_IMU_CFG:
                    {
                        memcpy(&set_imu_parm_sts,tm_frame.tm_data,4);
                        /* Check target pointing configuration response status */
                        if(!set_imu_parm_sts)
                            printf("Set IMU sensor parameter success\n");
                        else
                            printf("Set IMU sensor parameter failure\n");

                    }
                    break;

                case TM_GET_IMU_CFG:
                    {
                        /* Decode Location information */
                        memcpy(&imu_inf,tm_frame.tm_data, sizeof(imu_info));
#ifdef SNS_GET_INF_PRINT

                        printf("instance_id = %d \n",imu_inf.instance_id);
                        printf("power = %d \n",imu_inf.power);
                        printf("accel_x = %d \n",imu_inf.accel_x);
                        printf("gyro_y = %d \n",imu_inf.gyro_y);
                        printf("mag_y = %d \n",imu_inf.mag_y);

#endif
                    }
                    break;

                case TM_SET_THRUST_CTRL_CFG:
                    {
                        memcpy(&set_thrust_ctrl_parm_sts,tm_frame.tm_data,4);
                        /* Check target pointing configuration response status */
                        if(!set_thrust_ctrl_parm_sts)
                            printf("Set thruster parameter success\n");
                        else
                            printf("Set thruster parameter failure\n");

                    }
                    break;

                case TM_GET_THRUST_CTRL_CFG:
                    {
                        /* Decode Location information */
                        memcpy(&thrstr_inf,tm_frame.tm_data, sizeof(thruster_info));
                        if(thrstr_inf.calib_data_cnt == SNS_CALIB_DATA_CNT)
                        {
#ifdef SNS_GET_INF_PRINT

                            printf("instance_id = %d \n",thrstr_inf.instance_id);
                            printf("brd_err_count = %d \n",thrstr_inf.brd_err_count);
                            printf("strt_tm = %d \n",thrstr_inf.strt_tm);
                            printf("master_tm = %d \n",thrstr_inf.master_tm);
                            printf("bkpln_master_tm = %d \n",thrstr_inf.bkpln_master_tm);

#endif
                        }
                        else
                        {
                            printf("Invalid cnt\n");
                        }

                    }
                    break;

                case TM_SET_GPIO_EXP_CFG:
                    {
                        memcpy(&set_gpio_exp_parm_sts,tm_frame.tm_data,4);
                        /* Check target pointing configuration response status */
                        if(!set_gpio_exp_parm_sts)
                            printf("Set gpio expander parameter success\n");
                        else
                            printf("Set gpio expander parameter failure\n");

                    }
                    break;

                case TM_GET_GPIO_EXP_CFG:
                    {
                        /* Decode Location information */
                        memcpy(&gpio_expdr_cfg,tm_frame.tm_data, sizeof(gpio_exp_cfg));
#ifdef SNS_GET_INF_PRINT
                        printf("instance_id = %d \n",gpio_expdr_cfg.instance_id);
                        printf("intr_pin_polarity = %d \n",gpio_expdr_cfg.intr_pin_polarity);
#endif
                    }
                    break;

                case TM_SET_DIG_THERM_CFG:
                    {
                        memcpy(&set_dig_therm_parm_sts,tm_frame.tm_data,4);
                        /* Check target pointing configuration response status */
                        if(!set_dig_therm_parm_sts)
                            printf("Set digital thermostat parameter success\n");
                        else
                            printf("Set digital thermostat parameter failure\n");

                    }
                    break;

                case TM_GET_DIG_THERM_CFG:
                    {
                        /* Decode Location information */
                        memcpy(&dgtl_thrmst_cfg,tm_frame.tm_data, sizeof(digital_thermostat_cfg));
#ifdef SNS_GET_INF_PRINT
                        printf("instance_id=%d \n",dgtl_thrmst_cfg.instance_id);
                        printf("Polling timer periodicity = %d\n",dgtl_thrmst_cfg.polling_tmr_prdcty);
                        printf("high_temp_thrsld=%f\n",dgtl_thrmst_cfg.high_temp_thrsld);
                        printf("low_temp_thrsld=%f\n",dgtl_thrmst_cfg.low_temp_thrsld);
                        printf("Thermostat enable = %d\n",dgtl_thrmst_cfg.thrmst_enable);
                        printf("pin_polarity=%d\n",dgtl_thrmst_cfg.thrmst_pin_polarity);
                        printf("adc_resolution=%d\n",dgtl_thrmst_cfg.adc_resolution);
#endif
                    }
                    break;

                case TM_SET_PWR_MON_CFG:
                    {
                        memcpy(&set_pwr_mon_parm_sts,tm_frame.tm_data,4);
                        /* Check target pointing configuration response status */
                        if(!set_pwr_mon_parm_sts)
                            printf("Set power monitor parameter success\n");
                        else
                            printf("Set power monitor parameter failure\n");

                    }
                    break;

                case TM_GET_PWR_MON_CFG:
                    {
                        /* Decode Location information */
                        memcpy(&pwr_sns_mtr_cfg,tm_frame.tm_data, sizeof(power_mntr_sns_cfg));
#ifdef SNS_GET_INF_PRINT
                        printf("Instance_id = %d \n",pwr_sns_mtr_cfg.instance_id);
                        printf("Polling timer periodicity = %d\n",pwr_sns_mtr_cfg.polling_tmr_prdcty);
                        printf("Vbus Threshold = %f \n",pwr_sns_mtr_cfg.vbus_thrsld);
                        printf("Current Threshold = %f \n",pwr_sns_mtr_cfg.current_thrsld);
                        printf("Power threshold = %d \n",pwr_sns_mtr_cfg.power_thrsld);
                        printf("Interrupt Type = %d \n",pwr_sns_mtr_cfg.intr_type);
                        printf("Interrupt Pin Polarity = %d \n",pwr_sns_mtr_cfg.intr_pin_polarity);
                        printf("Conversion Type = %d \n",pwr_sns_mtr_cfg.conversion_type);
#endif
                    }
                    break;

                case TM_SET_VOLT_CTRL_MON_CFG:
                    {
                        memcpy(&set_volt_ctrl_mon_parm_sts,tm_frame.tm_data,4);
                        /* Check target pointing configuration response status */
                        if(!set_volt_ctrl_mon_parm_sts)
                            printf("Set voltage control and monitor parameter success\n");
                        else
                            printf("Set voltage control and monitor parameter failure\n");

                    }
                    break;

                case TM_GET_VOLT_CTRL_MON_CFG:
                    {
                        /* Decode Location information */
                        memcpy(&htswp_cntlr_cfg,tm_frame.tm_data, sizeof(hotswap_cntlr_cfg));
#ifdef SNS_GET_INF_PRINT
                        printf("Instance_id = %d \n",htswp_cntlr_cfg.instance_id);
                        printf("Polling timer periodicity = %d\n",htswp_cntlr_cfg.polling_tmr_prdcty);
                        printf("Voltage Threshold = %f \n",htswp_cntlr_cfg.voltage_thrsld);
                        printf("Current Threshold = %f \n",htswp_cntlr_cfg.current_thrsld);
                        printf("Hotswap_sts = %d \n",htswp_cntlr_cfg.hotswap_sts);
                        printf("Interrupt Mask = %d \n",htswp_cntlr_cfg.intr_msk);
                        printf("Interrupt Pin Polarity = %d \n",htswp_cntlr_cfg.intr_pin_polarity);
                        printf("Conversion Type = %d \n",htswp_cntlr_cfg.conversion_type);
#endif
                    }
                    break;

                case TM_SET_PWR_SEQ_MON_CFG:
                    {
                        memcpy(&set_pwr_seq_mon_parm_sts,tm_frame.tm_data,4);
                        /* Check target pointing configuration response status */
                        if(!set_pwr_seq_mon_parm_sts)
                            printf("Set power sequence and monitor parameter success\n");
                        else
                            printf("Set power sequence and monitor failure\n");
                    }
                    break;

                case TM_GET_PWR_SEQ_MON_CFG:
                    {
                        /* Decode Location information */
                        memcpy(&vltg_seq_mntr_cfg,tm_frame.tm_data, sizeof(voltage_seq_mntr_cfg));
#if 0
                        printf("instance_id = %d \n",vltg_seq_mntr_cfg.instance_id);
#endif
                    }
                    break;

                case TM_SET_DATA_LOG_CFG:
                    {
                        memcpy(&set_data_log_parm_sts,tm_frame.tm_data,4);
                        /* Check target pointing configuration response status */
                        if(!set_data_log_parm_sts)
                            printf("Set data logger parameter success\n");
                        else
                            printf("Set data logger parameter failure\n");

                    }
                    break;

                case TM_GET_DATA_LOG_CFG:
                    {
                        /* Decode Location information */
                        memcpy(&data_acq_inf,tm_frame.tm_data, sizeof(data_acq_dvc_info));
#ifdef SNS_GET_INF_PRINT
                        printf("instance_id = %d \n",data_acq_inf.instance_id);
                        printf("chnl_num = %d \n",data_acq_inf.chnl_num);
                        printf("pwr_dwn_optn = %d \n",data_acq_inf.pwr_dwn_optn);
                        printf("data = %d \n",data_acq_inf.data);
#endif
                    }
                    break;


                case TM_GET_SENSOR_DATA:
                    {
                        uint32_t sns_ahw_data;
                        memcpy(&sns_ahw_data,tm_frame.tm_data,4);
                        struct tm *tm_ptr;
                        sys_time_date_s sns_time;
                        printf("ahw_id = %d\n",sns_ahw_data);
                        switch(sns_ahw_data)
                        {

                            case TEMP_SENSOR_MCP9843_OBC:
                            case TEMP_SENSOR_MCP9843_PS:
                            case TEMP_SENSOR_MCP9843_EDGE:
                            case TEMP_SENSOR_MCP9843_GPS:
                                {
                                    int index;
                                    printf("ahw_id = %d\n",sns_ahw_data);
                                    memcpy(temp_data_buffer,tm_frame.tm_data+4,tm_frame.tm_len-4);

#ifdef SNS_GET_INF_PRINT
                                    for(index=0;index<SENSOR_MAX_BUFF_SIZE;index++)
                                    {
                                        printf("Temperature=%f ",temp_data_buffer[index].temperature);
                                        //printf(" Time :%ld \n",temp_data_buffer[index].temp_epoch_time);
                                        tm_ptr=localtime((time_t*)&temp_data_buffer[index].temp_epoch_time);
                                        if(tm_ptr)
                                        {
                                            sns_time.hour=tm_ptr->tm_hour;
                                            sns_time.minute=tm_ptr->tm_min;
                                            sns_time.seconds=tm_ptr->tm_sec;
                                            sns_time.date=tm_ptr->tm_mday;
                                            sns_time.month=tm_ptr->tm_mon +1;
                                            sns_time.year=tm_ptr->tm_year + 1900 -2000;
                                            printf(" Time :%d :%d :%d\n",sns_time.hour,sns_time.minute,sns_time.seconds);
                                        }
                                    }
#endif
                                }
                                break;

                            case POWER_SENSE_MONITOR_OBC:
                            case POWER_SENSE_MONITOR_PS:
                                {
                                    int index;
                                    printf("ahw_id = %d\n",sns_ahw_data);
                                    memcpy(psm_data_buffer,tm_frame.tm_data+4,tm_frame.tm_len-4);
                                    for(index=0;index<SENSOR_MAX_BUFF_SIZE;index++)
                                    {
                                        printf("vbus_voltage=%f ",psm_data_buffer[index].pwr.vbus_voltage);
                                        printf("vshunt_voltage=%f ",psm_data_buffer[index].pwr.vshunt_voltage);
                                        printf("current=%f ",psm_data_buffer[index].pwr.current);
                                        printf("power=%d ",psm_data_buffer[index].pwr.power);
                                        //printf(" Time :%lu \n",psm_data_buffer[index].psm_epoch_time);
                                        tm_ptr=localtime((time_t*)&psm_data_buffer[index].psm_epoch_time);
                                        if(tm_ptr)
                                        {
                                            sns_time.hour=tm_ptr->tm_hour;
                                            sns_time.minute=tm_ptr->tm_min;
                                            sns_time.seconds=tm_ptr->tm_sec;
                                            sns_time.date=tm_ptr->tm_mday;
                                            sns_time.month=tm_ptr->tm_mon +1;
                                            sns_time.year=tm_ptr->tm_year + 1900 -2000;
                                            printf(" Time :%d :%d :%d\n",sns_time.hour,sns_time.minute,sns_time.seconds);
                                        }
                                    }
                                    break;
                                }
                            case DT_DS620_EDGE:
                            case DT_DS620_PS:
                            case DT_DS620_SPE01:
                            case DT_DS620_SPE02:
                            case DT_DS620_SPB01:
                            case DT_DS620_SPW01:
                            case DT_DS620_SPW02:
                                {
                                    int index;
                                    printf("ahw_id = %d\n",sns_ahw_data);
                                    memcpy(dt_data_buffer,tm_frame.tm_data+4,tm_frame.tm_len-4);
#ifdef SNS_GET_INF_PRINT
                                    for(index=0;index<SENSOR_MAX_BUFF_SIZE;index++)
                                    {
                                        printf("Temperature=%lf ",dt_data_buffer[index].temperature);
                                        //					printf(" Time :%lu \n",dt_data_buffer[index].dt_epoch_time);
                                        tm_ptr=localtime((time_t*)&dt_data_buffer[index].dt_epoch_time);
                                        if(tm_ptr)
                                        {
                                            sns_time.hour=tm_ptr->tm_hour;
                                            sns_time.minute=tm_ptr->tm_min;
                                            sns_time.seconds=tm_ptr->tm_sec;
                                            sns_time.date=tm_ptr->tm_mday;
                                            sns_time.month=tm_ptr->tm_mon +1;
                                            sns_time.year=tm_ptr->tm_year + 1900 -2000;
                                            printf(" Time :%d :%d :%d\n",sns_time.hour,sns_time.minute,sns_time.seconds);
                                        }
                                    }
#endif
                                }

                                break;

                            case HSC_ADM1176_EDGE:
                            case HSC_ADM1176_PS_2:
                            case HSC_ADM1176_PS_1:
                                {

                                    int index;
                                    printf("ahw_id = %d\n",sns_ahw_data);
                                    memcpy(hsc_data_buffer,tm_frame.tm_data+4,tm_frame.tm_len-4);
#ifdef SNS_GET_INF_PRINT

                                    for(index=0;index<SENSOR_MAX_BUFF_SIZE;index++)
                                    {
                                        printf("voltage=%f ",hsc_data_buffer[index].hsc_data.voltage);
                                        printf("current=%f ",hsc_data_buffer[index].hsc_data.current);
                                        //			    printf(" Time :%lu \n",hsc_data_buffer[index].adm_epoch_time);
                                        tm_ptr=localtime((time_t*)&hsc_data_buffer[index].adm_epoch_time);
                                        if(tm_ptr)
                                        {
                                            sns_time.hour=tm_ptr->tm_hour;
                                            sns_time.minute=tm_ptr->tm_min;
                                            sns_time.seconds=tm_ptr->tm_sec;
                                            sns_time.date=tm_ptr->tm_mday;
                                            sns_time.month=tm_ptr->tm_mon +1;
                                            sns_time.year=tm_ptr->tm_year + 1900 -2000;
                                            printf(" Time :%d :%d :%d\n",sns_time.hour,sns_time.minute,sns_time.seconds);
                                        }
                                    }
#endif
                                }
                                break;
                            default:
                                {
                                    printf("Default\n");
                                    break;
                                }

                        }
                    }
                    break;

                case TM_SET_SPI_INTF_PARM:
                    {
                        memcpy(&spi_intf_param_rsp_sts,tm_frame.tm_data,4);
                        if(!spi_intf_param_rsp_sts)
                            printf("spi intf param success\n");
                        else
                            printf("spi intf param failure\n");
                    }
                    break;

                case TM_SET_ETH_INTF_PARM:
                    {
                        memcpy(&eth_intf_param_rsp_sts,tm_frame.tm_data,4);
                        if(!eth_intf_param_rsp_sts)
                            printf("Ethernet intf param success\n");
                        else
                            printf("Ethernet intf param failure\n");
                    }
                    break;
                case TM_SET_CAN_INTF_PARM:
                    {
                        memcpy(&can_intf_param_rsp_sts,tm_frame.tm_data,4);
                        if(!can_intf_param_rsp_sts)
                            printf("CAN intf param success\n");
                        else
                            printf("CAN intf param failure\n");
                    }
                    break;
                case TM_SET_I2C_INTF_PARM:
                    {
                        memcpy(&i2c_intf_param_rsp_sts,tm_frame.tm_data,4);
                        if(!i2c_intf_param_rsp_sts)
                            printf("I2C intf param success\n");
                        else
                            printf("I2C intf param failure\n");
                    }
                    break;
                case TM_SET_USB_INTF_PARM:
                    {
                        memcpy(&usb_intf_param_rsp_sts,tm_frame.tm_data,4);
                        if(!usb_intf_param_rsp_sts)
                            printf("USB intf param success\n");
                        else
                            printf("USB intf param failure\n");
                    }
                    break;
                case TM_SET_UART_INTF_PARM:
                    {
                        memcpy(&uart_intf_param_rsp_sts,tm_frame.tm_data,4);
                        if(!uart_intf_param_rsp_sts)
                            printf("UART intf param success\n");
                        else
                            printf("UART intf param failure\n");
                    }
                    break;
                case TM_GET_SPI_INTF_PARM:
                    {

                        tm_spi_intf_param_dec(tm_frame.tm_data, &spii);
                    }
                    break;
                case TM_GET_ETH_INTF_PARM:
                    {

                        tm_ethernet_init_param_dec(tm_frame.tm_data, &eth);
                    }
                    break;
                case TM_GET_CAN_INTF_PARM:
                    {

                        tm_can_init_param_dec(tm_frame.tm_data, &cis);
                    }
                    break;
                case TM_GET_I2C_INTF_PARM:
                    {

                        tm_i2c_init_param_dec(tm_frame.tm_data, &i2ci);
                    }
                    break;
                case TM_GET_USB_INTF_PARM:
                    {

                        tm_usb_init_param_dec(tm_frame.tm_data, &usbo);
                    }
                    break;
                case TM_GET_UART_INTF_PARM:
                    {

                        tm_uart_init_param_dec(tm_frame.tm_data, &uarti);
                    }
                    break;

                case TM_FTCI:
                case TM_FTFCI:
                case TM_FTSR:
                case TM_FTDS:
                case TM_FTDR:
                    //ft_destination_set(tm_src_id);
                    ft_payload_parser(tm_id,tm_src_id,tm_frame.tm_data,tm_frame.tm_len);
                    break;


                case TM_SET_COMMS_TX_CFG:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        /* Check Set TX configuration configuration response status */

                        if(!sts)
                        {
                            printf("MFCC APP: Set TX config is success \n");
                        }
                        else
                        {
                            printf("MFCC APP: Set TX config failure \n");
                        }

                    }
                    break;

                case TM_GET_COMMS_TX_CFG:
                    {
                        os_memcpy(&get_tx_cfg,tm_frame.tm_data,tm_len);
                        printf("Transmit frequency :%u\n",get_tx_cfg.tx_cfg_freq);
                        printf("Transmit modulation type (0 = BPSK 1 = QPSK 2 = 8PSK):%hu\n",get_tx_cfg.tx_cfg_type);
                        printf("Transmit symbol rate:%d\n",get_tx_cfg.tx_cfg_rate);
                        //printf("RRC rolloff(0 = 0.20 1 = 0.25 2 = 0.35):%hu\n",get_tx_cfg.tx_cfg_rolloff);
                        printf("Transmit power :%f\n", get_tx_cfg.tx_cfg_pout);
                        //printf("Automatic Level Control mode (0 = open-loop 1 = closed-loop):%hu\n", get_tx_cfg.tx_cfg_alc_mode);
                        printf("Enable Reed-Solomon coding (Type: 0 is FALSE or 1 is TRUE):%hu\n", get_tx_cfg.tx_cfg_rs);
                        printf("Enable convolutional coding (Type: 0 is FALSE or 1 is TRUE):%hu\n", get_tx_cfg.tx_cfg_cc);
                        printf("Enable randomization (Type: 0 is FALSE or 1 is TRUE):%hu\n",get_tx_cfg.tx_cfg_rand);
                        printf("Enable CRC checksum (Type: 0 is FALSE or 1 is TRUE):%hu\n", get_tx_cfg.tx_cfg_crc);
                        printf("Active transmitter time after each frame:%hi\n",get_tx_cfg.tx_cfg_idletime);
                        printf("Maximum payload size:%hi\n",get_tx_cfg.tx_cfg_size);
                        //printf("Satellite ID/address:%hi\n",get_tx_cfg.tx_cfg_id);
                        //printf("Encryption key:%s\n",get_tx_cfg.crypto_cfg.crypto_key);
                        //printf("Encrypt frames(Type: 0 is FALSE or 1 is TRUE):%hu\n",get_tx_cfg.crypto_cfg.crypto_encrypt);
                        //printf("Add authentication tag(Type: 0 is FALSE or 1 is TRUE):%hu\n",get_tx_cfg.crypto_cfg.crypto_auth);
                        //printf("PA temperature limit :%hhd\n",get_tx_cfg.tx_cfg_pa_templimit);

                    }
                    break;

                case TM_SET_COMMS_TX_CFG_FREQ:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        /* Check Set TX configuration configuration response status */

                        if(!sts)
                        {
                            printf("MFCC APP: Set TX config frequency is success \n");
                        }
                        else
                        {
                            printf("MFCC APP: Set TX config frequency is failure \n");
                        }

                    }
                    break;

                case TM_GET_COMMS_TX_CFG_FREQ:
                    {
                        os_memcpy(&get_tx_cfg.tx_cfg_freq,tm_frame.tm_data,tm_len);
                        printf("MFCC APP: Transmit frequency : %u, tm_len: %d\n",
                                get_tx_cfg.tx_cfg_freq,tm_len);
                    }
                    break;

                case TM_SET_COMMS_TX_CFG_TYPE:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        /* Check Set TX configuration configuration response status */

                        if(!sts)
                        {
                            printf("MFCC APP: Set TX config type is success \n");
                        }
                        else
                        {
                            printf("MFCC APP: Set TX config type failure \n");
                        }

                    }
                    break;

                case TM_GET_COMMS_TX_CFG_TYPE:
                    {
                        os_memcpy(&get_tx_cfg.tx_cfg_type,tm_frame.tm_data,tm_len);
                        printf("MFCC APP: Transmit modulation type : %hhd\n",
                                get_tx_cfg.tx_cfg_type);

                    }
                    break;

                case TM_SET_COMMS_TX_CFG_RATE:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        /* Check Set TX configuration configuration response status */

                        if(!sts)
                        {
                            printf("MFCC APP: Set TX config rate is success \n");
                        }
                        else
                        {
                            printf("MFCC APP: Set TX config rate failure \n");
                        }

                    }
                    break;

                case TM_GET_COMMS_TX_CFG_RATE:
                    {
                        os_memcpy(&get_tx_cfg.tx_cfg_rate,tm_frame.tm_data,tm_len);
                        printf("MFCC APP: Transmit symbol rate : %d\n",
                                get_tx_cfg.tx_cfg_rate);
                    }
                    break;

                case TM_SET_COMMS_TX_CFG_ROLLOFF:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{

                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            /* Check Set TX configuration configuration response status */

                            if(!sts)
                            {
                                printf("MFCC APP: Set TX config rolloff is success \n");
                            }
                            else
                            {
                                printf("MFCC APP: Set TX config rolloff failure \n");
                            }
                        }
                    }
                    break;

                case TM_GET_COMMS_TX_CFG_ROLLOFF:
                    {
                        os_memcpy(&get_tx_cfg.tx_cfg_rolloff,tm_frame.tm_data,tm_len);
                        printf("MFCC APP: RRC roll-off : %hu\n",
                                get_tx_cfg.tx_cfg_rolloff);

                    }
                    break;

                case TM_SET_COMMS_TX_CFG_POUT:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        /* Check Set TX configuration configuration response status */

                        if(!sts)
                        {
                            printf("MFCC APP: Set TX config pout is success \n");
                        }
                        else
                        {
                            printf("MFCC APP: Set TX config pout failure \n");
                        }

                    }
                    break;

                case TM_GET_COMMS_TX_CFG_POUT:
                    {
                        os_memcpy(&get_tx_cfg.tx_cfg_pout,tm_frame.tm_data,tm_len);
                        printf("MFCC APP: TX POUT : %f\n",
                                get_tx_cfg.tx_cfg_pout);

                    }
                    break;

                case TM_SET_COMMS_TX_CFG_ALC_MODE:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        /* Check Set TX configuration configuration response status */

                        if(!sts)
                        {
                            printf("MFCC APP: Set TX config alc mode is success \n");
                        }
                        else
                        {
                            printf("MFCC APP: Set TX config alc mode failure \n");
                        }

                    }
                    break;

                case TM_GET_COMMS_TX_CFG_ALC_MODE:
                    {
                        os_memcpy(&get_tx_cfg.tx_cfg_alc_mode,tm_frame.tm_data,tm_len);
                        printf("MFCC APP: Automatic Level Control mode (0 = open-loop 1 = closed-loop): %hu\n",
                                get_tx_cfg.tx_cfg_alc_mode);

                    }
                    break;

                case TM_SET_COMMS_TX_CFG_RS:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{

                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            /* Check Set TX configuration configuration response status */

                            if(!sts)
                            {
                                printf("MFCC APP: Set TX config read solomon is success \n");
                            }
                            else
                            {
                                printf("MFCC APP: Set TX config read solomon failure \n");
                            }
                        }
                    }
                    break;

                case TM_GET_COMMS_TX_CFG_RS:
                    {
                        os_memcpy(&get_tx_cfg.tx_cfg_rs,tm_frame.tm_data,tm_len);
                        printf("MFCC APP: Enable Reed-Solomon coding: %hu\n",
                                get_tx_cfg.tx_cfg_rs);

                    }
                    break;

                case TM_SET_COMMS_TX_CFG_CC:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        /* Check Set TX configuration configuration response status */

                        if(!sts)
                        {
                            printf("MFCC APP: Set TX config convolutional is success \n");
                        }
                        else
                        {
                            printf("MFCC APP: Set TX config convolutional failure \n");
                        }

                    }
                    break;

                case TM_GET_COMMS_TX_CFG_CC:
                    {
                        os_memcpy(&get_tx_cfg.tx_cfg_cc,tm_frame.tm_data,tm_len);
                        printf("MFCC APP:Enable convolutional coding: %hu\n",
                                get_tx_cfg.tx_cfg_cc);

                    }
                    break;

                case TM_SET_COMMS_TX_CFG_RAND:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        /* Check Set TX configuration configuration response status */

                        if(!sts)
                        {
                            printf("MFCC APP: Set TX config randomization is success \n");
                        }
                        else
                        {
                            printf("MFCC APP: Set TX config randomization failure \n");
                        }

                    }
                    break;

                case TM_GET_COMMS_TX_CFG_RAND:
                    {
                        os_memcpy(&get_tx_cfg.tx_cfg_rand,tm_frame.tm_data,tm_len);
                        printf("MFCC APP:Enable randomization: %hu\n",
                                get_tx_cfg.tx_cfg_rand);

                    }
                    break;

                case TM_SET_COMMS_TX_CFG_CRC:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{

                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            /* Check Set TX configuration configuration response status */

                            if(!sts)
                            {
                                printf("MFCC APP: Set TX config crc checksum is success \n");
                            }
                            else
                            {
                                printf("MFCC APP: Set TX config crc checksum failure \n");
                            }
                        }
                    }
                    break;

                case TM_GET_COMMS_TX_CFG_CRC:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&get_tx_cfg.tx_cfg_crc,tm_frame.tm_data,tm_len);
                            printf("MFCC APP:Enable CRC checksum: %hu\n",
                                    get_tx_cfg.tx_cfg_crc);
                        }

                    }
                    break;

                case TM_SET_COMMS_TX_CFG_IDLETIME:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        /* Check Set TX configuration configuration response status */

                        if(!sts)
                        {
                            printf("MFCC APP: Set TX config idletime is success \n");
                        }
                        else
                        {
                            printf("MFCC APP: Set TX config idletime failure \n");
                        }

                    }
                    break;

                case TM_GET_COMMS_TX_CFG_IDLETIME:
                    {
                        os_memcpy(&get_tx_cfg.tx_cfg_idletime,tm_frame.tm_data,tm_len);
                        printf("MFCC APP:Active transmitter time after each frame: %hi\n",
                                get_tx_cfg.tx_cfg_idletime);

                    }
                    break;

                case TM_SET_COMMS_TX_CFG_SIZE:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        /* Check Set TX configuration configuration response status */

                        if(!sts)
                        {
                            printf("MFCC APP: Set TX config payload size is success \n");
                        }
                        else
                        {
                            printf("MFCC APP: Set TX config payload size failure \n");
                        }

                    }
                    break;

                case TM_GET_COMMS_TX_CFG_SIZE:
                    {
                        os_memcpy(&get_tx_cfg.tx_cfg_size,tm_frame.tm_data,tm_len);
                        printf("MFCC APP:Maximum payload size: %hi\n",
                                get_tx_cfg.tx_cfg_size);

                    }
                    break;

                case TM_SET_COMMS_TX_CFG_ID:
                    {

                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{

                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            /* Check Set TX configuration configuration response status */

                            if(!sts)
                            {
                                printf("MFCC APP: Set TX config id is success \n");
                            }
                            else
                            {
                                printf("MFCC APP: Set TX config id failure \n");
                            }
                        }
                    }
                    break;

                case TM_GET_COMMS_TX_CFG_ID:
                    {
                        os_memcpy(&get_tx_cfg.tx_cfg_id,tm_frame.tm_data,tm_len);
                        printf("MFCC APP:Satellite ID/address: %hi\n",
                                get_tx_cfg.tx_cfg_id);

                    }
                    break;

                case TM_SET_COMMS_TX_CFG_PA_TEMPLIMIT:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{

                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            /* Check Set TX configuration configuration response status */

                            if(!sts)
                            {
                                printf("MFCC APP: Set TX config temprature limit is success \n");
                            }
                            else
                            {
                                printf("MFCC APP: Set TX config temprature limit failure \n");
                            }
                        }
                    }
                    break;

                case TM_SET_COMMS_ASM_CFG:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        /* Check Set TX configuration configuration response status */

                        if(!sts)
                        {
                            printf("MFCC APP: SET COMMS  ASM AFG SUCCESS \n");
                        }
                        else
                        {
                            printf("MFCC APP: SET COMMS  ASM AFG FAILURE \n");
                        }

                    }
                    break;


                case TM_GET_COMMS_TX_CFG_PA_TEMPLIMIT:
                    {
                        os_memcpy(&get_tx_cfg.tx_cfg_pa_templimit,tm_frame.tm_data,tm_len);
                        printf("MFCC APP: TMP LIMIT : %hhd\n",
                                get_tx_cfg.tx_cfg_pa_templimit);

                    }
                    break;

                case TM_GET_COMMS_TX_CFG_FRAMES:
                    {
                        os_memcpy(&get_tx_cfg.tx_cfg_frames,tm_frame.tm_data,tm_len);
                        printf("MFCC APP: TX CFG FRAMES: %d\n",
                                get_tx_cfg.tx_cfg_frames);

                    }
                    break;

                case TM_GET_COMMS_TX_CFG_PWR_FWD:
                    {
                        os_memcpy(&get_tx_cfg.tx_cfg_pwr_fwd,tm_frame.tm_data,tm_len);
                        printf("MFCC APP: Measured forward power: %f\n",
                                get_tx_cfg.tx_cfg_pwr_fwd);

                    }
                    break;

                case TM_GET_COMMS_TX_CFG_PWR_RFL:
                    {
                        os_memcpy(&get_tx_cfg.tx_cfg_pwr_rfl,tm_frame.tm_data,tm_len);
                        printf("MFCC APP: Measured reflected power: %f\n",
                                get_tx_cfg.tx_cfg_pwr_rfl);

                    }
                    break;

                case TM_SET_COMMS_RX_CFG:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                        {
                            printf("MFCC APP: Set RX config is success \n");
                        }
                        else
                        {
                            printf("MFCC APP:Set RX config failure \n");
                        }
                    }
                    break;

                case TM_GET_COMMS_RX_CFG:
                    {
                        os_memcpy(&get_rx_cfg,tm_frame.tm_data,tm_len);
                        printf("Receive frequency :%u\n",get_rx_cfg.rx_cfg_freq);
                        printf("Receive modulation type (0 = BPSK 1 = QPSK) :%hu\n",get_rx_cfg.rx_cfg_type);
                        printf("Receive symbol rate :%d\n",get_rx_cfg.rx_cfg_rate);
                        //printf("RRC roll-off (0 = 0.20 1 = 0.25 2 = 0.35) :%hu\n",get_rx_cfg.rx_cfg_rolloff);
                        //printf("Enable AFC :%hu\n",get_rx_cfg.afc_cfg.rx_cfg_afc_enable);
                        //printf("AFC adjustment range :%d\n",get_rx_cfg.afc_cfg.rx_cfg_afc_range);
                        printf("Enable Reed-Solomon coding (Type: 0 is FALSE or 1 is TRUE):%hu\n",get_rx_cfg.rx_cfg_rs);
                        printf("Enable convolutional coding (Type: 0 is FALSE or 1 is TRUE):%hu\n",get_rx_cfg.rx_cfg_cc);
                        printf("Enable randomization (Type: 0 is FALSE or 1 is TRUE): %hu\n",get_rx_cfg.rx_cfg_rand);
                        printf("Enable CRC checksum (Type: 0 is FALSE or 1 is TRUE): %hu\n",get_rx_cfg.rx_cfg_crc);
                        printf("Maximum payload size :%hu\n",get_rx_cfg.rx_cfg_size);
                        //printf("Satellite ID/address:%hu\n",get_rx_cfg.rx_cfg_id);
                        //                  printf("RX Enable AFC(Type: 0 is FALSE or 1 is TRUE):%c\n",get_rx_afc_cfg.rx_cfg_afc_enable);
                        //                  printf("RX AFC adjustment range:%u\n",get_rx_afc_cfg.rx_cfg_afc_range);
                        //printf("Decryption key:%s\n",get_rx_cfg.crypto_cfg.crypto_key);
                        //printf("Decrypt frames(Type: 0 is FALSE or 1 is TRUE):%hu\n",get_rx_cfg.crypto_cfg.crypto_decrypt);
                        //printf("Verify authentication tag(Type: 0 is FALSE or 1 is TRUE):%hu\n",get_rx_cfg.crypto_cfg.crypto_auth);

                    }
                    break;

                case TM_SET_COMMS_RX_CFG_FREQ:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                        {
                            printf("MFCC APP: Set RX config frequency is success \n");
                        }
                        else
                        {
                            printf("MFCC APP:Set RX config frequency failure \n");
                        }
                    }
                    break;

                case TM_GET_COMMS_RX_CFG_FREQ:
                    {
                        os_memcpy(&get_rx_cfg.rx_cfg_freq,tm_frame.tm_data,tm_len);
                        printf("MFCC APP: Receive frequency : %u\n",
                                get_rx_cfg.rx_cfg_freq);
                    }
                    break;

                case TM_SET_COMMS_RX_CFG_TYPE:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                        {
                            printf("MFCC APP: Set RX config type is success \n");
                        }
                        else
                        {
                            printf("MFCC APP:Set RX config type failure \n");
                        }
                    }
                    break;

                case TM_GET_COMMS_RX_CFG_TYPE:
                    {
                        os_memcpy(&get_rx_cfg.rx_cfg_type,tm_frame.tm_data,tm_len);
                        printf("MFCC APP:Receive modulation type (0 = BPSK 1 = QPSK): %hu\n",
                                get_rx_cfg.rx_cfg_type);
                    }
                    break;


                case TM_SET_COMMS_RX_CFG_RATE:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                        {
                            printf("MFCC APP: Set RX config rate is success \n");
                        }
                        else
                        {
                            printf("MFCC APP:Set RX config rate failure \n");
                        }
                    }
                    break;

                case TM_GET_COMMS_RX_CFG_RATE:
                    {
                        os_memcpy(&get_rx_cfg.rx_cfg_rate,tm_frame.tm_data,tm_len);
                        printf("MFCC APP:Receive symbol rate: %d\n",
                                get_rx_cfg.rx_cfg_rate);
                    }
                    break;

                case TM_SET_COMMS_RX_CFG_ROLLOFF:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(!sts)
                            {
                                printf("MFCC APP: Set RX config rolloff is success \n");
                            }
                            else
                            {
                                printf("MFCC APP:Set RX config rolloff failure \n");
                            }
                        }
                    }
                    break;

                case TM_GET_COMMS_RX_CFG_ROLLOFF:

                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&get_rx_cfg.rx_cfg_rolloff,tm_frame.tm_data,tm_len);
                            printf("MFCC APP: RRC roll-off : %hu\n",
                                    get_rx_cfg.rx_cfg_rolloff);
                        }
                    }
                    break;


                case TM_SET_COMMS_RX_CFG_RS:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(!sts)
                            {
                                printf("MFCC APP: Set RX config reed solomon is success \n");
                            }
                            else
                            {
                                printf("MFCC APP:Set RX config reed solomon failure \n");
                            }
                        }
                    }
                    break;

                case TM_GET_COMMS_RX_CFG_RS:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&get_rx_cfg.rx_cfg_rs,tm_frame.tm_data,tm_len);
                            printf("MFCC APP: Read solomon : %hu\n",
                                    get_rx_cfg.rx_cfg_rs);
                        }
                    }
                    break;

                case TM_SET_COMMS_RX_CFG_CC:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                        {
                            printf("MFCC APP: Set RX config convolutional is success \n");
                        }
                        else
                        {
                            printf("MFCC APP:Set RX config convolutional failure \n");
                        }
                    }
                    break;

                case TM_GET_COMMS_RX_CFG_CC:
                    {
                        os_memcpy(&get_rx_cfg.rx_cfg_cc,tm_frame.tm_data,tm_len);
                        printf("MFCC APP: Enable cc : %hu\n",
                                get_rx_cfg.rx_cfg_cc);
                    }
                    break;

                case TM_SET_COMMS_RX_CFG_RAND:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                        {
                            printf("MFCC APP: Set RX config enable randomization is success \n");
                        }
                        else
                        {
                            printf("MFCC APP:Set RX config enable randomization failure \n");
                        }
                    }
                    break;

                case TM_GET_COMMS_RX_CFG_RAND:
                    {
                        os_memcpy(&get_rx_cfg.rx_cfg_rand,tm_frame.tm_data,tm_len);
                        printf("MFCC APP: Enable rand : %hu\n",
                                get_rx_cfg.rx_cfg_rand);
                    }
                    break;

                case TM_SET_COMMS_RX_CFG_CRC:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{

                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(!sts)
                            {
                                printf("MFCC APP: Set RX config crc checksum is success \n");
                            }
                            else
                            {
                                printf("MFCC APP:Set RX config crc checksum failure \n");
                            }
                        }

                    }
                    break;

                case TM_GET_COMMS_RX_CFG_CRC:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&get_rx_cfg.rx_cfg_crc,tm_frame.tm_data,tm_len);
                            printf("MFCC APP: crc checksum : %hu\n",
                                    get_rx_cfg.rx_cfg_crc);
                        }
                    }
                    break;

                case TM_SET_COMMS_RX_CFG_SIZE:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                        {
                            printf("MFCC APP: Set RX config payload size is success \n");
                        }
                        else
                        {
                            printf("MFCC APP:Set RX config payload size failure \n");
                        }
                    }
                    break;

                case TM_GET_COMMS_RX_CFG_SIZE:
                    {
                        os_memcpy(&get_rx_cfg.rx_cfg_size,tm_frame.tm_data,tm_len);
                        printf("MFCC APP: RRC roll-off : %hu\n",
                                get_rx_cfg.rx_cfg_size);
                    }
                    break;

                case TM_SET_COMMS_RX_CFG_ID:
                    {

                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(!sts)
                            {
                                printf("MFCC APP: Set RX config satellite id is success \n");
                            }
                            else
                            {
                                printf("MFCC APP:Set RX config satellite id failure \n");
                            }

                        }
                    }
                    break;

                case TM_GET_COMMS_RX_CFG_ID:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&get_rx_cfg.rx_cfg_id,tm_frame.tm_data,tm_len);
                            printf("MFCC APP: satellite ID/add : %hu\n",
                                    get_rx_cfg.rx_cfg_id);

                        }
                    }
                    break;

                case TM_GET_COMMS_RX_CFG_FRAMES:
                    {
                        os_memcpy(&get_rx_cfg.rx_cfg_frames,tm_frame.tm_data,tm_len);
                        printf("MFCC APP: RX frames : %d\n",
                                get_rx_cfg.rx_cfg_frames);
                    }
                    break;

                case TM_GET_COMMS_RX_CFG_DETECTED:
                    {
                        os_memcpy(&get_rx_cfg.rx_cfg_detected,tm_frame.tm_data,tm_len);
                        printf("MFCC APP: Detected frames : %hhd\n",
                                get_rx_cfg.rx_cfg_detected);
                    }
                    break;

                case TM_GET_COMMS_RX_CFG_RSSI:
                    {
                        float RSSI[4]= {0};
                        os_memcpy(&RSSI[0],tm_frame.tm_data,tm_len);
                        printf("MFCC APP: Measured RSSI ch 0: %f\n", RSSI[0]);
                        printf("MFCC APP: Avg Measured RSSI ch 0: %f\n", RSSI[1]);
                        printf("MFCC APP: Measured RSSI ch 1: %f\n", RSSI[2]);
                        printf("MFCC APP: Avg Measured RSSI ch 1: %f\n", RSSI[3]);
                    }
                    break;

                case TM_GET_COMMS_RX_CFG_FREQERR:
                    {
                        int32_t doppler[2]= {0};
                        os_memcpy(&doppler[0],tm_frame.tm_data,tm_len);
                        printf("MFCC APP: Doppler freq : %d\n", doppler[0]);
                        printf("MFCC APP: Doppler freq : %d\n", doppler[1]);
                    }
                    break;

                case TM_GET_COMMS_RX_CFG_SYMERR:
                    {
                        os_memcpy(&get_rx_cfg.rx_cfg_symerr,tm_frame.tm_data,tm_len);
                        printf("MFCC APP: Est sym_rate error : %f\n",
                                get_rx_cfg.rx_cfg_symerr);
                    }
                    break;

                case TM_GET_COMMS_RX_CFG_EBN0:
                    {
                        os_memcpy(&get_rx_cfg.rx_cfg_ebn0,tm_frame.tm_data,tm_len);
                        printf("MFCC APP: Est Ed/NO : %f\n",
                                get_rx_cfg.rx_cfg_ebn0);
                    }
                    break;

                case TM_GET_COMMS_RX_CFG_CARRIER_LOCK:
                    {
                        os_memcpy(&get_rx_cfg.rx_cfg_carrier_lock,tm_frame.tm_data,tm_len);
                        printf("MFCC APP: carrier_lock : %hhd\n",
                                get_rx_cfg.rx_cfg_carrier_lock);
                    }
                    break;

                case TM_GET_COMMS_RX_FRAME_LOCK:
                    {
                        os_memcpy(&get_rx_cfg.rx_frame_lock,tm_frame.tm_data,tm_len);
                        printf("MFCC APP: Frame lock : %hhd\n",
                                get_rx_cfg.rx_frame_lock);
                    }
                    break;

                case TM_SET_COMMS_SYS_CFG:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(!sts)
                            {
                                printf("MFCC APP: Set SYS config is success \n");
                            }
                            else
                            {
                                printf("MFCC APP: Set SYS config failure \n");
                            }
                        }
                    }
                    break;

                case TM_GET_COMMS_SYS_CFG:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{

                            os_memcpy(&get_sys_cfg,tm_frame.tm_data,tm_len);
                            printf("System name :%s\n",get_sys_cfg.sys_name);
                            printf("System serial :%d\n",get_sys_cfg.boot_cfg.sys_serial);
                            printf("System version :%d\n",get_sys_cfg.boot_cfg.sys_sw_version);                                
                            printf("Number of times the system was booted:%d\n",get_sys_cfg.boot_cfg.sys_bootcount);                
                            printf("GWDT timer reset value:%d\n",get_sys_cfg.gwdt_cfg.sys_gwdt_init);
                            printf("GWDT counter:%d\n",get_sys_cfg.gwdt_cfg.sys_gwdt_counter);
                            printf("GWDT reset:%d\n",get_sys_cfg.gwdt_cfg.sys_gwdt_reset);
                            printf("CSP address of the device :%hhd\n",get_sys_cfg.csp_cfg.sys_csp_address);
                            printf("CSP routing table in CIDR notation :%s\n",get_sys_cfg.csp_cfg.sys_csp_routes);
                            printf("CAN-bus bitrate:%d\n",get_sys_cfg.can_cfg.sys_can_rate);
                            printf("Accept all CSP CAN-frames :%hu\n",get_sys_cfg.can_cfg.sys_can_promisc);                
                            printf("UART baudrate :%d\n",get_sys_cfg.uart_cfg.sys_uart_rate);
                            printf("UART multidrop mode:%hu\n",get_sys_cfg.uart_cfg.sys_uart_multidrop);
                            printf("IP stack enable :%hu\n",get_sys_cfg.net_cfg.sys_net_enable);
                            printf("Ethernet IP address :%s\n",get_sys_cfg.net_cfg.sys_net_en_ip);
                            printf("Ethernet network prefix bits :%hhd\n",get_sys_cfg.net_cfg.sys_net_en_prefix);
                            printf("Ethernet gateway IP address :%s\n",get_sys_cfg.net_cfg.sys_net_en_gw);
                            printf("Spacelink IP address :%s\n",get_sys_cfg.net_cfg.sys_net_rf_ip);
                            printf("Spacelink network prefix bits :%hhd\n",get_sys_cfg.net_cfg.sys_net_rf_prefix);
                            printf("Spacelink gateway IP address :%s\n",get_sys_cfg.net_cfg.sys_net_rf_gw);
                        }
                    }
                    break;
                case TM_SET_COMMS_ERR_CFG:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{

                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(!sts)
                            {
                                printf("MFCC APP: SET COMMS ERROR CFG IS SUCCESS \n");
                            }
                            else
                            {
                                printf("MFCC APP: SET COMMS ERROR CFG IS FAILURE \n");
                            }
                        }
                    }
                    break;

                case TM_GET_COMMS_BOOT_ACTIVATE:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&get_sys_cfg.sys_name,tm_frame.tm_data,tm_len);
                            printf("MFCC APP: system String name : %s\n",
                                    get_sys_cfg.sys_name);
                        }
                    }
                    break;

                case TM_SET_COMMS_TX_CFG_CRYPTO:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{

                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(!sts)
                            {
                                printf("MFCC APP: Set tx crypto config is success \n");
                            }
                            else
                            {
                                printf("MFCC APP: Set tx crypto config failure \n");
                            }
                        }
                    }
                    break;

                case TM_GET_COMMS_TX_CFG_CRYPTO:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&get_tx_crypto_cfg,tm_frame.tm_data,tm_len);
                            printf("MFCC APP: tx crypto key : %s\n",
                                    get_tx_crypto_cfg.crypto_key);
                            printf("MFCC APP: tx crypto encrypt : %hu\n",
                                    get_tx_crypto_cfg.crypto_encrypt);
                            printf("MFCC APP: tx crypto authentication : %hu\n",
                                    get_tx_crypto_cfg.crypto_auth);
                        }
                    }
                    break;
                case TM_SET_COMMS_RX_CFG_AFC:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                        {
                            printf("MFCC APP: Set rx afc config is success \n");
                        }
                        else
                        {
                            printf("MFCC APP: Set rx afc config failure \n");
                        }
                    }
                    break;

                case TM_GET_COMMS_RX_CFG_AFC:
                    {
                        os_memcpy(&get_rx_afc_cfg,tm_frame.tm_data,tm_len);
                        printf("MFCC APP: rx afc enable : %hu\n",
                                get_rx_afc_cfg.rx_cfg_afc_enable);
                        printf("MFCC APP: rx afc range : %d\n",
                                get_rx_afc_cfg.rx_cfg_afc_range);

                    }
                    break;
                case TM_SET_COMMS_RX_CFG_CRYPTO:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(!sts)
                            {
                                printf("MFCC APP: Set rx crypto config is success \n");
                            }
                            else
                            {
                                printf("MFCC APP: Set rx crypto config failure \n");
                            }
                        }
                    }
                    break;

                case TM_SET_COMMS_BCH_CFG:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                        {
                            printf("MFCC APP: SET COMMS BCH CFG IS SUCCESS \n");
                        }
                        else
                        {
                            printf("MFCC APP: SET COMMS BCH CFG IS FAILURE \n");
                        }
                    }
                    break;

                case TM_COMMS_RX_SEL_CFG:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                        {
                            printf("MFCC APP: SET COMMS RX RCV CH EN IS SUCCESS \n");
                        }
                        else if(sts == 2)
                        {
                            printf("MFCC APP: SET COMMS RX RCV CH EN IS FAILURE \n");
                        }
                    }  
                    break;

                case TM_COMMS_RX_SEL_DSB:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                        {
                            printf("MFCC APP: SET COMMS RX RCV CH DIS IS SUCCESS \n");
                        }
                        else if(sts == 2)
                        {
                            printf("MFCC APP: SET COMMS RX RCV CH DIS IS FAILURE \n");
                        }
                    }
                    break;

                case TM_COMMS_SBAND_BEACON_CFG:
                    {

                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{

                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(!sts)
                            {
                                printf("MFCC APP: SBAND BEACON CFG IS SUCCESS \n");
                            }
                            else
                            {
                                printf("MFCC APP: SBAND BEACON CFG IS FAIURE \n");
                            }

                        }
                    }
                    break;

                case TM_COMMS_SBAND_BEACON_START:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(sts)
                        {
                            printf("MFCC APP: SBAND BEACON START IS SUCCESS \n");
                        }
                        else
                        {
                            printf("MFCC APP: SBAND BEACON START IS FAILURE \n");
                        }
                    }
                    break;

                case TM_COMMS_SBAND_BEACON_STOP :
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(sts)
                        {
                            printf("MFCC APP: SBAND BEACON STOP IS SUCCESS \n");
                        }
                        else
                        {
                            printf("MFCC APP: SBAND BEACON STOP IS FAILURE \n");
                        }
                    }
                    break;


                case TM_GET_COMMS_RX_CFG_CRYPTO:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&get_rx_crypto_cfg,tm_frame.tm_data,tm_len);
                            printf("MFCC APP: rx crypto key : %s\n",
                                    get_rx_crypto_cfg.crypto_key);
                            printf("MFCC APP: rx crypto decrypt : %hu\n",
                                    get_rx_crypto_cfg.crypto_decrypt);
                            printf("MFCC APP: rx crypto authentication : %hu\n",
                                    get_rx_crypto_cfg.crypto_auth);
                        }
                    }
                    break;

                case TM_SET_COMMS_BOOT_CFG:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(!sts)
                            {
                                printf("MFCC APP: Set boot config is success \n");
                            }
                            else
                            {
                                printf("MFCC APP: Set boot config failure \n");
                            }
                        }
                    }
                    break;

                case TM_GET_COMMS_BOOT_CFG:
                    {
                        os_memcpy(&get_boot_cfg,tm_frame.tm_data,tm_len);
                        printf("MFCC APP: Boot Bootcount : %d\n",
                                get_boot_cfg.sys_bootcount);

                    }
                    break;

                case TM_SET_COMMS_GWDT_CFG:
                    {

                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(!sts)
                            {
                                printf("MFCC APP: Set gwdt config is success \n");
                            }
                            else
                            {
                                printf("MFCC APP: Set gwdt config failure \n");
                            }
                        }
                    }
                    break;

                case TM_GET_COMMS_GWDT_CFG:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&get_gwdt_cfg,tm_frame.tm_data,tm_len);
                            printf("MFCC APP: GWDT init : %d\n",
                                    get_gwdt_cfg.sys_gwdt_init);
                            printf("MFCC APP: GWDT counter : %d\n",
                                    get_gwdt_cfg.sys_gwdt_counter);
                            printf("MFCC APP: GWDT reset : %d\n",
                                    get_gwdt_cfg.sys_gwdt_reset);
                        }
                    }
                    break;
                case TM_SET_COMMS_CAN_CFG:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(!sts)
                            {
                                printf("MFCC APP: Set can config is success \n");
                            }
                            else
                            {
                                printf("MFCC APP: Set can config failure \n");
                            }
                        }
                    }
                    break;

                case TM_GET_COMMS_CAN_CFG:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&get_can_cfg,tm_frame.tm_data,tm_len);
                            printf("MFCC APP: CAN rate : %d\n",
                                    get_can_cfg.sys_can_rate);
                            printf("MFCC APP: CAN promisc : %hu\n",
                                    get_can_cfg.sys_can_promisc);
                        }
                    }
                    break;

                case TM_SET_COMMS_UART_CFG:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(!sts)
                            {
                                printf("MFCC APP: Set uart config is success \n");
                            }
                            else
                            {
                                printf("MFCC APP: Set uart config failure \n");
                            }
                        }
                    }
                    break;

                case TM_GET_COMMS_UART_CFG:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&get_uart_cfg,tm_frame.tm_data,tm_len);
                            printf("MFCC APP: UART rate : %d\n",
                                    get_uart_cfg.sys_uart_rate);
                            printf("MFCC APP: UART multidrop : %hu\n",
                                    get_uart_cfg.sys_uart_multidrop);
                        }
                    }
                    break;
                case TM_SET_COMMS_CSP_CFG:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(!sts)
                            {
                                printf("MFCC APP: Set csp config is success \n");
                            }
                            else
                            {
                                printf("MFCC APP: Set csp config failure \n");
                            }
                        }
                    }
                    break;

                case TM_GET_COMMS_CSP_CFG:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&get_csp_cfg,tm_frame.tm_data,tm_len);
                            printf("MFCC APP: CSP address : %hhd\n",
                                    get_csp_cfg.sys_csp_address);
                            printf("MFCC APP: CSP routes : %s\n",
                                    get_csp_cfg.sys_csp_routes);
                        }
                    }
                    break;
                case TM_SET_COMMS_NET_CFG:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(!sts)
                            {
                                printf("MFCC APP: Set Net config is success \n");
                            }
                            else
                            {
                                printf("MFCC APP: Set Net config failure \n");
                            }
                        }
                    }
                    break;

                case TM_GET_COMMS_NET_CFG:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&get_net_cfg,tm_frame.tm_data,tm_len);
                            printf("MFCC APP: Net enable : %hu\n",
                                    get_net_cfg.sys_net_enable);
                            printf("MFCC APP: Net en IP : %s\n",
                                    get_net_cfg.sys_net_en_ip);
                            printf("MFCC APP: Net en prefix : %hhd\n",
                                    get_net_cfg.sys_net_en_prefix);
                            printf("MFCC APP: Net en gw : %s\n",
                                    get_net_cfg.sys_net_en_gw);
                            printf("MFCC APP: Net rf IP : %s\n",
                                    get_net_cfg.sys_net_rf_ip);
                            printf("MFCC APP: Net rf prefix : %hhd\n",
                                    get_net_cfg.sys_net_rf_prefix);
                            printf("MFCC APP: Net rf gw : %s\n",
                                    get_net_cfg.sys_net_rf_gw);
                        }
                    }
                    break;

                case TM_GET_COMMS_TM_INFO:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&get_tm_prop,tm_frame.tm_data,tm_len);

                            printf("MFCC APP: temp_mcu: %hi\n",
                                    get_tm_prop.temp_mcu);
                            printf("MFCC APP: temp_fpga: %hi\n",
                                    get_tm_prop.temp_fpga);
                            printf("MFCC APP: temp_xcvr  : %hi\n",
                                    get_tm_prop.temp_xcvr);
                            printf("MFCC APP: volt vint: %f\n",
                                    (float)get_tm_prop.volt_vin);
                            printf("MFCC APP: volt vaux: %f\n",
                                    (float)get_tm_prop.volt_3v3);
                            printf("MFCC APP: volt vbram : %f\n",
                                    (float)get_tm_prop.volt_1v8);
                            printf("MFCC APP: volt vpint: %f\n",
                                    (float)get_tm_prop.volt_1v0);
                            printf("MFCC APP:.volt vpaux: %f\n",
                                    (float)get_tm_prop.volt_pa);
                            printf("MFCC APP: volt vpdro  : %f\n",
                                    (float)get_tm_prop.rsvd);
                        }
                        else {
                            os_memcpy(&get_tm_prop,tm_frame.tm_data,tm_len);
                            printf("MFCC APP: temp_psu  : %hi\n",
                                    get_tm_prop.temp_psu);
                            printf("MFCC APP: temp_mcu: %hi\n",
                                    get_tm_prop.temp_mcu);
                            printf("MFCC APP: temp_fpga: %hi\n",
                                    get_tm_prop.temp_fpga);
                            printf("MFCC APP: temp_xcvr  : %hi\n",
                                    get_tm_prop.temp_xcvr);
                            printf("MFCC APP:temp_lna: %hi\n",
                                    get_tm_prop.temp_lna);
                            printf("MFCC APP: temp_pa: %hi\n",
                                    get_tm_prop.temp_pa);
                            printf("MFCC APP: volt_vin : %hu\n",
                                    get_tm_prop.volt_vin);
                            printf("MFCC APP: volt_3v3: %hu\n",
                                    get_tm_prop.volt_3v3);
                            printf("MFCC APP:.volt_1v8: %hu\n",
                                    get_tm_prop.volt_1v8);
                            printf("MFCC APP: volt_1v0  : %hu\n",
                                    get_tm_prop.volt_1v0);
                            printf("MFCC APP: volt_pa: %hu\n",
                                    get_tm_prop.volt_pa);
                            printf("MFCC APP: cur_vin: %hi\n",
                                    get_tm_prop.cur_vin);
                            printf("MFCC APP:cur_3v3  : %hi\n",
                                    get_tm_prop.cur_3v3);
                            printf("MFCC APP: cur_1v8: %hi\n",
                                    get_tm_prop.cur_1v8);
                            printf("MFCC APP: cur_1v0: %hi\n",
                                    get_tm_prop.cur_1v0);
                            printf("MFCC APP: cur_pa  : %hi\n",
                                    get_tm_prop.cur_pa);
                            printf("MFCC APP: power_vin: %hi\n",
                                    get_tm_prop.power_vin);
                            printf("MFCC APP: power_3v3: %hu\n",
                                    get_tm_prop.power_3v3);
                            printf("MFCC APP: power_1v8: %hu\n",
                                    get_tm_prop.power_1v8);
                            printf("MFCC APP: power_1v0: %hu\n",
                                    get_tm_prop.power_1v0);
                            printf("MFCC APP: power_pa: %hu\n",
                                    get_tm_prop.power_pa);
                        }
                    }
                    break;

                case TM_GET_COMMS_RX_TM_INFO:
                    {	
                        if(radio_mod_id == 3)
                        {
                            os_memcpy(&get_rx_tm_xlink,tm_frame.tm_data,tm_len);
                            printf("MFCC APP: Received RX Channel NO : %f\n",
                                    get_rx_tm_xlink.rx_cfg_ebn0);
                            printf("MFCC APP: RX frames : %d\n",
                                    get_rx_tm_xlink.rx_cfg_frames);
                            printf("MFCC APP: RX detected : %d\n",
                                    get_rx_tm_xlink.rx_cfg_detected);
                            printf("MFCC APP: RX rssi : %lf\n",
                                    get_rx_tm_xlink.rx_cfg_rssi);
                            printf("MFCC APP: RX avg rssi : %lf\n",
                                    get_rx_tm_xlink.rx_avg_rssi);
                            printf("MFCC APP: RX freqerr : %lf\n",
                                    get_rx_tm_xlink.rx_cfg_freqerr);
                            printf("MFCC APP: RX carrier lock : %hu\n",
                                    get_rx_tm_xlink.rx_cfg_carrier_lock);
                            printf("MFCC APP: RX frame lock : %hu\n",
                                    get_rx_tm_xlink.rx_frame_lock);
                            printf("MFCC APP: RX frame lock : %lf\n",
                                    get_rx_tm_xlink.rx_cfg_symerr);
                            printf("MFCC APP: RX sir min : %u\n",
                                    get_rx_tm_xlink.rx_sir_min);
                            printf("MFCC APP: RX sir max : %u\n",
                                    get_rx_tm_xlink.rx_sir_max);
                            printf("MFCC APP: RX bch block cnt : %u\n",
                                    get_rx_tm_xlink.rx_bch_block_cnt);
                            printf("MFCC APP: RX bch err cnt : %u\n",
                                    get_rx_tm_xlink.rx_bch_err_cnt);

                        }
                        else{
                            os_memcpy(&get_rx_tm,tm_frame.tm_data,tm_len);
                            printf("MFCC APP: RX frames : %d\n",
                                    get_rx_tm.rx_cfg_frames);
                            printf("MFCC APP: RX detected : %d\n",
                                    get_rx_tm.rx_cfg_detected);
                            printf("MFCC APP: RX rssi : %lf\n",
                                    get_rx_tm.rx_cfg_rssi);
                            printf("MFCC APP: RX freqerr : %lf\n",
                                    get_rx_tm.rx_cfg_freqerr);
                            printf("MFCC APP: RX symerr : %lf\n",
                                    get_rx_tm.rx_cfg_symerr);
                            printf("MFCC APP: RX ebn0 : %lf\n",
                                    get_rx_tm.rx_cfg_ebn0);
                            printf("MFCC APP: RX carrier lock : %u\n",
                                    get_rx_tm.rx_cfg_carrier_lock);
                            printf("MFCC APP: RX frame lock : %u\n",
                                    get_rx_tm.rx_frame_lock);
                        }
                    }
                    break;

                case TM_GET_COMMS_TX_TM_INFO:
                    {
                        os_memcpy(&get_tx_tm,tm_frame.tm_data,tm_len);
                        printf("MFCC APP: TX frames  : %d\n",
                                get_tx_tm.tx_cfg_frames);
                        printf("MFCC APP: TX pwr rfl: %lf\n",
                                get_tx_tm.tx_cfg_pwr_rfl);

                    }
                    break;

                case TM_GET_COMMS_CSP_TM_INFO:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&get_csp_tm,tm_frame.tm_data,tm_len);

                            printf("\n I1_mtu              : %u",get_csp_tm.csp_int[0].mtu              );
                            printf("\n I1_tx               : %u",get_csp_tm.csp_int[0].tx               );
                            printf("\n I1_rx               : %u",get_csp_tm.csp_int[0].rx               );
                            printf("\n I1_tx_error         : %u",get_csp_tm.csp_int[0].tx_error         );
                            printf("\n I1_rx_error         : %u",get_csp_tm.csp_int[0].rx_error         );
                            printf("\n I1_drop             : %u",get_csp_tm.csp_int[0].drop             );
                            printf("\n I1_autherr          : %u",get_csp_tm.csp_int[0].autherr          );
                            printf("\n I1_frame            : %u",get_csp_tm.csp_int[0].frame            );
                            printf("\n I1_txbytes          : %u",get_csp_tm.csp_int[0].txbytes          );
                            printf("\n I1_rxbytes          : %u",get_csp_tm.csp_int[0].rxbytes          );
                            printf("\n I2_mtu              : %u",get_csp_tm.csp_int[1].mtu              );
                            printf("\n I2_tx               : %u",get_csp_tm.csp_int[1].tx               );
                            printf("\n I2_rx               : %u",get_csp_tm.csp_int[1].rx               );
                            printf("\n I2_tx_error         : %u",get_csp_tm.csp_int[1].tx_error         );
                            printf("\n I2_rx_error         : %u",get_csp_tm.csp_int[1].rx_error         );
                            printf("\n I2_drop             : %u",get_csp_tm.csp_int[1].drop             );
                            printf("\n I2_autherr          : %u",get_csp_tm.csp_int[1].autherr          );
                            printf("\n I2_frame            : %u",get_csp_tm.csp_int[1].frame            );
                            printf("\n I2_txbytes          : %u",get_csp_tm.csp_int[1].txbytes          );
                            printf("\n I2_rxbytes          : %u",get_csp_tm.csp_int[1].rxbytes          );
                            printf("\n I3_mtu              : %u",get_csp_tm.csp_int[2].mtu              );
                            printf("\n I3_tx               : %u",get_csp_tm.csp_int[2].tx               );
                            printf("\n I3_rx               : %u",get_csp_tm.csp_int[2].rx               );
                            printf("\n I3_tx_error         : %u",get_csp_tm.csp_int[2].tx_error         );
                            printf("\n I3_rx_error         : %u",get_csp_tm.csp_int[2].rx_error         );
                            printf("\n I3_drop             : %u",get_csp_tm.csp_int[2].drop             );
                            printf("\n I3_autherr          : %u",get_csp_tm.csp_int[2].autherr          );
                            printf("\n I3_frame            : %u",get_csp_tm.csp_int[2].frame            );
                            printf("\n I3_txbytes          : %u",get_csp_tm.csp_int[2].txbytes          );
                            printf("\n I3_rxbytes          : %u",get_csp_tm.csp_int[2].rxbytes          );
                            printf("\n csp_err_nomem    : %u",get_csp_tm.csp_err_nomem    );
                            printf("\n csp_err_inval    : %u",get_csp_tm.csp_err_inval    );
                            printf("\n csp_err_timedout : %u",get_csp_tm.csp_err_timedout );
                            printf("\n csp_err_used     : %u",get_csp_tm.csp_err_used     );
                            printf("\n csp_err_notsup   : %u",get_csp_tm.csp_err_notsup   );
                            printf("\n csp_err_busy     : %u",get_csp_tm.csp_err_busy     );
                            printf("\n csp_err_already  : %u",get_csp_tm.csp_err_already  );
                            printf("\n csp_err_reset    : %u",get_csp_tm.csp_err_reset    );
                            printf("\n csp_err_nobufs   : %u",get_csp_tm.csp_err_nobufs   );
                            printf("\n csp_err_tx       : %u",get_csp_tm.csp_err_tx       );
                            printf("\n csp_err_driver   : %u",get_csp_tm.csp_err_driver   );
                            printf("\n csp_err_again    : %u",get_csp_tm.csp_err_again    );
                            printf("\n csp_err_hmac     : %u",get_csp_tm.csp_err_hmac     );
                            printf("\n csp_err_xtea     : %u",get_csp_tm.csp_err_xtea     );
                            printf("\n csp_err_crc32    : %u",get_csp_tm.csp_err_crc32    );
                            printf("\n csp_err_sfp      : %u",get_csp_tm.csp_err_sfp      );
                        }
                    }
                    break;

                case TM_GET_COMMS_ASM_CFG:
                    {
                        uint8 ASM_START;
                        os_memcpy(&ASM_START,tm_frame.tm_data,tm_len);
                        printf("\n\r ASM START value is received \r\n");

                        printf("Xmt ASM at FrmStart 1: %d\n",ASM_START);

                    }
                    break;

                case TM_GET_COMMS_BCH_CFG:
                    {

                        os_memcpy(&rcv_counter,tm_frame.tm_data,tm_len);
                        printf("\n\r  BCH Parameter is received \r\n");
                        printf("MFCC APP:bch decoder mode %hu\n",rcv_counter.BchDec);
                        printf("MFCC APP:bch decoder ERR %hu\n",rcv_counter.AccBchErr);
                        printf("MFCC APP:bch decoder CNT mode %hu\n",rcv_counter.BchCountMode);

                    }
                    break;

                case TM_GET_COMMS_BEACON_CFG:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(!sts)
                            {
                                printf("MFCC APP: COMMS LOAD config is success \n");
                            }
                            else
                            {
                                printf("MFCC APP: COMMS LOAD config failure \n");
                            }
                        }
                    }
                    break;

                case TM_COMMS_LOAD_CFG:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(!sts)
                            {
                                printf("MFCC APP: COMMS LOAD config is success \n");
                            }
                            else
                            {
                                printf("MFCC APP: COMMS LOAD config failure \n");
                            }
                        }
                    }
                    break;

                case TM_COMMS_SAVE_CFG:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(!sts)
                            {
                                printf("MFCC APP: COMMS SAVE config is success \n");
                            }
                            else
                            {
                                printf("MFCC APP: COMMS SAVE config failure \n");
                            }
                        }
                    }
                    break;

                case TM_COMMS_RESET_CFG:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(!sts)
                            {
                                printf("MFCC APP: COMMS RESET config is success \n");
                            }
                            else
                            {
                                printf("MFCC APP: COMMS RESET config failure \n");
                            }
                        }
                    }
                    break;

                case TM_COMMS_LOCK_CFG:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(!sts)
                            {
                                printf("MFCC APP: COMMS LOCK config is success \n");
                            }
                            else
                            {
                                printf("MFCC APP: COMMS LOCK config failure \n");
                            }
                        }
                    }
                    break;
                case TM_COMMS_UNLOCK_CFG:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(!sts)
                            {
                                printf("MFCC APP: COMMS UNLOCK config is success \n");
                            }
                            else
                            {
                                printf("MFCC APP: COMMS UNLOCK config failure \n");
                            }
                        }
                    }
                    break;

                case TM_COMMS_ERASE_CFG:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(!sts)
                            {
                                printf("MFCC APP: COMMS ERASE config is success \n");
                            }
                            else
                            {
                                printf("MFCC APP: COMMS ERASE config failure \n");
                            }
                        }
                    }
                    break;
                case TM_COMMS_FW_CFG:
                    {

                        os_memcpy(&sts,tm_frame.tm_data,sizeof(uint8_t));
                        os_memcpy(&cnt,&tm_frame.tm_data[1],sizeof(uint8_t));

                        printf("The value of cnt is %d %ld, %ld\n", cnt, sizeof(xver.prog_version), sizeof(tm_frame.tm_data));
                        int j = 3;			 

                        for(int i= 0; i < cnt; i++)
                        {
                            os_memcpy(&xver1.prog_version[i], &tm_frame.tm_data[j], sizeof(VERSION_DATE_STRUCT));

                            printf("seconds: %d\n",xver1.prog_version[i].Seconds);
                            printf("Minute: %d\n",xver1.prog_version[i].Minutes);
                            printf("hours: %d\n",xver1.prog_version[i].Hours);
                            printf("year: %d\n",xver1.prog_version[i].Year);
                            printf("months: %d\n",xver1.prog_version[i].Months);
                            printf("day: %d\n",xver1.prog_version[i].Day);
                            printf("filename: %s\n",xver1.prog_version[i].FileName);
                            printf("start address: %d\n",xver1.prog_version[i].start_adr);
                            printf("length: %d\n",xver1.prog_version[i].len);
                            printf("flags(SOLL-1; RUN- 0x3;...): %d\n",xver1.prog_version[i].Flags);

                            j = j + (sizeof(xver.prog_version));
                        }
                        if(!sts)
                        {

                            printf("MFCC APP: FW_CFG IS SUCCESS \r\n");
                        }
                        else
                        {
                            printf("MFCC APP: FW_CFG IS FAILURE \r\n");
                        }


                    }
                    break;
                case  TM_COMMS_CUSTOM_TX:
                    {

                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                        {
                            printf("MFCC APP: COMMS CUSTOM TX IS SUCCESS \n");
                        }
                        else
                        {
                            printf("MFCC APP: COMMS CUSTOM TX IS FAILURE \n");
                        }

                        printf("received TM DATA :");
                        for(int i=0;i<tm_len;i++)
                        {
                            printf("0x%x",tm_frame.tm_data[i]);
                        }
                        printf("\n");
                    }
                    break;
                case  TM_COMMS_RESERVED:
                    {
                        if (radio_mod_id == 3)
                        {
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(sts == 10)
                            {
                                printf("The TM is Unknown");
                            }
                        }
                        else{
                            os_memcpy(&sts,tm_frame.tm_data,tm_len);
                            if(!sts)
                            {
                                printf("MFCC APP: COMMS RESERVED \n");
                            }
                            else
                            {
                                printf("MFCC APP: COMMS RESERVED \n");
                            }
                        }

                    }
                    break;
                case  TM_COMMS_INITIAL_SYNC:
                    {
                        uint8 janus1_rsp[50];
                        tctm_time_par_s *crnt_time_date = malloc(sizeof(tctm_time_par_s));
                        os_memcpy(janus1_rsp,tm_frame.tm_data,sizeof("Hello Antaris"));
                        printf("MFCC APP: COMMS initial sync is success: %s \n",janus1_rsp);
                        os_memcpy(crnt_time_date,tm_frame.tm_data+sizeof("Hello Antaris"),sizeof(tctm_time_par_s));
                        printf("MFCC APP: RSP RTC TIME-%d:%d:%d\n",crnt_time_date->Hour, crnt_time_date->Minute, crnt_time_date->Seconds);
                        printf("MFCC APP: RSP RTC DATE-%d:%d:%d\n",crnt_time_date->Date, crnt_time_date->Month, crnt_time_date->Year);
                        free(crnt_time_date);
#if 0
                        //os_memcpy(&sts,tm_frame.tm_data,sizeof(sts));
                        //os_memcpy(janus1_rsp,&tm_frame.tm_data[1],tm_len-sizeof(sts));
                        //if(!sts)
                        {
                        }
                        else
                        {
                            printf("MFCC APP: COMMS initial sync is failure : %d\n",sts);
                        }
#endif

                    }
                    break;
                    /*case  TM_COMMS_CUSTOM_TX:
                      {
                      uint8 janus1_rsp[50];
                      uint32 link_cnt =0;
                      os_memcpy(janus1_rsp,tm_frame.tm_data,18);
                      printf("MFCC APP: COMMS Auto sync is success: %s \n",janus1_rsp);

                      os_memcpy(&link_cnt,&tm_frame.tm_data[19],4);
                      printf("MFCC APP: COMMS Auto sync link count: %d \n",link_cnt);

                      os_memcpy(&get_rx_tm,&tm_frame.tm_data[21],sizeof(s_comms_rx_tm));
                      printf("MFCC APP: RX frames : %hhd\n",
                      get_rx_tm.rx_cfg_frames);
                      printf("MFCC APP: RX detected : %hhd\n",
                      get_rx_tm.rx_cfg_detected);
                      printf("MFCC APP: RX rssi : %lf\n",
                      get_rx_tm.rx_cfg_rssi);
                      printf("MFCC APP: RX freqerr : %lf\n",
                      get_rx_tm.rx_cfg_freqerr);
                      printf("MFCC APP: RX symerr : %lf\n",
                      get_rx_tm.rx_cfg_symerr);
                      printf("MFCC APP: RX ebn0 : %lf\n",
                      get_rx_tm.rx_cfg_ebn0);
                      printf("MFCC APP: RX carrier lock : %u\n",
                      get_rx_tm.rx_cfg_carrier_lock);
                      printf("MFCC APP: RX frame lock : %u\n",
                      get_rx_tm.rx_frame_lock);

                      }
                      break;*/

                case  TM_COMMS_BEACON_TX:
                    {


                        memcpy(&sdr_beacon_pld,tm_frame.tm_data,tm_len);

                        printf("BEACON DATA FROM SBAND");	
                        printf("Beacon message: %hhn\n",sdr_beacon_pld.bcon_utc_gps.bcon_msg);
                        printf("UTC time: %d\n",sdr_beacon_pld.bcon_utc_gps.utc_tim);
                        printf("UTC Time from GPS status: %d\n",sdr_beacon_pld.bcon_utc_gps.utc_gps_tim_sts);
                        printf("Latitude: %f\n",sdr_beacon_pld.bcon_utc_gps.latitude);
                        printf("Longitude: %f\n",sdr_beacon_pld.bcon_utc_gps.longitude);
                        printf("Altitude: %f\n",sdr_beacon_pld.bcon_utc_gps.altitude);
                        printf("Position x: %lf\n",sdr_beacon_pld.bcon_utc_gps.x_pos);
                        printf("Position y: %lf\n",sdr_beacon_pld.bcon_utc_gps.y_pos);
                        printf("Position z: %lf\n",sdr_beacon_pld.bcon_utc_gps.z_pos);
                        printf("Velocity x: %lf\n",sdr_beacon_pld.bcon_utc_gps.x_vel);
                        printf("Velocity y: %lf\n",sdr_beacon_pld.bcon_utc_gps.y_vel);
                        printf("Velocity z: %lf\n",sdr_beacon_pld.bcon_utc_gps.z_vel);
                        printf("FSM current state: %d\n",sdr_beacon_pld.obc_mh.fsm_state);
                        printf("No of OBC resets: %d\n",sdr_beacon_pld.obc_mh.num_resets);
                        printf("IO errors: %d\n",sdr_beacon_pld.obc_mh.io_err);
                        printf("System errors : %d\n",sdr_beacon_pld.obc_mh.sys_err);
                        printf("OBC Voltage sensor value: %d\n",sdr_beacon_pld.sen_mh.obc_volt_sensor);
                        printf("PS sensor value: %d\n",sdr_beacon_pld.sen_mh.ps_volt_sensor);
                        printf("OBC temperature: %d\n",sdr_beacon_pld.sen_mh.temp_obc);
                        printf("PS temperature: %d\n",sdr_beacon_pld.sen_mh.temp_ps);
                        printf("ES temperature: %d\n",sdr_beacon_pld.sen_mh.temp_es);
                        printf("GPS temperature: %d\n",sdr_beacon_pld.sen_mh.temp_gps);
                        printf("Total battery voltage: %d\n",sdr_beacon_pld.eps_mh.totl_btry_volt);
                        printf("Total panel power: %d\n",sdr_beacon_pld.eps_mh.totl_panel_pwr);
                        printf("Channel status: %d\n",sdr_beacon_pld.eps_mh.chnl_sts);
                        printf("Over current error flag byte1: %d\n",sdr_beacon_pld.eps_mh.overcrnt_err_flg_byte1);
                        printf("Over current error flag byte2: %d\n",sdr_beacon_pld.eps_mh.overcrnt_err_flg_byte2);
                        printf("ADCS Current state and ADCS Current mode: %d\n",sdr_beacon_pld.adcs_mh.fsm_state_mode);
                        printf("Sensor, actuators Power status: %d\n",sdr_beacon_pld.adcs_mh.sns_actr_pwr_sts);
                        printf("ADCS Actuator running status: %d\n",sdr_beacon_pld.adcs_mh.actrs_run_sts);
                        printf("SBAND SDR fsm state: %d\n",sdr_beacon_pld.sdr_sband_mh.sdr_fsm_st);
                        printf("SBAND Receive signal strength indicator 0: %d\n",sdr_beacon_pld.sdr_sband_mh.rssi0);
                        printf("SBAND Receive signal strength indicator 1: %d\n",sdr_beacon_pld.sdr_sband_mh.rssi1);
                        printf("SBAND RX error count: %d\n",sdr_beacon_pld.sdr_sband_mh.rx_err_cnt);
                        printf("SBAND TX frame count: %d\n",sdr_beacon_pld.sdr_sband_mh.tx_frm_cnt);
                        printf("SBAND RX frequency: %d\n",sdr_beacon_pld.sdr_sband_mh.rx_freq);
                        printf("SBAND Symbol frequency: %d\n",sdr_beacon_pld.sdr_sband_mh.symb_freq);
                        printf("SBAND Modulation type: %d\n",sdr_beacon_pld.sdr_sband_mh.mod);
                        printf("SBAND Roll off: %d\n",sdr_beacon_pld.sdr_sband_mh.roll_off);
                        printf("SBAND Randamoization enable: %d\n",sdr_beacon_pld.sdr_sband_mh.rand_enb);
                        printf("SBAND Convolution coding enable: %d\n",sdr_beacon_pld.sdr_sband_mh.cc_enb);
                        printf("SBAND Reed solomon enable: %d\n",sdr_beacon_pld.sdr_sband_mh.rs_enb);
                        printf("UHF SDR fsm state: %d\n",sdr_beacon_pld.sdr_uhf_mh.sdr_fsm_st);
                        printf("UHF Receive signal strength indicator 0: %d\n",sdr_beacon_pld.sdr_uhf_mh.rssi0);
                        printf("UHF Receive signal strength indicator 1: %d\n",sdr_beacon_pld.sdr_uhf_mh.rssi1);
                        printf("UHF RX error count: %d\n",sdr_beacon_pld.sdr_uhf_mh.rx_err_cnt);
                        printf("UHF TX frame count: %d\n",sdr_beacon_pld.sdr_uhf_mh.tx_frm_cnt);
                        printf("UHF RX frequency: %d\n",sdr_beacon_pld.sdr_uhf_mh.rx_freq);
                        printf("UHF Symbol frequency: %d\n",sdr_beacon_pld.sdr_uhf_mh.symb_freq);
                        printf("UHF Modulation type: %d\n",sdr_beacon_pld.sdr_uhf_mh.mod);
                        printf("UHF Roll off: %d\n",sdr_beacon_pld.sdr_uhf_mh.roll_off);
                        printf("UHF Cyclic redundancy check enable: %d\n",sdr_beacon_pld.sdr_uhf_mh.crc_enb);
                        printf("DC filter enable: %d\n",sdr_beacon_pld.sdr_uhf_mh.dc_filter_enb);
                        printf("UHF Convolution coding enable: %d\n",sdr_beacon_pld.sdr_uhf_mh.cc_enb);
                        printf("UHF Randamoization enable: %d\n",sdr_beacon_pld.sdr_uhf_mh.rand_enb);
                        printf("UHF Manchester coding enable: %d\n",sdr_beacon_pld.sdr_uhf_mh.manchester_coding_en);


                    }
                    break;


                case TM_OBC_IPCC_TEST:
                    {

                        icm_header_s hdr;
                        unsigned int *hdr_data = NULL;
                        uint8 no_fw, *dp;
                        char *token;
                        uint8 *ptr;
                        int i = 0;
                        // uint8 len =0;

                        if(tm_frame.tm_data[0] == 0)
                        {
                            os_memcpy(&sts,&tm_frame.tm_data[1],tm_len-1);
                            if(!sts)
                                printf("IPCC Trigger success\n");
                            else
                                printf("IPCC Trigger failure\n");
                        }
                        else
                        {
                            hdr_data = malloc(4);
                            os_memcpy(hdr_data, &tm_frame.tm_data[1],4);
                            /* Decode header information */
                            hdr.data_len = (((*hdr_data) & CRRN_DATA_LEN_MASK) >> CRRN_DATA_LEN_POS);
                            hdr.crrn_id  = (((*hdr_data) & CRRN_ID_MASK) >> CRRN_ID_POS);
                            hdr.crrn_type = (((*hdr_data) & CRRN_TYPE_MASK) >> CRRN_TYPE_POS);
                            printf("\nSuccessfully Received Interface message from PS\n");
                            printf("Type: %d, ID: %d, Len: %d\n",hdr.crrn_type, hdr.crrn_id, hdr.data_len);
                            if(31 == hdr.crrn_id)
                            {
                                ptr = &tm_frame.tm_data[5];

                                printf("Byte Stream in Dec: ");
                                for(i=0; i < 18;i++)
                                {
                                    printf("%d ",*ptr);
                                    ptr++;
                                }
                                printf("\n\n\n");
                                no_fw = tm_frame.tm_data[5];
                                printf("No. of SBAND firmware file is %d\n", no_fw);
                                dp = &tm_frame.tm_data[6];
                                token = strtok((char*)dp,",");
                                printf("Firmware file 1 is %s\n",token);
                                for(int cntr =2; cntr<=no_fw; cntr++)
                                {
                                    token = strtok(NULL,",");
                                    printf("Firmware file %d is %s\n",cntr,token);
                                }
                            }
                            if(32 == hdr.crrn_id)
                            {
                                if(tm_frame.tm_data[5] == 0)
                                    printf("TFTP FILE TRANSFER INITIATION SUCCESS\n");
                                else if(tm_frame.tm_data[5] == 1)
                                    printf("TFTP TRANSFER INITIATION FAILURE - INVALID INPUT\n");
                                else if(tm_frame.tm_data[5] == 2)
                                    printf("TFTP TRANSFER INITIATION FAILURE - FILE NOT FOUND\n");
                                else if(tm_frame.tm_data[5] == 3)
                                    printf("TFTP FAILURE CODE - %d\n",tm_frame.tm_data[5]);
                            }
                            if(33 == hdr.crrn_id)
                            {
                                if(tm_frame.tm_data[5] == 0)
                                    printf("SBAND FIRMWARE DELETION SUCCESS\n");
                                else if(tm_frame.tm_data[5] == 1)
                                    printf("SBAND FIRMEARE DELETION FAILURE\n");
                            }

                            if(230 == hdr.crrn_id)
                            {
                                if(tm_frame.tm_data[5] == 0)
                                    printf("SBAND FIRMWARE TRANSFER COMPLETE \n");
                                else if(tm_frame.tm_data[5] == 1)
                                    printf("SBAND FIRMEARE TRANSFER FAILURE\n");
                            }
                        }
                    }
                    break;

                case TM_OBC_ES_IPCC_TEST:
                    {

                        icm_header_s hdr;
                        unsigned int *hdr_data = NULL;

                        if(tm_frame.tm_data[0] == 0)
                        {
                            os_memcpy(&sts,&tm_frame.tm_data[1],tm_len-1);
                            if(!sts)
                                printf("IPCC Trigger success\n");
                            else
                                printf("IPCC Trigger failure\n");
                        }
                        else
                        {
                            hdr_data = malloc(tm_len-1);
                            os_memcpy(hdr_data, &tm_frame.tm_data[1],tm_len-1);
                            /* Decode header information */
                            hdr.data_len = (((*hdr_data) & CRRN_DATA_LEN_MASK) >> CRRN_DATA_LEN_POS);
                            hdr.crrn_id  = (((*hdr_data) & CRRN_ID_MASK) >> CRRN_ID_POS);
                            hdr.crrn_type = (((*hdr_data) & CRRN_TYPE_MASK) >> CRRN_TYPE_POS);
                            printf("\nSuccessfully Received Interface message from ES\n");
                            printf("Type: %d, ID: %d, Len: %d\n",hdr.crrn_type, hdr.crrn_id, hdr.data_len);
                        }
                    }
                    break;

                case TM_MEMD:
                    {
                        os_memcpy(&obc_mem_data,tm_frame.tm_data,4);
                        obc_mem_debug_tm_dec(&obc_mem_data);
                    }
                    break;

                    /** XLINK IQ spacecom */

                case TM_SBAND_SET_IDLE_CFG:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                            printf("MFCC APP: XBAND set idle is success \n");
                        else
                            printf("MFCC APP: XBAND set idle is failure \n");

                    }
                    break;
                case TM_SBAND_SET_RESET:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                            printf("MFCC APP: XBAND set reset is success \n");
                        else
                            printf("MFCC APP: XBAND set reset is failure \n");

                    }
                    break;
                case TM_SBAND_SET_START_RF_RCV:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                            printf("MFCC APP: XBAND set start RF recieve is success \n");
                        else
                            printf("MFCC APP: XBAND set start RF recieve is failure \n");

                    }
                    break;

                case TM_SBAND_SET_RF_XMT_DATA:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                            printf("MFCC APP: XBAND set RF XMT is success \n");
                        else
                            printf("MFCC APP: XBAND set RF XMT is failure \n");

                    }
                    break;
                case TM_SBAND_SET_DVBS2_CONF:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                            printf("MFCC APP: XBAND set DVBS2 config is success \n");
                        else
                            printf("MFCC APP: XBAND set DVBS2 config is failure \n");

                    }
                    break;
                case TM_SBAND_SET_IP_ADR_SAVE:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                            printf("MFCC APP: XBAND set IP ADR save is success \n");
                        else
                            printf("MFCC APP: XBAND set IP ADR save is failure \n");

                    }
                    break;
                case TM_SBAND_SET_IP_ADR:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                            printf("MFCC APP: XBAND set IP ADR is success \n");
                        else
                            printf("MFCC APP: XBAND set IP ADR is failure \n");

                    }
                    break;
                case TM_SBAND_GET_IP_ADR:
                    {
                        printf("\n\r TM_SBAND_GET_IP_ADR is received \r\n");
                        os_memcpy(&xip_adr.ip_address,tm_frame.tm_data,sizeof(xip_adr.ip_address));
                        printf("ip_address: %x\n",xip_adr.ip_address);
                        //printf("ip_address: %s\n",inet_ntoa(xip_adr.ip_address));

                    }
                    break;
                case TM_SBAND_GET_FLAGS_CONF:
                    {
                        printf("\n\r TM_SBAND_GET_FLAGS_CONF is received \r\n");
                    }
                    break;
                case TM_SBAND_SET_FLAGS_CONF:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                            printf("MFCC APP: XBAND set flag config is success \n");
                        else
                            printf("MFCC APP: XBAND set flag config is failure \n");

                    }
                    break;
                case TM_SBAND_SET_VERSION:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                            printf("MFCC APP: SBAND set version is success \n");
                        else
                            printf("MFCC APP: SBAND set version is failure \n");

                    }
                    break;


                case TM_SBAND_GET_TM_STORE:
                    {
                        //if (radio_mod_id == 3)
                        //{
                        printf("\n***************\n");
                        int j = 1;
                        os_memcpy(&cnt,tm_frame.tm_data,1);
                        printf("The value of cnt is %d\n", cnt);

                        for(int i= 0; i < cnt; i++)
                        {

                            os_memcpy(&xlink_tm_stor.sband_tm_store[i],&tm_frame.tm_data[j],sizeof(s_sband_periodic_tm));

                            printf("MFCC APP :temp_xcvr : %hi \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.cmn_tm.temp_xcvr );
                            printf("MFCC APP :temp_mcu : %hi \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.cmn_tm.temp_mcu );
                            printf("MFCC APP :temp_fpga : %hi \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.cmn_tm.temp_fpga );
                            printf("MFCC APP :volt_vint : %f \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.cmn_tm.volt_vint );
                            printf("MFCC APP :volt_vaux : %f \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.cmn_tm.volt_vaux );
                            printf("MFCC APP :volt_vbram : %f \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.cmn_tm.volt_vbram );
                            printf("MFCC APP :volt_vpint : %f \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.cmn_tm.volt_vpint );
                            printf("MFCC APP :volt_vpaux : %f \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.cmn_tm.volt_vpaux );
                            printf("MFCC APP :volt_vpdro : %f \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.cmn_tm.volt_vpdro );
                            printf("MFCC APP : Recv ch 0 \n" );
                            printf("MFCC APP :rx_cfg_frames : %d \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.rx_tm[0].rx_cfg_frames );
                            printf("MFCC APP :rx_cfg_detected : %d \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.rx_tm[0].rx_cfg_detected );
                            printf("MFCC APP :rx_cfg_rssi : %lf \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.rx_tm[0].rx_cfg_rssi );
                            printf("MFCC APP :rx_cfg_freqerr : %d \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.rx_tm[0].rx_cfg_freqerr );
                            printf("MFCC APP :rx_cfg_carrier_lock : %hu \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.rx_tm[0].rx_cfg_carrier_lock );
                            printf("MFCC APP :rx_frame_lock : %hu \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.rx_tm[0].rx_frame_lock );
                            printf("MFCC APP :rx_sir_min : %u \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.rx_tm[0].rx_sir_min );
                            printf("MFCC APP :rx_sir_max : %u \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.rx_tm[0].rx_sir_max );
                            printf("MFCC APP :rx_bch_block_i : %u \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.rx_tm[0].rx_bch_block_cnt );
                            printf("MFCC APP :rx_bch_err_cnt : %u \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.rx_tm[0].rx_bch_err_cnt );
                            printf("MFCC APP : Recv ch 1 \n" );
                            printf("MFCC APP :rx_cfg_frames : %d \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.rx_tm[1].rx_cfg_frames );
                            printf("MFCC APP :rx_cfg_detected : %d \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.rx_tm[1].rx_cfg_detected );
                            printf("MFCC APP :rx_cfg_rssi : %lf \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.rx_tm[1].rx_cfg_rssi );
                            printf("MFCC APP :rx_cfg_freqerr : %d \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.rx_tm[1].rx_cfg_freqerr );
                            printf("MFCC APP :rx_cfg_carrier_lock : %hu \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.rx_tm[1].rx_cfg_carrier_lock );
                            printf("MFCC APP :rx_frame_lock : %hu \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.rx_tm[1].rx_frame_lock );
                            printf("MFCC APP :rx_sir_min : %u \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.rx_tm[1].rx_sir_min );
                            printf("MFCC APP :rx_sir_max : %u \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.rx_tm[1].rx_sir_max );
                            printf("MFCC APP :rx_bch_block_i : %u \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.rx_tm[1].rx_bch_block_cnt );
                            printf("MFCC APP :rx_bch_err_cnt : %u \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.rx_tm[1].rx_bch_err_cnt );

                            printf("MFCC APP :tx_cfg_frames : %d \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.tx_tm.tx_cfg_frames );
                            printf("MFCC APP :tx_cfg_pwr_rfl : %f \n", xlink_tm_stor.sband_tm_store[i].comms_sband_tm_stor.tx_tm.tx_cfg_pwr_rfl );
                            /*j = j + (sizeof(s_sband_periodic_get_tm));*/
                            j = j + (sizeof(s_sband_periodic_tm));
                            printf("%d , %lu \n", j, sizeof(s_sband_periodic_tm));
                        }

                        //}
                    }
                    break;

                case TM_SBAND_GET_TM_ALL:
                    {

                        os_memcpy(&cnt,&tm_frame.tm_data[0],sizeof(uint8_t));

                        os_memcpy(&xlink_tm_stor,&tm_frame.tm_data[1],(sizeof(s_sband_periodic_tm)));

                        printf("MFCC APP :temp_xcvr : %hi \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.cmn_tm.temp_xcvr );
                        printf("MFCC APP :temp_mcu : %hi \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.cmn_tm.temp_mcu );
                        printf("MFCC APP :temp_fpga : %hi \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.cmn_tm.temp_fpga );
                        printf("MFCC APP :volt_vint : %f \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.cmn_tm.volt_vint );
                        printf("MFCC APP :volt_vaux : %f \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.cmn_tm.volt_vaux );
                        printf("MFCC APP :volt_vbram : %f \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.cmn_tm.volt_vbram );
                        printf("MFCC APP :volt_vpint : %f \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.cmn_tm.volt_vpint );
                        printf("MFCC APP :volt_vpaux : %f \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.cmn_tm.volt_vpaux );
                        printf("MFCC APP :volt_vpdro : %f \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.cmn_tm.volt_vpdro );
                        printf("MFCC APP : Recv ch 0 \n" );
                        printf("MFCC APP :rx_cfg_frames : %d \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.rx_tm[0].rx_cfg_frames );
                        printf("MFCC APP :rx_cfg_detected : %d \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.rx_tm[0].rx_cfg_detected );
                        printf("MFCC APP :rx_cfg_rssi : %lf \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.rx_tm[0].rx_cfg_rssi );
                        printf("MFCC APP :rx_cfg_freqerr : %d \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.rx_tm[0].rx_cfg_freqerr );
                        printf("MFCC APP :rx_cfg_carrier_lock : %hu \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.rx_tm[0].rx_cfg_carrier_lock );
                        printf("MFCC APP :rx_frame_lock : %hu \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.rx_tm[0].rx_frame_lock );
                        printf("MFCC APP :rx_sir_min : %u \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.rx_tm[0].rx_sir_min );
                        printf("MFCC APP :rx_sir_max : %u \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.rx_tm[0].rx_sir_max );
                        printf("MFCC APP :rx_bch_block_i : %u \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.rx_tm[0].rx_bch_block_cnt );
                        printf("MFCC APP :rx_bch_err_cnt : %u \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.rx_tm[0].rx_bch_err_cnt );
                        printf("MFCC APP : Recv ch 1 \n" );
                        printf("MFCC APP :rx_cfg_frames : %d \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.rx_tm[1].rx_cfg_frames );
                        printf("MFCC APP :rx_cfg_detected : %d \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.rx_tm[1].rx_cfg_detected );
                        printf("MFCC APP :rx_cfg_rssi : %lf \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.rx_tm[1].rx_cfg_rssi );
                        printf("MFCC APP :rx_cfg_freqerr : %d \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.rx_tm[1].rx_cfg_freqerr );
                        printf("MFCC APP :rx_cfg_carrier_lock : %hu \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.rx_tm[1].rx_cfg_carrier_lock );
                        printf("MFCC APP :rx_frame_lock : %hu \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.rx_tm[1].rx_frame_lock );
                        printf("MFCC APP :rx_sir_min : %u \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.rx_tm[1].rx_sir_min );
                        printf("MFCC APP :rx_sir_max : %u \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.rx_tm[1].rx_sir_max );
                        printf("MFCC APP :rx_bch_block_i : %u \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.rx_tm[1].rx_bch_block_cnt );
                        printf("MFCC APP :rx_bch_err_i : %u \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.rx_tm[1].rx_bch_err_cnt );

                        printf("MFCC APP :tx_cfg_frames : %d \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.tx_tm.tx_cfg_frames );
                        printf("MFCC APP :tx_cfg_pwr_rfl : %f \n", xlink_tm_stor.sband_tm_store[0].comms_sband_tm_stor.tx_tm.tx_cfg_pwr_rfl );


                    }
                    break;

                case TM_SBAND_GET_VERSION:
                    {

                        os_memcpy(&cnt,&tm_frame.tm_data[0],sizeof(uint8_t));

                        printf("The value of cnt is %d %ld, %ld\n", cnt, sizeof(xver.prog_version), sizeof(tm_frame.tm_data));
                        int j = 1;			 

                        for(int i= 0; i < cnt; i++)
                        {
                            os_memcpy(&xver1.prog_version[i], &tm_frame.tm_data[j], sizeof(VERSION_DATE_STRUCT));

                            printf("seconds: %d\n",xver1.prog_version[i].Seconds);
                            printf("Minute: %d\n",xver1.prog_version[i].Minutes);
                            printf("hours: %d\n",xver1.prog_version[i].Hours);
                            printf("year: %d\n",xver1.prog_version[i].Year);
                            printf("months: %d\n",xver1.prog_version[i].Months);
                            printf("day: %d\n",xver1.prog_version[i].Day);
                            printf("filename: %s\n",xver1.prog_version[i].FileName);
                            printf("start address: %d\n",xver1.prog_version[i].start_adr);
                            printf("length: %d\n",xver1.prog_version[i].len);
                            printf("flags(SOLL-1; RUN- 0x3;...): %d\n",xver1.prog_version[i].Flags);

                            j = j + (sizeof(xver.prog_version));
                        }
                        printf("\n\r TM_SBAND_GET_VERSION is received \r\n");
                    }
                    break;
                case TM_SBAND_SET_DEVICE_CONF:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                            printf("MFCC APP: SBAND set device config is success \n");
                        else
                            printf("MFCC APP: SBAND set device config is failure \n");

                    }
                    break;
                case TM_SBAND_GET_DEVICE_CONF:
                    {
                        os_memcpy(&xdev.HwPins,tm_frame.tm_data,sizeof(SERVICE_DEVICE_CONF_STRUCT));
                        printf("\n\r TM_SBAND_GET_DEVICE_CONF is received \r\n");

                        printf("RX-Mixer: %d\n",xdev.HwPins.RfeRx0On);
                        printf("TX-Mixer: %d\n",xdev.HwPins.RfeTx0On);
                        printf("RfePa0On: %d\n",xdev.HwPins.RfePa0On);
                        printf("RfeRxTx0: %d\n",xdev.HwPins.RfeRxTx0);
                        printf("RfeRx1On: %d\n",xdev.HwPins.RfeRx1On);
                        printf("ERfeTx1On: %d\n",xdev.HwPins.RfeTx1On);
                        printf("RfeRxTx1: %d\n",xdev.HwPins.RfeRxTx1);
                        printf("RfePa1On: %d\n",xdev.HwPins.RfePa1On);
                        printf("RfeOutEn: %d\n",xdev.HwPins.RfeOutEn);
                        printf("RfeGpio0: %d\n",xdev.HwPins.RfeGpio0);
                        printf("RfeLoopDet: %d\n",xdev.HwPins.RfeLoopDet);
                        printf("RfeLoMux: %d\n",xdev.HwPins.RfeLoMux);
                        printf("RfePowOn: %d\n",xdev.HwPins.RfePowOn);
                        printf("RfeDA: %d\n",xdev.HwPins.RfeDA);
                        printf("RfeCL: %d\n",xdev.HwPins.RfeCL);
                        printf("RfeEnAD5304: %d\n",xdev.HwPins.RfeEnAD5304);
                        printf("RfeEnSynth: %d\n",xdev.HwPins.RfeEnSynth);
                        printf("RfeEn3: %d\n",xdev.HwPins.RfeEn3);
                        printf("RfeEn4r: %d\n",xdev.HwPins.RfeEn4);
                        printf("RfeEn5: %d\n",xdev.HwPins.RfeEn5);
                        printf("7V0 PowerOn enable: %d\n",xdev.HwPins.Rfe7V0En);
                        printf("Rfe reserve to uint32: %d\n",xdev.HwPins.RfeRsvuint32);
                        printf("receive DownConversionFrequency channel 0: %d\n",xdev.RfeFreq.RxMix[0]);
                        printf("receive DownConversionFrequency channle 1: %d\n",xdev.RfeFreq.RxMix[1]);
                        printf("transmit UpConversionFrequency channel 0: %d\n",xdev.RfeFreq.TxMix[0]);
                        printf("transmit UpConversionFrequency channel 1: %d\n",xdev.RfeFreq.TxMix[1]);
                        printf("receive Frequency Channel0: %d\n",xdev.RfeFreq.RxFreq[0]);
                        printf("receive Frequency Channel1: %d\n",xdev.RfeFreq.RxFreq[1]);
                        printf("transmit Frequency Channel0: %d\n",xdev.RfeFreq.TxFreq[0]);
                        printf("transmit Frequency Channel1: %d\n",xdev.RfeFreq.TxFreq[1]);
                        printf("Rcv lowest  possible frequency Channel0: %d\n",xdev.LimFreq.RxLow[0]);
                        printf("Rcv lowest  possible frequency Channel1: %d\n",xdev.LimFreq.RxLow[1]);
                        printf("Rcv highest possible frequency Channel0: %u\n",xdev.LimFreq.RxHigh[0]);
                        printf("Rcv highest possible frequency Channel1: %u\n",xdev.LimFreq.RxHigh[1]);
                        printf("Xmt lowest  possible frequency Channel0: %d\n",xdev.LimFreq.TxLow[0]);
                        printf("Xmt lowest  possible frequency Channel1: %d\n",xdev.LimFreq.TxLow[1]);
                        printf("Xmt highest possible frequency Channel0: %d\n",xdev.LimFreq.TxHigh[0]);
                        printf("Xmt highest possible frequency Channel1: %d\n",xdev.LimFreq.TxHigh[1]);
                        printf("Flag for use 2Rx2Tx mode: %d\n",xdev.AdCtr._2Rx2Tx);
                        printf("Tx Level for XmtChannel 0 (0...2047): %d\n",xdev.AdCtr.TxLevel_0);
                        printf("Tx Level for XmtChannel 1 (0...2047): %d\n",xdev.AdCtr.TxLevel_1);
                        printf("AD9361 reference clock in MHz: %d\n",xdev.AdCtr.RefClk);
                        printf("Reserve: %d\n",xdev.AdCtr.Reserve);

                        printf("Xmt Modulation Channel_0 : %d\n",xdev.XmtCtr0.Modulat_0);
                        printf("Xmt Mode Channel_0: %d\n",xdev.XmtCtr0.Mode_0);
                        printf("Xmt FEC Channel_0: %d\n",xdev.XmtCtr0.Fec_0);
                        printf("Xmt Enable Channel 0: %d\n",xdev.XmtCtr0.ChEn_0);
                        printf("Xmt PseudoRanomizer 0: %d\n",xdev.XmtCtr0.PRnd_0 );
                        printf("Xmt ASM at FrmStart 0: %d\n",xdev.XmtCtr0.ASMStart_0);
                        printf("Xmt Offset Modulation 0: %d\n",xdev.XmtCtr0.OffsetMod_0);
                        printf("set FPGA output XmtOut_Data: %d\n",xdev.XmtCtr0.Ch1_diff_Ch2);
                        printf("Xmt On/Off Channel_0: %d\n",xdev.XmtCtr0.ChSwitchOn_0);
                        printf("Xmt Modulation Channel_1: %d\n",xdev.XmtCtr0.Modulat_1);
                        printf("Xmt Mode Channel_1: %d\n",xdev.XmtCtr0.Mode_1);
                        printf("Xmt FEC Channel_1: %d\n",xdev.XmtCtr0.Fec_1);
                        printf("Xmt Enable Channel 0: %d\n",xdev.XmtCtr0.ChEn_1);
                        printf("Xmt PseudoRanomizer 1: %d\n",xdev.XmtCtr0.PRnd_1);
                        printf("Xmt ASM at FrmStart 1: %d\n",xdev.XmtCtr0.ASMStart_1);
                        printf("Xmt Offset Modulation 1: %d\n",xdev.XmtCtr0.OffsetMod_1);
                        printf("Xmt On/Off Channel 1: %d\n",xdev.XmtCtr0.ChSwitchOn_1);
                        printf("Xmt 1-Offset Modulation normaly;: %d\n",xdev.XmtCtr0.OffsetModNormaly);
                        printf("AttTxGain_0: %d\n",xdev.XmtCtr3.AttTxGain_0);
                        printf("AttTxGain_1: %d\n",xdev.XmtCtr3.AttTxGain_1);
                        printf("TrFrmSz: %d\n",xdev.XmtCtr3.TrFrmSz);

                        printf("PhiOffset16: %d\n",xdev.XmtCtr4.PhiOffset16);
                        printf("y16: %d\n",xdev.XmtCtr4.Y16);
                        printf("TxSampFact: %d\n",xdev.XmtCtr4.TxSampFact);
                        printf("RsMode: %d\n",xdev.XmtCtr4.RsMode);

                        printf("RxGainMax: %d\n",xdev.RcvCtrCh[0].RxGainMax);
                        printf("ChEn: %d\n",xdev.RcvCtrCh[0].ChEn);
                        printf("Modulat: %d\n",xdev.RcvCtrCh[0].Modulat);
                        printf("MsbFirst: %d\n",xdev.RcvCtrCh[0].MsbFirst);
                        printf("Fec: %d\n",xdev.RcvCtrCh[0].Fec);
                        printf("PRnd: %d\n",xdev.RcvCtrCh[0].PRnd);
                        printf("BchDec: %d\n",xdev.RcvCtrCh[0].BchDec);
                        printf("AccBchErr: %d\n",xdev.RcvCtrCh[0].AccBchErr);
                        printf("RBchCountMode: %d\n",xdev.RcvCtrCh[0].BchCountMode);
                        printf("PowerOff: %d\n",xdev.RcvCtrCh[0].PwrOff);
                        printf("RcvCalib: %d\n",xdev.RcvCtrCh[0].RcvCalib);

                        printf("RxGainMax: %d\n",xdev.RcvCtrCh[1].RxGainMax);
                        printf("ChEn: %d\n",xdev.RcvCtrCh[1].ChEn);
                        printf("Modulat: %d\n",xdev.RcvCtrCh[1].Modulat);
                        printf("MsbFirst: %d\n",xdev.RcvCtrCh[1].MsbFirst);
                        printf("Fec: %d\n",xdev.RcvCtrCh[1].Fec);
                        printf("PRnd: %d\n",xdev.RcvCtrCh[1].PRnd);
                        printf("BchDec: %d\n",xdev.RcvCtrCh[1].BchDec);
                        printf("AccBchErr: %d\n",xdev.RcvCtrCh[1].AccBchErr);
                        printf("RBchCountMode: %d\n",xdev.RcvCtrCh[1].BchCountMode);
                        printf("PowerOff: %d\n",xdev.RcvCtrCh[1].PwrOff);
                        printf("RcvCalib: %d\n",xdev.RcvCtrCh[1].RcvCalib);

                        printf("XmtSymbFreq: %d\n",xdev.SymbFreq.XmtSymbFreq);
                        printf("RcvSymbFreq: %d\n",xdev.SymbFreq.RcvSymbFreq);

                        printf("RcvMode: %d\n",xdev.RcvCtr_0.RcvMode);
                        printf("RcvChannel: %d\n",xdev.RcvCtr_0.RcvChannel);
                        printf("ChSwitchOn_0: %d\n",xdev.RcvCtr_0.ChSwitchOn_0);
                        printf("ChSwitchOn_1: %d\n",xdev.RcvCtr_0.ChSwitchOn_1);
                        printf("DropSample: %d\n",xdev.RcvCtr_0.DropSample);
                        printf("dT_minus: %d\n",xdev.RcvCtr_0.dT_minus);
                        printf("dT_plus: %d\n",xdev.RcvCtr_0.dT_plus);
                        printf("Reserve: %d\n",xdev.RcvCtr_0.Reserve);

                    }
                    break;
                case TM_SBAND_GET_FEATURE_SELECT:
                    {
                        printf("Entered in feature select");
                        os_memcpy(&fur.feature_select,tm_frame.tm_data,sizeof(fur));                
                        printf("\n\r TM_SBAND_GET_FEATURE_SELECT is received \r\n");

                        printf("Crc16: %d\n",fur.feature_select.Crc16);
                        printf("Reserve_0: %d\n",fur.feature_select.Reserve_0);
                        printf("MoreXmtMod: %d\n",fur.feature_select.MoreXmtMod);
                        printf("XmtOffsetMod: %d\n",fur.feature_select.XmtOffsetMod);
                        printf("RsMode: %d\n",fur.feature_select.RsMode);
                        printf("XmtCh0_En: %d\n",fur.feature_select.XmtCh0_En);
                        printf("XmtCh1_En: %d\n",fur.feature_select.XmtCh1_En);
                        printf("RcvCh0_En: %d\n",fur.feature_select.RcvCh0_En);
                        printf("RcvCh1_Ene: %d\n",fur.feature_select.RcvCh1_En);
                        printf("RcvCh0_GainMax: %d\n",fur.feature_select.RcvCh0_GainMax);
                        printf("RcvCh1_GainMax: %d\n",fur.feature_select.RcvCh1_GainMax);
                        printf("DisableXmtSymbFreqChange: %d\n",fur.feature_select.DisableXmtSymbFreqChange);
                        printf("DisableRcvSymbFreqChange: %d\n",fur.feature_select.DisableRcvSymbFreqChange);
                        printf("DisableXmtUpSampling: %d\n",fur.feature_select.DisableXmtUpSampling);
                        printf("Reserve_1: %d\n",fur.feature_select.Reserve_1);
                        printf("XmtSymbFreq: %d\n",fur.feature_select.XmtSymbFreq);
                        printf("RcvSymbFreq: %d\n",fur.feature_select.RcvSymbFreq);
                        printf("Reserve_3: %d\n",fur.feature_select.Reserve_3);

                    }
                    break;
                case TM_SBAND_GET_COMMS_TM_INFO:
                    {
                        SERVICE_HOUSE_KEEP_STRUCT house;
                        os_memcpy(&house.HouseKeep,&tm_frame.tm_data[3],sizeof(house));
                        printf("\n\r TM_SBAND_GET_HOUSE_KEEP is received \r\n");
                        printf("AD9361: %d\n",house.HouseKeep.Temp.AD9361);
                        printf("EthPhy: %d\n",house.HouseKeep.Temp.EthPhy);
                        printf("Zynq: %d\n",house.HouseKeep.Temp.Zynq);
                        printf("Rest: %d\n",house.HouseKeep.Temp.Rest);

                        printf("On: %d\n",house.HouseKeep.RcvInfCh[0].On);
                        printf("Sync: %d\n",house.HouseKeep.RcvInfCh[0].Sync);
                        printf("idxGain: %d\n",house.HouseKeep.RcvInfCh[0].idxGain);
                        printf("SirMin: %d\n",house.HouseKeep.RcvInfCh[0].SirMin);
                        printf("SirMax: %d\n",house.HouseKeep.RcvInfCh[0].SirMax);
                        printf("DopplerFreq: %d\n",house.HouseKeep.RcvInfCh[0].DopplerFreq);
                        printf("Rest0: %d\n",house.HouseKeep.RcvInfCh[0].Rest0);
                        printf("PwrMin: %d\n",house.HouseKeep.RcvInfCh[0].PwrMin);
                        printf("PwrMax: %d\n",house.HouseKeep.RcvInfCh[0].PwrMax);
                        printf("RxState: %d\n",house.HouseKeep.RcvInfCh[0].RxState);
                        printf("Rest1: %d\n",house.HouseKeep.RcvInfCh[0].Rest1);
                        printf("BchBlockCount: %d\n",house.HouseKeep.RcvInfCh[0].BchBlockCount);
                        printf("BchErrCount: %d\n",house.HouseKeep.RcvInfCh[0].BchErrCount);                                                                                                                                                                                

                        printf("On: %d\n",house.HouseKeep.XmtInfCh[0].On);
                        printf("Modulation: %d\n",house.HouseKeep.XmtInfCh[0].Modulation);                
                        printf("Fec: %d\n",house.HouseKeep.XmtInfCh[0].Fec);
                        printf("Att: %d\n",house.HouseKeep.XmtInfCh[0].Att);
                        //printf("FpgaMode: %d\n",house.HouseKeep.XmtInfCh[0].FpgaMode);
                        printf("Rest: %d\n",house.HouseKeep.XmtInfCh[0].Rest);

                        printf("card_run_counter: %d\n",house.HouseKeep.card_run_counter);                                                                
                    }
                    break;

                case TM_SBAND_GET_XPA_INF:
                    {
                        SERVICE_XPA_INF_STRUCT xpa_inf;
                        os_memcpy(&xpa_inf,&tm_frame.tm_data,sizeof(xpa_inf));
                        printf("internal Power supply: %d\n",xpa_inf.PGOOD_0);
                        printf("internal amplifier current : %d\n",xpa_inf.Current_0);                
                        printf("internal Temperature: %d\n",xpa_inf.Temp_int_0);
                        printf("internal Power supply: %d\n",xpa_inf.PGOOD_1);
                        printf("internal amplifier current: %d\n",xpa_inf.Current_1);
                        printf("internal Temperature: %d\n",xpa_inf.Temp_int_1);
                    }
                    break;		

                case TM_SBAND_SET_PROD_KEY:
                    {
                        printf("\n\r TM_SBAND_SET_PROD_KEY is received \r\n");
                    }
                    break;

                case TM_XBAND:
                    {
                    }
                    break;

                case TM_XBAND_SET_IDLE_CFG:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                            printf("MFCC APP: XBAND set idle is success \n");
                        else
                            printf("MFCC APP: XBAND set idle is failure \n");

                    }
                    break;
                case TM_XBAND_SET_RESET:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                            printf("MFCC APP: XBAND set reset is success \n");
                        else
                            printf("MFCC APP: XBAND set reset is failure \n");

                    }
                    break;
                case TM_XBAND_SET_START_RF_RCV:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                            printf("MFCC APP: XBAND set start RF recieve is success \n");
                        else
                            printf("MFCC APP: XBAND set start RF recieve is failure \n");

                    }
                    break;

                case TM_XBAND_SET_RF_XMT_DATA:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                            printf("MFCC APP: XBAND set RF XMT is success \n");
                        else
                            printf("MFCC APP: XBAND set RF XMT is failure \n");

                    }
                    break;
                case TM_XBAND_SET_DVBS2_CONF:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                            printf("MFCC APP: XBAND set DVBS2 config is success \n");
                        else
                            printf("MFCC APP: XBAND set DVBS2 config is failure \n");

                    }
                    break;
                case TM_XBAND_SET_IP_ADR_SAVE:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                            printf("MFCC APP: XBAND set IP ADR save is success \n");
                        else
                            printf("MFCC APP: XBAND set IP ADR save is failure \n");

                    }
                    break;
                case TM_XBAND_SET_IP_ADR:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                            printf("MFCC APP: XBAND set IP ADR is success \n");
                        else
                            printf("MFCC APP: XBAND set IP ADR is failure \n");

                    }
                    break;
                case TM_XBAND_GET_IP_ADR:
                    {
                        printf("\n\r TM_XBAND_GET_IP_ADR is received \r\n");
                        os_memcpy(&xip_adr.ip_address,tm_frame.tm_data,sizeof(xip_adr.ip_address));
                        printf("ip_address: %x\n",xip_adr.ip_address);
                        //printf("ip_address: %s\n",inet_ntoa(xip_adr.ip_address));

                    }
                    break;
                case TM_XBAND_GET_FLAGS_CONF:
                    {
                        printf("\n\r TM_XBAND_GET_FLAGS_CONF is received \r\n");
                    }
                    break;
                case TM_XBAND_SET_FLAGS_CONF:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                            printf("MFCC APP: XBAND set flag config is success \n");
                        else
                            printf("MFCC APP: XBAND set flag config is failure \n");

                    }
                    break;
                case TM_XBAND_SET_VERSION:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                            printf("MFCC APP: XBAND set version is success \n");
                        else
                            printf("MFCC APP: XBAND set version is failure \n");

                    }
                    break;
                case TM_XBAND_GET_VERSION:
                    {
                        os_memcpy(&xver.prog_version,&tm_frame.tm_data[1],sizeof(SERVICE_VERSION_STRUCT));

                        printf("seconds: %d\n",xver.prog_version.Seconds);
                        printf("Minute: %d\n",xver.prog_version.Minutes);
                        printf("hours: %d\n",xver.prog_version.Hours);
                        printf("year: %d\n",xver.prog_version.Year);
                        printf("months: %d\n",xver.prog_version.Months);
                        printf("day: %d\n",xver.prog_version.Day);
                        printf("start address: %d\n",xver.prog_version.start_adr);
                        printf("length: %d\n",xver.prog_version.len);
                        printf("flags(SOLL-1; RUN- 0x2;...): %d\n",xver.prog_version.Flags);

                        printf("\n\r TM_XBAND_GET_VERSION is received \r\n");
                    }
                    break;
                case TM_XBAND_SET_DEVICE_CONF:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                            printf("MFCC APP: XBAND set device config is success \n");
                        else
                            printf("MFCC APP: XBAND set device config is failure \n");

                    }
                    break;
                case TM_XBAND_GET_DEVICE_CONF:
                    {
                        os_memcpy(&xdev.HwPins,tm_frame.tm_data,sizeof(SERVICE_DEVICE_CONF_STRUCT));
                        printf("\n\r TM_XBAND_GET_DEVICE_CONF is received \r\n");

                        printf("RX-Mixer: %d\n",xdev.HwPins.RfeRx0On);
                        printf("TX-Mixer: %d\n",xdev.HwPins.RfeTx0On);
                        printf("RfePa0On: %d\n",xdev.HwPins.RfePa0On);
                        printf("RfeRxTx0: %d\n",xdev.HwPins.RfeRxTx0);
                        printf("RfeRx1On: %d\n",xdev.HwPins.RfeRx1On);
                        printf("ERfeTx1On: %d\n",xdev.HwPins.RfeTx1On);
                        printf("RfeRxTx1: %d\n",xdev.HwPins.RfeRxTx1);
                        printf("RfePa1On: %d\n",xdev.HwPins.RfePa1On);
                        printf("RfeOutEn: %d\n",xdev.HwPins.RfeOutEn);
                        printf("RfeGpio0: %d\n",xdev.HwPins.RfeGpio0);
                        printf("RfeLoopDet: %d\n",xdev.HwPins.RfeLoopDet);
                        printf("RfeLoMux: %d\n",xdev.HwPins.RfeLoMux);
                        printf("RfePowOn: %d\n",xdev.HwPins.RfePowOn);
                        printf("RfeDA: %d\n",xdev.HwPins.RfeDA);
                        printf("RfeCL: %d\n",xdev.HwPins.RfeCL);
                        printf("RfeEnAD5304: %d\n",xdev.HwPins.RfeEnAD5304);
                        printf("RfeEnSynth: %d\n",xdev.HwPins.RfeEnSynth);
                        printf("RfeEn3: %d\n",xdev.HwPins.RfeEn3);
                        printf("RfeEn4r: %d\n",xdev.HwPins.RfeEn4);
                        printf("RfeEn5: %d\n",xdev.HwPins.RfeEn5);
                        printf("7V0 PowerOn enable: %d\n",xdev.HwPins.Rfe7V0En);
                        printf("Rfe reserve to uint32: %d\n",xdev.HwPins.RfeRsvuint32);
                        printf("receive DownConversionFrequency channel 0: %d\n",xdev.RfeFreq.RxMix[0]);
                        printf("receive DownConversionFrequency channle 1: %d\n",xdev.RfeFreq.RxMix[1]);
                        printf("transmit UpConversionFrequency channel 0: %d\n",xdev.RfeFreq.TxMix[0]);
                        printf("transmit UpConversionFrequency channel 1: %d\n",xdev.RfeFreq.TxMix[1]);
                        printf("receive Frequency Channel0: %d\n",xdev.RfeFreq.RxFreq[0]);
                        printf("receive Frequency Channel1: %d\n",xdev.RfeFreq.RxFreq[1]);
                        printf("transmit Frequency Channel0: %d\n",xdev.RfeFreq.TxFreq[0]);
                        printf("transmit Frequency Channel1: %d\n",xdev.RfeFreq.TxFreq[1]);
                        printf("Rcv lowest  possible frequency Channel0: %d\n",xdev.LimFreq.RxLow[0]);
                        printf("Rcv lowest  possible frequency Channel1: %d\n",xdev.LimFreq.RxLow[1]);
                        printf("Rcv highest possible frequency Channel0: %u\n",xdev.LimFreq.RxHigh[0]);
                        printf("Rcv highest possible frequency Channel1: %u\n",xdev.LimFreq.RxHigh[1]);
                        printf("Xmt lowest  possible frequency Channel0: %d\n",xdev.LimFreq.TxLow[0]);
                        printf("Xmt lowest  possible frequency Channel1: %d\n",xdev.LimFreq.TxLow[1]);
                        printf("Xmt highest possible frequency Channel0: %d\n",xdev.LimFreq.TxHigh[0]);
                        printf("Xmt highest possible frequency Channel1: %d\n",xdev.LimFreq.TxHigh[1]);
                        printf("Flag for use 2Rx2Tx mode: %d\n",xdev.AdCtr._2Rx2Tx);
                        printf("Tx Level for XmtChannel 0 (0...2047): %d\n",xdev.AdCtr.TxLevel_0);
                        printf("Tx Level for XmtChannel 1 (0...2047): %d\n",xdev.AdCtr.TxLevel_1);
                        printf("AD9361 reference clock in MHz: %d\n",xdev.AdCtr.RefClk);
                        printf("Reserve: %d\n",xdev.AdCtr.Reserve);

                        printf("Xmt Modulation Channel_0 : %d\n",xdev.XmtCtr0.Modulat_0);
                        printf("Xmt Mode Channel_0: %d\n",xdev.XmtCtr0.Mode_0);
                        printf("Xmt FEC Channel_0: %d\n",xdev.XmtCtr0.Fec_0);
                        printf("Xmt Enable Channel 0: %d\n",xdev.XmtCtr0.ChEn_0);
                        printf("Xmt PseudoRanomizer 0: %d\n",xdev.XmtCtr0.PRnd_0 );
                        printf("Xmt ASM at FrmStart 0: %d\n",xdev.XmtCtr0.ASMStart_0);
                        printf("Xmt Offset Modulation 0: %d\n",xdev.XmtCtr0.OffsetMod_0);
                        printf("set FPGA output XmtOut_Data: %d\n",xdev.XmtCtr0.Ch1_diff_Ch2);
                        printf("Xmt On/Off Channel_0: %d\n",xdev.XmtCtr0.ChSwitchOn_0);
                        printf("Xmt Modulation Channel_1: %d\n",xdev.XmtCtr0.Modulat_1);
                        printf("Xmt Mode Channel_1: %d\n",xdev.XmtCtr0.Mode_1);
                        printf("Xmt FEC Channel_1: %d\n",xdev.XmtCtr0.Fec_1);
                        printf("Xmt Enable Channel 0: %d\n",xdev.XmtCtr0.ChEn_1);
                        printf("Xmt PseudoRanomizer 1: %d\n",xdev.XmtCtr0.PRnd_1);
                        printf("Xmt ASM at FrmStart 1: %d\n",xdev.XmtCtr0.ASMStart_1);
                        printf("Xmt Offset Modulation 1: %d\n",xdev.XmtCtr0.OffsetMod_1);
                        printf("Xmt On/Off Channel 1: %d\n",xdev.XmtCtr0.ChSwitchOn_1);
                        printf("Xmt 1-Offset Modulation normaly;: %d\n",xdev.XmtCtr0.OffsetModNormaly);
                        printf("AttTxGain_0: %d\n",xdev.XmtCtr3.AttTxGain_0);
                        printf("AttTxGain_1: %d\n",xdev.XmtCtr3.AttTxGain_1);
                        printf("TrFrmSz: %d\n",xdev.XmtCtr3.TrFrmSz);

                        printf("PhiOffset16: %d\n",xdev.XmtCtr4.PhiOffset16);
                        printf("y16: %d\n",xdev.XmtCtr4.Y16);
                        printf("TxSampFact: %d\n",xdev.XmtCtr4.TxSampFact);
                        printf("RsMode: %d\n",xdev.XmtCtr4.RsMode);

                        printf("RxGainMax: %d\n",xdev.RcvCtrCh[0].RxGainMax);
                        printf("ChEn: %d\n",xdev.RcvCtrCh[0].ChEn);
                        printf("Modulat: %d\n",xdev.RcvCtrCh[0].Modulat);
                        printf("MsbFirst: %d\n",xdev.RcvCtrCh[0].MsbFirst);
                        printf("Fec: %d\n",xdev.RcvCtrCh[0].Fec);
                        printf("PRnd: %d\n",xdev.RcvCtrCh[0].PRnd);
                        printf("BchDec: %d\n",xdev.RcvCtrCh[0].BchDec);
                        printf("AccBchErr: %d\n",xdev.RcvCtrCh[0].AccBchErr);
                        printf("RBchCountMode: %d\n",xdev.RcvCtrCh[0].BchCountMode);
                        printf("PowerOff: %d\n",xdev.RcvCtrCh[0].PwrOff);
                        printf("RcvCalib: %d\n",xdev.RcvCtrCh[0].RcvCalib);

                        printf("XmtSymbFreq: %d\n",xdev.SymbFreq.XmtSymbFreq);
                        printf("RcvSymbFreq: %d\n",xdev.SymbFreq.RcvSymbFreq);

                        printf("RcvMode: %d\n",xdev.RcvCtr_0.RcvMode);
                        printf("RcvChannel: %d\n",xdev.RcvCtr_0.RcvChannel);
                        printf("ChSwitchOn_0: %d\n",xdev.RcvCtr_0.ChSwitchOn_0);
                        printf("ChSwitchOn_1: %d\n",xdev.RcvCtr_0.ChSwitchOn_1);
                        printf("DropSample: %d\n",xdev.RcvCtr_0.DropSample);
                        printf("dT_minus: %d\n",xdev.RcvCtr_0.dT_minus);
                        printf("dT_plus: %d\n",xdev.RcvCtr_0.dT_plus);
                        printf("Reserve: %d\n",xdev.RcvCtr_0.Reserve);

                    }
                    break;
                case TM_XBAND_GET_FEATURE_SELECT:
                    {
                        printf("Entered in feature select");
                        os_memcpy(&fur.feature_select,tm_frame.tm_data,sizeof(fur));                
                        printf("\n\r TM_XBAND_GET_FEATURE_SELECT is received \r\n");

                        printf("Crc16: %d\n",fur.feature_select.Crc16);
                        printf("Reserve_0: %d\n",fur.feature_select.Reserve_0);
                        printf("MoreXmtMod: %d\n",fur.feature_select.MoreXmtMod);
                        printf("XmtOffsetMod: %d\n",fur.feature_select.XmtOffsetMod);
                        printf("RsMode: %d\n",fur.feature_select.RsMode);
                        printf("XmtCh0_En: %d\n",fur.feature_select.XmtCh0_En);
                        printf("XmtCh1_En: %d\n",fur.feature_select.XmtCh1_En);
                        printf("RcvCh0_En: %d\n",fur.feature_select.RcvCh0_En);
                        printf("RcvCh1_Ene: %d\n",fur.feature_select.RcvCh1_En);
                        printf("RcvCh0_GainMax: %d\n",fur.feature_select.RcvCh0_GainMax);
                        printf("RcvCh1_GainMax: %d\n",fur.feature_select.RcvCh1_GainMax);
                        printf("DisableXmtSymbFreqChange: %d\n",fur.feature_select.DisableXmtSymbFreqChange);
                        printf("DisableRcvSymbFreqChange: %d\n",fur.feature_select.DisableRcvSymbFreqChange);
                        printf("DisableXmtUpSampling: %d\n",fur.feature_select.DisableXmtUpSampling);
                        printf("Reserve_1: %d\n",fur.feature_select.Reserve_1);
                        printf("XmtSymbFreq: %d\n",fur.feature_select.XmtSymbFreq);
                        printf("RcvSymbFreq: %d\n",fur.feature_select.RcvSymbFreq);
                        printf("Reserve_3: %d\n",fur.feature_select.Reserve_3);

                    }
                    break;
                case TM_XBAND_GET_HOUSE_KEEP:
                    {
                        SERVICE_HOUSE_KEEP_STRUCT house;
                        os_memcpy(&house.HouseKeep,&tm_frame.tm_data[3],sizeof(house));
                        printf("\n\r TM_XBAND_GET_HOUSE_KEEP is received \r\n");
                        printf("AD9361: %d\n",house.HouseKeep.Temp.AD9361);
                        printf("EthPhy: %d\n",house.HouseKeep.Temp.EthPhy);
                        printf("Zynq: %d\n",house.HouseKeep.Temp.Zynq);
                        printf("Rest: %d\n",house.HouseKeep.Temp.Rest);

                        printf("On: %d\n",house.HouseKeep.RcvInfCh[0].On);
                        printf("Sync: %d\n",house.HouseKeep.RcvInfCh[0].Sync);
                        printf("idxGain: %d\n",house.HouseKeep.RcvInfCh[0].idxGain);
                        printf("SirMin: %d\n",house.HouseKeep.RcvInfCh[0].SirMin);
                        printf("SirMax: %d\n",house.HouseKeep.RcvInfCh[0].SirMax);
                        printf("DopplerFreq: %d\n",house.HouseKeep.RcvInfCh[0].DopplerFreq);
                        printf("Rest0: %d\n",house.HouseKeep.RcvInfCh[0].Rest0);
                        printf("PwrMin: %d\n",house.HouseKeep.RcvInfCh[0].PwrMin);
                        printf("PwrMax: %d\n",house.HouseKeep.RcvInfCh[0].PwrMax);
                        printf("RxState: %d\n",house.HouseKeep.RcvInfCh[0].RxState);
                        printf("Rest1: %d\n",house.HouseKeep.RcvInfCh[0].Rest1);
                        printf("BchBlockCount: %d\n",house.HouseKeep.RcvInfCh[0].BchBlockCount);
                        printf("BchErrCount: %d\n",house.HouseKeep.RcvInfCh[0].BchErrCount);                                                                                                                                                                                

                        printf("On: %d\n",house.HouseKeep.XmtInfCh[0].On);
                        printf("Modulation: %d\n",house.HouseKeep.XmtInfCh[0].Modulation);                
                        printf("Fec: %d\n",house.HouseKeep.XmtInfCh[0].Fec);
                        printf("Att: %d\n",house.HouseKeep.XmtInfCh[0].Att);

                        printf("Rest: %d\n",house.HouseKeep.XmtInfCh[0].Rest);

                        printf("card_run_counter: %d\n",house.HouseKeep.card_run_counter);                                                                
                    }
                    break;
                case TM_XBAND_GET_XPA_INF:
                    {
                        printf("\n\r TM_XBAND_GET_XPA_INF is received \r\n");

                    }
                    break;


                case TM_XBAND_SET_PROD_KEY:
                    {
                        printf("\n\r TM_XBAND_SET_PROD_KEY is received \r\n");
                    }
                    break;

                case TM_COMMS_UHF_SET_TX_CFG:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                            printf("MFCC APP: UHF TX config is SUCCESS \n");
                        else
                            printf("MFCC APP: UHF TX  config is FAILURE \n");

                    }                                       
                    break;

                case TM_COMMS_UHF_SET_RX_CFG:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                            printf("MFCC APP: UHF RX config is SUCCESS  \n");
                        else
                            printf("MFCC APP: UHF RX  config is FAILURE \n");

                    }                                       
                    break;

                case TM_COMMS_UHF_SET_TX_PKT_CFG:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                            printf("MFCC APP: UHF TX PKT config is SUCCESS  \n");
                        else
                            printf("MFCC APP: UHF TX PKT config is FAILURE \n");

                    }                                       
                    break;

                case TM_COMMS_UHF_SET_RX_PKT_CFG:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                            printf("MFCC APP: UHF RX PKT config is SUCCESS  \n");
                        else
                            printf("MFCC APP: UHF RX PKT config is FAILURE \n");

                    }                                       
                    break;

                case TM_COMMS_UHF_SET_PWR_CFG:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                            printf("MFCC APP: UHF power setting is SUCCESS  \n");
                        else
                            printf("MFCC APP: UHF power setting is FAILURE \n");

                    }                                       
                    break;

                case TM_COMMS_UHF_GET_TM_INFO:
                    {
#if 0
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                        {
                            printf("MFCC APP: UHF get TM is success \n");
                        }
                        else
                        {
                            printf("MFCC APP: UHF get TM failure \n");
                        }
#endif
                        os_memcpy(&get_full_tm,tm_frame.tm_data,sizeof(s_uhf_get_full_tm));
                        printf("up time:%u\n",get_full_tm.uptime);
                        printf("uart0 rx count:%u\n",get_full_tm.uart0_rx_count);
                        printf("uart1 rx count:%u\n",get_full_tm.uart1_rx_count);
                        printf("rx mode:%u\n",get_full_tm.rx_mode);
                        printf("tx mode:%u\n",get_full_tm.tx_mode);
                        for(int i = 0; i< 10;i++)
                        {
                            printf("adc:%d\n",get_full_tm.adc[i]);
                        }
                        printf("last rssi:%u\n",get_full_tm.last_rssi);
                        printf("last lqi:%u\n",get_full_tm.last_lqi);
                        printf("last freq:%u\n",get_full_tm.last_freqest);
                        printf("Pkt sent:%u\n",get_full_tm.Pkt_sent);
                        printf("cs count:%u\n",get_full_tm.cs_count);
                        printf("Pkt good:%u\n",get_full_tm.Pkt_good);
                        printf("Pkt rejected checksum:%u\n",get_full_tm.Pkt_rejected_checksum);
                        printf("Pkt rejected reserved:%u\n",get_full_tm.Pkt_rejected_reserved);
                        printf("Pkt rejected other:%u\n",get_full_tm.Pkt_rejected_other);
                        printf("reserved0:%u\n",get_full_tm.reserved0);
                        //printf("reserved1:%u\n",get_full_tm.reserved1);

                    }
                    break;

                case TM_COMMS_UHF_GET_TX_CFG:
                    {
                        //memcpy(&get_rf_tx_cfg,tm_frame.tm_data,sizeof(s_uhf_rf_cfg));
                        printf("\nTM Len: %d\n",tm_len);
                        memcpy(&get_rf_tx_cfg,tm_frame.tm_data,tm_len);
                        printf("base frequency :%f\n",get_rf_tx_cfg.Base_Frequency);
                        printf("if frequency :%f\n",get_rf_tx_cfg.IF_Frequnecy);
                        printf("channel number :%hhu\n",get_rf_tx_cfg.Channel_Number);
                        printf("channel spacing :%f\n",get_rf_tx_cfg.Channel_Spacing);
                        printf("frequency offset :%f\n",get_rf_tx_cfg.Frequency_Offset);
                        printf("modulation type :%hhu\n",get_rf_tx_cfg.Modulation_Type);
                        printf("sync mode :%hhu\n",get_rf_tx_cfg.Sync_Mode);
                        printf("data rate :%f\n",get_rf_tx_cfg.Data_Rate);
                        printf("enable dc filter :%hhu\n",get_rf_tx_cfg.Enable_DC_filter);
                        printf("fec enable :%hhu\n",get_rf_tx_cfg.FEC_enable);
                        printf("preamble number :%hhu\n",get_rf_tx_cfg.Preamble_Num);
                        printf("channel bw :%f\n",get_rf_tx_cfg.Channel_BW);
                        printf("manchester enable :%hhu\n",get_rf_tx_cfg.Manchester_Enable);
                        printf("frequency deviation :%f\n",get_rf_tx_cfg.Frequency_deviation);
                    }
                    break;

                case TM_COMMS_UHF_GET_RX_CFG:
                    {
                        printf("\nTM Len: %d\n",tm_len);
                        memcpy(&get_rf_rx_cfg,tm_frame.tm_data,sizeof(s_uhf_rf_rx_cfg));
                        printf("Base Frequency:%f\n",get_rf_rx_cfg.Base_Frequency);
                        printf("IF Frequency:%f\n",get_rf_rx_cfg.IF_Frequnecy);
                        printf("Channel Number:%hhu\n",get_rf_rx_cfg.Channel_Number);
                        printf("Channel Spacing:%f\n",get_rf_rx_cfg.Channel_Spacing);
                        printf("Frequency Offset:%f\n",get_rf_rx_cfg.Frequency_Offset);
                        printf("Modulation Type:%hhu\n",get_rf_rx_cfg.Modulation_Type);
                        printf("Sync Mode:%hhu\n",get_rf_rx_cfg.Sync_Mode);
                        printf("Data Rate:%f\n",get_rf_rx_cfg.Data_Rate);
                        printf("Enable DC filter:%hhu\n",get_rf_rx_cfg.Enable_DC_filter);
                        printf("FEC enable:%hhu\n",get_rf_rx_cfg.FEC_enable);
                        printf("Preamble Number:%hhu\n",get_rf_rx_cfg.Preamble_Num);
                        printf("Channel BW:%f\n",get_rf_rx_cfg.Channel_BW);
                        printf("Manchester Enable:%hhu\n",get_rf_rx_cfg.Manchester_Enable);
                        printf("Frequency deviation:%f\n",get_rf_rx_cfg.Frequency_deviation);
                        printf("RX Sync Time Out:%f\n",get_rf_rx_cfg.RX_Sync_Time_Out);
                        printf("RX Attenuation:%hhu\n",get_rf_rx_cfg.RX_Attenuation);
                    }
                    break;

                case TM_COMMS_UHF_GET_TX_PKT_CFG:
                    {
                        printf("\nTM Len: %d\n",tm_len);
                        memcpy(&get_rf_tx_pkt_cfg,tm_frame.tm_data,sizeof(s_uhf_rf_tx_pkt_cfg));
                        printf("Demod Sync Word:%hu\n",get_rf_tx_pkt_cfg.Demod_Sync_Word);
                        printf("Maximum Packet Length:%hhu\n",get_rf_tx_pkt_cfg.Max_Packet_Length);
                        printf("Whitening Enable:%hhu\n",get_rf_tx_pkt_cfg.Whitening_Enable);
                        printf("Packet Format:%hhu\n",get_rf_tx_pkt_cfg.Packet_Format);
                        printf("CRC Enable:%hhu\n",get_rf_tx_pkt_cfg.CRC_Enable);
                        printf("Pkt Length Config:%hhu\n",get_rf_tx_pkt_cfg.Pkt_Len_Config);
                        printf("Device Address:%hhu\n",get_rf_tx_pkt_cfg.Device_Addr);
                    }
                    break;

                case TM_COMMS_UHF_GET_RX_PKT_CFG:
                    {
                        printf("\nTM Len: %d\n",tm_len);
                        memcpy(&get_rf_rx_pkt_cfg,tm_frame.tm_data,sizeof(s_uhf_rf_rx_pkt_cfg));
                        printf("Demod Sync Word:%hu\n",get_rf_rx_pkt_cfg.Demod_Sync_Word);
                        printf("Maximum Packet Length:%hhu\n",get_rf_rx_pkt_cfg.Max_Packet_Length);
                        printf("Whitening Enable:%hhu\n",get_rf_rx_pkt_cfg.Whitening_Enable);
                        printf("Packet Format:%hhu\n",get_rf_rx_pkt_cfg.Packet_Format);
                        printf("CRC Enable:%hhu\n",get_rf_rx_pkt_cfg.CRC_Enable);
                        printf("Pkt Length Config:%hhu\n",get_rf_rx_pkt_cfg.Pkt_Len_Config);
                        printf("device address :%hhu\n",get_rf_rx_pkt_cfg.Device_Addr);
                    }
                    break;

                case TM_COMMS_UHF_GET_PWR_CFG:
                    {
                        printf("\nTM Len: %d\n",tm_len);
                        memcpy(&get_pwr_stng,tm_frame.tm_data,sizeof(s_uhf_set_pwr_stng));
                        printf("Maximum DVGA Gain :%hhu\n",get_pwr_stng.Max_DVGA_Gain);
                        printf("Maximum LNA Gain: %hhu\n",get_pwr_stng.Max_LNA_Gain);
                        printf("LNA_Sel :%hhu\n",get_pwr_stng.LNA_Sel);
                        printf("Filter Length:%hhu\n",get_pwr_stng.Filter_Len);
                        printf("Power table selection:%hhu\n",get_pwr_stng.Power_Table_sel);
                        printf("RF Output Power:%hhu\n",get_pwr_stng.RF_Output_Power);
                    }
                    break;
#if 0 
                case TM_COMMS_UHF_GET_BASE_TM:
                    {
                        memcpy(&get_tm,tm_frame.tm_data,sizeof(s_uhf_get_basic_tm));
                        printf("up time :%u\n",get_tm.uptime);
                        printf("uart0 rx count:%u\n",get_tm.uart0_rx_count);
                        printf("uart1 rx count:%u\n",get_tm.uart1_rx_count);
                        printf("rx mode:%hhu\n",get_tm.rx_mode);
                        printf("tx mode:%hhu\n",get_tm.tx_mode);
                    }
                    break;

                case TM_COMMS_UHF_GET_FULL_TM:
                    {
                        memcpy(&get_full_tm,tm_frame.tm_data,sizeof(s_uhf_get_full_tm));
                        printf("up time:%u\n",get_full_tm.uptime);
                        printf("uart0 rx count:%u\n",get_full_tm.uart0_rx_count);
                        printf("uart1 rx count:%u\n",get_full_tm.uart1_rx_count);
                        printf("rx mode:%u\n",get_full_tm.rx_mode);
                        printf("tx mode:%u\n",get_full_tm.tx_mode);
                        for(int i = 0; i< 10;i++)
                        {
                            printf("adc:%u\n",get_full_tm.adc[i]);
                        }
                        printf("last rssi:%u\n",get_full_tm.last_rssi);
                        printf("last lqi:%u\n",get_full_tm.last_lqi);
                        printf("Pkt sent:%u\n",get_full_tm.last_freqest);
                        printf("Pkt sent:%u\n",get_full_tm.Pkt_sent);
                        printf("cs count:%u\n",get_full_tm.cs_count);
                        printf("Pkt goog:%u\n",get_full_tm.Pkt_good);
                        printf("Pkt rejected checksum:%u\n",get_full_tm.Pkt_rejected_checksum);
                        printf("Pkt rejected reserved:%u\n",get_full_tm.Pkt_rejected_reserved);
                        printf("Pkt rejected other:%u\n",get_full_tm.Pkt_rejected_other);
                        printf("reserved0:%u\n",get_full_tm.reserved0);
                        printf("reserved1:%u\n",get_full_tm.reserved1);
                    }
                    break;
#endif


                    /*           case TM_COMMS_UHF_GET_FULL_CFG:
                                 {
                                 memcpy(&get_reg_map,tm_frame.tm_data,sizeof(s_uhf_cc1110_reg_map));
                                 printf("sync1:%x\n",get_reg_map.sync1);
                                 printf("sync0:%x\n",get_reg_map.sync0);
                                 printf("pkt length:%x\n",get_reg_map.pktlen);
                                 printf("pkt control1:%x\n",get_reg_map.pktctrl1);
                                 printf("pkt control0:%x\n",get_reg_map.pktctrl0);
                                 printf("address:%x\n",get_reg_map.addr);
                                 printf("channr:%x\n",get_reg_map.channr);
                                 printf("frequency control 1:%x\n",get_reg_map.fsctrl1);
                                 printf("frequency control 0:%x\n",get_reg_map.fsctrl0);
                                 printf("frequency2:%x\n",get_reg_map.freq2);
                                 printf("frequency1:%x\n",get_reg_map.freq1);
                                 printf("frequency0:%x\n",get_reg_map.freq0);
                                 printf("modem configuration4:%x\n",get_reg_map.mdmcfg4);
                                 printf("modem configuration3:%x\n",get_reg_map.mdmcfg3);
                                 printf("modem configuration2:%x\n",get_reg_map.mdmcfg2);
                                 printf("modem configuration1:%x\n",get_reg_map.mdmcfg1);
                                 printf("modem configuration0:%x\n",get_reg_map.mdmcfg0);
                                 printf("deviation:%x\n",get_reg_map.deviatn);
                                 printf("main radio contol state machine 2:%x\n",get_reg_map.mcsm2);
                                 printf("main radio contol state machine 1:%x\n",get_reg_map.mcsm1);
                                 printf("main radio contol state machine 0::%x\n",get_reg_map.mcsm0);
                                 printf("frequency offset configuration:%x\n",get_reg_map.foccfg);
                                 printf("bit synchronization configuration:%x\n",get_reg_map.bscfg);
                                 printf("asc control2:%x\n",get_reg_map.agcctrl2);
                                 printf("asc control1:%x\n",get_reg_map.agcctrl1);
                                 printf("asc control0:%x\n",get_reg_map.agcctrl0);
                                 printf("front end rx configuration1:%x\n",get_reg_map.frend1);
                                 printf("front end rx configuration0:%x\n",get_reg_map.frend0);
                                 printf("frequency synthesizer calibration3:%x\n",get_reg_map.fscal3);
                                 printf("frequency synthesizer calibration2:%x\n",get_reg_map.fscal2);
                                 printf("frequency synthesizer calibration1:%x\n",get_reg_map.fscal1);
                                 printf("frequency synthesizer calibration0:%x\n",get_reg_map.fscal0);
                                 printf("test2:%x\n",get_reg_map.test2);
                                 printf("test1:%x\n",get_reg_map.test1);
                                 printf("test0:%x\n",get_reg_map.test0);
                                 printf("pa table7:%x\n",get_reg_map.pa_table7);
                                 printf("pa table6:%x\n",get_reg_map.pa_table6);
                                 printf("pa table5:%x\n",get_reg_map.pa_table5);
                                 printf("pa table4:%x\n",get_reg_map.pa_table4);
                                 printf("pa table3:%x\n",get_reg_map.pa_table3);
                                 printf("pa table2:%x\n",get_reg_map.pa_table2);
                                 printf("pa table1:%x\n",get_reg_map.pa_table1);
                                 printf("pa table0:%x\n",get_reg_map.pa_table0);
                                 printf("io configuration2:%x\n",get_reg_map.iocfg2);
                                 printf("io configuration1:%x\n",get_reg_map.iocfg1);
                                 printf("io configuration0:%x\n",get_reg_map.iocfg0);
                                 }
                                 break;*/

                case TM_COMMS_UHF_BEACON_CFG:
                    {
                        memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                        {
                            printf("MFCC APP: UHF BEACON is COMPLETE \n");
                        }
                        else
                        {
                            printf("MFCC APP: UHF BEACON FAILURE \n");
                        }
                    }
                    break;

                case TM_COMMS_UHF_SET_CFG:
                    {
                        memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                        {
                            printf("MFCC APP: UHF set cfg is COMPLETE \n");
                        }
                        else
                        {
                            printf("MFCC APP: UHF set cfg failure \n");
                        }
                    }
                    break;

                case TM_COMMS_UHF_BEACON_TX_ST:
                    {
                        memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                        {
                            printf("MFCC APP: UHF BEACON TX START SUCCESS \n");
                        }
                        else
                        {
                            printf("MFCC APP: UHF BEACON TX START FAILURE \n");
                        }
                    }
                    break;


                case TM_COMMS_UHF_BEACON_TX_STOP:
                    {
                        memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                        {
                            printf("MFCC APP: UHF BEACON TX STOP SUCCESS \n");
                        }
                        else
                        {
                            printf("MFCC APP: UHF BEACON TX STOP FAILURE \n");
                        }
                    }
                    break;

                case TM_COMMS_UHF_BEACON_DATA:
                    {
                        memcpy(&sdr_beacon_pld,tm_frame.tm_data,tm_len);

                        printf("BEACON DATA via UHF MODULE");
                        printf("Beacon message: %hhn\n",sdr_beacon_pld.bcon_utc_gps.bcon_msg);
                        printf("UTC time: %d\n",sdr_beacon_pld.bcon_utc_gps.utc_tim);
                        printf("UTC Time from GPS status: %d\n",sdr_beacon_pld.bcon_utc_gps.utc_gps_tim_sts);
                        printf("Latitude: %f\n",sdr_beacon_pld.bcon_utc_gps.latitude);
                        printf("Longitude: %f\n",sdr_beacon_pld.bcon_utc_gps.longitude);
                        printf("Altitude: %f\n",sdr_beacon_pld.bcon_utc_gps.altitude);
                        printf("Position x: %lf\n",sdr_beacon_pld.bcon_utc_gps.x_pos);
                        printf("Position y: %lf\n",sdr_beacon_pld.bcon_utc_gps.y_pos);
                        printf("Position z: %lf\n",sdr_beacon_pld.bcon_utc_gps.z_pos);
                        printf("Velocity x: %lf\n",sdr_beacon_pld.bcon_utc_gps.x_vel);
                        printf("Velocity y: %lf\n",sdr_beacon_pld.bcon_utc_gps.y_vel);
                        printf("Velocity z: %lf\n",sdr_beacon_pld.bcon_utc_gps.z_vel);
                        printf("FSM current state: %d\n",sdr_beacon_pld.obc_mh.fsm_state);
                        printf("No of OBC resets: %d\n",sdr_beacon_pld.obc_mh.num_resets);
                        printf("IO errors: %d\n",sdr_beacon_pld.obc_mh.io_err);
                        printf("System errors : %d\n",sdr_beacon_pld.obc_mh.sys_err);
                        printf("OBC Voltage sensor value: %d\n",sdr_beacon_pld.sen_mh.obc_volt_sensor);
                        printf("PS sensor value: %d\n",sdr_beacon_pld.sen_mh.ps_volt_sensor);
                        printf("OBC temperature: %d\n",sdr_beacon_pld.sen_mh.temp_obc);
                        printf("PS temperature: %d\n",sdr_beacon_pld.sen_mh.temp_ps);
                        printf("ES temperature: %d\n",sdr_beacon_pld.sen_mh.temp_es);
                        printf("GPS temperature: %d\n",sdr_beacon_pld.sen_mh.temp_gps);
                        printf("Total battery voltage: %d\n",sdr_beacon_pld.eps_mh.totl_btry_volt);
                        printf("Total panel power: %d\n",sdr_beacon_pld.eps_mh.totl_panel_pwr);
                        printf("Channel status: %d\n",sdr_beacon_pld.eps_mh.chnl_sts);
                        printf("Over current error flag byte1: %d\n",sdr_beacon_pld.eps_mh.overcrnt_err_flg_byte1);
                        printf("Over current error flag byte2: %d\n",sdr_beacon_pld.eps_mh.overcrnt_err_flg_byte2);
                        printf("ADCS Current state and ADCS Current mode: %d\n",sdr_beacon_pld.adcs_mh.fsm_state_mode);
                        printf("Sensor, actuators Power status: %d\n",sdr_beacon_pld.adcs_mh.sns_actr_pwr_sts);
                        printf("ADCS Actuator running status: %d\n",sdr_beacon_pld.adcs_mh.actrs_run_sts);
                        printf("SDR fsm state: %d\n",sdr_beacon_pld.sdr_sband_mh.sdr_fsm_st);
                        printf("SBAND Receive signal strength indicator 0: %d\n",sdr_beacon_pld.sdr_sband_mh.rssi0);
                        printf("SBAND Receive signal strength indicator 1: %d\n",sdr_beacon_pld.sdr_sband_mh.rssi1);
                        printf("SBAND RX error count: %d\n",sdr_beacon_pld.sdr_sband_mh.rx_err_cnt);
                        printf("SBAND TX frame count: %d\n",sdr_beacon_pld.sdr_sband_mh.tx_frm_cnt);
                        printf("SBAND RX frequency: %d\n",sdr_beacon_pld.sdr_sband_mh.rx_freq);
                        printf("SBAND Symbol frequency: %d\n",sdr_beacon_pld.sdr_sband_mh.symb_freq);
                        printf("SBAND Modulation type: %d\n",sdr_beacon_pld.sdr_sband_mh.mod);
                        printf("SBAND Roll off: %d\n",sdr_beacon_pld.sdr_sband_mh.roll_off);
                        printf("SBAND Randamoization enable: %d\n",sdr_beacon_pld.sdr_sband_mh.rand_enb);
                        printf("SBAND Convolution coding enable: %d\n",sdr_beacon_pld.sdr_sband_mh.cc_enb);
                        printf("SBAND Reed solomon enable: %d\n",sdr_beacon_pld.sdr_sband_mh.rs_enb);
                        printf("UHF SDR fsm state: %d\n",sdr_beacon_pld.sdr_uhf_mh.sdr_fsm_st);
                        printf("UHF Receive signal strength indicator 0: %d\n",sdr_beacon_pld.sdr_uhf_mh.rssi0);
                        printf("UHF Receive signal strength indicator 1: %d\n",sdr_beacon_pld.sdr_uhf_mh.rssi1);
                        printf("UHF RX error count: %d\n",sdr_beacon_pld.sdr_uhf_mh.rx_err_cnt);
                        printf("UHF TX frame count: %d\n",sdr_beacon_pld.sdr_uhf_mh.tx_frm_cnt);
                        printf("UHF RX frequency: %d\n",sdr_beacon_pld.sdr_uhf_mh.rx_freq);
                        printf("UHF Symbol frequency: %d\n",sdr_beacon_pld.sdr_uhf_mh.symb_freq);
                        printf("UHF Modulation type: %d\n",sdr_beacon_pld.sdr_uhf_mh.mod);
                        printf("UHF Roll off: %d\n",sdr_beacon_pld.sdr_uhf_mh.roll_off);
                        printf("UHF Cyclic redundancy check enable: %d\n",sdr_beacon_pld.sdr_uhf_mh.crc_enb);
                        printf("UHF DC filter enable: %d\n",sdr_beacon_pld.sdr_uhf_mh.dc_filter_enb);
                        printf("UHF Convolution coding enable: %d\n",sdr_beacon_pld.sdr_uhf_mh.cc_enb);
                        printf("UHF Randamoization enable: %d\n",sdr_beacon_pld.sdr_uhf_mh.rand_enb);
                        printf("UHF Manchester coding enable: %d\n",sdr_beacon_pld.sdr_uhf_mh.manchester_coding_en);
                    }
                    break;

                case TM_COMMS_UHF_FW_CFG:
                    {
                        memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                        {
                            printf("MFCC APP: UHF FW SUCCESS \n");
                        }
                        else
                        {
                            printf("MFCC APP: UHF FW FAILURE \n");
                        }
                    }
                    break;

                case TM_COMMS_UHF_FW_CFG_ACTIVATE:
                    {
                        memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(sts == 4)
                        {
                            printf("MFCC APP: UHF FW CFG ACT SUCCESS \n");
                        }
                        else if (sts == 5)
                        {
                            printf("MFCC APP: UHF FW CFG ACT FAILURE \n");
                        }
                        else if (sts == 6)
                        {
                            printf("MFCC APP: UHF FW CFG ACT DELAY \n");
                        }
                        else if (sts == 7)
                        {
                            printf("MFCC APP: UHF FW CFG ACT FAILURE - DATA NOT RCV \n");
                        }
                        else if (sts == 8)
                        {
                            printf("MFCC APP: UHF FW CFG ACT FAILURE - WRONG FW \n");
                        }
                        else if (sts == 9)
                        {
                            printf("MFCC APP: UHF FW CFG ACT FAILURE - BAD CHK SUM \n");
                        }
                    }
                    break;

                case TM_COMMS_UHF_CSP_TM_INFO:
                    {
                        memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                        {
                            printf("MFCC APP: UHF CSP SUCCESS \n");
                        }
                        else
                        {
                            printf("MFCC APP: UHF CSP FAILURE \n");
                        }
                    }
                    break;

                case TM_COMMS_UHF_GET_TM_STORE:
                    {
                        int i;
                        int j = 1;
                        os_memcpy(&cnt,tm_frame.tm_data,1);
                        printf("The value of cnt is %d\n", cnt);
                        for( i= 0; i < cnt; i++)
                        {
                            os_memcpy(&uhf_get_tm_stor.uhf_tm_store[i],&tm_frame.tm_data[j],sizeof(s_uhf_get_full_tm));
                            printf("up time:%u\n",uhf_get_tm_stor.uhf_tm_store[i].comms_uhf_tm_stor.uptime);
                            printf("uart0 rx count:%u\n",uhf_get_tm_stor.uhf_tm_store[i].comms_uhf_tm_stor.uart0_rx_count);
                            printf("uart1 rx count:%u\n",uhf_get_tm_stor.uhf_tm_store[i].comms_uhf_tm_stor.uart1_rx_count);
                            printf("rx mode:%u\n",uhf_get_tm_stor.uhf_tm_store[i].comms_uhf_tm_stor.rx_mode);
                            printf("tx mode:%u\n",uhf_get_tm_stor.uhf_tm_store[i].comms_uhf_tm_stor.tx_mode);
                            for(int k = 0; k< 10;k++)
                            {
                                printf("adc:%u\n",uhf_get_tm_stor.uhf_tm_store[i].comms_uhf_tm_stor.adc[k]);
                            }
                            printf("last rssi:%u\n",uhf_get_tm_stor.uhf_tm_store[i].comms_uhf_tm_stor.last_rssi);
                            printf("last lqi:%u\n",uhf_get_tm_stor.uhf_tm_store[i].comms_uhf_tm_stor.last_lqi);
                            printf("last freq set:%u\n",uhf_get_tm_stor.uhf_tm_store[i].comms_uhf_tm_stor.last_freqest);
                            printf("Pkt sent:%u\n",uhf_get_tm_stor.uhf_tm_store[i].comms_uhf_tm_stor.Pkt_sent);
                            printf("cs count:%u\n",uhf_get_tm_stor.uhf_tm_store[i].comms_uhf_tm_stor.cs_count);
                            printf("Pkt good:%u\n",uhf_get_tm_stor.uhf_tm_store[i].comms_uhf_tm_stor.Pkt_good);
                            printf("Pkt rejected checksum:%u\n",uhf_get_tm_stor.uhf_tm_store[i].comms_uhf_tm_stor.Pkt_rejected_checksum);
                            printf("Pkt rejected reserved:%u\n",uhf_get_tm_stor.uhf_tm_store[i].comms_uhf_tm_stor.Pkt_rejected_reserved);
                            printf("Pkt rejected other:%u\n",uhf_get_tm_stor.uhf_tm_store[i].comms_uhf_tm_stor.Pkt_rejected_other);
                            printf("reserved0:%u\n",uhf_get_tm_stor.uhf_tm_store[i].comms_uhf_tm_stor.reserved0);

                            j = j + (sizeof(s_uhf_get_full_tm));
                        }

                        if(cnt == i)
                        {
                            printf("MFCC APP: UHF TM STORE SUCCESS \n");
                        }
                        else
                        {
                            printf("MFCC APP: UHF TM STORE FAILURE \n");
                        }
                    }
                    break;
                case TM_COMMS_UHF_GET_FW_STS:
                    {

                        memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(tm_frame.tm_data[0] == 0)
                        {
                            printf("MFCC APP: COMMS UHF FW AVAILABLE FOR BOOT \n");
                        }
                        else if(tm_frame.tm_data[0] == 1)
                        {
                            printf("MFCC APP: COMMS UHF FW CORRUPTED \n");
                        }
                        else if(tm_frame.tm_data[0] == 2)
                        {
                            printf("MFCC APP: COMMS UHF FW NVM LEN MISMATCH \n");
                        }

                    }
                    break;


                case TM_GET_SDR_CFG:
                    {

                        printf("\nTM Len: %d\n",tm_len);
                        memcpy(&set_sdr_cfg,tm_frame.tm_data,sizeof(s_sdr_cfg));

                        printf("radio ID :%hhu\n",set_sdr_cfg.radio_id);
                        printf("sdr status :%hhu\n",set_sdr_cfg.sdr_sts);
                        printf("sdr duplex type: :%hhu\n",set_sdr_cfg.sdr_dplx_typ);
                        printf("sdr number of rx :%hhu\n",set_sdr_cfg.sdr_num_rx);
                        printf("sdr number of tx :%hhu\n",set_sdr_cfg.sdr_num_tx);
                        printf("sdr combined rx support :%hhu\n",set_sdr_cfg.combined_rx_support);
                        printf("sdr combined tx support :%hhu\n",set_sdr_cfg.combined_tx_support);
                        printf("sdr minimum frequency :%u\n",set_sdr_cfg.min_frequency);
                        printf("sdr maximum frequency :%u\n",set_sdr_cfg.max_frequency);
                        printf("minimum rx frequency :%hhu\n",set_sdr_cfg.min_frequency_rx);
                        printf("maximum rx frquency :%hhu\n",set_sdr_cfg.max_frequency_rx);

                    }
                    break;

                case TM_GET_SDR_STS:
                    {
                        uint8_t sdr_sts;
                        printf("\nTM Len: %d\n",tm_len);
                        memcpy(&sdr_sts,tm_frame.tm_data,sizeof(sdr_sts));

                        printf("SDR status :%hhu\n",sdr_sts);

                    }
                    break;
                case TM_GET_SDR_TMR_CFG:
                    {

                        printf("\nTM Len: %d\n",tm_len);
                        memcpy(&sdr_tmr_cfg,tm_frame.tm_data,sizeof(s_sdr_tmr_cfg));

                        printf("beacon enable timer :%u\n",sdr_tmr_cfg.beacon_enb_tmr);
                        printf("beacon periodicity timer :%u\n",sdr_tmr_cfg.beacon_prd_tmr);
                        printf("beacon rep timer :%u\n",sdr_tmr_cfg.beaocn_rep_tmr);
                        printf("tx data rep cnt :%u\n",sdr_tmr_cfg.tx_data_rep_cnt);
                        printf("sdr tm timer :%u\n",sdr_tmr_cfg.sdr_tm_tmr);
                        printf("sdr tx on timer :%u\n",sdr_tmr_cfg.sdr_tx_on_tmr);
                        printf("sdr rx on timer :%u\n",sdr_tmr_cfg.sdr_rx_on_tmr);
                        printf("sdr tm read timer :%u\n",sdr_tmr_cfg.sdr_tm_read_tmr);

                    }
                    break;

                case TM_GET_SDR_RX_RSSI_CFG:
                    {

                        printf("\nTM Len: %d\n",tm_len);
                        memcpy(&sdr_rx_rssi_cfg,tm_frame.tm_data,sizeof(s_sdr_rx_rssi_cfg));

                        printf("valid rssi count :%hhu\n",sdr_rx_rssi_cfg.valid_rssi_cnt);
                        printf("inv rssi count :%hhu\n",sdr_rx_rssi_cfg.inv_rssi_cnt);
                        printf("rssi minimum :%f\n",sdr_rx_rssi_cfg.rssi_min);
                        printf("rssi typical :%f\n",sdr_rx_rssi_cfg.rssi_typ);
                        printf("rssi periodicity timer :%u\n",sdr_rx_rssi_cfg.rssi_prd_tmr);
                        printf("short rx on tmr :%u\n",sdr_rx_rssi_cfg.short_rx_on_timer);
                        printf("long rx on tmr :%u\n",sdr_rx_rssi_cfg.long_rx_on_timer);

                    }
                    break;

                case TM_GET_SDR_TM_CFG:
                    {

                        printf("\nTM Len: %d\n",tm_len);
                        memcpy(&sdr_tm_cfg,tm_frame.tm_data,sizeof(s_sdr_tm_cfg));

                        printf("TM auto read sts :%hhu\n",sdr_tm_cfg.tm_auto_read_sts);
                        printf("TM read periodicity :%d\n",sdr_tm_cfg.tm_read_periodicity);
                        printf("TM short storage :%d\n",sdr_tm_cfg.tm_short_storage_duration);
                        printf("TM long storage :%d\n",sdr_tm_cfg.tm_long_storage_duration);
                    }
                    break;

                case TM_GET_SDR_SENS_CFG:
                    {

                        uint8_t temp_count =0;
                        uint8_t volt_count =0;
                        uint8_t cur_count =0;
                        printf("\nTM Len: %d\n",tm_len);
                        memcpy(&sdr_sns_cfg,tm_frame.tm_data,sizeof(s_sdr_sens_cfg));

                        for(temp_count = 0;temp_count<3;temp_count++)
                        {    
                            printf("Temp sens type thrs :%hu\n",sdr_sns_cfg.temp_sensor[0].temp_sens_typ_thrs);
                            printf("Temp sens min thrs :%hu\n",sdr_sns_cfg.temp_sensor[0].temp_sens_min_thrs);
                            printf("Temp sens max thrs :%hu\n",sdr_sns_cfg.temp_sensor[0].temp_sens_max_thrs);
                        }
                        for(volt_count = 0;volt_count<6;volt_count++)
                        {
                            printf("Volt sens type thrs :%hu\n",sdr_sns_cfg.volt_sensor[0].volt_sens_typ_thrs);
                            printf("Volt sens min thrs :%hu\n",sdr_sns_cfg.volt_sensor[0].volt_sens_min_thrs);
                            printf("Volt sens max thrs :%hu\n",sdr_sns_cfg.volt_sensor[0].volt_sens_max_thrs);
                        }
                        for(cur_count = 0;cur_count<2;cur_count++)
                        {
                            printf("Cur sens typ thrs :%hu\n",sdr_sns_cfg.current_sensor[0].cur_sens_typ_thrs);
                            printf("Cur sens min thrs :%hu\n",sdr_sns_cfg.current_sensor[0].cur_sens_min_thrs);
                            printf("Cur sens max thrs :%hu\n",sdr_sns_cfg.current_sensor[0].cur_sens_max_thrs);
                        }

                    }
                    break;

                case TM_SET_SDR_CFG:
                    {
                        memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(sts == SDR_APP_SUCCESS)
                        {
                            printf("MFCC APP: SET SDR CFG is SUCCESS \n");
                        }
                        else
                        {
                            printf("MFCC APP: SET SDR CFG  FAILURE \n");
                        }
                    }
                    break;

                case TM_SET_SDR_OVER_RULE_CFG:
                    {

                        memcpy(&sts,tm_frame.tm_data,sizeof(sts));
                        if(sts == SDR_SET_OVER_RULE_SUCCESS)
                        {
                            printf("MFCC APP: SET OVERRULE  CFG is SUCCESS \n");
                        }
                        else
                        {
                            printf("MFCC APP:  SDR OVERRULE CFG is FAILURE \n");
                        }
                        }
                    break;

                case TM_GET_SDR_OVER_RULE_CFG:
                    {
                        memcpy(&tctm_overrule,tm_frame.tm_data,sizeof(s_tctm_rm_overrule));
                        printf("Overrule provision status :%hhu\n",tctm_overrule.overrule_enb);
                        printf("Normal radio ID :%hhu\n",tctm_overrule.norm_radio_id);
                        printf("Safe radio ID :%hhu\n",tctm_overrule.safe_radio_id);
                    }
                    break;

                   case TM_SET_SDR_SCH_BEACON_CFG:
                    {

                        memcpy(&sts,tm_frame.tm_data,sizeof(sts));
                        if(sts == SDR_SET_GPASS_SUCCESS)
                        {
                            printf("MFCC APP: BEACON CFG is SUCCESS \n");
                        }
                        else
                        {
                            printf("MFCC APP:BEACON  CFG is FAILURE \n");
                        }
                        }
                    break;

                   case TM_GET_SDR_SCH_BEACON_CFG:
                    {
                        memcpy(&gpass_beacon_cfg,tm_frame.tm_data,sizeof(s_gpass_beacon_cfg));    
                        printf("gpass beacon tx enable=%hhu\n",gpass_beacon_cfg.gpass_beacon_tx_enb);
                        printf("Beacon tx count :%hhu\n",gpass_beacon_cfg.beacon_tx_count);
                        printf("Beacon tx interval :%hhu\n",gpass_beacon_cfg.beacon_tx_interval);

                    }
                    break;


                case TM_SET_SDR_STS:
                    {
                        memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                        {
                            printf("MFCC APP: SET SDR STATUS is SUCCESS \n");
                        }
                        else
                        {
                            printf("MFCC APP: SET SDR STSTUS is FAILURE \n");
                        }
                    }
                    break;

                case TM_SET_SDR_TMR_CFG:
                    {
                        memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(sts == SDR_SET_TMR_SUCCESS)
                        {
                            printf("MFCC APP: SET TIMER CFG is SUCCESS \n");
                        }
                        else
                        {
                            printf("MFCC APP:  SDR TIMER CFG is FAILURE \n");
                        }
                    }
                    break;

                case TM_SET_SDR_RX_RSSI_CFG:
                    {
                        memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(sts == SDR_RX_RSSI_SUCCESS)
                        {
                            printf("MFCC APP: SET RX RSSI is SUCCESS \n");
                        }
                        else
                        {
                            printf("MFCC APP: SDR RX RSSI is FAILURE \n");
                        }
                    }
                    break;

                case TM_SET_SDR_TM_CFG:
                    {
                        memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(sts == SDR_SET_TM_SUCCESS)
                        {
                            printf("MFCC APP: SET SDR TM SUCCESS \n");
                        }
                        else
                        {
                            printf("MFCC APP: SET SDR TM FAILURE \n");
                        }
                    }
                    break;

                case TM_SET_SDR_SENS_CFG:
                    {
                        memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(sts == SDR_SET_SENS_SUCCESS)
                        {
                            printf("MFCC APP: SET SDR SENS SUCCESS \n");
                        }
                        else
                        {
                            printf("MFCC APP: SET SDR SENS FAILURE \n");
                        }
                    }
                    break;

                case TM_GET_OBC_SW_STS:
                    {
                        uint8 i;
                        uint8 sub_mod_sts[OBC_SUB_MOD_MAX];
                        uint8 ipcc_socket_sts = 0;
                        os_memcpy(sub_mod_sts,tm_frame.tm_data,sizeof(sub_mod_sts));

                        for(i=0;i<OBC_SUB_MOD_MAX;i++)
                        {
                            printf("software status of channel %d: %d \n",i,sub_mod_sts[i]);
                        }

                        os_memcpy(&ipcc_socket_sts,&tm_frame.tm_data[sizeof(sub_mod_sts)],1);

                        printf("\nIPCC Socket status is %d\n",ipcc_socket_sts);


                    }
                    break;
                case TM_SET_SSD_SLOT:
                    {

                        uint8_t sts = ssd_slec_resp;
                        os_memcpy(&ssd_slec_resp,tm_frame.tm_data,4);
                        if(sts == 0)
                            printf("SSD Slots Selection Success \n");
                        else 
                            printf("SSD Slots Selection Fail  \n");

                    }
                    break;
                case TM_SET_SSD_HEAT_ENABLE:
                    {
                        os_memcpy(&ssd_heat_slec_resp,tm_frame.tm_data,4);

                        if(ssd_heat_slec_resp ==0)
                        {
                            printf("SSD Heat Coil ON/OFF Status Success \n");
                        }
                        else 
                        {

                            printf("SSD Heat Coil ON/OFF Status Success \n");
                        }
                    }
                    break;

                case TM_SET_GPS_TIME_SYNC_PRDCTY:
                    {
                        uint8_t sts;
                        os_memcpy(&sts,tm_frame.tm_data,1);
                        if(sts == 0)
                        {
                            printf("gps time sync periodicity set success\n");
                        }
                        else
                        {
                            printf("gps time sync periodicity set fail\n");
                        }
                    }
                    break;

                case TM_GET_GPS_TIME_SYNC_PRDCTY:
                    {
                        uint8_t sts = 1;
                        uint32_t get_gps_sync;
                        os_memcpy(&sts,&tm_frame.tm_data[0],1);
                        os_memcpy(&get_gps_sync,&tm_frame.tm_data[1],4);
                        if(sts == 0)
                        {
                            printf("GPS sync periodicity %d minutes\n",get_gps_sync);
                        }
                        else
                        {
                            printf("Get GPS time sync periodicity fail");
                        }
                    }
                    break;

                case TM_SYNC_GPS_TIME:
                    {
                        uint8_t sts;
                        uint64_t sync_gps_time;
                        os_memcpy(&sts,&tm_frame.tm_data[0],1);
                        os_memcpy(&sync_gps_time,&tm_frame.tm_data[1],8);
                        if(sts == 0)
                        {
                            printf("sync gps time success\n");
                            printf("UTC time synced : %lu\n", sync_gps_time);
                        }
                        else
                        {
                            printf("SYNC GPS Time fail\n");
                        }
                    }
                    break;
                case TM_GPS_GET_GPS_TIME:
                    {
                        uint8_t sts = 1;
                        s_oem7_time gps_time = {0};
                        os_memcpy(&sts, &tm_frame.tm_data[0], 1);
                        os_memcpy(&gps_time, &tm_frame.tm_data[1], sizeof(s_oem7_time));
                        if(sts == 0)
                        {
                            printf("GPS time success\n");
                            printf("GPS clock status : %d\n", gps_time.clock_status);
                            printf("GPS offset : %lf\n", gps_time.offset);
                            printf("GPS offset_std : %lf\n", gps_time.offset_std);
                            printf("GPS utc_offset : %lf\n", gps_time.utc_offset);
                            printf("GPS utc_year : %d\n", gps_time.utc_year);
                            printf("GPS utc_month : %hu\n", gps_time.utc_month);
                            printf("GPS utc_day : %hu\n", gps_time.utc_day);
                            printf("GPS utc_hour : %hu\n", gps_time.utc_hour);
                            printf("GPS utc_minutes : %hu\n", gps_time.utc_min);
                            printf("GPS utc_milliseconds : %d\n", gps_time.utc_ms);
                            printf("GPS utc_status : %d\n", gps_time.utc_status);
                        }
                        else
                        {
                            printf("GET GPS Time fail\n");
                        }
                    }
                    break;
                case TM_GET_SSD_HEAT_ENABLE:
                    {
                        memcpy(&board_id,tm_frame.tm_data,1);
                        memcpy(&heat_en_sts,tm_frame.tm_data+1,1);
                        printf("SSD HEAT enable status for board ID %hhu is 0x%x\n",board_id,heat_en_sts);
                    }
                    break;

                case TM_GET_SSD_SLOT:
                    {
                        memcpy(&board_id,tm_frame.tm_data,1);
                        memcpy(&ssd_sts,tm_frame.tm_data+1,1);
                        printf("SSD slot selection status for board ID %hhu is 0x%x\n",board_id,ssd_sts);
                    }
                    break;

                case TM_PS_STAGED_TC:
                    {
                        memcpy(&sts,tm_frame.tm_data,1);
                        printf("Received status :%hhu \n",sts);
                    }
                    break;

                case TM_GET_OBC_NVM_REVISION_NUM:
                    {
                        printf("\n");
                        printf("Read version\n");
                        printf("OBC version: %d.%d\n",tm_frame.tm_data[0], tm_frame.tm_data[1]);
                        printf("NVM version: %d.%d\n",tm_frame.tm_data[3], tm_frame.tm_data[2]);
                        printf("\n");
                    }
                    break;

                case TM_SET_SCH_ON_OFF:
                    {
                        printf("tm decode\n");
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        printf("Received : %d\n",sts);
                    }
                    break;

                case TM_DEFERRED_STRG:
                    {
                        uint32 tc_def_ptr;
                        printf("tm decode\n");
                        os_memcpy(&tc_def_ptr,tm_frame.tm_data,tm_len);
                        printf("DEFERRED STORAGE: TC sequence is written in the following address : %u\n",tc_def_ptr);
                    }
                    break;
                case TM_EXTRNL_MEM_TEST:
                    {
                        ext_mem_test_tc_tm_s mem_tst_sts;
                        printf("tm decode\n");
                        os_memcpy(&mem_tst_sts,tm_frame.tm_data,tm_len);
                        printf("Received status : %x",mem_tst_sts.sts);
                        if(mem_tst_sts.sts == 0)
                        {
                            printf("\nExternal Memory Test Operation SUCCESS\n");
                        }
                        else
                        {
                            printf("\nExternal Memory Test Operation FAIL\n");
                        }
                    }
                    break;
                case TM_SNS_THRSLD_STS:
                    {
                        uint32 sns_thrsld_sts;
                        printf("tm decode %d\n",*(tm_frame.tm_data));
                        os_memcpy(&sns_thrsld_sts,tm_frame.tm_data,tm_len);
                        switch(sns_thrsld_sts)
                        {
                            case OBC_TEMP_SNS_HIGH_THRSLD:
                                printf("OBC_TEMP_SNS_HIGH_THRSLD Received\n");
                                break;
                            case PS_TEMP_SNS_HIGH_THRSLD:
                                printf("PS_TEMP_SNS_HIGH_THRSLD Received\n");
                                break;
                            case EDGE_TEMP_SNS_HIGH_THRSLD:
                                printf("EDGE_TEMP_SNS_HIGH_THRSLD Received\n");
                                break;
                            case GPS_TEMP_SNS_HIGH_THRSLD:
                                printf("GPS_TEMP_SNS_HIGH_THRSLD Received\n");
                                break;
                            case OBC_TEMP_SNS_LOW_THRSLD:
                                printf("OBC_TEMP_SNS_LOW_THRSLD Received\n");
                                break;
                            case PS_TEMP_SNS_LOW_THRSLD:
                                printf("PS_TEMP_SNS_LOW_THRSLD Received\n");
                                break;
                            case EDGE_TEMP_SNS_LOW_THRSLD:
                                printf("EDGE_TEMP_SNS_LOW_THRSLD Received\n");
                                break;
                            case GPS_TEMP_SNS_LOW_THRSLD:
                                printf("GPS_TEMP_SNS_LOW_THRSLD Received\n");
                                break;
                            case OBC_PWR_SNS_HIGH_THRSLD:
                                printf("OBC_PWR_SNS_HIGH_THRSLD Received\n");
                                break;
                            case PS_PWR_SNS_HIGH_THRSLD:
                                printf("PS_PWR_SNS_HIGH_THRSLD Received\n");
                                break;
                            case OBC_PWR_SNS_LOW_THRSLD:
                                printf("OBC_PWR_SNS_LOW_THRSLD Received\n");
                                break;
                            case PS_PWR_SNS_LOW_THRSLD:
                                printf("PS_PWR_SNS_LOW_THRSLD Received\n");
                                break;
                            default:
                                printf("Invalid SNS status %d\n",sns_thrsld_sts);
                        }
                    }
                    break;


                case TM_NVM:
                    {
                        uint8 i;
                        nvm_data_hdr_rec = (nvm_param*)tm_frame.tm_data;
                        nvm_data_pld_rec = tm_frame.tm_data+sizeof(nvm_param);
                        //os_memcpy(nvm_data_1,tm_frame.tm_data+sizeof(nvm_param),sizeof(nvm_data_1));
                        for( i = 0; i < nvm_data_hdr_rec->len; i++)
                        {
                            printf("%d\n",nvm_data_pld_rec[i]);
                        }
                    }
                    break;
                case TM_TEST_GPIO:
                    {
                        uint8_t sts;
                        memcpy(&sts,tm_frame.tm_data,1);
                        if(sts ==0)
                            printf("GPIO Pin TEST SUCCESS \n");
                        else
                            printf("GPIO Pin TEST FAIL \n");
                    }
                    break;

                case TM_TEST_SENSOR:

                    {
                        uint8_t sts;
                        memcpy(&sts,tm_frame.tm_data,1);
                        if(sts ==0)
                            printf("SENSOR TEST SUCCESS \n");
                        else
                            printf("SENSOR TEST FAIL \n");
                    }
                    break;

                case TM_TEST_GPIO_EXP:
                    {
                        uint8_t sts;
                        memcpy(&sts,tm_frame.tm_data,1);
                        if(sts ==0)
                            printf("GPIO EXPANDER TEST SUCCESS \n");
                        else
                            printf("GPIO EXPANDER TEST FAIL \n");
                    }

                    break;

                case TM_SPI_UART_CONV_TEST:
                    {
                        memcpy(&spi_uart_conv,tm_frame.tm_data,sizeof(s_test_spi_uart_conv));
                        if(spi_uart_conv.status == 0)
                        {
                            if(spi_uart_conv.test_mode == 0)
                            {
                                printf("MFCC APP: SPI to UART CONV SELF TEST SUCCESS \n");
                            }
                            else if(spi_uart_conv.test_mode == 1)
                            {
                                printf("MFCC APP: SPI to UART TX CONV CHANNEL TEST SUCCESS \n");
                            }
                            else if(spi_uart_conv.test_mode == 2)
                            {
                                printf("MFCC APP: SPI to UART RX CONV CHANNEL TEST SUCCESS \n");
                                printf("RX Data= %15s\n",spi_uart_conv.data);
                                
                               /* for (int i = 0; spi_uart_conv.data[i] != '\0'; i++)
                                {
                                    printf("%hhd ", spi_uart_conv.data[i]);
                                }
                                printf("\n");*/
                                
                            }
                        }
                        else
                        {
                            printf("MFCC APP: SPI to UART CONV TEST FAIL \n");
                        }
                    }
                    break;

                case TM_NVM_COMMIT:
                    {
                        uint8_t sts;
                        memcpy(&sts,tm_frame.tm_data,1);
                        if(sts ==0)
                            printf("NVM COMMIT SUCCESS \n");
                        else
                            printf("NVM COMMIT FAIL \n");
                    }
                    break;

                case TM_NVM_COMMIT_PRDCTY_TIM_CFG:
                    {
                        uint8_t sts;
                        memcpy(&sts,tm_frame.tm_data,1);
                        if(sts ==0)
                            printf("NVM COMMIT PERIODICITY CONFIG TIMER SUCESS \n");
                        else
                            printf("NVM COMMIT PERIODICITY CONFIG TIMER FAIL \n");
                    }
                    break;

                case TM_MNGR_GS_CONTACT:
                    {
                        os_memcpy(&sts,tm_frame.tm_data,tm_len);
                        if(!sts)
                            printf("MFCC APP: SET GS contact is success \n");
                        else
                            printf("MFCC APP: SET GS contact is failure \n");
                    }
                    break;

                case TM_GET_CUR_TIME:
                    {
                        memcpy(&sts,tm_frame.tm_data,1);
                        if(sts == 0)
                        {
                            printf("EPS STATUS - SUCCESS\n");
                        }
                        else if(sts == 2 )
                        {
                            printf("INVALID INSTANCE\n");
                        }
                        else if(sts == 5)
                        {
                            printf("COMMUNICATION ERROR\n");
                        }
                        else
                        {
                            printf("Invalid sts\n");
                        }
                        memcpy(&cur_time_rsp_sts,&tm_frame.tm_data[1],tm_frame.tm_len-1);
                        printf("SOS Time: %d :%d :%d \n",cur_time_rsp_sts.hour,cur_time_rsp_sts.minute,cur_time_rsp_sts.seconds);
                        printf("SOS Date: %d :%d :%d \n",cur_time_rsp_sts.date,cur_time_rsp_sts.month,cur_time_rsp_sts.year);
                    }
                    break;

                case TM_TCTM_DEQUEUE:
                    {
                        uint32_t dqueue_sts;
                        os_memcpy(&dqueue_sts,tm_frame.tm_data,4);
                        printf("Dequeue STS : %d\n",dqueue_sts);
                    }
                    break;
                case TM_GET_PS_TEMP:
                    {
                        ps_get_temp_s ps_get_temp;
                        os_memcpy(&ps_get_temp,tm_frame.tm_data,tm_frame.tm_len);
                        printf("Device id:%d\n",ps_get_temp.dev_id);
                        printf("Temp:%d\n",ps_get_temp.temp);
                    }
                    break;

                case TM_GET_PS_TIME:
                    {
                        ps_get_time_s ps_get_time;
                        os_memcpy(&ps_get_time,tm_frame.tm_data,tm_frame.tm_len);
                        printf("Device id:%d\n",ps_get_time.dev_id);
                        printf("Uptime:%d\n",ps_get_time.uptime);
                        printf("Epoch time:%d\n",ps_get_time.epoch_time);
                    }
                    break;
                case TM_GET_MCU_CHIP_INFO:
                    {
                        ps_get_chip_info_s ps_get_chip_info;
                        os_memcpy(&ps_get_chip_info,tm_frame.tm_data,sizeof(ps_get_chip_info_s));
                        printf("Device id:%d\n",ps_get_chip_info.dev_id);
                        printf("processor name:%s\n",ps_get_chip_info.processor_name);
                        //printf("chip id:%c%c\n",ps_get_chip_info.chip_id[0],ps_get_chip_info.chip_id[1]);
                        if(ps_get_chip_info.dev_id == 0)
                        {
                            printf("chip id: %c%c\n",ps_get_chip_info.chip_id&0xFF,ps_get_chip_info.chip_id>>8);
                        }
                        else
                        {
                            printf("chip id:%d\n",ps_get_chip_info.chip_id);
                        }
                        printf("clock speed:%d MHz\n",ps_get_chip_info.clock_speed);
                        printf("number of core:%d\n",ps_get_chip_info.cores);
                        printf("cache size:%d KB\n",ps_get_chip_info.cache_size);
                    }
                    break;

                case TM_GET_MCU_EXT_MEM_INFO:
                    {
                        //  if(tm_frame.tm_data[0] == 0)
                        // {
                        mcu_get_ext_mem_s mcu_get_ext_mem;
                        os_memcpy(&mcu_get_ext_mem,&tm_frame.tm_data[0],tm_frame.tm_len);
                        printf("Dev id:%d\n",mcu_get_ext_mem.dev_id);
                        printf("Mem count:%d\n",mcu_get_ext_mem.mem_cnt);
                        for(uint8_t cnt=0;cnt < mcu_get_ext_mem.mem_cnt;cnt++)
                        {
                            printf("tot_mem of %d :%ld \n",cnt,mcu_get_ext_mem.ext_mem_info[cnt].tot_mem);
                            printf("free_mem of %d:%ld \n",cnt,mcu_get_ext_mem.ext_mem_info[cnt].free_mem);
                            printf("used_mem of %d:%ld \n",cnt,mcu_get_ext_mem.ext_mem_info[cnt].used_mem);
                        }
#if 0
                        printf("Flash_fmc_tot_mem:%d KB\n",mcu_get_ext_mem.ext_mem_info[1].tot_mem);
                        printf("flash_fmc_free_mem:%d KB\n",mcu_get_ext_mem.ext_mem_info[1].free_mem);
                        printf("flash_fmc_used_mem:%d KB\n",mcu_get_ext_mem.ext_mem_info[1].used_mem);
                        printf("Flash_qspi_tot_mem:%d KB\n",mcu_get_ext_mem.ext_mem_info[2].tot_mem);
                        printf("flash_qspi_free_mem:%d KB\n",mcu_get_ext_mem.ext_mem_info[2].free_mem);
                        printf("flash_qspi_used_mem:%d KB\n",mcu_get_ext_mem.ext_mem_info[2].used_mem);

                        printf("flash_qspi_tot_mem:%d KB\n",obc_get_ext_mem.flash_qspi_tot_mem);
                        printf("flash_qspi_used_mem:%d KB\n",obc_get_ext_mem.flash_qspi_used_mem);
                        printf("flash_fmc_tot_mem:%d KB\n",obc_get_ext_mem.flash_fmc_tot_mem);
                        printf("flash_fmc_used_mem:%d KB\n",obc_get_ext_mem.flash_fmc_used_mem);

                    }
                    else if(tm_frame.tm_data[0] == 1)
                    {
                        ps_get_ext_mem_s ps_get_ext_mem;
                        os_memcpy(&ps_get_ext_mem,&tm_frame.tm_data[0],tm_frame.tm_len);
                        printf("Dev id:%d\n",ps_get_ext_mem.dev_id);
                        printf("total memory:%ld KB\n",ps_get_ext_mem.tot_mem);
                        printf("available memory:%ld KB\n",ps_get_ext_mem.available_mem);
                        printf("free memory:%ld KB\n",ps_get_ext_mem.free_mem);
                    }
                    else
                    {
                        /*TODO*/
                    }
#endif
                    }
                    break;
                case TM_GET_MCU_INT_MEM_INFO:
                    {
                        obc_get_int_mem_s obc_get_int_mem;
                        os_memcpy(&obc_get_int_mem,&tm_frame.tm_data[0],tm_frame.tm_len);
                        printf("Internal mem total :%d\n",obc_get_int_mem.iram_tot_mem);
                        printf("Internal mem used :%d\n",obc_get_int_mem.iram_used_mem);	
                        printf("Internal mem free :%d\n",obc_get_int_mem.iram_free_mem);	

                    }
                    break;
                case TM_GET_MCU_INT_PHERIPHARL_INFO:
                    {
                        obc_get_int_pher_info_s obc_get_int_pher_info;
                        os_memcpy(&obc_get_int_pher_info,&tm_frame.tm_data[0],tm_frame.tm_len);
                        printf("len :%d\n",tm_frame.tm_len);
                        printf("internal pher info :%d\n",obc_get_int_pher_info.pheripheral_cnt);
                        for(uint8_t i = 0;i < MAX_INT_PHER_CNT ; i++)
                        {	
                            printf("Internal pher info of %d is :%x\n",i,obc_get_int_pher_info.pher_infor_buf[i].pher_id);
                            printf("Internal pher info of %d is :%x\n",i,obc_get_int_pher_info.pher_infor_buf[i].pher_speed);
                        }

                    }
                    break;

                case TM_CONOPS_SCH_LUT_CFG:
                case TM_CONOPS_SCH_LUT_RUN_CTRL:
                case TM_CONOPS_SCH_STS_INFO:
					conops_sch_tm_decode(tm_id,tm_frame.tm_data,tm_frame.tm_len);				
                    break;

                case TM_SET_EPS_CTRL_DEV_TMR:
                case TM_SET_EPS_BTRY_VOLT_THRSHLD:
                case TM_SET_EPS_CTRL_CHNL_ST:
                case TM_SET_EPS_BTRY_CTRL_CH_MAP:
                case TM_GET_EPS_BTRY_CTRL_CH_MAP:
                case TM_GET_EPS_DEV_HW_STS:
                case TM_EPS_SIM_BTRY_VOLT:
                case TM_ALERT_FLAG_OVR_CUR_ERR_HANDLE:
                case TM_SET_CONV_BOARD_PARM:
                case TM_SET_BATT_BOARD_PARM:
                case TM_SET_OUT_CHNL_ENB:
                case TM_SET_OUT_CHNL_CUR_LMT:
                case TM_SET_EPS_MODE_CFG:
                case TM_GET_CONV_BOARD_PARM:
                case TM_GET_BATT_BOARD_PARM:
                case TM_GET_OUT_CHNL_PARM:
                case TM_GET_EPS_MODE_CFG:
                case TM_GET_EPS_ALERT_INFO:
                case TM_GET_EPS_FW:
                case TM_EPS_FW_UPDATE:
                case TM_EPS_MCU_RST :
                case TM_SET_EPS_COM_TIMEOUT:
                case TM_GET_EPS_COM_TIMEOUT :
                case TM_EPS_GET_BUFFER:
                case TM_EPS_HEALTH_STS:
                    //case TM_EPS_GET_CRC:// need to be removed
#ifdef EPS_SIMU_EN 
                case TM_SET_EPS_SIM_EXPOSURE_TYPE:
                case TM_SET_EPS_SIM_CH_CRNT:
                case TM_SET_EPS_SIM_BTRY_VOLT:
                case TM_SET_EPS_SIM_BTRY_TEMP:
#endif                      
                    { 
                        eps_tm_decode(tm_id,tm_frame.tm_data,tm_frame.tm_len);
                    }
                    break;

case TM_GET_MCU_EXT_PHERIPHARL_INFO:
{
    obc_get_ext_pher_info_s obc_get_ext_pher_info;
    os_memcpy(&obc_get_ext_pher_info,tm_frame.tm_data,tm_frame.tm_len);
                        printf("External pher info :%d\n",obc_get_ext_pher_info.pheripheral_cnt);
                        for(uint8_t i = 0;i < MAX_EXT_PHER_CNT ; i++)
                        {	
                            printf("External pher info of %d is :%x\n",i,obc_get_ext_pher_info.pher_infor_buf[i].pher_id);
                            printf("External pher info of %d is :%x\n",i,obc_get_ext_pher_info.pher_infor_buf[i].pher_speed);
                        }

                    }
                    break;
                case TM_GET_MCU_RST_INFO:
                    {
                        int i;
                        memcpy((uint8_t*)&receive_data,tm_frame.tm_data,sizeof(reset_info));
                        printf("Reset info array index = %d\n",receive_data.arr_index);
                        for(i = 0 ; i <  MAX_RBT_RSN_ARR; i++)
                        {
                            printf("Reset cause : [%d] %s ",receive_data.reset_arr[i].reset_reason,\
                                    reset_cause_get_name(receive_data.reset_arr[i].reset_reason));
                            printf("Reset Time:%ld\n",receive_data.reset_arr[i].get_time);
                        }
                        printf("Total reset count = %d\n",receive_data.rst_count);
                    }
                    break;

                case TM_GET_HEALTH_METRICS:
                    {
                        tm_process_health_data(tm_frame.tm_data, tm_frame.tm_len);
                    }
                    break;
                case TM_CHNGE_QUEUE_PRIORITY:
                    {
                        if(tm_frame.tm_data[0] == 0)
                        {
                            printf("[GS][HM_FW]Queue Priority change success\n");
                        }
                        else
                        {
                            printf("[GS][HM_FW]Queue Priority change failed\n");
                        }
                    }
                    break;

                case TM_CHNGE_MODULE_PRIORITY:
                    {
                        if(tm_frame.tm_data[0] == 0)
                        {
                            printf("[GS][HM_FW]Module Priority change success\n");
                        }
                        else
                        {
                            printf("[GS][HM_FW]Module Priority change failed\n");
                        }
                    }
                    break;

                    case TM_HM_TEST_CASE_REQ:
                    {
                        uint32_t test_case_id, test_case_rsp;
                        os_memcpy(&test_case_id,&tm_frame.tm_data[0],sizeof(uint32_t));
                        os_memcpy(&test_case_rsp,&tm_frame.tm_data[4],sizeof(uint32_t));

                        if((test_case_id == OBC_STRESS_TEST_SIMU) || (test_case_id == ERROR_HANDLER_STRESS_TEST_SIMU) || (test_case_id == COMMS_SBAND_STRESS_TEST_SIMU) || (test_case_id==COMMS_UHF_STRESS_TEST_SIMU))
                        {

                            if(( test_case_rsp== 0) && (hm_fw_cb.integrity_fail == 0))
                            {
                                printf("[GS][HM_FW]HM TEST CASE PASS\n");
                            }
                            else
                            {
                                printf("[GS][HM_FW]HM TEST CASE FAIL\n");
                            }
                        }
                        else if( test_case_rsp== EPS_STRESS_TEST_SIMU)
                        {
                            if(( test_case_rsp== 0) && (hm_fw_cb.integrity_fail == 0) && (hm_fw_cb.integrity_pass_cnt[EPS_STRESS_TEST_SIMU]== 4))
                            {
                                 printf("[GS][HM_FW]HM TEST CASE PASS\n");
                            }
                            else
                            {
                                printf("[GS][HM_FW]HM TEST CASE FAIL\n");
                            }
                        }
                        else if(test_case_id== ADCS_STRESS_TEST_SIMU)
                        {
                            if((test_case_rsp== 0) && (hm_fw_cb.integrity_fail == 0) && (hm_fw_cb.integrity_pass_cnt[ADCS_STRESS_TEST_SIMU] == 14))
                            {
                                 printf("[GS][HM_FW]HM TEST CASE PASS\n");
                            }
                            else
                            {
                                printf("[GS][HM_FW]HM TEST CASE FAIL\n");
                            }
                        }
                         else if(test_case_id== SENSORS_STRESS_TEST_SIMU)
                        {
                            if((test_case_rsp== 0) && (hm_fw_cb.integrity_fail == 0) && (hm_fw_cb.integrity_pass_cnt[SENSORS_STRESS_TEST_SIMU] == 16))
                            {
                                 printf("[GS][HM_FW]HM TEST CASE PASS\n");
                            }
                            else
                            {
                                printf("[GS][HM_FW]HM TEST CASE FAIL\n");
                            }
                        }
                        else if((test_case_id==DL_REQ_SUCC_VAL_MOD_QUEUE_ACTIVE) || (test_case_id==MAX_TM_DOWNLOAD_CHECK_62K))
                        {
                            if((test_case_rsp== 0) && (hm_fw_cb.integrity_fail == 0))
                            {
                                printf("[GS][HM_FW]HM TEST CASE PASS\n");
                            }
                            else
                            {
                                printf("[GS][HM_FW]HM TEST CASE FAIL\n");
                            }
                        }

                        else
                        {
                            if(test_case_rsp== 0)
                            {
                                printf("[GS][HM_FW]HM TEST CASE PASS\n");
                            }
                            else
                            {
                                printf("[GS][HM_FW]HM TEST CASE FAIL\n");
                            }

                        }
                    }
                    break;

                    case TM_PRINT_MEM_LEAK:
                    {
                        uint16_t inst_cnt = 0;
                        uint32_t data_idx = 0;
                        s_mem_leak_info mem_leak_info;
                        memcpy(&inst_cnt, &tm_frame.tm_data[0], sizeof(inst_cnt));
                        data_idx += sizeof(inst_cnt);

                        for(int i = 0; i < inst_cnt; i++)
                        {
                            memcpy(&mem_leak_info.time_stamp, &tm_frame.tm_data[data_idx], sizeof(mem_leak_info.time_stamp));
                            data_idx += sizeof(mem_leak_info.time_stamp);

                            memcpy(&mem_leak_info.alct_mem_len, &tm_frame.tm_data[data_idx], sizeof(mem_leak_info.alct_mem_len));
                            data_idx += sizeof(mem_leak_info.alct_mem_len);

                            memcpy(&mem_leak_info.file_name_len, &tm_frame.tm_data[data_idx], sizeof(mem_leak_info.file_name_len));
                            data_idx += sizeof(mem_leak_info.file_name_len);

                            mem_leak_info.file_name = (char*)&tm_frame.tm_data[data_idx];
                            data_idx += mem_leak_info.file_name_len;

                            memcpy(&mem_leak_info.line_number, &tm_frame.tm_data[data_idx], sizeof(mem_leak_info.line_number));
                            data_idx += sizeof(mem_leak_info.line_number);
                            if(mem_leak_info.alct_mem_len >> MEM_TYPE_FLAG_OFST)
                            {
                                printf("Memory type:- E_RAM Time:- %d File Name:- %.*s Line Number:- %d Allocated len:- %d\n",\
                                        mem_leak_info.time_stamp, mem_leak_info.file_name_len, mem_leak_info.file_name,\
                                        mem_leak_info.line_number, mem_leak_info.alct_mem_len & 0x7FFFFFFF);
                            }
                            else
                            {
                                printf("Memory type:- I_RAM Time:- %d File Name:- %.*s Line Number:- %d Allocated len:- %d\n",\
                                        mem_leak_info.time_stamp, mem_leak_info.file_name_len, mem_leak_info.file_name,\
                                        mem_leak_info.line_number, mem_leak_info.alct_mem_len & 0x7FFFFFFF);
                            }
                        }
                    }
                    break;
                    case TM_GET_TCTM_DBG_INFO:
{
    s_tctm_dbg_info tctm_dbg_info = {0};

    os_memcpy(&tctm_dbg_info, tm_frame.tm_data, sizeof(s_tctm_dbg_info));
    for(int i = 0; i < MAX_TCTM_DBG_INFO; i++)
    {
        printf("Idx:- %d : TC Rcvd Time:- %d, DST Id:- %d, TC Id:- %d\n",i,\
                tctm_dbg_info.tc_dbg_info[i].tc_rcvd_time, tctm_dbg_info.tc_dbg_info[i].dst_id,\
                tctm_dbg_info.tc_dbg_info[i].tc_id);
        printf("Idx:- %d : TM Sent Time:- %d, SRC Id:- %d, TM Id:- %d\n",i,\
                tctm_dbg_info.tm_dbg_info[i].tm_sent_time, tctm_dbg_info.tm_dbg_info[i].src_id,\
                tctm_dbg_info.tm_dbg_info[i].tm_id);
    }

}
break;
                default :
                    {
                        printf("Invalid TM ID received %d\n",tm_id);
                    }
            }
        }
    }while(rem_size != 0);
    /* Free allocated memories */
    free(tm_frame.tm_data);
    if(tm_data != tm_stream_data)
    {
        free(tm_data);
    }
    if(ctrl_param.encrypt)
    {
        free(param.key);
    }
    if(tm_frame.cmac_hmac)
    {
        free(tm_frame.cmac_hmac);
    }

    return 0;
}

#if 0
void eps_get_dev_hw_sts_print(uint8 val)
{
    // uint8 i;
    //    for( i =0 ; i<SAT_DEV_MAX_CNT ; i++)
    //  {
    switch(val)
    {
        case 0:
            printf("OFF\n");
            break;
        case 1:
            printf("ON\n");
            break;
        case 2:
            printf("RESTART\n");
            break;
        case 3:
            printf("BOOT\n");
            break;
        case 4:
            printf("SHUT_DOWN\n");
            break;
        case 5:
            printf("ERROR\n");
            break;
    }
    //   }
}
#endif
/**
 * @brief Function that validates sequence number
 */
void mfcc_validate_seq_num(uint16 actual_seq_no)
{
    static uint16 expected_seq_no = 1;
    uint32 missing_frames , i = 0;
    if(expected_seq_no != actual_seq_no)
    {
        if(actual_seq_no > expected_seq_no)
        {
            missing_frames = actual_seq_no - expected_seq_no;
            for (i=0; i<missing_frames; i++)
            {
                //printf("Warning !!! Missing frame. Sequence number : %d \n",expected_seq_no);
                expected_seq_no++;
            }
        }
        else
        {
            printf(" Warning !!! Received the same packet again : %d \n",actual_seq_no);
        }

    }
    expected_seq_no++;
}
/*********************************************************************************/
/******************* TeleCommand Encode Functions ********************************/
/*********************************************************************************/

/*!
 * @brief This API encodes the Interface Control Messsage for
 * Target point request
 */
int8 tc_tty_data_enc(uint8* data, uint8* tc_tty_data, uint32 data_size)
{
    int8 status = 0;

    /* Encode data parameters */
    memcpy(data,tc_tty_data,data_size);

    status = TCTM_OK;

    return status;
}

/*int8 tc_trgt_point_req_enc(uint8* data, tctm_trgt_pt_req_s *tpr)
  {
  int8 status;

// Encode data parameters
memcpy(data,&tpr->lat,4); data += 4;
memcpy(data,&tpr->longit,4); data += 4;
memcpy(data,&tpr->alt,4); data += 4;
 *data = tpr->pld_hw_id; data += 1;
 *data = tpr->act_tmr_min; data += 1;
 *data = tpr->act_tmr_sec; data += 1;
 memcpy(data,&tpr->act_tmr_ms,2);

 status = TCTM_OK;

 return status;
 }*/

int8 obc_mem_debug_tc_encode(uint8  mem_type)
{
    //int8 status;
    //uint8_t max_memory_type =4;
    if((mem_type) < e_max_memory_type)
    {
        switch(mem_type)
        {
            case e_mem_debug_sdram_test:
                {
                    mem_debug_data = (mem_type<<4) & 0xf0;
                    printf("sdram %d",mem_type);
                }
                break;

            case e_mem_debug_fmc_nor_flash:
                {
                    mem_debug_data = (mem_type<<4) & 0xf0;
                }
                break;

            case e_mem_debug_qspi_nor_flash:
                {
                    mem_debug_data = (mem_type<<4) & 0xf0;
                }
                break;

            case e_iram_heap_availablity:
                {
                    mem_debug_data = (mem_type<<4) & 0xf0;
                }
                break;

            default:
                printf("Invalid memory type %d",mem_type);
                break;
        }
    }
    else
    {
        printf("Invalid memory type");
    }
    //status = TCTM_OK;
    //return status;
    return 1;
}

int8 tc_schedule_deploy_enc(uint8 *data, uint8 num_days)
{
    int8 status = 0;
    orbit_lut_cfg_s orb_lut_cfg;

    *data = num_days; data++;

    orb_lut_cfg.date = 2;
    orb_lut_cfg.month = 11;
    orb_lut_cfg.year = 2022;
    orb_lut_cfg.orbit_lut_map[0] = 1;
    orb_lut_cfg.orbit_lut_map[1] = 1;
    orb_lut_cfg.orbit_lut_map[2] = 1;
    orb_lut_cfg.orbit_lut_map[3] = 1;
    orb_lut_cfg.orbit_lut_map[4] = 1;
    orb_lut_cfg.orbit_lut_map[5] = 1;
    orb_lut_cfg.orbit_lut_map[6] = 1;
    orb_lut_cfg.orbit_lut_map[7] = 1;
    orb_lut_cfg.orbit_lut_map[8] = 1;
    orb_lut_cfg.orbit_lut_map[9] = 1;
    orb_lut_cfg.orbit_lut_map[10] = 1;
    orb_lut_cfg.orbit_lut_map[11] = 1;
    orb_lut_cfg.orbit_lut_map[12] = 1;
    orb_lut_cfg.orbit_lut_map[13] = 1;
    orb_lut_cfg.orbit_lut_map[14] = 1;
    orb_lut_cfg.orbit_lut_map[15] = 1;
    memcpy(data,&orb_lut_cfg,sizeof(orbit_lut_cfg_s));
    data += sizeof(orbit_lut_cfg_s);

    orb_lut_cfg.date = 3;
    orb_lut_cfg.month = 11;
    orb_lut_cfg.year = 2022;
    orb_lut_cfg.orbit_lut_map[0] = 0;
    orb_lut_cfg.orbit_lut_map[1] = 0;
    orb_lut_cfg.orbit_lut_map[2] = 0;
    orb_lut_cfg.orbit_lut_map[3] = 0;
    orb_lut_cfg.orbit_lut_map[4] = 0;
    orb_lut_cfg.orbit_lut_map[5] = 0;
    orb_lut_cfg.orbit_lut_map[6] = 0;
    orb_lut_cfg.orbit_lut_map[7] = 2;
    orb_lut_cfg.orbit_lut_map[8] = 0;
    orb_lut_cfg.orbit_lut_map[9] = 0;
    orb_lut_cfg.orbit_lut_map[10] = 1;
    orb_lut_cfg.orbit_lut_map[11] = 0;
    orb_lut_cfg.orbit_lut_map[12] = 0;
    orb_lut_cfg.orbit_lut_map[13] = 0;
    orb_lut_cfg.orbit_lut_map[14] = 0;
    orb_lut_cfg.orbit_lut_map[15] = 0;
    memcpy(data,&orb_lut_cfg,sizeof(orbit_lut_cfg_s));
    status = TCTM_OK;

    return status;
}

int8 tc_schedule_cfg_lut_enc(uint8 *data, uint16 num_events)
{
    int8 status = 0;
    uint8 lut_id;
    schedule_event_s event_info;

    lut_id = 1;

    *data = lut_id; data++;
    memcpy(data,&num_events,sizeof(num_events)); data += sizeof(num_events);

    ////////////////////////////////////
    //////IoT-Mode A
    /////////////////////////////////
    event_info.event_id = ADCS_POINT;
    event_info.event_exec_time.min = 1;
    event_info.event_exec_time.sec = 10;
    event_info.event_arg = INDONESIAN_BRDR_LAT;
    memcpy(data,&event_info,sizeof(event_info)); data += sizeof(event_info);

    event_info.event_id = POWER_ON_PLD;
    event_info.event_exec_time.min = 1;
    event_info.event_exec_time.sec = 40;
    event_info.event_arg = 1;
    memcpy(data,&event_info,sizeof(event_info)); data += sizeof(event_info);

    event_info.event_id = BOOT_UP_PLD_VM;
    event_info.event_exec_time.min = 2;
    event_info.event_exec_time.sec = 0;
    event_info.event_arg = 10;
    memcpy(data,&event_info,sizeof(event_info)); data += sizeof(event_info);

    event_info.event_id = STAGED_TC;
    event_info.event_exec_time.min = 2;
    event_info.event_exec_time.sec = 20;
    event_info.event_arg = 100;
    memcpy(data,&event_info,sizeof(event_info)); data += sizeof(event_info);

    event_info.event_id = SHUTDOWN_PLD_VM;
    event_info.event_exec_time.min = 2;
    event_info.event_exec_time.sec = 50;
    event_info.event_arg = 10;
    memcpy(data,&event_info,sizeof(event_info)); data += sizeof(event_info);

    ////////////////////////////////////
    //////IoT-Mode B
    /////////////////////////////////
    event_info.event_id = ADCS_POINT;
    event_info.event_exec_time.min = 3;
    event_info.event_exec_time.sec = 10;
    event_info.event_arg = INDONESIAN_BRDR_LAT;
    memcpy(data,&event_info,sizeof(event_info)); data += sizeof(event_info);

    event_info.event_id = POWER_ON_PLD;
    event_info.event_exec_time.min = 3;
    event_info.event_exec_time.sec = 30;
    event_info.event_arg = 1;
    memcpy(data,&event_info,sizeof(event_info)); data += sizeof(event_info);

    event_info.event_id = BOOT_UP_PLD_VM;
    event_info.event_exec_time.min = 3;
    event_info.event_exec_time.sec = 50;
    event_info.event_arg = 10;
    memcpy(data,&event_info,sizeof(event_info)); data += sizeof(event_info);

    event_info.event_id = STAGED_TC;
    event_info.event_exec_time.min = 4;
    event_info.event_exec_time.sec = 10;
    event_info.event_arg = 100;
    memcpy(data,&event_info,sizeof(event_info)); data += sizeof(event_info);

    event_info.event_id = SHUTDOWN_PLD_VM;
    event_info.event_exec_time.min = 4;
    event_info.event_exec_time.sec = 30;
    event_info.event_arg = 10;
    memcpy(data,&event_info,sizeof(event_info)); data += sizeof(event_info);

    ////////////////////////////////////
    //////Netra Firmware update
    /////////////////////////////////
    event_info.event_id = POWER_ON_PLD;
    event_info.event_exec_time.min = 4;
    event_info.event_exec_time.sec = 55;
    event_info.event_arg = 1;
    memcpy(data,&event_info,sizeof(event_info)); data += sizeof(event_info);

    event_info.event_id = BOOT_UP_PLD_VM;
    event_info.event_exec_time.min = 5;
    event_info.event_exec_time.sec = 40;
    event_info.event_arg = 10;
    memcpy(data,&event_info,sizeof(event_info)); data += sizeof(event_info);

    event_info.event_id = STAGED_TC;
    event_info.event_exec_time.min = 6;
    event_info.event_exec_time.sec = 0;
    event_info.event_arg = 100;
    memcpy(data,&event_info,sizeof(event_info)); data += sizeof(event_info);

    event_info.event_id = SHUTDOWN_PLD_VM;
    event_info.event_exec_time.min = 6;
    event_info.event_exec_time.sec = 30;
    event_info.event_arg = 10;
    memcpy(data,&event_info,sizeof(event_info)); data += sizeof(event_info);

    ////////////////////////////////////
    //////Netra APP update
    /////////////////////////////////
    event_info.event_id = POWER_ON_PLD;
    event_info.event_exec_time.min = 7;
    event_info.event_exec_time.sec = 30;
    event_info.event_arg = 1;
    memcpy(data,&event_info,sizeof(event_info)); data += sizeof(event_info);

    event_info.event_id = BOOT_UP_PLD_VM;
    event_info.event_exec_time.min = 8;
    event_info.event_exec_time.sec = 0;
    event_info.event_arg = 10;
    memcpy(data,&event_info,sizeof(event_info)); data += sizeof(event_info);

    event_info.event_id = STAGED_TC;
    event_info.event_exec_time.min = 8;
    event_info.event_exec_time.sec = 30;
    event_info.event_arg = 100;
    memcpy(data,&event_info,sizeof(event_info)); data += sizeof(event_info);

    event_info.event_id = SHUTDOWN_PLD_VM;
    event_info.event_exec_time.min = 9;
    event_info.event_exec_time.sec = 0;
    event_info.event_arg = 10;
    memcpy(data,&event_info,sizeof(event_info)); data += sizeof(event_info);

    ////////////////////////////////////
    //////TransCelestial Campaign 0
    /////////////////////////////////
    event_info.event_id = ADCS_POINT;
    event_info.event_exec_time.min = 9;
    event_info.event_exec_time.sec = 30;
    event_info.event_arg = INDONESIAN_BRDR_LAT;
    memcpy(data,&event_info,sizeof(event_info)); data += sizeof(event_info);

    event_info.event_id = POWER_ON_PLD;
    event_info.event_exec_time.min = 9;
    event_info.event_exec_time.sec = 50;
    event_info.event_arg = 2;
    memcpy(data,&event_info,sizeof(event_info)); data += sizeof(event_info);

    event_info.event_id = BOOT_UP_PLD_VM;
    event_info.event_exec_time.min = 10;
    event_info.event_exec_time.sec = 10;
    event_info.event_arg = 11;
    memcpy(data,&event_info,sizeof(event_info)); data += sizeof(event_info);

    event_info.event_id = STAGED_TC;
    event_info.event_exec_time.min = 10;
    event_info.event_exec_time.sec = 30;
    event_info.event_arg = 100;
    memcpy(data,&event_info,sizeof(event_info)); data += sizeof(event_info);

    event_info.event_id = SHUTDOWN_PLD_VM;
    event_info.event_exec_time.min = 10;
    event_info.event_exec_time.sec = 50;
    event_info.event_arg = 10;
    memcpy(data,&event_info,sizeof(event_info)); data += sizeof(event_info);

    status = TCTM_OK;

    return status;
}

int8 tc_spi_intf_param_enc(uint8* data, tctm_spi_init_s *spii)
{
    int8 status = 0;

    /* Encode data parameters */
    memcpy(data,spii,sizeof(tctm_spi_init_s));
    status = TCTM_OK;

    return status;
}

int8 tc_ethernet_init_param_enc(uint8* data, tctm_ethernet_init_s *eth)
{
    int8 status = 0;

    /* Encode data parameters */
    memcpy(data,eth,sizeof(tctm_ethernet_init_s));
    status = TCTM_OK;

    return status;
}

int8 tc_can_init_param_enc(uint8* data, tctm_can_init_s *cis)
{
    int8 status = 0;

    /* Encode data parameters */
    memcpy(data,cis,sizeof(tctm_can_init_s));
    status = TCTM_OK;

    return status;
}

int8 tc_i2c_init_param_enc(uint8* data, tctm_i2c_init_s *i2ci)
{
    int8 status = 0;

    /* Encode data parameters */
    memcpy(data,i2ci,sizeof(tctm_i2c_init_s));
    status = TCTM_OK;

    return status;
}

int8 tc_usb_init_param_enc(uint8* data, tctm_usb_otg_cfg_s *usbo)
{
    int8 status = 0;

    /* Encode data parameters */
    memcpy(data,usbo,sizeof(tctm_usb_otg_cfg_s));
    status = TCTM_OK;

    return status;
}

int8 tc_uart_init_param_enc(uint8* data, tctm_uart_init_s *uarti)
{
    int8 status = 0;

    /* Encode data parameters */
    memcpy(data,uarti,sizeof(tctm_uart_init_s));
    status = TCTM_OK;

    return status;
}

int8 tc_set_cur_time_enc(uint8* data, tctm_time_par_s *time)
{
    int8 status = 0;

    memcpy(data,time,sizeof(tctm_time_par_s));


    status = TCTM_OK;

    return status;
}

/*********************************************************************************/
/******************* TeleMetry Decode Functions ********************************/
/*********************************************************************************/

/*!
 * @brief This API decodes the TM for GNNS location
 * sharing information
 */
/*int8 tm_gnss_loc_info_dec(uint8* data, tctm_gnss_loc_info_s *gli)
  {
  int8 status;

// Decode data parameters 
gli->status = *data; data += 4;
memcpy(&gli->lat,data,4); data += 4;
memcpy(&gli->longit,data,4); data += 4;
memcpy(&gli->alt,data,4);
if(!gli->status)
{
printf("GNSS Location Information Received Successfully\n");
printf("Latitude : %f\n",gli->lat);
printf("Longitude : %f\n",gli->longit);
printf("Altitude : %f\n",gli->alt);
}
else
{
printf("GNSS Location Information Receiption Failure \n");
}

status = TCTM_OK;
return status;
}*/
int8 tm_obc_soft_reset_dec(uint8* data, uint32* rst_sts)
{
    int8 status = 0;
    memcpy(rst_sts,data,sizeof(uint32));
    status = TCTM_OK;
    return status;

}

int8 obc_mem_debug_tm_dec(uint32 *data)
{
    int8 status = 0;

    memcpy(&mem_debug_data,data,4);
    if((mem_debug_data >>4 & 0x0f) < e_iram_heap_availablity)
    {
        printf("The TM encode memory type is: %d\n",mem_debug_data >> 4 & 0x0f);
        printf("The TM encode memory status is: %d\n",(mem_debug_data & 0x08)>>3);
    }
    else
    {
        printf("the TM encode heap memory is : %d\n",mem_debug_data);
    }
    status = TCTM_OK;
    return status;
}

int8 tm_tty_data_dec(uint8* data, uint8* tm_tty_data, uint32 data_size)
{
    int8 status = 0;

    /* Decode data parameters */
    memcpy(tm_tty_data,data,data_size);

    status = TCTM_OK;
    return status;
}
int8 tm_spi_intf_param_dec(uint8* data, tctm_spi_init_s *spii)
{
    int8 status = 0;

    /* Decode data parameters */
    memcpy(&spii,data,sizeof(spii));
    printf("SPI mode Received Successfully\n");

    status = TCTM_OK;
    return status;
}

int8 tm_ethernet_init_param_dec(uint8* data, tctm_ethernet_init_s *eth)
{
    int8 status = 0;

    /* Decode data parameters */
    memcpy(&eth,data,sizeof(eth));
    printf("Ethernet speed Received Successfully\n");
    status = TCTM_OK;
    return status;
}

int8 tm_can_init_param_dec(uint8* data, tctm_can_init_s *cis)
{
    int8 status = 0;

    /* Decode data parameters */
    memcpy(&cis,data,sizeof(cis));
    printf("CAN prescaler Received Successfully\n");
    status = TCTM_OK;
    return status;
}

int8 tm_i2c_init_param_dec(uint8* data, tctm_i2c_init_s *i2ci)
{
    int8 status = 0;

    /* Decode data parameters */
    memcpy(&i2ci,data,sizeof(i2ci));
    printf("I2C Timing Received Successfully\n");
    status = TCTM_OK;
    return status;
}

int8 tm_usb_init_param_dec(uint8* data, tctm_usb_otg_cfg_s *usbo)
{
    int8 status = 0;

    /* Decode data parameters */
    memcpy(&usbo,data,sizeof(usbo));
    printf("USB Dev_endpoints Received Successfully\n");

    status = TCTM_OK;
    return status;
}

int8 tm_uart_init_param_dec(uint8* data, tctm_uart_init_s *uarti)
{
    int8 status = 0;

    /* Decode data parameters */
    memcpy(&uarti,data,sizeof(uarti));
    printf("UART baudrateReceived Successfully\n");
    status = TCTM_OK;
    return status;
}


#ifdef INC_READ_ENB
int16_t socket_temp_read(uint8_t *ptr,uint16_t read_len )
{
    int16_t bytesize = 0;
    int i=0;
    uint16_t temp_len = read_len;
    // For timeout error, retry until expected byte comes
    for( i=0;i<read_len; )
    {
        bytesize = recv(sockfd, &ptr[i], temp_len ,MSG_DONTWAIT);
        if(bytesize>0)
        {
            i += bytesize;
            temp_len = temp_len - bytesize;
            //		printf(" iter %d\n",i);
        }
        //usleep(1000);
        if(read_len == i)
        {
            break;
        }
    }
    //	printf("temp read len %d\n",i);
    return i;
}
#endif

#if 0
void *mfcc_tm_listener_thread(void *params)
{
    int32 port = atoi(tctm_soc_inf.port_num);
    int32 addr = inet_addr(tctm_soc_inf.ip_addr);
    int32_t status,bytesize;
    struct sockaddr_in servaddr; // cli;
    uint8 buffer[BUFF_READ_MAX_SIZE];

#ifdef TM_STORAGE
    FILE *fptr;
#endif

    // socket create and verification
    sockfd = socket(AF_INET, SOCK_STREAM, 0);
    if (sockfd == -1) {
        printf("socket creation failed...\n");
        status = sockfd;
    }
    else
    {
        bzero(&servaddr, sizeof(servaddr));

        // assign IP, PORT
        servaddr.sin_family = AF_INET;
        servaddr.sin_addr.s_addr = addr;
        servaddr.sin_port = htons(port);

        struct timeval tv;
        tv.tv_sec = 0;
        tv.tv_usec = 5000;
        setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, (const char*)&tv, sizeof tv);

        printf(" connecting to server ..");
        // connect the client socket to server socket
        while (connect(sockfd, (struct sockaddr*)&servaddr, sizeof(servaddr)) < 0)
        {
            usleep(1000);
            //printf(".");
            /* wait for server */
            //printf("SOCKET: connected to the server..\n");
        }
        while(1)
        {
            //usleep(1000);
            memset(buffer,0,BUFF_READ_MAX_SIZE);
#ifdef INC_READ_ENB
            bytesize = recv(sockfd, buffer, 20 ,MSG_DONTWAIT);
#else
            bytesize = recv(sockfd, buffer, BUFF_READ_MAX_SIZE ,MSG_DONTWAIT);
#endif
            //bytesize = recv(sockfd, buffer, 213 ,MSG_DONTWAIT);
            //bytesize = recv(sockfd, buffer, BUFF_READ_MAX_SIZE,MSG_DONTWAIT);
            //bytesize = recv(sockfd, buffer, BUFF_READ_MAX_SIZE,MSG_DONTWAIT);
            if((bytesize==0) || (bytesize == EAGAIN) || (bytesize == -1))
            {
                //printf("[Socket TCTM] Warning/Error no %d \n",bytesize);
                usleep(100);
            }
            else if(bytesize>0)
            {
                printf("[Socket TCTM] Successfully Received data of size %d\n",bytesize);
#ifdef PRINT_BUF_ON
                printf("Received data stream: ");
#endif
                int i = 0;
#ifdef TM_STORAGE
                fptr = fopen("mfcc_tm_dump.txt", "ab+");
#endif
                for (i = 0; i< bytesize; i++)
                {
#ifdef PRINT_BUF_ON
                    printf("%x ",buffer[i]);
#endif
#ifdef TM_STORAGE
                    fprintf(fptr, "0x%02x,",buffer[i]);
#endif
                }
#ifdef PRINT_BUF_ON
                printf("\n");
#endif
#ifdef TM_STORAGE
                fprintf(fptr, "\n");
                fclose(fptr);
#endif
                status = mfcc_tm_parser(buffer,bytesize);
                if(status < 0)
                {
                    pthread_exit(NULL);
                }
            }
            else
            {
                printf("[Socket TCTM] Warning/Error no %d \n",bytesize);
                printf("[Socket TCTM] Successfully closing socket\n");
                close(sockfd);
            }
        }
    }
    return 0;
}
#endif
void *mfcc_tm_listener_thread(void *params)
{
    csp_recv_tc();
    return 0;
}

int32_t mfcc_tcp_send(uint32_t addr, uint32_t port, uint8_t *data, uint32_t size)
{
    int32_t status = 0;
#if 0
    status = write(sockfd, data, size);
    printf("[SOCKET] Successfully transferred data .. %d\n", status);
    return 0;
#endif
    status = csp_send_tm(data, size);
    printf("[CSP_SOCKET] Successfully transferred data .. %d\n",status);
    return 0;
}

int8 get_crnt_time_date(tctm_time_par_s *get_time_date)
{
    time_t rawtime;
    struct tm *crnt_dt_tm;

#if 1  // It reads current system time
    time( &rawtime );
    //crnt_dt_tm = localtime( &rawtime );
    crnt_dt_tm = gmtime( &rawtime );
#else
    /** Set the Fixed launch time UTC/ GMT: Friday, 10 February 2023 04:06:00 */
    rawtime = 1676001960 ;

    //rawtime = 1675982160; // Has to be in IST, as PC was set to IST If your PC has different time zone , please handle it.
    //rawtime = 1676021760; // Has to be in IST, as PC was set to IST If your PC has different time zone , please handle it.
    crnt_dt_tm = gmtime( &rawtime );
#endif

    get_time_date->Hour  =crnt_dt_tm->tm_hour ;
    get_time_date->Minute =crnt_dt_tm->tm_min;
    get_time_date->Seconds  =crnt_dt_tm->tm_sec;
    get_time_date->Date  =crnt_dt_tm->tm_mday;
    get_time_date->Month  =crnt_dt_tm->tm_mon+1;
    get_time_date->Year  =crnt_dt_tm->tm_year+1900;
    printf("%2d:%2d:%2d\r\n",get_time_date->Hour,get_time_date->Minute,get_time_date->Seconds);
    printf("%2d-%2d-%2d\r\n",get_time_date->Date,get_time_date->Month,get_time_date->Year);

    return 1;
}
#if 0
void sat_dev_print()
{

    printf("\n0. TRANSCELESTIAL\n");
    printf("1. X_BAND\n");
    printf("2. S_BAND\n");
    printf("3. PL_AICRAFT--UNUSED\n");
    printf("4. ADCS\n");
    printf("5. PROP_UNIT_THRUSTER\n");
    printf("6. PL_ZES\n");
    printf("7. PL_SAYARLABS\n");
    printf("8. PL_NETRA\n");
    printf("9. EDGE_BRD\n");
    printf("10. OBC_PS_GPS_STD_PL_BRD\n");
    printf("11. HMR\n");
    printf("12. PL_SERVER\n");
    printf("13. GPS\n");

}
#endif

void sat_dev_print()
{

    printf("\n0. TRANSCELESTIAL\n");
    printf("1. S_BAND\n");
    printf("2. X_BAND\n");
    printf("3. HW_PL_STS300\n");
    printf("4. ADCS\n");
    printf("5. PROP_UNIT_THRUSTER\n");
    printf("6. HW_UHF\n");
    printf("7. HW_PL_SCANWAY\n");
    printf("8. PL_NETRA\n");
    printf("9. EDGE_BRD\n");
    printf("10. OBC_PS_GPS_STD_PL_BRD\n");
    printf("11. HMR\n");
    printf("12. PL_SERVER\n");
    printf("13. GPS\n");

}
void log_notificataion_api_dwld(ft_notification_info *ft_sts)
{
    uint32_t u16cnt;
    uint8_t init_start = 0;
    init_start=init_start;

    printf("LOG App notification API invoked !!!!\n");

    if(ft_sts->status == transfer_download_success)
    {
        printf("1. download success\n");
        if(ft_sts->dwld_info.tx_mode == 1)
        {
            printf("2. Transfer mode : DATA\n");
            FILE *fptr_write;
            if (ft_sts->dwld_info.rx_file_id == 1)
            {
                printf("3. Logger data received of size: %u bytes\n\n",ft_sts->dwld_info.size_file_or_data);
                fptr_write = fopen("obc_log_via_ftm.bin","wb");
            }
            else if (ft_sts->dwld_info.rx_file_id == 2)
            {
                printf("3. Memory  data received of size: %u bytes\n\n",ft_sts->dwld_info.size_file_or_data);
                fptr_write = fopen("obc_mem.bin","wb");
            }
            else
            {
                printf("3. Logger data received of size: %u bytes\n\n",ft_sts->dwld_info.size_file_or_data);
                fptr_write = fopen("obc_log_via_ftm.bin","wb");
            }

            //printf("#########  OBC debug print Start #######\n",ft_sts->dwld_info.size_file_or_data);
            for (u16cnt = 0; u16cnt < ft_sts->dwld_info.size_file_or_data; u16cnt++)
            {
                //printf("%c",ft_sts->dwld_info.bulkdata_ptr[u16cnt]);
                fwrite(&ft_sts->dwld_info.bulkdata_ptr[u16cnt], sizeof(unsigned char), 1, fptr_write);
            }
            fclose(fptr_write);
            //printf("#########  OBC debug print End #######\n",ft_sts->dwld_info.size_file_or_data);
        }
        else
        {
            printf("2. Transfer mode : FILE\n");
            printf("3. File Stored path : ");
            for (u16cnt = 0; u16cnt < ft_sts->dwld_info.path_filename_buf_length; u16cnt++)
            {
                printf("%c",ft_sts->dwld_info.storage_path_and_File_name[u16cnt]);
            }
            printf("\n4. File size : %u",ft_sts->dwld_info.size_file_or_data);
        }
        init_start = 0;
    }
    else if(ft_sts->status == crc_error)
    {
        printf("1. download failed/ CRC error\n");
        if(ft_sts->dwld_info.tx_mode == 1)
        {
            printf("2. Transfer mode : DATA\n");
        }
        init_start = 0;
    }
    else if(ft_sts->status == transfer_suspended)
    {
        printf("1. download suspended by sender [Timeout mode]\n");
    }
    else if(ft_sts->status == transfer_suspended_savecontext)
    {
        printf("1. download suspended by sender [Save Context Mode]\n");
    }
    else if(ft_sts->status == transfer_resumed)
    {
        printf("1. downloading resumed by sender\n");
    }
    else if(ft_sts->status == transfer_resume_accepted)
    {
        printf("1. downloading resumed back by sender\n");
    }
    else if(ft_sts->status == tx_terminated_suspend_timeout_expired)
    {
        printf("1. download Terminated due to suspend timeout expired\n");
    }
    else if(ft_sts->status == transfer_suspend_accepted)
    {
        printf("1. download Suspend - Timeout mode Accepted by Sender\n");
    }
    else if(ft_sts->status == transfer_suspend_savecontext_accepeted)
    {
        printf("1. Download Suspend - SaveContext mode Accepted by Sender\n");
    }
    else if(ft_sts->status == transfer_resumed_restorecontext)
    {
        printf("1. Download Resume Savecontext mode Requested by Sender\n");
    }
    else if(ft_sts->status == transfer_download_ready)
    {
        printf("1. Download request received\n");
        if(ft_sts->dwld_info.tx_mode == 1)
        {
            printf("2. Transfer mode : DATA\n");
            ft_get_receiver_node_storage_address((uint64_t)log_buff);
        }
        else
        {
            printf("2. Transfer mode : FILE\n");
            printf("3. File size: %d\n",ft_sts->dwld_info.size_file_or_data);
            ft_get_receiver_node_storage_address(0x12345678);
        }
    }
    else if(ft_sts->status == transfer_resume_savecontext_accepeted)
    {
        printf("1. download Resume - Savecontext mode Accepted by Sender\n");
        init_start = 1;
    }
    else if(ft_sts->status == transmission_terminated_by_rx_node)
    {
        printf("1. download Terminated by Receiver node\n");
        init_start = 0;
    }
    else if(ft_sts->status == transfer_otsu)
    {

    }
    else if(ft_sts->status == transfer_suspend_tout_not_accepted)
    {
        printf("1. suspend timeout request not completed\n");
    }
    else if(ft_sts->status == transfer_suspend_savecontext_failed)
    {
        printf("1. suspend savecontxt request not completed\n");
    }
    else if(ft_sts->status == transfer_rseume_tout_not_accepted)
    {
        printf("1. resume timeout request not completed\n");
    }
    else if(ft_sts->status == transfer_resume_restorecontext_failed)
    {
        printf("1. resume savecontxt request not completed\n");
    }
    else
    {
        printf("Invalid Notification not processed\n");
    }

    printf("\n-------------/End/---------------\n\n");


}

void module_level_display(uint8_t level)
{
    if(0x00 == level)
    {
        printf("ALL LOGS DISABLE");
    }
    else if(0x1f == level)
    {
        printf("ALL LOGS ENABLE");
    }
    else
    {
        if(level & 0x01)
        {
            printf("ERROR,");
        }
        if(level & 0x02)
        {
            printf("WARNING,");
        } 
        if(level & 0x04)
        {
            printf("INFO L1,");
        }
        if(level & 0x08)
        {
            printf("INFO L2,");
        }
        if(level & 0x10)
        {
            printf("INFO L3,");
        }
    }

}

uint8_t module_level_selection()
{
    uint8_t lev=0;
    char level[10]={0};
    char *sub_str={0};
    //int a[5]={1,2,3,4,5};
    printf("Select your log level:\n");
    printf("0.All log disable\n");
    printf("1.Error only\n");
    printf("2.Warning only\n");
    printf("3.Info1\n");
    printf("4.Info2\n");
    printf("5.Info3\n");
    printf("6.All log enable\n");
    printf("Example : If you want error,warning and info2 log,enter 1,2,4\n");
    scanf("%s",level);

    sub_str= strtok(level, ",");
    while(sub_str!=NULL)
    {
        switch(*sub_str)
        {
            case '0':
                lev=lev|ALL_LOGS_DIS;
                sub_str= strtok(NULL, ",");
                break;
            case '1':
                lev=lev|ERROR_LOGS_EN;
                sub_str= strtok(NULL, ",");
                break;
            case '2':
                lev=lev|WARNING_LOGS_EN;
                sub_str= strtok(NULL, ",");
                break;
            case '3':
                lev=lev|INFO_L1_LOGS_EN;
                sub_str= strtok(NULL, ",");
                break;
            case '4':
                lev=lev|INFO_L2_LOGS_EN;
                sub_str= strtok(NULL,",");
                break;
            case '5':
                lev=lev|INFO_L3_LOGS_EN;
                sub_str=strtok(NULL,",");
                break;
            case '6':
                lev=lev|ALL_LOGS_EN;
                sub_str=strtok(NULL,",");
                break;
        }

    }
    return lev;
}

uint8_t*  log_lev_cfg_encode(uint16_t *tc_len)
{
    uint8_t* tc_data=NULL;
    uint8_t *ptr; 
    uint8_t mode_selc;
    uint8_t module_selection;
    printf("\n1.Set levels for all modules one by one\n");
    printf("2.Set levels for specific module\n");
    printf("3.Enable all level for all modules\n");
    printf("4.Enable only error level for all modules\n");
    printf("5.Reset to default settings\n");
    printf("6.Set levels for multiple modules\n");


    scanf("%hhu",&mode_selc);
    if((1<=mode_selc)&&(mode_selc<=6))
    {
        switch(mode_selc)
        {

            case 1:
                {
                    tc_data=malloc(LOG_MODULE_MAX+2);
                    tc_data[0] = mode_selc;
                    tc_data[1]=LOG_MODULE_MAX;
                    printf("Enter your level selection for ADCS:\n\n");
                    tc_data[LOG_ADCS+2]=module_level_selection();
                    printf("Enter your level selection for OTSU:\n\n");
                    tc_data[LOG_OTSU+2]=module_level_selection();
                    printf("Enter your level selection for COMMS:\n\n");
                    tc_data[LOG_COMMS+2]=module_level_selection();
                    printf("Enter your level selection for FTM:\n\n");
                    tc_data[LOG_FTM+2]=module_level_selection();
                    printf("Enter your level selection for OBC:\n\n");
                    tc_data[LOG_OBC+2]=module_level_selection();
                    printf("Enter your level selection for EPS:\n\n");
                    tc_data[LOG_EPS+2]=module_level_selection();
                    printf("Enter your level selection for TCTM:\n\n");
                    tc_data[LOG_TCTM+2]=module_level_selection();
                    printf("Enter your level selection for SCHEDULER:\n\n");
                    tc_data[LOG_SCHEDULER+2]=module_level_selection();
                    printf("Enter your level selection for AHW:\n\n");
                    tc_data[LOG_AHW+2]=module_level_selection();
                    printf("Enter your level selection for LOGGER:\n\n");
                    tc_data[LOG_LOGGER+2]=module_level_selection();
                    printf("Enter your level selection for ERROR HANDLER:\n\n");
                    tc_data[LOG_ERROR_HANDLER+2]=module_level_selection();
                    printf("Enter your level selection for HM:\n\n");
                    tc_data[LOG_HM+2]=module_level_selection();
                    printf("Enter your level selection for IPCC:\n\n");
                    tc_data[LOG_HM+2]=module_level_selection();
                    *tc_len=LOG_MODULE_MAX+2;
                    printf("LOG:%hu,%hhu\n",*tc_len,tc_data[0]);
                }
                break;

            case 2:
                {
                    tc_data=malloc(3);
                    tc_data[0] = mode_selc;
                    printf("Select Modules:\n");
                    printf("1.ADCS\n");
                    printf("2.OTSU\n");
                    printf("3.COMMS\n");
                    printf("4.FTM\n");
                    printf("5.OBC\n");
                    printf("6.EPS\n");
                    printf("7.TCTM\n");
                    printf("8.SCHEDULER\n");
                    printf("9.AHW\n");
                    printf("10.LOGGER\n");
                    printf("11.ERROR HANDLER\n");
                    printf("12.HM\n");
                    printf("13.IPCC\n");
                    scanf("%hhu",&module_selection);
                    switch(module_selection)
                    {
                        case 1:
                            tc_data[1]=LOG_ADCS;
                            tc_data[2]=module_level_selection();
                            break;
                        case 2:
                            tc_data[1]=LOG_OTSU;
                            tc_data[2]=module_level_selection();
                            break;
                        case 3:
                            tc_data[1]=LOG_COMMS;
                            tc_data[2]=module_level_selection();
                            break;
                        case 4:
                            tc_data[1]=LOG_FTM;
                            tc_data[2]=module_level_selection();
                            break;
                        case 5:
                            tc_data[1]=LOG_OBC;
                            tc_data[2]=module_level_selection();
                            break;
                        case 6:
                            tc_data[1]=LOG_EPS;
                            tc_data[2]=module_level_selection();
                            break;
                        case 7:
                            tc_data[1]=LOG_TCTM;
                            tc_data[2]=module_level_selection();
                            break;
                        case 8:
                            tc_data[1]=LOG_SCHEDULER;
                            tc_data[2]=module_level_selection();
                            break;
                        case 9:
                            tc_data[1]=LOG_AHW;
                            tc_data[2]=module_level_selection();
                            break;
                        case 10:
                            tc_data[1]=LOG_LOGGER;
                            tc_data[2]=module_level_selection();
                            break;
                        case 11:
                            tc_data[1]=LOG_ERROR_HANDLER;
                            tc_data[2]=module_level_selection();
                            break;
                        case 12:
                            tc_data[1]=LOG_HM;
                            tc_data[2]=module_level_selection();
                            break;
                        case 13:
                            tc_data[1]=LOG_IPCC;
                            tc_data[2]=module_level_selection();
                            break;

                        default:
                            break;

                    }
                    *tc_len=3;
                }
                break;

            case 3:
                {
                    tc_data=malloc(LOG_MODULE_MAX+2);
                    tc_data[0] = mode_selc;
                    tc_data[1] = LOG_MODULE_MAX;
                    tc_data[LOG_ADCS+2]          = ALL_LOGS_EN;
                    tc_data[LOG_OTSU+2]          = ALL_LOGS_EN;
                    tc_data[LOG_COMMS+2]         = ALL_LOGS_EN;
                    tc_data[LOG_FTM+2]           = ALL_LOGS_EN;
                    tc_data[LOG_OBC+2]           = ALL_LOGS_EN;
                    tc_data[LOG_EPS+2]           = ALL_LOGS_EN;
                    tc_data[LOG_TCTM+2]          = ALL_LOGS_EN;
                    tc_data[LOG_SCHEDULER+2]     = ALL_LOGS_EN;
                    tc_data[LOG_AHW+2]           = ALL_LOGS_EN;
                    tc_data[LOG_LOGGER+2]        = ALL_LOGS_EN;
                    tc_data[LOG_ERROR_HANDLER+2] = ALL_LOGS_EN;
                    tc_data[LOG_HM+2]            = ALL_LOGS_EN;
                    tc_data[LOG_IPCC+2]          = ALL_LOGS_EN;
                    *tc_len=LOG_MODULE_MAX+2;
                    break;
                }
            case 4:
                {

                    tc_data=malloc(LOG_MODULE_MAX+2);
                    tc_data[0] = mode_selc;
                    tc_data[1] = LOG_MODULE_MAX;
                    tc_data[LOG_ADCS+2]          = ERROR_LOGS_EN;
                    tc_data[LOG_OTSU+2]          = ERROR_LOGS_EN;
                    tc_data[LOG_COMMS+2]         = ERROR_LOGS_EN;
                    tc_data[LOG_FTM+2]           = ERROR_LOGS_EN;
                    tc_data[LOG_OBC+2]           = ERROR_LOGS_EN;
                    tc_data[LOG_EPS+2]       	 = ERROR_LOGS_EN;
                    tc_data[LOG_TCTM+2]          = ERROR_LOGS_EN;
                    tc_data[LOG_SCHEDULER+2]     = ERROR_LOGS_EN;
                    tc_data[LOG_AHW+2]           = ERROR_LOGS_EN;
                    tc_data[LOG_LOGGER+2]        = ERROR_LOGS_EN;
                    tc_data[LOG_ERROR_HANDLER+2] = ERROR_LOGS_EN;
                    tc_data[LOG_HM+2] = ERROR_LOGS_EN;
                    tc_data[LOG_IPCC+2] = ERROR_LOGS_EN;
                    *tc_len=LOG_MODULE_MAX+2;
                    break;
                }
            case 5:
                {
                    tc_data=malloc(LOG_MODULE_MAX+2);
                    tc_data[0] = mode_selc;
                    tc_data[1] = LOG_MODULE_MAX;
                    tc_data[LOG_ADCS+2]          = ALL_LOGS_EN;
                    tc_data[LOG_OTSU+2]          = ALL_LOGS_EN;
                    tc_data[LOG_COMMS+2]         = ALL_LOGS_EN;
                    tc_data[LOG_FTM+2]           = ALL_LOGS_EN;
                    tc_data[LOG_OBC+2]           = ALL_LOGS_EN;
                    tc_data[LOG_EPS+2]           = ALL_LOGS_EN;
                    tc_data[LOG_TCTM+2]          = ALL_LOGS_EN;
                    tc_data[LOG_SCHEDULER+2]     = ALL_LOGS_EN;
                    tc_data[LOG_AHW+2]           = ALL_LOGS_EN;
                    tc_data[LOG_LOGGER+2]        = ALL_LOGS_EN;
                    tc_data[LOG_ERROR_HANDLER+2] = ALL_LOGS_EN;
                    tc_data[LOG_HM+2] = ALL_LOGS_EN;
                    tc_data[LOG_IPCC+2] = ALL_LOGS_EN;
                    *tc_len=LOG_MODULE_MAX+2;
                    break;
                }


            case 6:
                {
                    uint8_t module_cnt = 0,cntr = 0;
                    uint8_t  module[9]={0};
                    ptr=malloc(22);
                    uint8_t i=2;
                    ptr[0] = mode_selc;
                    printf("Enter the number of modules to configure\n");
                    scanf("%hhu", &module_cnt);
                    printf("Select Modules:\n");
                    printf("1.ADCS\n");
                    printf("2.OTSU\n");
                    printf("3.COMMS\n");
                    printf("4.FTM\n");
                    printf("5.OBC\n");
                    printf("6.EPS\n");
                    printf("7.TCTM\n");
                    printf("8.SCHEDULER\n");
                    printf("9.AHW\n");
                    printf("10.LOGGER\n");
                    printf("11.ERROR HANDLER\n");
                    printf("12.HM");
                    printf("13.IPCC");
                    for(cntr = 0; cntr<module_cnt; cntr++)
                    {
                        scanf("%hhu",&module[cntr]);
                    }
                    printf("Enter the level configuration for selected modules");
                    for(cntr = 0; cntr<module_cnt; cntr++)
                    {
                        switch(module[cntr])
                        {
                            case 1:
                                ptr[i]=LOG_ADCS;
                                i++;
                                printf("\nEnter your level selection for ADCS:\n");
                                ptr[i]=module_level_selection();
                                i++;
                                break;
                            case 2:
                                ptr[i]=LOG_OTSU;
                                i++;
                                printf("\nEnter your level selection for OTSU:\n");
                                ptr[i]=module_level_selection();
                                i++;
                                break;
                            case 3:
                                ptr[i]=LOG_COMMS;
                                i++;
                                printf("\nEnter your level selection for OTSU:\n");
                                ptr[i]=module_level_selection();
                                i++;
                                break;
                            case 4:
                                ptr[i]=LOG_FTM;
                                i++;
                                printf("\nEnter your level selection for FTM:\n");
                                ptr[i]=module_level_selection();
                                i++;
                                break;
                            case 5:
                                ptr[i]=LOG_OBC;
                                i++;
                                printf("\nEnter your level selection for OBC:\n");
                                ptr[i]=module_level_selection();
                                i++;
                                break;
                            case 6:
                                ptr[i]=LOG_EPS;
                                i++;
                                printf("\nEnter your level selection for EPS:\n");
                                ptr[i]=module_level_selection();
                                i++;
                                break;
                            case 7:
                                ptr[i]=LOG_TCTM;
                                i++;
                                printf("\nEnter your level selection for TCTM:\n");
                                ptr[i]=module_level_selection();
                                i++;
                                break;
                            case 8:
                                ptr[i]=LOG_SCHEDULER;
                                i++;
                                printf("\nEnter your level selection for SCHEDULER:\n");
                                ptr[i]=module_level_selection();
                                i++;
                                break;
                            case 9:
                                ptr[i]=LOG_AHW;
                                i++;
                                printf("\nEnter your level selection for AHW:\n");
                                ptr[i]=module_level_selection();
                                i++;
                                break;
                            case 10:
                                ptr[i]=LOG_LOGGER;
                                i++;
                                printf("\nEnter your level selection for LOGGER:\n");
                                ptr[i]=module_level_selection();
                                i++;
                                break;
                            case 11:
                                ptr[i]=LOG_ERROR_HANDLER;
                                i++;
                                printf("\nEnter your level selection for ERROR HANDLER:\n");
                                ptr[i]=module_level_selection();
                                i++;
                                break;
                            case 12:
                                ptr[i]=LOG_HM;
                                i++;
                                printf("\nEnter your level selection for HM:\n");
                                ptr[i]=module_level_selection();
                                i++;
                                break;
                            case 13:
                                ptr[i]=LOG_IPCC;
                                i++;
                                printf("\nEnter your level selection for IPCC:\n");
                                ptr[i]=module_level_selection();
                                i++;
                                break;

                        }
                    }
                    ptr[1]=module_cnt;
                    *tc_len =(module_cnt*2)+2;    ///module count  i byte - levels for i no of modules 
                    tc_data = malloc(*tc_len);
                    os_memcpy(tc_data,ptr,*tc_len);
                }

                break;

        }

    }
    else
    {
        printf("INVALID SELECTION\n");
    }
    return tc_data;
}

uint32_t file_Crc32(uint32_t Crc, uint32_t Data)
{
    uint8_t index;

    Crc = Crc ^ Data;
    for (index = 0; index < 32; index++)
    {
        if (Crc & 0x80000000)
        {
            Crc = (Crc << 1) ^ 0x04C11DB7;  // Polynomial used in STM32
        }
        else
        {
            Crc = (Crc << 1);
        }
    }

    return (Crc);
}

long int file_findSize(char file_name[])
{
    // opening the file in read mode
    FILE *fp = fopen(file_name, "r");

    // checking if the file exist or not
    if (fp == NULL)
    {
        printf("SIZE | File opening error %s !\n",file_name);
        return -1;
    }

    fseek(fp, 0L, SEEK_END);

    // calculating the size of the file
    long int res = ftell(fp);

    // closing the file
    fclose(fp);

    return res;
}

uint32_t file_checksum(char file_name[], uint32_t length)
{
    uint32_t read_buffer = 0xffffffff;
    uint32_t calc_CRC;
    // opening the file in read mode
    FILE *fp = fopen(file_name, "r");

    // checking if the file exist or not
    if (fp == NULL)
    {
        printf("INTG | File opening error %s !\n",file_name);
        return 0;
    }

    calc_CRC = 0xFFFFFFFF;
    while (length > 3)
    {
        fread(&read_buffer, 4, 1, fp);
        calc_CRC =file_Crc32(calc_CRC, read_buffer);
        length -= 4;
    }

    // closing the file
    fclose(fp);
    return calc_CRC;
}
int8_t get_sub_mod_task_id(uint8 sub_mod)
{
    switch(sub_mod)
    {
        case TC_TM_BUFFER_APP_EPS:
            {
                return EPS_TASK;
            }
            break;
        case TC_TM_BUFFER_APP_ADCS:
            {
                return ADCS_CONTROLLER;
            }
            break;
        case TC_TM_BUFFER_APP_COMMSS_SBAND:
            {
                return COMMS_SBAND_CTLR;
            }
            break;
        case TC_TM_BUFFER_APP_COMMSS_UHF:
            {
                return COMMS_UHF_CTLR;
            }
            break;
        case TC_TM_BUFFER_APP_SENSOR:
            {
                return OBC_SENSOR_HDLR;
            }
            break;
        case TC_TM_BUFFER_APP_OBC:
            {
                return OBC_MAIN;
            }
            break;
        case TC_TM_BUFFER_APP_ERR_HDLR:
            {
                return ERR_HANDLER; 
            }
            break;
#ifdef TEST_LAYER
        case TC_TM_BUFFER_TEST_TASK:
            {
                return TEST_TASK;
            }
            break;
#endif
        default:
            {
                return -1;
            }
            break;

    }
}

void sch_tc_update_offset()
{

    uint32_t position = 0;
    uint32_t file_size = 0;
    uint32_t offset = 0;
    uint16_t len = 0;
    char r_buff[60] = {0};// = NULL;
    char *r_buff1 = NULL;
    char *sub_str = NULL;

    if(apd_owrt == 1)
    {
        file_w  = fopen(SCH_TC_FILE,"r");
        if (file_w == NULL)
        {
            printf("\nSCH File Open Error!-%s",SCH_TC_FILE);
            exit(1);
        }

        fseek(file_w,0,SEEK_END);
        file_size = ftell(file_w);
        if(file_size == 0)
        {
            return;
        }

        position = file_size - 2; // Set the position to the second-to-last character

        while(position > 0)
        {
            fseek(file_w, position, SEEK_SET);
            if(fgetc(file_w) == '\n')
            {
                break; // Found the end of the last line
            }
            position--;
        }

        fread(r_buff,sizeof(unsigned char),60,file_w);
        sub_str = strtok_r(r_buff, ",", &r_buff1);
        sub_str = strtok_r(r_buff1, ",", &r_buff1);
        sub_str = strtok_r(r_buff1, ",", &r_buff1);
        offset = strtol(sub_str, NULL, 16);
        sub_str = strtok_r(r_buff1, ",", &r_buff1);
        len = strtol(sub_str, NULL, 16);
        // 1 byte added for radio id
        wr_offset = offset + len + 1;
        printf("\noff[%d]+len[%d]=Totl_Offset[%d]\n\n", offset,len,wr_offset);

    }
}

void tm_process_health_data(uint8_t *data_ptr, uint32_t len)
{
    printf("[GS][HM_FW]TM_GET_HEALTH_METRICS tm frame len %d\n", len);


    uint8_t *pld_ptr = malloc(len);


    if(pld_ptr)
    {
        memcpy(pld_ptr, data_ptr, len);

        uint8_t sub_mod_id        = pld_ptr[0];
        uint8_t queue_id          = pld_ptr[1];
        uint16_t no_of_instance;
        memcpy(&no_of_instance, &pld_ptr[2],2); 
        uint8_t* data = &pld_ptr[4];

        printf("[GS][HM_FW]TM_GET_HEALTH_METRICS sub_mod_id  %d queue_id %d num_of_instance %d\n", sub_mod_id, queue_id, no_of_instance);
        if(no_of_instance == 0)
        {
            printf("[GS][HM_FW]Tm_GET_HEALTH_METRICS No Health info available for Submod %d queue %d\n",sub_mod_id,queue_id);
            return;
        }
        /** switch submodule id */
        switch(sub_mod_id)
        {

            case TC_TM_BUFFER_APP_EPS:
                {
                    hm_fw_eps_tm(queue_id,no_of_instance, data);
                }
                break;

            case TC_TM_BUFFER_APP_ADCS:
                {
                    health_metric_print(queue_id, no_of_instance, data);
                }
                break;

            case TC_TM_BUFFER_APP_COMMSS_SBAND:
                {
                    hm_fw_comms_sband_tm(queue_id,no_of_instance, data);
                }
                break;

            case TC_TM_BUFFER_APP_COMMSS_UHF:
                {
                    hm_fw_comms_uhf_tm(queue_id,no_of_instance, data);
                }
                break;

            case TC_TM_BUFFER_APP_SENSOR:
                {
                    hm_fw_sensors_tm(queue_id,no_of_instance,data);
                }
                break;

            case TC_TM_BUFFER_APP_OBC:
                {
                    hm_fw_obc_tm(queue_id,no_of_instance, data);
                }
                break;

            case TC_TM_BUFFER_APP_ERR_HDLR:
                {
                    hm_fw_err_hdlr_tm(queue_id,no_of_instance, data);
                }
                break;
#ifdef TEST_LAYER
            case TC_TM_BUFFER_TEST_TASK:
                {
                    hm_fw_test_case_tm(queue_id,no_of_instance, data);
                }
                break;
#endif
            default:
                {
                    printf("[GS][HM_FW]Submodule Decoding yet to be done on this TM\n");
                }
                break;
        }
    }
    else
    {
        printf("[GS][HM_FW]Malloc failed\n");
    }
    free(pld_ptr);
}

void hm_fw_sensors_tm(uint8_t queue_id, uint16_t num_of_instance, uint8_t* data)
{

    struct tm *tm_ptr;
    sys_time_date_s sns_time;

    psm_data_s psm_data_buffer_hlt;
    temp_data_s temp_data_buffer_hlt;
    dt_data_s dt_data_buffer_hlt;
    hsc_data_s hsc_data_buffer_hlt;

    int index;
    uint32_t data_idx = 0;

    /**  - Switch based on queue id */
    switch(queue_id)
    {
        case PSM_PS_DATA_QUEUE_ID:
        case PSM_OBC_DATA_QUEUE_ID:
            {
                printf("[GS][HM_FW]PSM OBC DATA received\n");
                printf("[GS][HM_FW]Number of instance %d\n", num_of_instance);
                for(index=0;index<num_of_instance;index++)
                {
                    memcpy((uint8_t*)&psm_data_buffer_hlt, &data[data_idx], sizeof(psm_data_s));
                    printf("[GS][HM_FW]vbus_voltage=%f ",psm_data_buffer_hlt.pwr.vbus_voltage);
                    printf("[GS][HM_FW]vshunt_voltage=%f ",psm_data_buffer_hlt.pwr.vshunt_voltage);
                    printf("[GS][HM_FW]current=%f ",psm_data_buffer_hlt.pwr.current);
                    printf("[GS][HM_FW]power=%d ",psm_data_buffer_hlt.pwr.power);
                    tm_ptr=localtime((time_t*)&psm_data_buffer_hlt.psm_epoch_time);
                    if(tm_ptr)
                    {
                        sns_time.hour=tm_ptr->tm_hour;
                        sns_time.minute=tm_ptr->tm_min;
                        sns_time.seconds=tm_ptr->tm_sec;
                        sns_time.date=tm_ptr->tm_mday;
                        sns_time.month=tm_ptr->tm_mon +1;
                        sns_time.year=tm_ptr->tm_year + 1900 -2000;
                        printf("[GS][HM_FW] Time :%d :%d :%d\n",sns_time.hour,sns_time.minute,sns_time.seconds);
                    }
                    data_idx += sizeof(psm_data_s);

                }
            }
            break;
        case DT_PS_DATA_QUEUE_ID:
        case DT_EDGE_DATA_QUEUE_ID:
        case DT_SPE01_DATA_QUEUE_ID:
        case DT_SPE02_DATA_QUEUE_ID:
        case DT_SPB01_DATA_QUEUE_ID:
        case DT_SPW01_DATA_QUEUE_ID:
        case DT_SPW02_DATA_QUEUE_ID:    
            {
                printf("[GS][HM_FW]Number of instance %d\n", num_of_instance);
#ifdef SNS_GET_INF_PRINT
                for(index=0;index<num_of_instance;index++)
                {
                    memcpy((uint8_t*)&dt_data_buffer_hlt, &data[data_idx], sizeof(dt_data_s));

                    printf("[GS][HM_FW]Temperature=%lf ",dt_data_buffer_hlt.temperature);
                    //                                  printf(" Time :%lu \n",dt_data_buffer[index].dt_epoch_time);
                    tm_ptr=localtime((time_t*)&dt_data_buffer_hlt.dt_epoch_time);
                    if(tm_ptr)
                    {
                        sns_time.hour=tm_ptr->tm_hour;
                        sns_time.minute=tm_ptr->tm_min;
                        sns_time.seconds=tm_ptr->tm_sec;
                        sns_time.date=tm_ptr->tm_mday;
                        sns_time.month=tm_ptr->tm_mon +1;
                        sns_time.year=tm_ptr->tm_year + 1900 -2000;
                        printf("[GS][HM_FW] Time :%d :%d :%d\n",sns_time.hour,sns_time.minute,sns_time.seconds);
                        data_idx += sizeof(dt_data_s);
                    }
                }
#endif
            }
            break;
        case TEMP_OBC_DATA_QUEUE_ID:
        case TEMP_PS_DATA_QUEUE_ID:
        case TEMP_ES_DATA_QUEUE_ID:
        case TEMP_GPS_DATA_QUEUE_ID:
            {
                printf("[GS][HM_FW]TEMP OBC DATA QUEUE received\n");
                printf("[GS][HM_FW]Number of instance %d\n", num_of_instance);

#ifdef SNS_GET_INF_PRINT
                for(index=0;index<num_of_instance;index++)
                {
                    memcpy((uint8_t*)&temp_data_buffer_hlt, &data[data_idx], sizeof(temp_data_s));
                    printf("[GS][HM_FW]Temperature=%f ",temp_data_buffer_hlt.temperature);
                    tm_ptr=localtime((time_t*)&temp_data_buffer_hlt.temp_epoch_time);
                    if(tm_ptr)
                    {
                        sns_time.hour=tm_ptr->tm_hour;
                        sns_time.minute=tm_ptr->tm_min;
                        sns_time.seconds=tm_ptr->tm_sec;
                        sns_time.date=tm_ptr->tm_mday;
                        sns_time.month=tm_ptr->tm_mon +1;
                        sns_time.year=tm_ptr->tm_year + 1900 -2000;
                        printf("[GS][HM_FW] Time :%d :%d :%d\n",sns_time.hour,sns_time.minute,sns_time.seconds);
                    }
                    data_idx += sizeof(temp_data_s);
                }
#endif
            }
            break;
        case HSC_EDGE_DATA_QUEUE_ID:
        case HSC_PS1_DATA_QUEUE_ID:
        case HSC_PS2_DATA_QUEUE_ID:
            {
                printf("[GS][HM_FW]Number of instance %d\n", num_of_instance);
#ifdef SNS_GET_INF_PRINT

                for(index=0;index<num_of_instance;index++)
                {
                    memcpy((uint8_t*)&hsc_data_buffer_hlt,&data[data_idx],sizeof(hsc_data_s));
                    printf("[GS][HM_FW]voltage=%f ",hsc_data_buffer_hlt.hsc_data.voltage);
                    printf("[GS][HM_FW]current=%f ",hsc_data_buffer_hlt.hsc_data.current);
                    tm_ptr=localtime((time_t*)&hsc_data_buffer_hlt.adm_epoch_time);
                    if(tm_ptr)
                    {
                        sns_time.hour=tm_ptr->tm_hour;
                        sns_time.minute=tm_ptr->tm_min;
                        sns_time.seconds=tm_ptr->tm_sec;
                        sns_time.date=tm_ptr->tm_mday;
                        sns_time.month=tm_ptr->tm_mon +1;
                        sns_time.year=tm_ptr->tm_year + 1900 -2000;
                        printf("[GS][HM_FW] Time :%d :%d :%d\n",sns_time.hour,sns_time.minute,sns_time.seconds);
                        data_idx += sizeof(hsc_data_s);
                    }
                }
#endif
            }
            break;
        default:
            {
            }
            break;
    }
}

void hm_fw_test_case_tm(uint8_t queue_id, uint16_t num_of_instance, uint8_t* data)
{
    uint16_t index;
    uint32_t inst_size=0;
    hm_fw_cb.integrity_fail = 0;
    static uint8_t pass_cnt[HM_TEST_CASE_MAX] = {0};
    
    switch(hm_fw_cb.test_case_id)
    {
         case OBC_STRESS_TEST_SIMU :
            {
                printf("[GS][HM_FW]OBC HEALTH DATA received\n");
                inst_size = sizeof(s_obc_health_info);
            }
            break;
         case EPS_STRESS_TEST_SIMU:
            {
                switch(queue_id)
                {
                    case 1:
                        {
                            printf("[GS][HM_FW]EPS HEALTH DATA received\n");
                            inst_size = sizeof(eps_alert_flag_tmr_s);
                            printf("[GS][HM_FW]size of eps_alert_flag :%d\n",inst_size);
                        }
                        break;
                    case 2:
                        {
                            printf("[GS][HM_FW]EPS HEALTH DATA received\n");
                            inst_size = sizeof(eps_get_chnl_par_tmr_s);
                            printf("[GS][HM_FW]size of eps_get_chnl_par :%d\n",inst_size);
                        }
                        break;
                    case 3:
                        {
                            printf("[GS][HM_FW]EPS HEALTH DATA received\n");
                            inst_size = sizeof(eps_get_btry_brd_tmr_s);
                            printf("[GS][HM_FW]size of eps_battery_board :%d\n",inst_size);
                        }
                        break;
                    case 4:
                        {
                            printf("[GS][HM_FW]EPS HEALTH DATA received\n");
                            inst_size = sizeof(eps_get_conv_brd_tmr_s);
                            printf("[GS][HM_FW]size of eps_get_conv_brd_tmr_s :%d\n",inst_size);
                        }
                        break;
                    default:
                        {
                            printf("INVALID QUEUE ID");
                        }
                        break;
                }
            }
            break;
        case ADCS_STRESS_TEST_SIMU:
            {
                switch(queue_id)
                {
                    case 1:
                        {
                            printf("[GS][HM_FW]ADCS HEALTH DATA received\n");
                            inst_size = sizeof(s_adcs_hm_sen_cur);
                            printf("[GS][HM_FW]size of s_adcs_hm_sen_cur :%d\n",inst_size);
                        }
                        break;
                    case 2:
                        {
                            printf("[GS][HM_FW]ADCS HEALTH DATA received\n");
                            inst_size = sizeof(s_adcs_hm_cons_cur);
                            printf("[GS][HM_FW]size of s_adcs_hm_cons_cur:%d\n",inst_size);
                        }
                        break;
                    case 3:
                        {
                            printf("[GS][HM_FW]ADCS HEALTH DATA received\n");
                            inst_size = sizeof(s_adcs_hm_rw_cur);
                            printf("[GS][HM_FW]size of s_adcs_hm_rw_cur:%d\n",inst_size);
                        }
                        break;
                    case 4:
                        {
                            printf("[GS][HM_FW]ADCS HEALTH DATA received\n");
                            inst_size = sizeof(s_adcs_hm_css_vector);
                            printf("[GS][HM_FW]size of s_adcs_hm_css_vector:%d\n",inst_size);
                        }
                        break;

                    case 5:
                        {
                            printf("[GS][HM_FW]ADCS HEALTH DATA received\n");
                            inst_size = sizeof(s_adcs_hm_est_att_angl);
                            printf("[GS][HM_FW]size of s_adcs_hm_est_att_angl :%d\n",inst_size);
                        }
                        break;
                    case 6:
                        {
                            printf("[GS][HM_FW]ADCS HEALTH DATA received\n");
                            inst_size = sizeof(s_adcs_hm_raw_mag_measure);
                            printf("[GS][HM_FW]size of s_adcs_hm_raw_mag_measure:%d\n",inst_size);
                        }
                        break;
                    case 7:
                        {
                            printf("[GS][HM_FW]ADCS HEALTH DATA received\n");
                            inst_size = sizeof(s_adcs_hm_raw_rates);
                            printf("[GS][HM_FW]size of s_adcs_hm_raw_rates :%d\n",inst_size);
                        }
                        break;
                    case 8:
                        {
                            printf("[GS][HM_FW]ADCS HEALTH DATA received\n");
                            inst_size = sizeof(s_adcs_hm_meas_rates);
                            printf("[GS][HM_FW]size of s_adcs_hm_meas_rates:%d\n",inst_size);
                        }
                        break;

                    case 9:
                        {
                            printf("[GS][HM_FW]ADCS HEALTH DATA received\n");
                            inst_size = sizeof(s_adcs_hm_fss_vec);
                            printf("[GS][HM_FW]size of s_adcs_hm_fss_vec:%d\n",inst_size);
                        }
                        break;
                    case 10:
                        {
                            printf("[GS][HM_FW]ADCS HEALTH DATA received\n");
                            inst_size = sizeof(s_adcs_hm_est_rates_sns);
                            printf("[GS][HM_FW]size of s_adcs_hm_est_rates_sns:%d\n",inst_size);
                        }
                        break;

                    case 11:
                        {
                            printf("[GS][HM_FW]ADCS HEALTH DATA received\n");
                            inst_size = sizeof(s_adcs_hm_misc_cur);
                            printf("[GS][HM_FW]size of s_adcs_hm_misc_cur :%d\n",inst_size);
                        }
                        break;
                    case 12:
                        {
                            printf("[GS][HM_FW]ADCS HEALTH DATA received\n");
                            inst_size = sizeof(s_adcs_hm_temp);
                            printf("[GS][HM_FW]size of s_adcs_hm_temp:%d\n",inst_size);
                        }
                        break;
                    case 13:
                        {
                            printf("[GS][HM_FW]ADCS HEALTH DATA received\n");
                            inst_size = sizeof(s_adcs_hm_est_rate_sns_temp);
                            printf("[GS][HM_FW]size of s_adcs_hm_est_rate_sns_temp:%d\n",inst_size);
                        }
                        break;
                    case 14:
                        {
                            printf("[GS][HM_FW]ADCS HEALTH DATA received\n");
                            inst_size = sizeof(s_adcs_hm_crnt_state);
                            printf("[GS][HM_FW]size of s_adcs_hm_crnt_state:%d\n",inst_size);
                        }
                        break;

                    default:
                        {
                            printf("INVALID QUEUE ID");
                        }
                        break;
                }
            }
            break;

        case SENSORS_STRESS_TEST_SIMU:
            {
                switch(queue_id)
                {
                    case 1:
                        {
                            printf("[GS][HM_FW]SENSORS HEALTH DATA received\n");
                            inst_size = sizeof(hsc_data_s);
                        }
                        break;
                    case 2:
                        {
                            printf("[GS][HM_FW]SENSORS HEALTH DATA received\n");
                            inst_size = sizeof(hsc_data_s);
                        }
                        break;
                    case 3:
                        {
                            printf("[GS][HM_FW]SENSORS HEALTH DATA received\n");
                            inst_size = sizeof(hsc_data_s);
                        }
                        break;
                    case 4:
                        {
                            printf("[GS][HM_FW]SENSORS HEALTH DATA received\n");
                            inst_size = sizeof(dt_data_s);
                        }
                        break;

                    case 5:
                        {
                            printf("[GS][HM_FW]SENSORS HEALTH DATA received\n");
                            inst_size = sizeof(dt_data_s);
                        }
                        break;
                    case 6:
                        {
                            printf("[GS][HM_FW]SENSORS HEALTH DATA received\n");
                            inst_size = sizeof(psm_data_s);
                        }
                        break;
                    case 7:
                        {
                            printf("[GS][HM_FW]SENSORS HEALTH DATA received\n");
                            inst_size = sizeof(psm_data_s);
                        }
                        break;
                    case 8:
                        {
                            printf("[GS][HM_FW]SENSORS HEALTH DATA received\n");
                            inst_size = sizeof(temp_data_s);
                        }
                        break;

                    case 9:
                        {
                            printf("[GS][HM_FW]SENSORS HEALTH DATA received\n");
                            inst_size = sizeof(temp_data_s);
                        }
                        break;
                    case 10:
                        {
                            printf("[GS][HM_FW]SENSORS HEALTH DATA received\n");
                            inst_size = sizeof(temp_data_s);
                        }
                        break;

                    case 11:
                        {
                            printf("[GS][HM_FW]SENSORS HEALTH DATA received\n");
                            inst_size = sizeof(temp_data_s);
                        }
                        break;
                    case 12:
                        {
                            printf("[GS][HM_FW]SENSORS HEALTH DATA received\n");
                            inst_size = sizeof(temp_data_s);
                        }
                        break;
                    case 13:
                        {
                            printf("[GS][HM_FW]SENSORS HEALTH DATA received\n");
                            inst_size = sizeof(temp_data_s);
                        }
                        break;
                    case 14:
                        {
                            printf("[GS][HM_FW]SENSORS HEALTH DATA received\n");
                            inst_size = sizeof(temp_data_s);
                        }
                        break;
                    case 15:
                        {
                            printf("[GS][HM_FW]SENSORS HEALTH DATA received\n");
                            inst_size = sizeof(temp_data_s);
                        }
                        break;
                    case 16:
                        {
                            printf("[GS][HM_FW]SENSORS HEALTH DATA received\n");
                            inst_size = sizeof(temp_data_s);
                        }
                        break;

                    default:
                        {
                            printf("INVALID QUEUE ID");
                        }
                        break;
                }
            }
            break;

         case ERROR_HANDLER_STRESS_TEST_SIMU:
            {
                printf("[GS][HM_FW]ERROR HANDLER HEALTH DATA received\n");
                inst_size = 41;
            }
            break;
         case MAX_TM_DOWNLOAD_CHECK_62K:
         case COMMS_SBAND_STRESS_TEST_SIMU:
            {
                printf("[GS][HM_FW]COMMS SBAND HANDLER HEALTH DATA received\n");
                inst_size = sizeof(s_sband_periodic_tm);
            }
            break;
         case COMMS_UHF_STRESS_TEST_SIMU:
            {
                printf("[GS][HM_FW]COMMS UHF HANDLER HEALTH DATA received\n");
                inst_size = sizeof(s_uhf_get_full_tm);
            }
            break;
        case DL_REQ_SUCC_VAL_MOD_QUEUE_ACTIVE:
            {
                inst_size=INST_SIZE5;
            }
            break;
        default:
            {
                printf("[GS][HM_FW]INVALID TEST CASE ID\n");
            }
            break;
    }
    for(index=0;index<num_of_instance*inst_size;index++)
    {
        if(data[index] != 0xA5)
        {
            hm_fw_cb.integrity_fail = 1;

            printf("Queue ID : %d, number of instance : %d,Inst size: %d, Index cnt: %d\n",queue_id,num_of_instance,inst_size,index);
            printf("Failed data :%d\n",data[index]);
            break;
        }
    }

    printf("TOTAL INDEX CNT: %d\n",index);
    if(hm_fw_cb.integrity_fail)
    {
        printf("INTEGRITY FAIL\n");                }
    else
    {
        pass_cnt[hm_fw_cb.test_case_id]++;
        printf("INTEGRITY PASS\n");
    }

    hm_fw_cb.integrity_pass_cnt[hm_fw_cb.test_case_id] = pass_cnt[hm_fw_cb.test_case_id];

    switch(hm_fw_cb.test_case_id)
    {
        case EPS_STRESS_TEST_SIMU:
            {
                if(pass_cnt[hm_fw_cb.test_case_id] == 5)
                {
                    pass_cnt[hm_fw_cb.test_case_id] = 1;
                }
            }
            break;
        case ADCS_STRESS_TEST_SIMU:
            {
                if(pass_cnt[hm_fw_cb.test_case_id] == 15)
                {
                    pass_cnt[hm_fw_cb.test_case_id] = 1;
                }
            }
            break;

        case SENSORS_STRESS_TEST_SIMU:
            {
                if(pass_cnt[hm_fw_cb.test_case_id] == 17)
                {
                    pass_cnt[hm_fw_cb.test_case_id] = 1;
                }
            }
            break;
    }
}

void hm_fw_obc_tm(uint8_t queue_id, uint16_t num_of_instance, uint8_t* data)
{
    s_obc_health_info obc_health_data;
    uint16_t index;
    uint32_t data_idx = 0;

    /**  - Switch based on queue id */
    switch(queue_id)
    {
        case OBC_DATA_QUEUE_ID:
            {
                printf("[GS][HM_FW]OBC HEALTH DATA received\n");
                printf("[GS][HM_FW]Number of instance %d\n", num_of_instance);
                for(index=1;index<=num_of_instance;index++)
                {
                    memcpy((uint8_t*)&obc_health_data, &data[data_idx], sizeof(s_obc_health_info));
                    printf("[GS][HM_FW]INSTANCE %d\n\n ",index);
                    printf("[GS][HM_FW]Time stamp=%ld\n ",obc_health_data.timestamp);
                    printf("[GS][HM_FW]Fsm state=%d\n ",obc_health_data.fsm_state);
                    printf("[GS][HM_FW]No of resets=%d\n ",obc_health_data.num_resets);
                    printf("[GS][HM_FW]I/O Errors=%d\n ",obc_health_data.io_err);
                    printf("[GS][HM_FW]System error=%d\n ",obc_health_data.sys_err);
                    printf("[GS][HM_FW]CPU Utilization=%f\n ",obc_health_data.cpuUtil);
                    printf("[GS][HM_FW]Iram remaining heap=%d\n ",obc_health_data.iram_rem_heap);
                    printf("[GS][HM_FW]Eram remaining heap=%d\n ",obc_health_data.eram_rem_heap);
                    printf("[GS][HM_FW]Uptime=%d\n ",obc_health_data.uptime);
                    printf("[GS][HM_FW]Reset cause=%d\n\n ",obc_health_data.reset_cause);

                    for(int cntr = 0; cntr<OS_TASK_MAX; cntr++)
                    {
                        if(obc_health_data.ipc_fail_cntr[cntr] != 0)
                        {
                            printf("[GS][HM_FW]IPC Fail Count for task %d = %d\n",cntr,obc_health_data.ipc_fail_cntr[cntr]);
                        }
                    }
                    data_idx += sizeof(s_obc_health_info);
                }

            }
            break;

        default:
            {
            }
            break;

    }

}


void hm_fw_err_hdlr_tm(uint8_t queue_id, uint16_t num_of_instance, uint8_t* data)
{
    uint8_t inc, tot_err_cnt,error_cnt;
    uint8_t tot_grp_cnt;
    uint32_t err_fault_set;
    uint8_t offset = 1;
    tot_grp_cnt = data[0];
    printf("\nTotal Fault status Groups received %d\n",tot_grp_cnt);
    printf("------------------------------\n");
    for (inc = 0; inc < tot_grp_cnt; inc++)
    {
        tot_err_cnt = data[offset];
        if(inc == 0) printf("\nFault Status for IO as follows:");
        else if(inc == 1) printf("\nFault Status for AHW set 1 as follows:");
        else if(inc == 2) printf("\nFault Status for AHW set 2 as follows:");
        else if(inc == 3) printf("\nFault Status for System as follows:");
        else if(inc == 4) printf("\nFault Status for Services as follows:");
        else if(inc == 5) printf("\nFault Status for Coremodules as follows:");
        else if(inc == 6) printf("\nFault Status for ADCS as follows:");
        else if(inc == 7) printf("\nFault Status for Eps as follows:");
        else
            printf("Invalid TC\n");

        printf("\nTotal Error codes: %x\n",tot_err_cnt);
        offset = offset + 1;
        memcpy(&err_fault_set, &data[offset], 4);
        for(error_cnt = 0; error_cnt < tot_err_cnt; error_cnt++)
        {
            if((err_fault_set >> error_cnt) &0x01)
            {
                printf("Bit%02d - Fault\n", error_cnt);
            }
            else
            {
                printf("Bit%02d - No Fault\n", error_cnt);
            }
        }
        printf("----------------------------------------------------\n");
        offset = offset + 4;
    }
}

void hm_fw_eps_tm(uint8_t queue_id, uint16_t num_of_instance, uint8_t* data)
{

    int index;
    eps_alert_flag_tmr_s     eps_get_alert_hm[HM_EPS_RD_BFR_MAX_SIZE];
    eps_get_btry_brd_tmr_s   eps_get_btry_brd_hm[HM_EPS_RD_BFR_MAX_SIZE];
    eps_get_conv_brd_tmr_s   eps_get_conv_brd_hm[HM_EPS_RD_BFR_MAX_SIZE];
    eps_get_chnl_par_tmr_s   eps_get_out_chnl_hm[HM_EPS_RD_BFR_MAX_SIZE];


    printf("====================================================\n");
    printf("[GS][HM_FW]EPS HEALTH DATA START\n");
    printf("[GS][HM_FW]Number of instance %d\n", num_of_instance);

    switch(queue_id)
    {
        case EPS_CONV_BRD_QUEUE_ID:
            {
                printf("[GS][HM_FW] EPS get conv brd\n");
                memcpy((uint8_t*)&eps_get_conv_brd_hm, data,(sizeof(eps_get_conv_brd_tmr_s)* num_of_instance));
                for(index=0;index<num_of_instance;index++)
                {

                    printf("[GS][HM_FW]INSTANCE %d\n\n ",index);
                    printf("RTC time :%lu\t\n",eps_get_conv_brd_hm[index].time);
		    printf("output convertor voltage cnt \t:%d\n",eps_get_conv_brd_hm[index].op_conv_volt_cnt);
		    printf("pannel voltage count \t:%d\n",eps_get_conv_brd_hm[index].pv_volt_cnt);
		    printf("pannel current count \t:%d\n",eps_get_conv_brd_hm[index].pv_cur_cnt);
                    printf("pv_volt_1 \t:%f\n",eps_get_conv_brd_hm[index].pv_volt[0]);
                    printf("pv_volt_2 \t:%f\n",eps_get_conv_brd_hm[index].pv_volt[1]);
                    printf("pv_volt_3 \t:%f\n",eps_get_conv_brd_hm[index].pv_volt[2]);
                    printf("pv_volt_4 \t:%f\n",eps_get_conv_brd_hm[index].pv_volt[3]);
                    printf("pv_cur_1  \t:%f\n",eps_get_conv_brd_hm[index].pv_cur[0]);
                    printf("pv_cur_2  \t:%f\n",eps_get_conv_brd_hm[index].pv_cur[1]);
                    printf("pv_cur_3  \t:%f\n",eps_get_conv_brd_hm[index].pv_cur[2]);
                    printf("pv_cur_4  \t:%f\n",eps_get_conv_brd_hm[index].pv_cur[3]);
                    printf("pv_volt_conv_1 \t:%f\n",eps_get_conv_brd_hm[index].op_volt_conv_read[0]);
                    printf("pv_volt_conv_2 \t:%f\n",eps_get_conv_brd_hm[index].op_volt_conv_read[1]);
                    printf("pv_volt_conv_3 \t:%f\n",eps_get_conv_brd_hm[index].op_volt_conv_read[2]);
                    printf("pv_volt_conv_4 \t:%f\n",eps_get_conv_brd_hm[index].op_volt_conv_read[3]);

                }

            }
            break;

        case EPS_BTRY_BRD_QUEUE_ID:
            {
                printf("[GS][HM_FW] EPS get battery brd \n");
                memcpy((uint8_t*)&eps_get_btry_brd_hm, data,(sizeof(eps_get_btry_brd_tmr_s)*num_of_instance));
                for(index=0;index<num_of_instance;index++)
                {

                    printf("[GS][HM_FW]INSTANCE %d\n\n ",index);
                    printf("RTC time :%lu\t\n",eps_get_btry_brd_hm[index].time);
		    printf("battery temperature count \t:%d\n",eps_get_btry_brd_hm[index].btry_temp_cnt);
		    printf("battery voltage count \t:%d\n",eps_get_btry_brd_hm[index].btry_volt_cnt);
                    printf("tot_vol     \t:%f\n",eps_get_btry_brd_hm[index].totl_vol);
                    printf("batt_volt_1 \t:%f\n",eps_get_btry_brd_hm[index].vol_ch[0]);
                    printf("batt_volt_2 \t:%f\n",eps_get_btry_brd_hm[index].vol_ch[1]);
                    printf("batt_volt_3 \t:%f\n",eps_get_btry_brd_hm[index].vol_ch[2]);
                    printf("batt_current\t:%f\n",eps_get_btry_brd_hm[index].totl_crnt);
                    printf("temp_1      \t:%d\n",eps_get_btry_brd_hm[index].tempr[0]);
                    printf("temp_2      \t:%d\n",eps_get_btry_brd_hm[index].tempr[1]);
                    printf("temp_3      \t:%d\n",eps_get_btry_brd_hm[index].tempr[2]);
                    printf("temp_4      \t:%d\n",eps_get_btry_brd_hm[index].tempr[3]);
                    printf("temp_5      \t:%d\n",eps_get_btry_brd_hm[index].tempr[4]);
                    printf("temp_6      \t:%d\n",eps_get_btry_brd_hm[index].tempr[5]);
                    printf("temp_7      \t:%d\n",eps_get_btry_brd_hm[index].tempr[6]);
                    printf("temp_8      \t:%d\n",eps_get_btry_brd_hm[index].tempr[7]);
		    printf("Battery charging status:");
                    if(eps_get_btry_brd_hm[index].btry_chrg_sts == 0xFF)
                        printf("ERROR\n");
                    else if(eps_get_btry_brd_hm[index].btry_chrg_sts == 1)
                        printf("CHARGE\n");
                    else if(eps_get_btry_brd_hm[index].btry_chrg_sts == 0)
                        printf("DISCHARGE\n");
                    else
                        printf("INVALID VALUE\n");

                }
            }
            break;

        case EPS_CHNL_PAR_QUEUE_ID:
            {
                printf("[GS][HM_FW]EPS get OUTPUT_CNANNEL_PARAM\n");
                memcpy(&eps_get_out_chnl_hm, data,(sizeof(eps_get_chnl_par_tmr_s)*num_of_instance));
                for(index=0;index<num_of_instance;index++)
                {

                    printf("[GS][HM_FW]INSTANCE %d\n\n ",index);
		    printf("RTC time \t:%lu \n",eps_get_out_chnl_hm[index].time);
                    printf("output voltage rail count \t:%d\n",eps_get_out_chnl_hm[index].volt_rail_cnt);
                    printf("chnl_1 tot_volt_12v  \t:%f\n",eps_get_out_chnl_hm[index].rd_crnt_val[0]);
                    printf("chnl_2 tot_volt_12v  \t:%f\n",eps_get_out_chnl_hm[index].rd_crnt_val[1]);
                    printf("chnl_3 tot_volt_5v    \t:%f\n",eps_get_out_chnl_hm[index].rd_crnt_val[2]);
                    printf("chnl_4 tot_volt_5v   \t:%f\n",eps_get_out_chnl_hm[index].rd_crnt_val[3]);
                    printf("chnl_5 tot_volt_5v    \t:%f\nn",eps_get_out_chnl_hm[index].rd_crnt_val[4]);
                    printf("chnl_5 tot_volt_3.3v  \t:%f\n",eps_get_out_chnl_hm[index].rd_crnt_val[5]);
                    printf("chnl_5 tot_volt_BATTV \t:%f\n",eps_get_out_chnl_hm[index].rd_crnt_val[6]);
                    printf("chnl_6 tot_volt_12v   \t:%f\n",eps_get_out_chnl_hm[index].rd_crnt_val[7]);
                    printf("chnl_6 tot_volt_3.3v  \t:%f\n",eps_get_out_chnl_hm[index].rd_crnt_val[8]);
                    printf("chnl_7 tot_volt_3.3   \t:%f\n",eps_get_out_chnl_hm[index].rd_crnt_val[9]);
                    printf("chnl_7 tot_volt_BATTv    \t:%f\n",eps_get_out_chnl_hm[index].rd_crnt_val[10]);
                    printf("chnl_8 tot_volt_12v  \t:%f\n",eps_get_out_chnl_hm[index].rd_crnt_val[11]);
                    printf("chnl_9 tot_volt_5V\t:%f\n",eps_get_out_chnl_hm[index].rd_crnt_val[12]);
                    printf("chnl_10 tot_volt_BATTV\t:%f\n",eps_get_out_chnl_hm[index].rd_crnt_val[13]);
                    printf("chnl_11 tot_volt_BATTV\t:%f\n",eps_get_out_chnl_hm[index].rd_crnt_val[14]);
                    printf("chnl_12 tot_volt_BATTV\t:%f\n",eps_get_out_chnl_hm[index].rd_crnt_val[15]);

                }
            }
            break;

        case  EPS_ALRT_FLAG_QUEUE_ID:
            {
                uint32_t tmp_val = 0;

                printf("[GS][HM_FW]EPS get ALERT FLAG \n");
                memcpy(&eps_get_alert_hm, data, (sizeof(eps_alert_flag_tmr_s)*num_of_instance));
                for(index=0;index<num_of_instance;index++)
                {
                    printf("[GS][HM_FW]INSTANCE %d\n\n ",index);
                    printf("RTC time \t:%lu \n",eps_get_alert_hm[index].time);
                    tmp_val = eps_get_alert_hm[index].value;

                    printf("mode \t:%d\n",tmp_val & 0x07);

                    if(tmp_val & 0x08)
                    {
                        printf("chnl_1_12v ovf : 1\n");
                    }
                    else
                    {
                        printf("chnl_1_12v ovf : 0\n");
                    }

                    if(tmp_val & 0x10)
                    {
                        printf("chnl_2_12v ovf : 1\n");
                    }
                    else
                    {
                        printf("chnl_2_12v ovf : 0\n");
                    }

                    if(tmp_val & 0x20)
                    {
                        printf("chnl_3_5v ovf : 1\n");
                    }
                    else
                    {
                        printf("chnl_3_5v ovf : 0\n");
                    }

                                            if(tmp_val & 0x40)
                                            {
                                                printf("chnl_4_5v ovf : 1\n");
                                            }
                                            else
                                            {	 
                                                printf("chnl_4_5v ovf : 0\n");
                                            }

                                            if(tmp_val & 0x80)
                                            {
                                                printf("chnl_5_5v ovf : 1\n");
                                            }
                                            else
                                            {
                                                printf("chnl_5_5v ovf : 0\n");
                                            }  

                                            if(tmp_val & 0x0100)
                                            {
                                                printf("chnl_5_3.3v ovf : 1\n");
                                            }
                                            else
                                            {
                                                printf("chnl_5_3.3v ovf : 0\n");
                                            }  

                                            if(tmp_val & 0x0200)
                                            {
                                                printf("chnl_5_battv ovf : 1\n");
                                            }
                                            else
                                            {
                                                printf("chnl_5_battv ovf : 0\n");
                                            }  

                                            if(tmp_val & 0x0400) 
                                            {
                                                printf("chnl_6_12v ovf : 1\n");
                                            }
                                            else
                                            {
                                                printf("chn_6_l12v ovf : 0\n");
                                            }  

                                            if(tmp_val & 0x0800)
                                            {
                                                printf("chnl_6_3.3v ovf : 1\n");
                                            }
                                            else
                                            {
                                                printf("chnl_6_3.3v ovf : 0\n");
                                            }  

                                            if(tmp_val & 0x1000)
                                            {
                                                printf("chnl_7_5v ovf : 1\n");
                                            }
                                            else
                                            {
                                                printf("chnl_7_5v ovf : 0\n");
                                            }  

                                            if(tmp_val & 0x2000)
                                            {
                                                printf("chnl_7_BATTv ovf : 1\n");
                                            }
                                            else
                                            {
                                                printf("chnl_7_BATTv ovf : 0\n");
                                            }  

                                            if(tmp_val & 0x4000)
                                            {
                                                printf("chnl_8_12v ovf : 1\n");
                                            }
                                            else
                                            {
                                                printf("chnl_8_12v ovf : 0\n");
                                            }  

                                            if(tmp_val & 0x8000 )
                                            {
                                                printf("chnl_9_5v ovf : 1\n");
                                            }
                                            else
                                            {
                                                printf("chnl_9_5v ovf : 0\n");
                                            }  

                                            if(tmp_val & 0x010000 )
                                            {
                                                printf("chnl_10_battv ovf : 1\n");
                                            }
                                            else
                                            {
                                                printf("chnl_10_battv ovf : 0\n");
                                            }  

                                            if(tmp_val & 0x020000)
                                            {
                                                printf("chnl_11_battv ovf : 1\n");
                                            }
                                            else
                                            {
                                                printf("chnl_11_battv ovf : 0\n");
                                            }  

                                            if(tmp_val & 0x040000)
                                            {
                                                printf("chnl_12_battv ovf : 1\n");
                                            }
                                            else
                                            {
                                                printf("chnl_12_battv ovf : 0\n");
                                            } 

                                            if(tmp_val & 0x080000)
                                            {
                                                printf("battery charging ovf : 1\n");
                                            }
                                            else
                                            {
                                                printf("battery charging ovf : 0\n");
                                            }  

                                            if(tmp_val & 0x100000)
                                            {
                                                printf("battery discharging ovf : 1\n");
                                            }
                                            else
                                            {
                                                printf("battey discharging ovf : 0\n");
                                            }  
                                            if(tmp_val & 0x200000)
                                            {
                                                printf("battery voltage below 10.7v flag : 1\n");
                                            }
                                            else
                                            {
                                                printf("battey voltage below 10.7v flag : 0\n");
                                            }  

                }
            }
            break;

        default:
            printf("invalid id\n");
            break;

    }

    printf("[GS][HM_FW]EPS HEALTH DATA END\n");
    printf("====================================================\n");
}

void hm_fw_comms_sband_tm(uint8_t queue_id, uint16_t num_of_instance, uint8_t* data)
{
    s_sband_periodic_get_tm xlink_tm_stor;
    int index;
    uint32_t data_idx = 0;

    printf("====================================================\n");
    printf("[GS][HM_FW]COMMS SBAND HEALTH DATA START\n");
    /**  - Switch based on queue id */
    switch(queue_id)
    {
        case SBAND_PERIODIC_TM_QUEUE_ID:
            {
                printf("[GS][HM_FW]SBAND HEALTH DATA\n");
                for(index=0;index<num_of_instance;index++)
                {
                    memcpy((uint8_t*)&xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor, &data[data_idx], sizeof(s_sband_periodic_tm));
                    printf("[GS][HM_FW]INSTANCE %d\n\n ",index);
                    printf("[GS][HM_FW]Time stamp=%ld\n ",xlink_tm_stor.sband_tm_store->time_stamp);
                    printf("MFCC APP :temp_xcvr : %hi \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.cmn_tm.temp_xcvr );
                    printf("MFCC APP :temp_mcu : %hi \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.cmn_tm.temp_mcu );
                    printf("MFCC APP :temp_fpga : %hi \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.cmn_tm.temp_fpga );
                    printf("MFCC APP :volt_vint : %f \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.cmn_tm.volt_vint );
                    printf("MFCC APP :volt_vaux : %f \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.cmn_tm.volt_vaux );
                    printf("MFCC APP :volt_vbram : %f \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.cmn_tm.volt_vbram );
                    printf("MFCC APP :volt_vpint : %f \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.cmn_tm.volt_vpint );
                    printf("MFCC APP :volt_vpaux : %f \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.cmn_tm.volt_vpaux );
                    printf("MFCC APP :volt_vpdro : %f \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.cmn_tm.volt_vpdro );
                    printf("MFCC APP : Recv ch 0 \n" );
                    printf("MFCC APP :rx_cfg_frames : %d \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.rx_tm[0].rx_cfg_frames );
                    printf("MFCC APP :rx_cfg_detected : %d \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.rx_tm[0].rx_cfg_detected );
                    printf("MFCC APP :rx_cfg_rssi : %lf \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.rx_tm[0].rx_cfg_rssi );
                    printf("MFCC APP :rx_cfg_freqerr : %d \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.rx_tm[0].rx_cfg_freqerr );
                    printf("MFCC APP :rx_cfg_carrier_lock : %hu \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.rx_tm[0].rx_cfg_carrier_lock );
                    printf("MFCC APP :rx_frame_lock : %hu \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.rx_tm[0].rx_frame_lock );
                    printf("MFCC APP :rx_sir_min : %u \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.rx_tm[0].rx_sir_min );
                    printf("MFCC APP :rx_sir_max : %u \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.rx_tm[0].rx_sir_max );
                    printf("MFCC APP :rx_bch_block_i : %u \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.rx_tm[0].rx_bch_block_cnt );
                    printf("MFCC APP :rx_bch_err_cnt : %u \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.rx_tm[0].rx_bch_err_cnt );
                    printf("MFCC APP : Recv ch 1 \n" );
                    printf("MFCC APP :rx_cfg_frames : %u \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.rx_tm[1].rx_cfg_frames );
                    printf("MFCC APP :rx_cfg_detected : %d \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.rx_tm[1].rx_cfg_detected );
                    printf("MFCC APP :rx_cfg_rssi : %lf \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.rx_tm[1].rx_cfg_rssi );
                    printf("MFCC APP :rx_cfg_freqerr : %d \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.rx_tm[1].rx_cfg_freqerr );
                    printf("MFCC APP :rx_cfg_carrier_lock : %hu \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.rx_tm[1].rx_cfg_carrier_lock );
                    printf("MFCC APP :rx_frame_lock : %hu \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.rx_tm[1].rx_frame_lock );
                    printf("MFCC APP :rx_sir_min : %u \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.rx_tm[1].rx_sir_min );
                    printf("MFCC APP :rx_sir_max : %u \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.rx_tm[1].rx_sir_max );
                    printf("MFCC APP :rx_bch_block_i : %u \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.rx_tm[1].rx_bch_block_cnt );
                    printf("MFCC APP :rx_bch_err_cnt : %u \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.rx_tm[1].rx_bch_err_cnt );

                    printf("MFCC APP :tx_cfg_frames : %d \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.tx_tm.tx_cfg_frames );
                    printf("MFCC APP :tx_cfg_pwr_rfl : %f \n", xlink_tm_stor.sband_tm_store[index].comms_sband_tm_stor.tx_tm.tx_cfg_pwr_rfl );

                    data_idx += sizeof(s_sband_periodic_tm);
                }
            }
            break;

        default:
            {
            }
            break;
    }

    printf("[GS][HM_FW]COMMS SBAND HEALTH DATA END\n");
    printf("====================================================\n");
}

void hm_fw_comms_uhf_tm(uint8_t queue_id, uint16_t num_of_instance, uint8_t* data)
{
     s_comms_uhf_get_tm_prop uhf_get_tm_stor;
    int index;
    uint32_t data_idx = 0;

    printf("====================================================\n");
    printf("[GS][HM_FW]COMMS UHF HEALTH DATA START\n");
    /**  - Switch based on queue id */
    switch(queue_id)
    {
        case UHF_TM_PROP_QUEUE_ID:
            {
                for(index=0;index<num_of_instance;index++)
                {
                    memcpy((uint8_t*)&uhf_get_tm_stor.uhf_tm_store[index], &data[data_idx], sizeof(s_uhf_get_full_tm));

                    printf("[GS][HM_FW]INSTANCE %d\n\n ",index);
                    printf("[GS][HM_FW]Time stamp=%ld\n ",uhf_get_tm_stor.uhf_tm_store->time_stamp);
                    printf("up time:%u\n",uhf_get_tm_stor.uhf_tm_store[index].comms_uhf_tm_stor.uptime);
                    printf("uart0 rx count:%u\n",uhf_get_tm_stor.uhf_tm_store[index].comms_uhf_tm_stor.uart0_rx_count);
                    printf("uart1 rx count:%u\n",uhf_get_tm_stor.uhf_tm_store[index].comms_uhf_tm_stor.uart1_rx_count);
                    printf("rx mode:%u\n",uhf_get_tm_stor.uhf_tm_store[index].comms_uhf_tm_stor.rx_mode);
                    printf("tx mode:%u\n",uhf_get_tm_stor.uhf_tm_store[index].comms_uhf_tm_stor.tx_mode);
                    for(int k = 0; k< 10;k++)
                    {
                        printf("adc:%d\n",uhf_get_tm_stor.uhf_tm_store[index].comms_uhf_tm_stor.adc[k]);
                    }
                    printf("last rssi:%u\n",uhf_get_tm_stor.uhf_tm_store[index].comms_uhf_tm_stor.last_rssi);
                    printf("last lqi:%u\n",uhf_get_tm_stor.uhf_tm_store[index].comms_uhf_tm_stor.last_lqi);
                    printf("last freq set:%u\n",uhf_get_tm_stor.uhf_tm_store[index].comms_uhf_tm_stor.last_freqest);
                    printf("Pkt sent:%u\n",uhf_get_tm_stor.uhf_tm_store[index].comms_uhf_tm_stor.Pkt_sent);
                    printf("cs count:%u\n",uhf_get_tm_stor.uhf_tm_store[index].comms_uhf_tm_stor.cs_count);
                    printf("Pkt good:%u\n",uhf_get_tm_stor.uhf_tm_store[index].comms_uhf_tm_stor.Pkt_good);
                    printf("Pkt rejected checksum:%u\n",uhf_get_tm_stor.uhf_tm_store[index].comms_uhf_tm_stor.Pkt_rejected_checksum);
                    printf("Pkt rejected reserved:%u\n",uhf_get_tm_stor.uhf_tm_store[index].comms_uhf_tm_stor.Pkt_rejected_reserved);
                    printf("Pkt rejected other:%u\n",uhf_get_tm_stor.uhf_tm_store[index].comms_uhf_tm_stor.Pkt_rejected_other);
                    printf("reserved0:%u\n",uhf_get_tm_stor.uhf_tm_store[index].comms_uhf_tm_stor.reserved0);

                    data_idx += sizeof(s_uhf_get_full_tm);
                }
                if(num_of_instance == index)
                {
                    printf("MFCC APP: UHF TM STORE SUCCESS \n");
                }
                else
                {
                    printf("MFCC APP: UHF TM STORE FAILURE \n");
                }
            }
            break;

        default:
            {
            }
            break;
    }

    printf("====================================================\n");
    printf("[GS][HM_FW]COMMS UHF HEALTH DATA END\n");
}
/*
   void hm_fw_adcs_tm(uint8_t queue_id, uint8_t num_of_instance, uint8_t* data)
   {
   int index;
   uint32_t data_idx = 0;

// Switch based on queue id 
switch(queue_id)
{
case :
{
for(index=0;index<num_of_instance;index++)
{
memcpy((uint8_t*)&obc_health_data, &data[data_idx], sizeof(s_obc_health_info));

data_idx += sizeof(s_obc_health_info);
}
}
break;

default:
{
}
break;
}

}
*/



uint8 tc_deffered_storage[5*1024] = {0};
#define DEFERRED_STORAGE_TC_LEN_IDX     (4)
#define DEFERRED_STORAGE_MAX_LEN        (1024)

uint8 handle_tc_deferred_storage(void)
{

    char *file_name;
    file_name = SCH_TC_FILE;

    FILE *tc_fp = fopen(file_name, "r");

    // reading line by line, max 1024 bytes
    const unsigned MAX_LENGTH = 1024;
    char buffer[MAX_LENGTH];
    char *token;
    uint16_t itr = 0;

    s_tc_defferd_strg strg = {0};
    uint16 tc_len=0;
    uint8* tc_data;
    uint8 pck_offset_flag = 0;
    uint32 tmp_u32 = 0;
    uint16 tmp_u16 = 0;
    uint8 tmp_u8 = 0;
    tmp_u8 = tmp_u8;
    char *sub_str = NULL;
    char *rem_str = NULL;

    if (tc_fp == NULL)
    {
        printf("MFCC APP Error: could not open file %s\n", file_name);
        return 1;
    }

    tc_data = (uint8_t *)malloc(DEFERRED_STORAGE_MAX_LEN);
    tc_len = sizeof(strg);
    while (fgets(buffer, MAX_LENGTH, tc_fp))
    {
        /*
         * Refer Conops_Scheduler UserManual for file format releated information
         */
        //Frame info byte
        sub_str = strtok_r(buffer, ",", &rem_str);
        tmp_u8 = strtoul(sub_str, NULL, 16);
        // If Frame info = 1 data present in the frame, 0 data not present
        if(tmp_u8 == 1)
        {
            sub_str = strtok_r(rem_str, ",", &rem_str);
            //offset
            sub_str = strtok_r(rem_str, ",", &rem_str);
            tmp_u32 = strtoul(sub_str, NULL, 16);

            //length
            sub_str = strtok_r(rem_str, ",", &rem_str);
            tmp_u16 = strtoul(sub_str, NULL, 16);
            // Payload length + Radio Id length
            strg.data_len = tmp_u16 + 1;

            //dest_id
            sub_str = strtok_r(rem_str, ",", &rem_str);
            tmp_u8 = strtoul(sub_str, NULL, 16);

            //tc_id
            sub_str = strtok_r(rem_str, ",", &rem_str);
            tmp_u16 = strtoul(sub_str, NULL, 16);

            /* get the first token */
            token = strtok(rem_str, ",");

            /* walk through other tokens */
            while( token != NULL )
            {
                tc_deffered_storage[itr] = (int)strtol(token, NULL, 0);
                token = strtok(NULL, ",");
                itr++;
            }

            /* Copy payload length */
            //memcpy(&strg.data_len, &tc_deffered_storage[DEFERRED_STORAGE_TC_LEN_IDX], sizeof(strg.data_len));

            /* Verify Current payload length not exceed MAX len */
            if(tc_len + strg.data_len > DEFERRED_STORAGE_MAX_LEN)
            {
                sleep(1);
                mfcc_adcs_tc_send(TC_DEFERRED_STRG, tc_data, tc_len);
                pck_offset_flag = 0;
                tc_len = sizeof(strg);
            }

            /* Copy payload offset */
            if(pck_offset_flag == 0)
            {
                strg.wrt_offset = tmp_u32;
                //memcpy(&strg.wrt_offset, tc_deffered_storage, sizeof(strg.wrt_offset));
                pck_offset_flag = 1;
            }

            // Append payload data
            os_memcpy(&tc_data[tc_len], &tc_deffered_storage, strg.data_len);
            // Increment TC Length
            tc_len += strg.data_len;
            // Assign payload data length
            strg.data_len = tc_len - sizeof(strg);
            os_memcpy(tc_data, &strg, sizeof(strg));
            printf("strg.wrt_offset is %d \n",strg.wrt_offset);
            printf("strg.data_len is %d \n",strg.data_len);
            itr = 0;
        }
    }

    if(tc_len > sizeof(strg))
    {
        sleep(1);
        mfcc_adcs_tc_send(TC_DEFERRED_STRG, tc_data, tc_len);
    }

    free(tc_data);
    // close the file
    fclose(tc_fp);

    return 0;
}

char* reset_cause_get_name(uint32_t reset_cause)
{
    char* reset_cause_name = "UNDEFINED";
    switch (reset_cause)
    {
        case RESET_CAUSE_UNKNOWN:
            reset_cause_name = "UNKNOWN";
            break;
        case RESET_CAUSE_LOW_POWER_RESET:
            reset_cause_name = "LOW_POWER_RESET";
            break;
        case RESET_CAUSE_WINDOW_WATCHDOG_RESET:
            reset_cause_name = "WINDOW_WATCHDOG_RESET";
            break;
        case RESET_CAUSE_INDEPENDENT_WATCHDOG_RESET:
            reset_cause_name = "INDEPENDENT_WATCHDOG_RESET";
            break;
        case RESET_CAUSE_SOFTWARE_RESET:
            reset_cause_name = "SOFTWARE_RESET";
            break;
        case RESET_CAUSE_POWER_ON_POWER_DOWN_RESET:
            reset_cause_name = "POWER-ON_RESET (POR) / POWER-DOWN_RESET (PDR)";
            break;
        case RESET_CAUSE_EXTERNAL_RESET_PIN_RESET:
            reset_cause_name = "EXTERNAL_RESET_PIN_RESET";
            break;
        case RESET_CAUSE_BROWNOUT_RESET:
            reset_cause_name = "BROWNOUT_RESET (BOR)";
            break;
    }

    return reset_cause_name;
}

